Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d22ee9cfa | |||
| 94e9a09aea | |||
| fbf3dc5dae | |||
| 31a3eb2b8f | |||
| a7c1864f7a | |||
| 000da4df04 | |||
| 4aed06eb44 | |||
| 22c6ce68f2 | |||
| 72c08964f9 | |||
| 680072fa83 | |||
| cea59cba29 | |||
| bcd7628c0a | |||
| ac4a5e8055 | |||
| aed9c61804 | |||
| aeb0a58f5c | |||
| da4961f698 | |||
| 29c2885475 | |||
| 17a6aea76d | |||
| 9d5c83b5ba | |||
| 5c305a088d | |||
| b3108715b1 | |||
| 3730afe092 | |||
| ee32663bdd | |||
| 2818c7b09f | |||
| bf930ec6eb | |||
| b21594367f | |||
| 4ad7124dcf | |||
| 27a354545c | |||
| 7e07427238 | |||
| 7e016ad147 | |||
| 619d768cc3 | |||
| c9cc778333 | |||
| 567f2386bb | |||
| cc19c90e19 | |||
| 73010a2a4a | |||
| ee6d20ddeb | |||
| ec69324496 | |||
| 5dc568bc86 | |||
| faa8e21594 | |||
| 82d361d7ef | |||
| e9fb5ac088 | |||
| 8ca78cbe4b | |||
| 2213e576ec | |||
| 30603ac3f6 | |||
| 1def341c03 | |||
| 3657efc44f | |||
| 5bcb05e0f6 | |||
| 3071947c28 | |||
| 8fbab92e1b | |||
| 83374615aa | |||
| ee49593055 | |||
| f93d0f2466 | |||
| 95b517d620 | |||
| 0190ed596e | |||
| d0b2bf3250 |
73
Logo/logo.scad
Normal file
73
Logo/logo.scad
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
length = 10;
|
||||||
|
n = 5;
|
||||||
|
|
||||||
|
// Draw all geometry
|
||||||
|
//translate([0,0]) polygon(ngon(n, length));
|
||||||
|
|
||||||
|
translate([0,0]) hollow_ngon(n, length);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Simple list comprehension for creating N-gon vertices
|
||||||
|
function ngon(num, r) =
|
||||||
|
[for (i=[0:num-1], a=i*360/num) [ r*cos(a), r*sin(a) ]];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module hollow_ngon(num, r, width = 1) {
|
||||||
|
difference() {
|
||||||
|
translate([0,0]) polygon(ngon(num, r));
|
||||||
|
translate([0,0]) polygon(ngon(num, r-width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
l = 10;
|
||||||
|
|
||||||
|
|
||||||
|
CubePoints = [
|
||||||
|
[ 0, 0, 0 ], //0
|
||||||
|
[ 10, 0, 0 ], //1
|
||||||
|
[ 10, 7, 0 ], //2
|
||||||
|
[ 0, 7, 0 ], //3
|
||||||
|
[ 0, 0, 5 ], //4
|
||||||
|
[ 10, 0, 5 ], //5
|
||||||
|
[ 10, 7, 5 ], //6
|
||||||
|
[ 0, 7, 5 ]]; //7
|
||||||
|
|
||||||
|
CubeFaces = [
|
||||||
|
[0,1,2,3], // bottom
|
||||||
|
[4,5,1,0], // front
|
||||||
|
[7,6,5,4], // top
|
||||||
|
[5,6,2,1], // right
|
||||||
|
[6,7,3,2], // back
|
||||||
|
[7,4,0,3]]; // left
|
||||||
|
|
||||||
|
polyhedron( CubePoints, CubeFaces );
|
||||||
|
|
||||||
|
//The coordinates of the 12 additional vertices are (0, ±(1 + h), ±(1 − h2)), (±(1 + h), ±(1 − h2), 0) and (±(1 − h2), 0, ±(1 + h)).
|
||||||
|
// (0, ±(1 + h), ±(1 − h2)),
|
||||||
|
// (0, (1 + h), (1 − h2) ),
|
||||||
|
// (±(1 + h), ±(1 − h2), 0)
|
||||||
|
// (±(1 − h2), 0, ±(1 + h))
|
||||||
|
|
||||||
|
steps = 50;
|
||||||
|
sides = 5;
|
||||||
|
|
||||||
|
|
||||||
|
vert = [
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
points = [
|
||||||
|
// first expression generating the points in the positive Y quadrant
|
||||||
|
//(0, ±(1 + h), ±(1 − h2)),
|
||||||
|
for (a = [0 : sides]) [ a, 10 * sin(a * 360 / steps) + 10 ],
|
||||||
|
// second expression generating the points in the negative Y quadrant
|
||||||
|
for (a = [steps : -1 : 0]) [ a, 10 * cos(a * 360 / steps) - 20 ],
|
||||||
|
// additional list of fixed points
|
||||||
|
[ 10, -3 ], [ 3, 0 ], [ 10, 3 ]
|
||||||
|
];
|
||||||
|
|
||||||
|
polygon(points);
|
||||||
@@ -20,14 +20,18 @@
|
|||||||
"@quasar/extras": "^1.13.5",
|
"@quasar/extras": "^1.13.5",
|
||||||
"@types/katex": "^0.14.0",
|
"@types/katex": "^0.14.0",
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
|
"@types/validator": "^13.7.2",
|
||||||
"@vuetify/vite-plugin": "1.0.0-alpha.10",
|
"@vuetify/vite-plugin": "1.0.0-alpha.10",
|
||||||
|
"chart.js": "^3.7.1",
|
||||||
"dependency-graph": "^0.11.0",
|
"dependency-graph": "^0.11.0",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"katex": "^0.15.3",
|
"katex": "^0.15.3",
|
||||||
"mathjs": "^10.4.3",
|
"mathjs": "^10.4.3",
|
||||||
"quasar": "^2.6.6",
|
"quasar": "^2.6.6",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
|
"validator": "^13.7.0",
|
||||||
"vue": "^3.2.25",
|
"vue": "^3.2.25",
|
||||||
|
"vue-chart-3": "^3.1.8",
|
||||||
"vue-router": "^4.0.14",
|
"vue-router": "^4.0.14",
|
||||||
"vuetify": "3.0.0-beta.0"
|
"vuetify": "3.0.0-beta.0"
|
||||||
},
|
},
|
||||||
|
|||||||
43
pnpm-lock.yaml
generated
43
pnpm-lock.yaml
generated
@@ -7,11 +7,13 @@ specifiers:
|
|||||||
'@quasar/vite-plugin': ^1.0.9
|
'@quasar/vite-plugin': ^1.0.9
|
||||||
'@types/katex': ^0.14.0
|
'@types/katex': ^0.14.0
|
||||||
'@types/uuid': ^8.3.4
|
'@types/uuid': ^8.3.4
|
||||||
|
'@types/validator': ^13.7.2
|
||||||
'@typescript-eslint/eslint-plugin': ^5.18.0
|
'@typescript-eslint/eslint-plugin': ^5.18.0
|
||||||
'@typescript-eslint/parser': ^5.18.0
|
'@typescript-eslint/parser': ^5.18.0
|
||||||
'@vitejs/plugin-vue': ^2.3.1
|
'@vitejs/plugin-vue': ^2.3.1
|
||||||
'@volar/vue-language-service': ^0.33.9
|
'@volar/vue-language-service': ^0.33.9
|
||||||
'@vuetify/vite-plugin': 1.0.0-alpha.10
|
'@vuetify/vite-plugin': 1.0.0-alpha.10
|
||||||
|
chart.js: ^3.7.1
|
||||||
dependency-graph: ^0.11.0
|
dependency-graph: ^0.11.0
|
||||||
eslint: ^8.13.0
|
eslint: ^8.13.0
|
||||||
install: ^0.13.0
|
install: ^0.13.0
|
||||||
@@ -21,8 +23,10 @@ specifiers:
|
|||||||
sass: 1.32.0
|
sass: 1.32.0
|
||||||
typescript: ^4.5.4
|
typescript: ^4.5.4
|
||||||
uuid: ^8.3.2
|
uuid: ^8.3.2
|
||||||
|
validator: ^13.7.0
|
||||||
vite: ^2.9.0
|
vite: ^2.9.0
|
||||||
vue: ^3.2.25
|
vue: ^3.2.25
|
||||||
|
vue-chart-3: ^3.1.8
|
||||||
vue-router: ^4.0.14
|
vue-router: ^4.0.14
|
||||||
vue-tsc: ^0.33.9
|
vue-tsc: ^0.33.9
|
||||||
vuetify: 3.0.0-beta.0
|
vuetify: 3.0.0-beta.0
|
||||||
@@ -32,14 +36,18 @@ dependencies:
|
|||||||
'@quasar/extras': 1.13.5
|
'@quasar/extras': 1.13.5
|
||||||
'@types/katex': 0.14.0
|
'@types/katex': 0.14.0
|
||||||
'@types/uuid': 8.3.4
|
'@types/uuid': 8.3.4
|
||||||
|
'@types/validator': 13.7.2
|
||||||
'@vuetify/vite-plugin': 1.0.0-alpha.10_vite@2.9.1+vuetify@3.0.0-beta.0
|
'@vuetify/vite-plugin': 1.0.0-alpha.10_vite@2.9.1+vuetify@3.0.0-beta.0
|
||||||
|
chart.js: 3.7.1
|
||||||
dependency-graph: 0.11.0
|
dependency-graph: 0.11.0
|
||||||
install: 0.13.0
|
install: 0.13.0
|
||||||
katex: 0.15.3
|
katex: 0.15.3
|
||||||
mathjs: 10.4.3
|
mathjs: 10.4.3
|
||||||
quasar: 2.6.6
|
quasar: 2.6.6
|
||||||
uuid: 8.3.2
|
uuid: 8.3.2
|
||||||
|
validator: 13.7.0
|
||||||
vue: 3.2.31
|
vue: 3.2.31
|
||||||
|
vue-chart-3: 3.1.8_chart.js@3.7.1+vue@3.2.31
|
||||||
vue-router: 4.0.14_vue@3.2.31
|
vue-router: 4.0.14_vue@3.2.31
|
||||||
vuetify: 3.0.0-beta.0_vue@3.2.31
|
vuetify: 3.0.0-beta.0_vue@3.2.31
|
||||||
|
|
||||||
@@ -389,6 +397,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
|
resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/validator/13.7.2:
|
||||||
|
resolution: {integrity: sha512-KFcchQ3h0OPQgFirBRPZr5F/sVjxZsOrQHedj3zi8AH3Zv/hOLx2OLR4hxR5HcfoU+33n69ZuOfzthKVdMoTiw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@types/vfile-message/2.0.0:
|
/@types/vfile-message/2.0.0:
|
||||||
resolution: {integrity: sha512-GpTIuDpb9u4zIO165fUy9+fXcULdD8HFRNli04GehoMVbeNq7D6OBnqSmg3lxZnC+UvgUhEWKxdKiwYUkGltIw==}
|
resolution: {integrity: sha512-GpTIuDpb9u4zIO165fUy9+fXcULdD8HFRNli04GehoMVbeNq7D6OBnqSmg3lxZnC+UvgUhEWKxdKiwYUkGltIw==}
|
||||||
deprecated: This is a stub types definition. vfile-message provides its own type definitions, so you do not need this installed.
|
deprecated: This is a stub types definition. vfile-message provides its own type definitions, so you do not need this installed.
|
||||||
@@ -1069,6 +1081,10 @@ packages:
|
|||||||
is-regex: 1.1.4
|
is-regex: 1.1.4
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/chart.js/3.7.1:
|
||||||
|
resolution: {integrity: sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/chokidar/3.5.3:
|
/chokidar/3.5.3:
|
||||||
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
||||||
engines: {node: '>= 8.10.0'}
|
engines: {node: '>= 8.10.0'}
|
||||||
@@ -1214,6 +1230,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==}
|
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/csstype/3.0.11:
|
||||||
|
resolution: {integrity: sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/currently-unhandled/0.4.1:
|
/currently-unhandled/0.4.1:
|
||||||
resolution: {integrity: sha1-mI3zP+qxke95mmE2nddsF635V+o=}
|
resolution: {integrity: sha1-mI3zP+qxke95mmE2nddsF635V+o=}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -2447,6 +2467,10 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-locate: 4.1.0
|
p-locate: 4.1.0
|
||||||
|
|
||||||
|
/lodash-es/4.17.21:
|
||||||
|
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/lodash.iteratee/4.7.0:
|
/lodash.iteratee/4.7.0:
|
||||||
resolution: {integrity: sha1-vkF32yiajMw8CZDx2ya1si/BVUw=}
|
resolution: {integrity: sha1-vkF32yiajMw8CZDx2ya1si/BVUw=}
|
||||||
dev: true
|
dev: true
|
||||||
@@ -3745,6 +3769,11 @@ packages:
|
|||||||
spdx-expression-parse: 3.0.1
|
spdx-expression-parse: 3.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/validator/13.7.0:
|
||||||
|
resolution: {integrity: sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==}
|
||||||
|
engines: {node: '>= 0.10'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/vfile-message/1.1.1:
|
/vfile-message/1.1.1:
|
||||||
resolution: {integrity: sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==}
|
resolution: {integrity: sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3907,6 +3936,20 @@ packages:
|
|||||||
resolution: {integrity: sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==}
|
resolution: {integrity: sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vue-chart-3/3.1.8_chart.js@3.7.1+vue@3.2.31:
|
||||||
|
resolution: {integrity: sha512-zX5ajjQi/PocEqLETlej3vp92q/tnI/Fvu2RVb++Kap8qOrXu6PXCpodi73BFrWzEGZIAnqoUxC3OIkRWD657g==}
|
||||||
|
peerDependencies:
|
||||||
|
chart.js: '=> ^3.1.0'
|
||||||
|
vue: '>= 3'
|
||||||
|
dependencies:
|
||||||
|
'@vue/runtime-core': 3.2.31
|
||||||
|
'@vue/runtime-dom': 3.2.31
|
||||||
|
chart.js: 3.7.1
|
||||||
|
csstype: 3.0.11
|
||||||
|
lodash-es: 4.17.21
|
||||||
|
vue: 3.2.31
|
||||||
|
dev: false
|
||||||
|
|
||||||
/vue-demi/0.12.5_vue@3.2.31:
|
/vue-demi/0.12.5_vue@3.2.31:
|
||||||
resolution: {integrity: sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==}
|
resolution: {integrity: sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|||||||
74
src/App.vue
74
src/App.vue
@@ -1,48 +1,94 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Home from "./pages/Login.vue";
|
import Home from "./pages/Home.vue";
|
||||||
// This starter template is using Vue 3 <script setup> SFCs
|
// This starter template is using Vue 3 <script setup> SFCs
|
||||||
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
|
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
|
||||||
import HelloWorld from "./components/HelloWorld.vue";
|
|
||||||
import { MathStatement } from "./support/parse";
|
import { MathStatement } from "./support/parse";
|
||||||
import { MathPage } from "./support/page";
|
import { MathPage } from "./support/page";
|
||||||
import { ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
|
import { checkLoggedIn, loggedOut, loggedIn } from "./support/auth";
|
||||||
|
import router from "./router";
|
||||||
|
import { Dark } from "quasar";
|
||||||
|
|
||||||
(window as any).Stmt = MathStatement;
|
(window as any).Stmt = MathStatement;
|
||||||
(window as any).Pg = MathPage;
|
(window as any).Pg = MathPage;
|
||||||
|
|
||||||
|
const status = ref(checkLoggedIn());
|
||||||
|
(async () => {
|
||||||
|
const response = await fetch("/api/login/status/", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const res = ((await response.json()) as unknown) as any;
|
||||||
|
if (res.data.hasUser) {
|
||||||
|
loggedIn();
|
||||||
|
}
|
||||||
|
status.value = checkLoggedIn();
|
||||||
|
})();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
status.value = checkLoggedIn();
|
||||||
|
console.log(status.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.afterEach(() => {
|
||||||
|
status.value = checkLoggedIn();
|
||||||
|
console.log(status.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
const logout = async () => {
|
||||||
|
const response = await fetch("/api/logout/", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
loggedOut();
|
||||||
|
status.value = checkLoggedIn();
|
||||||
|
router.push({ path: "/" });
|
||||||
|
};
|
||||||
|
Dark.set(true)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-layout view="hHr LpR fFf">
|
<q-layout view="hHr LpR fFf">
|
||||||
<q-header elevated class="bg-primary text-white" height-hint="98">
|
<q-header elevated class="bg-primary text-white">
|
||||||
<q-toolbar>
|
<q-toolbar>
|
||||||
<q-toolbar-title>
|
<q-toolbar-title>
|
||||||
<q-avatar>
|
<q-avatar size="50px">
|
||||||
<img src="https://cdn.quasar.dev/logo-v2/svg/logo-mono-white.svg" />
|
<img src="./assets/l2.svg" />
|
||||||
</q-avatar>
|
</q-avatar>
|
||||||
Title
|
<span style="font-family: 'Cinzel Decorative', cursive;">Crystal Math Worktable</span>
|
||||||
</q-toolbar-title>
|
</q-toolbar-title>
|
||||||
|
<q-btn v-if="status" @click="logout()" label="Logout"></q-btn>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
|
|
||||||
<q-tabs align="left">
|
<!-- <q-tabs>
|
||||||
<q-route-tab to="/Scratch" label="Scratch" />
|
<q-route-tab to="/Scratch" label="Scratch" />
|
||||||
<q-route-tab to="/Editor" label="Editor" />
|
<q-route-tab to="/Editor" label="Editor" />
|
||||||
|
<q-tab v-if="status" @click="logout()" label="Logout" />
|
||||||
</q-tabs>
|
</q-tabs>-->
|
||||||
</q-header>
|
</q-header>
|
||||||
|
|
||||||
<q-page-container>
|
<q-page-container style="display: flex;padding-top: 0px;">
|
||||||
<router-view />
|
<router-view />
|
||||||
</q-page-container>
|
</q-page-container>
|
||||||
</q-layout>
|
</q-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@import url("https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&display=swap");
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #2c3e50;
|
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
.titleBar {
|
||||||
|
font-family: "Cinzel Decorative";
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
||||||
<defs>
|
<defs>
|
||||||
<pattern id="smallGrid" width="8" height="8" patternUnits="userSpaceOnUse">
|
<pattern id="smallGrid" width="25" height="25" patternUnits="userSpaceOnUse">
|
||||||
<path d="M 8 0 L 0 0 0 8" fill="none" stroke="gray" stroke-width="0.5"/>
|
<!-- <path d="M 25 0 L 0 0 0 25" fill="none" stroke="gray" stroke-width="0.5"/> -->
|
||||||
|
<circle cx="0.5" cy=".5" r=".25" stroke="#bcbcbc" fill="transparent" stroke-width="1"/>
|
||||||
</pattern>
|
</pattern>
|
||||||
<pattern id="grid" width="80" height="80" patternUnits="userSpaceOnUse">
|
<pattern id="grid" width="250" height="250" patternUnits="userSpaceOnUse">
|
||||||
<rect width="80" height="80" fill="url(#smallGrid)"/>
|
<rect width="250" height="250" fill="url(#smallGrid)"/>
|
||||||
<path d="M 80 0 L 0 0 0 80" fill="none" stroke="gray" stroke-width="1"/>
|
<path d="M 250 0 L 0 0 0 250" fill="none" stroke="#f5f5f5" stroke-width="2"/>
|
||||||
</pattern>
|
</pattern>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 561 B After Width: | Height: | Size: 679 B |
77
src/assets/l2.svg
Normal file
77
src/assets/l2.svg
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="210mm"
|
||||||
|
height="297mm"
|
||||||
|
viewBox="0 0 210 297"
|
||||||
|
version="1.1"
|
||||||
|
id="svg13372"
|
||||||
|
inkscape:version="1.2-beta (1b65182ce9, 2022-04-05)"
|
||||||
|
sodipodi:docname="l2.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview13374"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pagecheckerboard="true"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="0.733172"
|
||||||
|
inkscape:cx="497.15483"
|
||||||
|
inkscape:cy="634.23044"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1001"
|
||||||
|
inkscape:window-x="-7"
|
||||||
|
inkscape:window-y="-7"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="g5278">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid59924" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs13369" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:label="Text"
|
||||||
|
transform="matrix(0.26458333,0,0,0.26458333,10.166581,13.777983)"
|
||||||
|
style="fill:#550000">
|
||||||
|
<g
|
||||||
|
id="g5278">
|
||||||
|
<g
|
||||||
|
aria-label="C"
|
||||||
|
transform="scale(0.96764101,1.0334411)"
|
||||||
|
id="text6305"
|
||||||
|
style="font-weight:bold;font-size:969.291px;font-family:'Cinzel Decorative';-inkscape-font-specification:'Cinzel Decorative Bold';fill:#ffffff;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4.8">
|
||||||
|
<path
|
||||||
|
d="m 734.8651,491.73955 q 0,166.71805 -90.14406,260.73928 -89.17477,93.05194 -252.98496,93.05194 -110.49917,0 -199.67395,-46.52597 Q 103.85665,752.47883 54.422811,672.02768 5.9582599,591.57652 5.9582599,492.70884 q 0,-99.83698 48.4645511,-180.28813 48.464549,-80.45116 133.762159,-126.00783 85.29761,-46.52597 189.98104,-46.52597 65.91179,0 133.76216,18.41653 68.81966,17.44724 114.37634,47.49526 l 19.38582,136.67003 h -8.72362 Q 616.6116,261.04829 542.94548,215.49161 469.27937,168.96564 379.1353,168.96564 q -128.9157,0 -215.1826,92.08265 -85.297614,91.11335 -85.297614,229.72197 0,138.60861 88.205484,232.62984 89.17477,93.05194 232.62984,93.05194 143.45507,0 233.59914,-93.05194 91.11335,-93.05194 91.11335,-254.92354 h 9.69291 q 0.96929,11.63149 0.96929,23.26299 z"
|
||||||
|
style="font-weight:normal;-inkscape-font-specification:'Cinzel Decorative'"
|
||||||
|
id="path5280" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
aria-label="M"
|
||||||
|
transform="scale(0.97653789,1.0240258)"
|
||||||
|
id="text6413"
|
||||||
|
style="font-size:463.256px;font-family:'Cinzel Decorative';-inkscape-font-specification:'Cinzel Decorative';fill:#ffffff;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4.8">
|
||||||
|
<path
|
||||||
|
d="m 75.88058,279.97194 q 26.40559,-11.11814 45.86235,-11.11814 19.45675,0 34.28094,3.70605 14.82419,3.70605 30.11164,12.50791 15.75071,8.33861 29.18513,20.84652 25.94234,24.55257 44.00932,55.59072 l 92.6512,173.72101 134.34425,-231.16475 h 4.1693 l 48.17863,272.39453 q 11.11814,63.00282 38.45024,100.0633 27.33211,37.52374 75.04748,37.52374 3.24279,0 6.02233,0 v 4.63256 q -25.47908,6.94884 -50.03165,6.94884 -50.03165,0 -91.26144,-39.37676 -39.84001,-37.52374 -54.20095,-109.79168 l -22.69954,-134.8075 -87.09213,151.02146 q -17.60373,29.18513 -18.06699,51.42142 h -4.1693 L 215.32064,425.43433 192.62109,610.73674 q -1.38976,10.65489 9.26513,17.14047 4.1693,2.77954 8.80186,2.77954 h 7.4121 v 4.1693 h -96.82051 v -4.63256 h 7.4121 q 12.04465,0 21.30977,-6.94884 9.72838,-7.4121 12.04466,-19.92001 l 31.50141,-220.97312 q -20.84652,-37.06048 -47.71537,-65.78235 -30.11164,-32.42792 -63.00282,-32.42792 -3.242792,0 -6.022328,0.46325 z"
|
||||||
|
style="font-weight:bold;-inkscape-font-specification:'Cinzel Decorative Bold'"
|
||||||
|
id="path5283" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.1 KiB |
54040
src/assets/logo.svg
Normal file
54040
src/assets/logo.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 2.7 MiB |
@@ -1,9 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineEmits, ref} from 'vue'
|
import {defineEmits, onMounted, ref} from 'vue'
|
||||||
import {MathStatement} from '../support/parse'
|
import {MathStatement} from '../support/parse'
|
||||||
import Katex from '../components/Katex.vue'
|
import Katex from './Katex.vue'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import {StatementID} from '../types'
|
import {StatementID} from '../support/types'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
statement?: MathStatement,
|
||||||
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(eventName: 'save', statement: MathStatement): void
|
(eventName: 'save', statement: MathStatement): void
|
||||||
@@ -28,8 +32,8 @@ const validateExpression = () => {
|
|||||||
return 'The expression is invalid'
|
return 'The expression is invalid'
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( stmt.defines().length > 0 ) {
|
if ( stmt.defines().length > 0 || stmt.isFunctionDeclaration() ) {
|
||||||
return 'Expressions cannot declare variables'
|
return 'Expressions cannot declare variables or functions'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,16 +43,28 @@ const saveExpression = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('save', new MathStatement(
|
if ( props.statement ) {
|
||||||
uuidv4() as StatementID,
|
props.statement.raw = expressionValue.value
|
||||||
expressionValue.value
|
emit('save', props.statement)
|
||||||
))
|
} else {
|
||||||
|
emit('save', new MathStatement(
|
||||||
|
uuidv4() as StatementID,
|
||||||
|
expressionValue.value
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( props.statement ) {
|
||||||
|
expressionValue.value = props.statement.raw
|
||||||
|
updateExpressionPreview()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section v-if="expressionValue">
|
||||||
<div style="display: flex; justify-content: center">
|
<div style="display: flex; justify-content: center">
|
||||||
<Katex
|
<Katex
|
||||||
:key="expressionPreviewKey"
|
:key="expressionPreviewKey"
|
||||||
97
src/components/FunctionEditor.vue
Normal file
97
src/components/FunctionEditor.vue
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {MathStatement} from '../support/parse'
|
||||||
|
import {onMounted, ref} from 'vue'
|
||||||
|
import {v4 as uuidv4} from 'uuid'
|
||||||
|
import {StatementID} from '../support/types'
|
||||||
|
import Katex from './Katex.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
statement?: MathStatement,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(eventName: 'save', statement: MathStatement): void,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const functionPreview = ref(MathStatement.temp(''))
|
||||||
|
let functionPreviewKey = ref(uuidv4())
|
||||||
|
const functionError = ref<string|undefined>(undefined)
|
||||||
|
const functionValue = ref('')
|
||||||
|
|
||||||
|
const updateFunctionPreview = () => {
|
||||||
|
const previewStmt = MathStatement.temp(functionValue.value)
|
||||||
|
if ( previewStmt.isValid() ) {
|
||||||
|
functionPreview.value = MathStatement.temp(functionValue.value)
|
||||||
|
functionPreviewKey.value = uuidv4()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const validateFunction = () => {
|
||||||
|
if ( !functionValue.value ) {
|
||||||
|
return 'Missing function declaration'
|
||||||
|
}
|
||||||
|
|
||||||
|
const stmt = MathStatement.temp(functionValue.value)
|
||||||
|
if ( !stmt.isValid() || !stmt.isFunctionDeclaration() ) {
|
||||||
|
return 'Function definition is invalid'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !stmt.isNotRecursive() ) {
|
||||||
|
return 'A function may not reference itself'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveFunction = () => {
|
||||||
|
functionError.value = validateFunction()
|
||||||
|
if ( functionError.value ) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( props.statement ) {
|
||||||
|
props.statement.raw = functionValue.value
|
||||||
|
emit('save', props.statement)
|
||||||
|
} else {
|
||||||
|
emit('save', new MathStatement(
|
||||||
|
uuidv4() as StatementID,
|
||||||
|
functionValue.value
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( props.statement ) {
|
||||||
|
functionValue.value = props.statement.raw
|
||||||
|
updateFunctionPreview()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<div v-if="functionValue" style="display: flex; justify-content: center">
|
||||||
|
<Katex
|
||||||
|
:key="functionPreviewKey"
|
||||||
|
:statement="functionPreview"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section v-if="functionError">
|
||||||
|
<div style="color: darkred; font-weight: bold">{{ functionError }}</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<q-input
|
||||||
|
v-model="functionValue"
|
||||||
|
v-on:update:model-value="() => updateFunctionPreview()"
|
||||||
|
outlined
|
||||||
|
type="textarea"
|
||||||
|
autogrow
|
||||||
|
label="Value"
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions align="right" class="text-primary">
|
||||||
|
<q-btn flat label="Cancel" v-close-popup></q-btn>
|
||||||
|
<q-btn flat label="Save" @click="() => saveFunction()"></q-btn>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
73
src/components/ImageBox.vue
Normal file
73
src/components/ImageBox.vue
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { ImageContainer } from "../support/types";
|
||||||
|
import { stepX, stepY } from "../support/const";
|
||||||
|
const props = defineProps<{ value: ImageContainer }>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(eventName: 'move', x: number, y: number): void,
|
||||||
|
(eventName: 'edit',): void,
|
||||||
|
(eventName: 'remove',): void,
|
||||||
|
|
||||||
|
}>()
|
||||||
|
|
||||||
|
|
||||||
|
function onControlledDrag(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
const { x, y } = e.data;
|
||||||
|
props.value.x = x;
|
||||||
|
props.value.y = y;
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
function onControlledDragStop(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
// console.log(typeof(e))
|
||||||
|
const { x, y } = e.data;
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
console.log(self)
|
||||||
|
emit('move', x, y);
|
||||||
|
onControlledDrag(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Draggable
|
||||||
|
:grid="[stepX, stepY]"
|
||||||
|
:default-position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
:position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
@stop="onControlledDragStop"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<q-card flat bordered>
|
||||||
|
<q-card-section style="padding: 0">
|
||||||
|
<div class="row items-center no-wrap">
|
||||||
|
<q-card-section>
|
||||||
|
<q-img :src="props.value.url" style="min-width: 200px"></q-img>
|
||||||
|
</q-card-section>
|
||||||
|
<div class="col-auto">
|
||||||
|
<q-btn color="grey-7" round flat icon="more_vert">
|
||||||
|
<q-menu cover auto-close>
|
||||||
|
<q-list>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('edit')">Edit</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</Draggable>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="sass" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
126
src/components/Login.vue
Normal file
126
src/components/Login.vue
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import validator from 'validator'
|
||||||
|
import { checkLoggedIn, loggedIn } from '../support/auth'
|
||||||
|
import router from '../router'
|
||||||
|
const name = ref<string>('')
|
||||||
|
const email = ref<string>('')
|
||||||
|
const password = ref<string>('')
|
||||||
|
const passwordConfirm = ref<string>('')
|
||||||
|
const btnDisabled = ref<boolean>(true)
|
||||||
|
const isRegistration = ref<boolean>(false)
|
||||||
|
const error = ref<string>('')
|
||||||
|
|
||||||
|
const checkForm = () => {
|
||||||
|
btnDisabled.value =
|
||||||
|
(isRegistration.value
|
||||||
|
&& (password.value != passwordConfirm.value
|
||||||
|
|| name.value.length == 0))
|
||||||
|
|| password.value.length < 8
|
||||||
|
|| email.value.length == 0
|
||||||
|
|| !validator.isEmail(email.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const submit = async () => {
|
||||||
|
if (isRegistration.value == true) {
|
||||||
|
error.value = await register()
|
||||||
|
} else {
|
||||||
|
error.value = await login()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const login = async () => {
|
||||||
|
const response = await fetch('/api/login/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ email: email.value, password: password.value })
|
||||||
|
})
|
||||||
|
|
||||||
|
const user = (await response.json()) as unknown as any
|
||||||
|
if (!user.success) {
|
||||||
|
return user.message
|
||||||
|
}
|
||||||
|
loggedIn()
|
||||||
|
router.push({ path: '/Listings'})
|
||||||
|
}
|
||||||
|
|
||||||
|
const register = async () => {
|
||||||
|
const response = await fetch('/api/register', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ name:name.value, email:email.value, password:password.value })
|
||||||
|
})
|
||||||
|
const user = (await response.json()) as unknown as any
|
||||||
|
if (!user.success) {
|
||||||
|
return user.message
|
||||||
|
}
|
||||||
|
loggedIn()
|
||||||
|
router.push({ path: '/Listings'})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( checkLoggedIn() ) {
|
||||||
|
router.push({ path: '/Listings'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-card-section v-if="!isRegistration">
|
||||||
|
<q-form class="q-gutter-md">
|
||||||
|
<q-input v-model="email" v-on:keyup="checkForm()" type="email" label="email" />
|
||||||
|
<q-input v-model="password" v-on:keyup="checkForm()" type="password" label="password" />
|
||||||
|
</q-form>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section v-else>
|
||||||
|
<q-form class="q-gutter-md">
|
||||||
|
<q-input v-model="name" v-on:keyup="checkForm()" type="text" label="name" />
|
||||||
|
<q-input v-model="email" v-on:keyup="checkForm()" type="email" label="email" />
|
||||||
|
<q-input v-model="password" v-on:keyup="checkForm()" type="password" label="password" />
|
||||||
|
<q-input
|
||||||
|
v-model="passwordConfirm"
|
||||||
|
v-on:keyup="checkForm()"
|
||||||
|
type="password"
|
||||||
|
label="password confirmation"
|
||||||
|
/>
|
||||||
|
</q-form>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section v-if="error">
|
||||||
|
<p class="error">
|
||||||
|
<b>{{ error }}</b>
|
||||||
|
</p>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions class="q-px-md">
|
||||||
|
<q-btn
|
||||||
|
unelevated
|
||||||
|
color="primary"
|
||||||
|
size="lg"
|
||||||
|
:disable="btnDisabled"
|
||||||
|
class="full-width"
|
||||||
|
:label="isRegistration ? 'Register' : 'Login'"
|
||||||
|
@click="submit()"
|
||||||
|
/>
|
||||||
|
</q-card-actions>
|
||||||
|
<q-card-section class="text-center q-pa-none">
|
||||||
|
<p class="text-grey-6">
|
||||||
|
{{ isRegistration ? 'Have an account?' : 'Not registered?' }}
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click="isRegistration = !isRegistration; checkForm()"
|
||||||
|
>{{ isRegistration ? 'Login' : 'Create an Account' }}</a>
|
||||||
|
</p>
|
||||||
|
</q-card-section>
|
||||||
|
</template>
|
||||||
|
<style>
|
||||||
|
.error {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
152
src/components/RangeChart.vue
Normal file
152
src/components/RangeChart.vue
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import * as math from 'mathjs'
|
||||||
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
import { LineChart } from 'vue-chart-3'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { Chart, ChartData, ChartOptions, registerables } from 'chart.js'
|
||||||
|
import { MathStatement } from '../support/parse'
|
||||||
|
import { ChartBox } from '../support/types'
|
||||||
|
import { stepX, stepY } from '../support/const'
|
||||||
|
|
||||||
|
Chart.register(...registerables)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(eventName: 'move', x: number, y: number): void,
|
||||||
|
(eventName: 'edit'): void,
|
||||||
|
(eventName: 'remove'): void,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
fn: MathStatement,
|
||||||
|
value: ChartBox,
|
||||||
|
}>()
|
||||||
|
const options = ref({
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
labels: {
|
||||||
|
color: "white",
|
||||||
|
font: {
|
||||||
|
size: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
ticks: {
|
||||||
|
color: "white",
|
||||||
|
font: {
|
||||||
|
size: 15,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: '#ccc'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
x: {
|
||||||
|
ticks: {
|
||||||
|
color: "white",
|
||||||
|
font: {
|
||||||
|
size: 14
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
color: '#ccc'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const getChartData = (): ChartData<'line'> => {
|
||||||
|
const range = []
|
||||||
|
const min = Math.min(props.value.minX, props.value.maxX)
|
||||||
|
const max = Math.max(props.value.minX, props.value.maxX)
|
||||||
|
for (let i = min; i <= max; i += parseFloat(String(props.value.stepX)) || 1) {
|
||||||
|
range.push(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!props.fn.isFunctionDeclaration()) {
|
||||||
|
throw new TypeError('Cannot chart node that is not a function.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const node = props.fn.parse() as math.FunctionAssignmentNode
|
||||||
|
const fn = node.compile().evaluate() // FIXME need dependencies in scope
|
||||||
|
|
||||||
|
console.log('getChartData', {
|
||||||
|
labels: range.map(x => `${x}`),
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: node.name,
|
||||||
|
data: range.map(n => fn(n)),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
labels: range.map(x => `${x}`),
|
||||||
|
datasets: [{
|
||||||
|
label: node.name,
|
||||||
|
backgroundColor: '#553564',
|
||||||
|
data: range.map(x => fn(x)),
|
||||||
|
pointRadius: 5
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const chartData = ref(getChartData())
|
||||||
|
const chartKey = ref(uuidv4())
|
||||||
|
computed(() => {
|
||||||
|
chartData.value = getChartData()
|
||||||
|
chartKey.value = uuidv4()
|
||||||
|
})
|
||||||
|
|
||||||
|
function onControlledDrag(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
const { x, y } = e.data;
|
||||||
|
props.value.x = x;
|
||||||
|
props.value.y = y;
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
function onControlledDragStop(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
// console.log(typeof(e))
|
||||||
|
const { x, y } = e.data;
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
console.log(self)
|
||||||
|
emit('move', x, y);
|
||||||
|
onControlledDrag(e);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<Draggable
|
||||||
|
:grid="[stepX, stepY]"
|
||||||
|
:default-position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
:position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
@stop="onControlledDragStop"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style="background: var(--q-dark); display: flex; flex-direction: row; border: 1px solid #ccc; border-radius: 3px;"
|
||||||
|
>
|
||||||
|
<LineChart :options="options" :chartData="chartData" :key="chartKey" class="inner-chart" />
|
||||||
|
<div class="sidebar">
|
||||||
|
<q-btn color="grey-7" round flat icon="more_vert">
|
||||||
|
<q-menu cover auto-close>
|
||||||
|
<q-list>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('edit')">Edit</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Draggable>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
||||||
118
src/components/RangeChartEditor.vue
Normal file
118
src/components/RangeChartEditor.vue
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import * as math from 'mathjs'
|
||||||
|
import {onMounted, ref} from 'vue'
|
||||||
|
import {MathStatement} from '../support/parse'
|
||||||
|
import {v4 as uuidv4} from 'uuid'
|
||||||
|
import Katex from './Katex.vue'
|
||||||
|
import {ChartBox, StatementID} from '../support/types'
|
||||||
|
import {MathPage} from '../support/page'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
page: MathPage,
|
||||||
|
chartBox?: ChartBox,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(eventName: 'save', statement: ChartBox): void,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const chartBoxModalError = ref<string|undefined>(undefined)
|
||||||
|
const chartBoxFunctionName = ref('')
|
||||||
|
const chartBoxMinXValue = ref(0)
|
||||||
|
const chartBoxMaxXValue = ref(30)
|
||||||
|
const chartBoxStepXValue = ref(1)
|
||||||
|
|
||||||
|
const validateChartBox = () => {
|
||||||
|
if ( !chartBoxFunctionName.value ) {
|
||||||
|
return 'Missing function name'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isNaN(parseFloat(String(chartBoxMinXValue.value))) ) {
|
||||||
|
return 'Invalid minimum X-value'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isNaN(parseFloat(String(chartBoxMaxXValue.value))) ) {
|
||||||
|
return 'Invalid maximum X-value'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isNaN(parseFloat(String(chartBoxStepXValue.value))) ) {
|
||||||
|
return 'Invalid X-value step size'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !props.page.getFunctionByName(chartBoxFunctionName.value) ) {
|
||||||
|
return 'Invalid function name'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveChartBox = () => {
|
||||||
|
chartBoxModalError.value = validateChartBox()
|
||||||
|
if ( chartBoxModalError.value ) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( props.chartBox ) {
|
||||||
|
props.chartBox.fnName = chartBoxFunctionName.value
|
||||||
|
props.chartBox.minX = chartBoxMinXValue.value
|
||||||
|
props.chartBox.maxX = chartBoxMaxXValue.value
|
||||||
|
props.chartBox.stepX = chartBoxStepXValue.value
|
||||||
|
emit('save', props.chartBox)
|
||||||
|
} else {
|
||||||
|
emit('save', new ChartBox(
|
||||||
|
chartBoxFunctionName.value,
|
||||||
|
chartBoxMinXValue.value,
|
||||||
|
chartBoxMaxXValue.value,
|
||||||
|
chartBoxStepXValue.value,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( props.chartBox ) {
|
||||||
|
chartBoxFunctionName.value = props.chartBox.fnName
|
||||||
|
chartBoxMinXValue.value = props.chartBox.minX
|
||||||
|
chartBoxMaxXValue.value = props.chartBox.maxX
|
||||||
|
chartBoxStepXValue.value = props.chartBox.stepX
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section v-if="chartBoxModalError">
|
||||||
|
<div style="color: darkred; font-weight: bold">{{ chartBoxModalError }}</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<q-input
|
||||||
|
v-model="chartBoxFunctionName"
|
||||||
|
outlined
|
||||||
|
autofocus
|
||||||
|
label="Function name"
|
||||||
|
/>
|
||||||
|
<br>
|
||||||
|
<q-input
|
||||||
|
v-model="chartBoxMinXValue"
|
||||||
|
outlined
|
||||||
|
autofocus
|
||||||
|
label="Minimum X-value"
|
||||||
|
/>
|
||||||
|
<br>
|
||||||
|
<q-input
|
||||||
|
v-model="chartBoxMaxXValue"
|
||||||
|
outlined
|
||||||
|
autofocus
|
||||||
|
label="Maximum X-value"
|
||||||
|
/>
|
||||||
|
<br>
|
||||||
|
<q-input
|
||||||
|
v-model="chartBoxStepXValue"
|
||||||
|
outlined
|
||||||
|
autofocus
|
||||||
|
label="X-value step size"
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions align="right" class="text-primary">
|
||||||
|
<q-btn flat label="Cancel" v-close-popup></q-btn>
|
||||||
|
<q-btn flat label="Save" @click="() => saveChartBox()"></q-btn>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
2
src/components/RichTextEditor.vue
Normal file
2
src/components/RichTextEditor.vue
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
|
||||||
0
src/components/RichTextModal.vue
Normal file
0
src/components/RichTextModal.vue
Normal file
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {EvaluationResult, Maybe} from '../types'
|
import {EvaluationResult, Maybe} from '../support/types'
|
||||||
import {MathStatement} from '../support/parse'
|
import {MathStatement} from '../support/parse'
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
import Katex from './Katex.vue'
|
import Katex from './Katex.vue'
|
||||||
@@ -36,18 +36,10 @@ computed(() => value = getValueStatement())
|
|||||||
.sidebar {
|
.sidebar {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-button {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="math-statement" style="background: white">
|
<div class="math-statement" style="background: var(--q-dark)">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<Katex :statement="statement" size="big"/>
|
<Katex :statement="statement" size="big"/>
|
||||||
<div class="result" v-if="value">
|
<div class="result" v-if="value">
|
||||||
@@ -56,9 +48,18 @@ computed(() => value = getValueStatement())
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<button class="edit-button" @click="() => $emit('edit')" title="Edit this expression">
|
<q-btn color="grey-7" round flat icon="more_vert">
|
||||||
<img src="../assets/edit.svg" alt="Edit" height="16">
|
<q-menu cover auto-close>
|
||||||
</button>
|
<q-list>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('edit')">Edit</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item clickable>
|
||||||
|
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,24 +1,58 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { RichTextBox } from "../support/types";
|
||||||
|
import { stepX, stepY } from "../support/const";
|
||||||
|
const props = defineProps<{ value: RichTextBox }>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(eventName: 'move', x: number, y: number): void,
|
||||||
|
(eventName: 'edit',): void,
|
||||||
|
(eventName: 'remove',): void,
|
||||||
|
|
||||||
|
}>()
|
||||||
|
|
||||||
|
|
||||||
|
function onControlledDrag(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
const { x, y } = e.data;
|
||||||
|
props.value.x = x;
|
||||||
|
props.value.y = y;
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
function onControlledDragStop(e: { event: MouseEvent, data: { x: number, y: number } }) {
|
||||||
|
// console.log(typeof(e))
|
||||||
|
const { x, y } = e.data;
|
||||||
|
// const x = e.x;
|
||||||
|
// const y = e.y;
|
||||||
|
console.log(self)
|
||||||
|
emit('move', x, y);
|
||||||
|
onControlledDrag(e);
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
statement: { type: String, required: true },
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Draggable :grid="[25, 25]">
|
<Draggable
|
||||||
<div style="display: flex">
|
:grid="[stepX, stepY]"
|
||||||
|
:default-position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
:position="{ x: props.value.x, y: props.value.y }"
|
||||||
|
@stop="onControlledDragStop"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
<q-card flat bordered>
|
<q-card flat bordered>
|
||||||
<q-card-section>
|
<q-card-section style="padding: 0">
|
||||||
<div class="row items-center no-wrap">
|
<div class="row items-center no-wrap">
|
||||||
<q-card-section v-html="props.statement" />
|
<q-card-section v-html="props.value.text" />
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<q-btn color="grey-7" round flat icon="more_vert">
|
<q-btn color="grey-7" round flat icon="more_vert">
|
||||||
<q-menu cover auto-close>
|
<q-menu cover auto-close>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section @click="() => $emit('edit')">Edit</q-item-section>
|
<q-item-section @click="() => $emit('edit')">
|
||||||
|
<q-item-label>Edit</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
||||||
@@ -34,4 +68,6 @@ const props = defineProps({
|
|||||||
</Draggable>
|
</Draggable>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="sass" scoped></style>
|
<style lang="sass" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref} from 'vue'
|
import * as math from 'mathjs'
|
||||||
|
import {onMounted, ref} from 'vue'
|
||||||
import {MathStatement} from '../support/parse'
|
import {MathStatement} from '../support/parse'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import {v4 as uuidv4} from 'uuid'
|
||||||
import Katex from '../components/Katex.vue'
|
import Katex from './Katex.vue'
|
||||||
import {StatementID} from '../types'
|
import {StatementID} from '../support/types'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
statement?: MathStatement,
|
||||||
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(eventName: 'save', statement: MathStatement): void,
|
(eventName: 'save', statement: MathStatement): void,
|
||||||
@@ -48,11 +53,27 @@ const saveNewVariable = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('save', new MathStatement(
|
if ( props.statement ) {
|
||||||
uuidv4() as StatementID,
|
props.statement.raw = `${newVariableName.value} = ${newVariableValue.value}`
|
||||||
`${newVariableName.value} = ${newVariableValue.value}`
|
emit('save', props.statement)
|
||||||
))
|
} else {
|
||||||
|
emit('save', new MathStatement(
|
||||||
|
uuidv4() as StatementID,
|
||||||
|
`${newVariableName.value} = ${newVariableValue.value}`
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( props.statement ) {
|
||||||
|
const [ define ] = props.statement.defines()
|
||||||
|
newVariableName.value = define.name
|
||||||
|
|
||||||
|
const [_, ...rest] = props.statement.raw.split('=')
|
||||||
|
newVariableValue.value = rest.join('=')
|
||||||
|
updateNewVariablePreview()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
31
src/main.ts
31
src/main.ts
@@ -12,7 +12,7 @@ import router from './router'
|
|||||||
App UI
|
App UI
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
*/
|
*/
|
||||||
import { Quasar } from 'quasar'
|
import { Dark, Quasar } from 'quasar'
|
||||||
|
|
||||||
// Import icon libraries
|
// Import icon libraries
|
||||||
import '@quasar/extras/roboto-font-latin-ext/roboto-font-latin-ext.css'
|
import '@quasar/extras/roboto-font-latin-ext/roboto-font-latin-ext.css'
|
||||||
@@ -20,8 +20,8 @@ import '@quasar/extras/material-icons/material-icons.css'
|
|||||||
import '@quasar/extras/fontawesome-v6/fontawesome-v6.css'
|
import '@quasar/extras/fontawesome-v6/fontawesome-v6.css'
|
||||||
|
|
||||||
// A few examples for animations from Animate.css:
|
// A few examples for animations from Animate.css:
|
||||||
// import @quasar/extras/animate/fadeIn.css
|
import '@quasar/extras/animate/fadeInUp.css'
|
||||||
// import @quasar/extras/animate/fadeOut.css
|
import '@quasar/extras/animate/fadeOutUp.css'
|
||||||
|
|
||||||
// Import Quasar css
|
// Import Quasar css
|
||||||
import 'quasar/src/css/index.sass'
|
import 'quasar/src/css/index.sass'
|
||||||
@@ -32,7 +32,6 @@ import 'quasar/src/css/index.sass'
|
|||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
*/
|
*/
|
||||||
import { DraggablePlugin } from '@braks/revue-draggable'
|
import { DraggablePlugin } from '@braks/revue-draggable'
|
||||||
import { createAuth0 } from '@auth0/auth0-vue'
|
|
||||||
|
|
||||||
import 'katex/dist/katex.min.css'
|
import 'katex/dist/katex.min.css'
|
||||||
import 'katex/dist/contrib/auto-render.min'
|
import 'katex/dist/contrib/auto-render.min'
|
||||||
@@ -47,16 +46,22 @@ import App from './App.vue'
|
|||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(Quasar, {
|
app.use(Quasar, {
|
||||||
plugins: {}, // import Quasar plugins and add here
|
plugins: {Dark}, // import Quasar plugins and add here
|
||||||
})
|
config: {
|
||||||
|
brand: {
|
||||||
|
primary: '#553564',
|
||||||
|
secondary: '#7da9b2',
|
||||||
|
accent: '#9C27B0',
|
||||||
|
|
||||||
app.use(
|
dark: '#1d1d1d',
|
||||||
createAuth0({
|
|
||||||
domain: 'dev-ge84r-eu.us.auth0.com',
|
positive: '#21BA45',
|
||||||
client_id: 'zHjZGg1uPws0DkQg5bRdKcDX8m6AuTZl', // eslint-disable-line camelcase
|
negative: '#C10015',
|
||||||
redirect_uri: window.location.origin, // eslint-disable-line camelcase
|
info: '#31CCEC',
|
||||||
}),
|
warning: '#F2C037',
|
||||||
)
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,193 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import WrapperBox from '../components/WrapperBox.vue'
|
import { MathPage } from '../support/page'
|
||||||
import {MathPage} from '../support/page'
|
import { MathStatement } from '../support/parse'
|
||||||
import {MathStatement} from '../support/parse'
|
import { ChartBox, EvaluationResult, hasOwnProperty } from '../support/types'
|
||||||
import Katex from '../components/Katex.vue'
|
|
||||||
import {EvaluationResult, StatementID} from '../types'
|
|
||||||
import Statement from '../components/Statement.vue'
|
import Statement from '../components/Statement.vue'
|
||||||
import VarDeclEditor from './VarDeclEditor.vue'
|
import VarDeclEditor from '../components/VarDeclEditor.vue'
|
||||||
import ExpressionEditor from './ExpressionEditor.vue'
|
import ExpressionEditor from '../components/ExpressionEditor.vue'
|
||||||
import TextBox from '../components/TextBox.vue'
|
import TextBox from '../components/TextBox.vue'
|
||||||
|
import ImageBox from '../components/ImageBox.vue'
|
||||||
|
|
||||||
const math = new MathPage(uuidv4())
|
import FunctionEditor from '../components/FunctionEditor.vue'
|
||||||
const statements = ref<MathStatement[]>([])
|
import { RichTextBox, ImageContainer } from '../support/types'
|
||||||
const evaluation = ref<EvaluationResult|undefined>()
|
import RangeChart from '../components/RangeChart.vue'
|
||||||
const statementsKey = ref<string>(uuidv4())
|
import RangeChartEditor from '../components/RangeChartEditor.vue'
|
||||||
|
import { stepX, stepY } from '../support/const'
|
||||||
|
import { checkLoggedIn, loggedOut } from '../support/auth'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
pageId?: number,
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const math = ref(new MathPage(uuidv4()));
|
||||||
|
const pageTitle = ref('New Page');
|
||||||
|
const statements = ref<MathStatement[]>([]);
|
||||||
|
const evaluation = ref<EvaluationResult | undefined>();
|
||||||
|
const statementsKey = ref<string>(uuidv4());
|
||||||
const leftDrawerOpen = ref(false);
|
const leftDrawerOpen = ref(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const variableListingColumns = [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
field: 'name',
|
||||||
|
label: 'Variable',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'value',
|
||||||
|
field: 'value',
|
||||||
|
label: 'Value',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const stmOnControlledDragStop = (stmt: MathStatement) => (e: { event: MouseEvent, data: { x: number, y: number } }) => {
|
||||||
|
console.log(e)
|
||||||
|
console.log("moved stm5", stmt)
|
||||||
|
const { x, y } = e.data;
|
||||||
|
stmt.x = x;
|
||||||
|
stmt.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const variableListingRows = ref<({ name: string, value: string })[]>([])
|
||||||
|
|
||||||
|
const functionListingColumns = [
|
||||||
|
{
|
||||||
|
name: 'value',
|
||||||
|
field: 'value',
|
||||||
|
label: 'Function',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const functionListingRows = ref<({ name: string, value: string })[]>([])
|
||||||
|
|
||||||
function toggleLeftDrawer() {
|
function toggleLeftDrawer() {
|
||||||
leftDrawerOpen.value = !leftDrawerOpen.value;
|
leftDrawerOpen.value = !leftDrawerOpen.value
|
||||||
}
|
}
|
||||||
|
|
||||||
const newVariableModalOpen = ref(false)
|
const newVariableModalOpen = ref(false)
|
||||||
const openNewVariableDeclModal = () => {
|
const openNewVariableDeclModal = () => {
|
||||||
newVariableModalOpen.value = true
|
newVariableModalOpen.value = true
|
||||||
}
|
};
|
||||||
|
|
||||||
const newExpressionModalOpen = ref(false)
|
const newExpressionModalOpen = ref(false)
|
||||||
const openNewExpressionModal = () => {
|
const openNewExpressionModal = () => {
|
||||||
newExpressionModalOpen.value = true
|
newExpressionModalOpen.value = true
|
||||||
|
};
|
||||||
|
|
||||||
|
const newFunctionModalOpen = ref(false)
|
||||||
|
const openNewFunctionModal = () => {
|
||||||
|
newFunctionModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const editingStatement = ref<MathStatement | undefined>()
|
||||||
|
const editExpressionModalOpen = ref(false)
|
||||||
|
const openEditExpressionModal = () => {
|
||||||
|
editExpressionModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const editVarDeclModalOpen = ref(false)
|
||||||
|
const openEditVarDeclModal = () => {
|
||||||
|
editVarDeclModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const editFunctionModalOpen = ref(false)
|
||||||
|
const openEditFunctionModal = () => {
|
||||||
|
editFunctionModalOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateStatements = () => {
|
const updateStatements = () => {
|
||||||
statements.value = math.getStatements()
|
statements.value = math.value.getStatements();
|
||||||
try {
|
try {
|
||||||
evaluation.value = math.evaluate()
|
evaluation.value = math.value.evaluate()
|
||||||
|
const variableValues: ({ name: string, value: string })[] = []
|
||||||
|
|
||||||
|
for (const name in evaluation.value!.variables) {
|
||||||
|
if (!hasOwnProperty(evaluation.value!.variables, name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = String(evaluation.value!.variables[name] ?? '')
|
||||||
|
try {
|
||||||
|
const stmt = MathStatement.temp(value)
|
||||||
|
value = stmt.toHTMLString()
|
||||||
|
} catch (_) { }
|
||||||
|
|
||||||
|
variableValues.push({
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
variableListingRows.value = variableValues
|
||||||
|
|
||||||
|
const functionValues: ({ name: string, value: string })[] = []
|
||||||
|
for (const stmt of math.value.functions()) {
|
||||||
|
const node = stmt.parse() as math.FunctionAssignmentNode
|
||||||
|
functionValues.push({
|
||||||
|
name: node.name,
|
||||||
|
value: stmt.toHTMLString(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
functionListingRows.value = functionValues
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
console.error(_)
|
||||||
evaluation.value = undefined
|
evaluation.value = undefined
|
||||||
}
|
}
|
||||||
statementsKey.value = uuidv4()
|
statementsKey.value = uuidv4()
|
||||||
}
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateStatements()
|
||||||
|
})
|
||||||
|
|
||||||
const saveNewVariable = (stmt: MathStatement) => {
|
const saveNewVariable = (stmt: MathStatement) => {
|
||||||
math.addStatement(stmt)
|
math.value.addStatement(stmt)
|
||||||
newVariableModalOpen.value = false
|
newVariableModalOpen.value = false
|
||||||
updateStatements()
|
updateStatements()
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveNewExpression = (stmt: MathStatement) => {
|
||||||
|
math.value.addStatement(stmt)
|
||||||
|
newExpressionModalOpen.value = false
|
||||||
|
updateStatements()
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveNewFunction = (stmt: MathStatement) => {
|
||||||
|
math.value.addStatement(stmt)
|
||||||
|
newFunctionModalOpen.value = false
|
||||||
|
updateStatements()
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveNewExpression = (stmt: MathStatement) => {
|
const editStatement = (stmt: MathStatement) => {
|
||||||
math.addStatement(stmt)
|
editingStatement.value = stmt
|
||||||
newExpressionModalOpen.value = false
|
console.log('editStatement', stmt)
|
||||||
|
if (stmt.isFunctionDeclaration()) {
|
||||||
|
openEditFunctionModal()
|
||||||
|
} else if (stmt.isDeclaration()) {
|
||||||
|
openEditVarDeclModal()
|
||||||
|
} else {
|
||||||
|
openEditExpressionModal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeStatement = (stmt: MathStatement) => {
|
||||||
|
math.value.removeStatement(stmt.id)
|
||||||
|
updateStatements()
|
||||||
|
}
|
||||||
|
|
||||||
|
const finishEditStatement = () => {
|
||||||
|
editExpressionModalOpen.value = false
|
||||||
|
editVarDeclModalOpen.value = false
|
||||||
|
editFunctionModalOpen.value = false
|
||||||
updateStatements()
|
updateStatements()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,26 +195,243 @@ const saveNewExpression = (stmt: MathStatement) => {
|
|||||||
Rich Text Stuff
|
Rich Text Stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const richTextStatments = ref([
|
const makeNewRichTextBox = () => {
|
||||||
{ text: "test" },
|
richTextStatements.value.push(new RichTextBox(''));
|
||||||
{ text: "test2" },
|
richEditID.value = richTextStatements.value.length - 1;
|
||||||
{ text: "test3" },
|
richEditExpression.value = richTextStatements.value[richEditID.value].text;
|
||||||
]);
|
richEditModal.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const chartBoxKey = ref(uuidv4())
|
||||||
|
const chartBoxes = ref<ChartBox[]>([])
|
||||||
|
|
||||||
|
const newChartModalOpen = ref(false)
|
||||||
|
const openNewChartModal = () => {
|
||||||
|
newChartModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveNewChartBox = (chartBox: ChartBox) => {
|
||||||
|
chartBoxes.value.push(chartBox)
|
||||||
|
newChartModalOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const editingChartBox = ref<ChartBox | undefined>()
|
||||||
|
const chartEditModalOpen = ref(false)
|
||||||
|
const openChartEditModal = (box: ChartBox) => {
|
||||||
|
editingChartBox.value = box
|
||||||
|
chartEditModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveEditingChartBox = () => {
|
||||||
|
chartEditModalOpen.value = false
|
||||||
|
chartBoxKey.value = uuidv4()
|
||||||
|
}
|
||||||
|
|
||||||
|
const moveChartBox = (id: number, x: number, y: number) => {
|
||||||
|
chartBoxes.value[id].x = x
|
||||||
|
chartBoxes.value[id].y = y
|
||||||
|
}
|
||||||
|
const removeChartBox = (id: number) => {
|
||||||
|
chartBoxes.value.splice(id, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const richTextStatements = ref<RichTextBox[]>([
|
||||||
|
new RichTextBox("Hello World"),
|
||||||
|
]);
|
||||||
const richEditModal = ref(false);
|
const richEditModal = ref(false);
|
||||||
const richEditExpression = ref("");
|
const richEditExpression = ref("");
|
||||||
const richEditID = ref(0);
|
const richEditID = ref(0);
|
||||||
|
|
||||||
const richEditStatement = (id: number) => {
|
const richEditStatement = (id: number) => {
|
||||||
console.log("editing statement", id, richEditModal);
|
|
||||||
richEditModal.value = true;
|
richEditModal.value = true;
|
||||||
richEditID.value = id;
|
richEditID.value = id;
|
||||||
richEditExpression.value = richTextStatments.value[richEditID.value].text;
|
richEditExpression.value = richTextStatements.value[richEditID.value].text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const moveRichTextBox = (id: number, x: number, y: number) => {
|
||||||
|
richEditID.value = id;
|
||||||
|
richTextStatements.value[richEditID.value].x = x;
|
||||||
|
richTextStatements.value[richEditID.value].y = y;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function richUpdateValue() {
|
function richUpdateValue() {
|
||||||
richTextStatments.value[richEditID.value].text = richEditExpression.value;
|
richTextStatements.value[richEditID.value].text = richEditExpression.value;
|
||||||
}
|
}
|
||||||
|
const removeRichTextBox = (id: number) => {
|
||||||
|
console.log(richTextStatements.value[id]);
|
||||||
|
richTextStatements.value.splice(id, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Image box
|
||||||
|
*/
|
||||||
|
|
||||||
|
const makeNewImageBox = () => {
|
||||||
|
images.value.push(new ImageContainer(''));
|
||||||
|
imageID.value = images.value.length - 1;
|
||||||
|
imageURL.value = images.value[richEditID.value].url;
|
||||||
|
imageModal.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const images = ref<ImageContainer[]>([]);
|
||||||
|
|
||||||
|
const imageModal = ref(false);
|
||||||
|
const imageURL = ref("");
|
||||||
|
const imageID = ref(0);
|
||||||
|
|
||||||
|
const imageEditStatement = (id: number) => {
|
||||||
|
imageModal.value = true;
|
||||||
|
imageID.value = id;
|
||||||
|
imageURL.value = images.value[imageID.value].url;
|
||||||
|
};
|
||||||
|
|
||||||
|
const moveImageBox = (id: number, x: number, y: number) => {
|
||||||
|
imageID.value = id;
|
||||||
|
images.value[imageID.value].x = x;
|
||||||
|
images.value[imageID.value].y = y;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function imageUpdateValue() {
|
||||||
|
images.value[imageID.value].url = imageURL.value;
|
||||||
|
}
|
||||||
|
const removeimageBox = (id: number) => {
|
||||||
|
console.log(images.value[id]);
|
||||||
|
images.value.splice(id, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Auth
|
||||||
|
*/
|
||||||
|
const status = ref(checkLoggedIn())
|
||||||
|
const logout = async () => {
|
||||||
|
const response = await fetch('/api/logout/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
loggedOut()
|
||||||
|
status.value = checkLoggedIn()
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
status.value = checkLoggedIn()
|
||||||
|
console.log(status.value)
|
||||||
|
if (status.value == false) {
|
||||||
|
router.push({ path: '/' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const serialize = () => {
|
||||||
|
return {
|
||||||
|
title: pageTitle.value,
|
||||||
|
page: math.value.serialize(),
|
||||||
|
textBoxes: richTextStatements.value.map(x => x.serialize()),
|
||||||
|
chartBoxes: chartBoxes.value.map(x => x.serialize()),
|
||||||
|
imageBoxes: images.value.map(x => x.serialize()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const editorPageId = ref<number|undefined>()
|
||||||
|
const saveEditorPage = async (close = false) => {
|
||||||
|
const params = {
|
||||||
|
serialData: JSON.stringify(serialize()),
|
||||||
|
} as any
|
||||||
|
|
||||||
|
if ( editorPageId.value ) {
|
||||||
|
params.pageId = editorPageId.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/api/editor/page', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = (await response.json()) as unknown as any
|
||||||
|
if (!result.success) {
|
||||||
|
return alert('Failed to save page: ' + result.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
editorPageId.value = result.data.pageId
|
||||||
|
if ( close ) {
|
||||||
|
await router.push('/Listings')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteEditorPage = async (close = false) => {
|
||||||
|
const params = {
|
||||||
|
serialData: JSON.stringify(serialize()),
|
||||||
|
} as any
|
||||||
|
|
||||||
|
if ( editorPageId.value ) {
|
||||||
|
params.pageId = editorPageId.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/api/editor/page', {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
})
|
||||||
|
await router.push('/Listings')
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadEditorPage = async () => {
|
||||||
|
if ( !editorPageId.value ) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const pageId = editorPageId.value
|
||||||
|
const response = await fetch(`/api/editor/page?pageId=${pageId}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = (await response.json()) as unknown as any
|
||||||
|
if (!result.success) {
|
||||||
|
return alert('Failed to load page: ' + result.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
const serialData = result.data.serialData
|
||||||
|
const serialized = JSON.parse(serialData) as any
|
||||||
|
math.value = MathPage.deserialize(serialized.page)
|
||||||
|
richTextStatements.value = serialized.textBoxes.map((box: any) => RichTextBox.deserialize(box))
|
||||||
|
chartBoxes.value = serialized.chartBoxes.map((box: any) => ChartBox.deserialize(box))
|
||||||
|
images.value = serialized.imageBoxes.map((box: any) => ImageContainer.deserialize(box))
|
||||||
|
pageTitle.value = serialized.title ?? 'New Page'
|
||||||
|
updateStatements()
|
||||||
|
chartBoxKey.value = uuidv4()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if ( props.pageId ) {
|
||||||
|
editorPageId.value = props.pageId
|
||||||
|
loadEditorPage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramPageId = router.currentRoute.value.params.pageId
|
||||||
|
if ( !Array.isArray(paramPageId) && !isNaN(parseInt(paramPageId, 10)) ) {
|
||||||
|
editorPageId.value = parseInt(paramPageId, 10)
|
||||||
|
loadEditorPage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -86,73 +441,195 @@ function richUpdateValue() {
|
|||||||
<q-btn dense flat round icon="menu" @click="toggleLeftDrawer" />
|
<q-btn dense flat round icon="menu" @click="toggleLeftDrawer" />
|
||||||
|
|
||||||
<q-toolbar-title>
|
<q-toolbar-title>
|
||||||
<q-avatar>
|
<q-avatar size="50px">
|
||||||
<img src="https://cdn.quasar.dev/logo-v2/svg/logo-mono-white.svg" />
|
<img src="../assets/l2.svg" />
|
||||||
</q-avatar>
|
</q-avatar>
|
||||||
Title
|
<span style="font-family: 'Cinzel Decorative', cursive;">
|
||||||
|
Crystal Math Worktable
|
||||||
|
</span>
|
||||||
</q-toolbar-title>
|
</q-toolbar-title>
|
||||||
|
|
||||||
|
<q-btn v-if="status" @click="logout()" label="Logout"></q-btn>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
<q-tabs align="left">
|
|
||||||
<q-route-tab to="/Scratch" label="Scratch" />
|
|
||||||
<q-route-tab to="/Editor" label="Editor" />
|
|
||||||
</q-tabs>
|
|
||||||
</q-header>
|
</q-header>
|
||||||
|
|
||||||
<q-drawer show-if-above v-model="leftDrawerOpen" side="left" bordered>
|
<q-drawer show-if-above v-model="leftDrawerOpen" side="left" bordered>
|
||||||
<div class="column" style="height: 100%">
|
<div class="column" style="height: 100%">
|
||||||
<div class="col">variables</div>
|
<div>
|
||||||
|
<q-input
|
||||||
|
v-model="pageTitle"
|
||||||
|
label="Title"
|
||||||
|
style="padding: 10px"
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<q-separator />
|
<q-table
|
||||||
function
|
flat
|
||||||
|
title="Variables"
|
||||||
|
:rows="variableListingRows"
|
||||||
|
:columns="variableListingColumns"
|
||||||
|
row-key="name"
|
||||||
|
hide-no-data
|
||||||
|
hide-bottom
|
||||||
|
:pagination="{ rowsPerPage: 10000 }"
|
||||||
|
style="height: 100%; border-radius: 0"
|
||||||
|
>
|
||||||
|
<template v-slot:body="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-td key="name" :props="props">{{ props.row.name }}</q-td>
|
||||||
|
<q-td key="value" :props="props">
|
||||||
|
<div v-html="props.row.value"></div>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<!-- <q-separator />-->
|
||||||
|
<q-table
|
||||||
|
flat
|
||||||
|
title="Functions"
|
||||||
|
:rows="functionListingRows"
|
||||||
|
:columns="functionListingColumns"
|
||||||
|
row-key="name"
|
||||||
|
hide-no-data
|
||||||
|
hide-bottom
|
||||||
|
hide-header
|
||||||
|
:pagination="{ rowsPerPage: 10000 }"
|
||||||
|
style="height: 100%; border-top: 1px solid lightgrey; border-radius: 0"
|
||||||
|
>
|
||||||
|
<template v-slot:body="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-td key="value" :props="props">
|
||||||
|
<div v-html="props.row.value"></div>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- drawer content -->
|
<!-- drawer content -->
|
||||||
</q-drawer>
|
</q-drawer>
|
||||||
|
|
||||||
<q-page-container id="editor" style="display: flex">
|
<q-page-container id="editor" style='padding: 0'>
|
||||||
<!-- <WrapperBox />-->
|
<span v-for="(chartBox, index) in chartBoxes" style="display: flex">
|
||||||
|
<RangeChart
|
||||||
|
:fn="math.getFunctionByNameOrFail(chartBox.fnName)"
|
||||||
|
:key="chartBoxKey"
|
||||||
|
:value="chartBox"
|
||||||
|
v-on:move="(x, y) => moveChartBox(index, x, y)"
|
||||||
|
v-on:remove="() => removeChartBox(index)"
|
||||||
|
v-on:edit="() => openChartEditModal(chartBox)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
|
||||||
<span v-for="statement in statements">
|
<span v-for="statement in statements" style="display: flex">
|
||||||
<Draggable
|
<Draggable
|
||||||
:grid="[25, 25]"
|
:grid="[stepX, stepY]"
|
||||||
|
:position="{ x: statement.x, y: statement.y }"
|
||||||
|
:default-position="{ x: statement.x, y: statement.y }"
|
||||||
|
@stop="(e: { event: MouseEvent, data: { x: number, y: number } }) => stmOnControlledDragStop(statement)(e)"
|
||||||
>
|
>
|
||||||
<Statement
|
<div>
|
||||||
:key="statementsKey"
|
<Statement
|
||||||
:statement="statement"
|
:key="statementsKey"
|
||||||
:evaluation="evaluation"
|
:statement="statement"
|
||||||
/>
|
:evaluation="evaluation"
|
||||||
|
v-on:edit="() => editStatement(statement)"
|
||||||
|
v-on:remove="() => removeStatement(statement)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</Draggable>
|
</Draggable>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<q-dialog v-model="newVariableModalOpen">
|
<q-dialog v-model="newVariableModalOpen">
|
||||||
<VarDeclEditor
|
<VarDeclEditor v-on:save="(s) => saveNewVariable(s)" />
|
||||||
v-on:save="s => saveNewVariable(s)"
|
|
||||||
/>
|
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
<q-dialog v-model="newExpressionModalOpen">
|
<q-dialog v-model="newExpressionModalOpen">
|
||||||
<ExpressionEditor
|
<ExpressionEditor v-on:save="(s) => saveNewExpression(s)" />
|
||||||
v-on:save="s => saveNewExpression(s)"
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="editExpressionModalOpen">
|
||||||
|
<ExpressionEditor :statement="editingStatement" v-on:save="() => finishEditStatement()" />
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="editVarDeclModalOpen">
|
||||||
|
<VarDeclEditor :statement="editingStatement" v-on:save="() => finishEditStatement()" />
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="newFunctionModalOpen">
|
||||||
|
<FunctionEditor v-on:save="(s) => saveNewFunction(s)" />
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="editFunctionModalOpen">
|
||||||
|
<FunctionEditor :statement="editingStatement" v-on:save="() => finishEditStatement()" />
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="newChartModalOpen">
|
||||||
|
<!-- // @ts-ignore -->
|
||||||
|
<RangeChartEditor :page="math" v-on:save="c => saveNewChartBox(c)" />
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="chartEditModalOpen">
|
||||||
|
<RangeChartEditor
|
||||||
|
:page="math"
|
||||||
|
:chartBox="editingChartBox"
|
||||||
|
v-on:save="() => saveEditingChartBox()"
|
||||||
/>
|
/>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-page-sticky position="top-right" :offset="[18, 18]">
|
||||||
|
<q-btn fab icon="save" title="Save" color="primary" @click="() => saveEditorPage()"/>
|
||||||
|
</q-page-sticky>
|
||||||
|
|
||||||
|
<q-page-sticky position="top-right" :offset="[18, 90]">
|
||||||
|
<q-btn fab icon="close" title="Save and close" color="primary" @click="() => saveEditorPage(true)"/>
|
||||||
|
</q-page-sticky>
|
||||||
|
<q-page-sticky position="top-right" :offset="[18, 162]">
|
||||||
|
<q-btn fab icon="delete_forever" title="Delete forever" color="primary" @click="() => deleteEditorPage()"/>
|
||||||
|
</q-page-sticky>
|
||||||
|
|
||||||
<q-page-sticky position="bottom-right" :offset="[32, 32]">
|
<q-page-sticky position="bottom-right" :offset="[32, 32]">
|
||||||
<q-fab color="primary" icon="add" direction="left">
|
<q-fab color="primary" icon="add" direction="left">
|
||||||
<q-fab-action
|
<q-fab-action
|
||||||
color="secondary"
|
color="secondary"
|
||||||
label="x"
|
label="x"
|
||||||
label-style="font-family: serif; font-size: 1.4em; padding: 0"
|
label-style="font-family: serif; font-size: 1.4rem; padding: 0"
|
||||||
title="Add a variable declaration"
|
title="Add a variable declaration"
|
||||||
@click="() => openNewVariableDeclModal()"
|
@click="() => openNewVariableDeclModal()"
|
||||||
/>
|
/>
|
||||||
<q-fab-action
|
<q-fab-action
|
||||||
color="secondary"
|
color="secondary"
|
||||||
icon="code"
|
icon="code"
|
||||||
label-style="font-family: serif; font-size: 1.4em; padding: 0"
|
|
||||||
title="Add an expression"
|
title="Add an expression"
|
||||||
@click="() => openNewExpressionModal()"
|
@click="() => openNewExpressionModal()"
|
||||||
/>
|
/>
|
||||||
|
<q-fab-action
|
||||||
|
color="secondary"
|
||||||
|
icon="functions"
|
||||||
|
title="Add a new function"
|
||||||
|
@click="() => openNewFunctionModal()"
|
||||||
|
/>
|
||||||
|
<q-fab-action
|
||||||
|
color="secondary"
|
||||||
|
icon="format_quote"
|
||||||
|
title="Add a text box"
|
||||||
|
@click="() => makeNewRichTextBox()"
|
||||||
|
/>
|
||||||
|
<q-fab-action
|
||||||
|
color="secondary"
|
||||||
|
icon="image"
|
||||||
|
title="Add an image box"
|
||||||
|
@click="() => makeNewImageBox()"
|
||||||
|
/>
|
||||||
|
<q-fab-action
|
||||||
|
color="secondary"
|
||||||
|
icon="show_chart"
|
||||||
|
title="Add a new chart"
|
||||||
|
@click="() => openNewChartModal()"
|
||||||
|
/>
|
||||||
</q-fab>
|
</q-fab>
|
||||||
</q-page-sticky>
|
</q-page-sticky>
|
||||||
|
|
||||||
@@ -165,28 +642,45 @@ function richUpdateValue() {
|
|||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
<span v-for="(item, index) in richTextStatments">
|
|
||||||
<TextBox
|
|
||||||
:statement="item.text"
|
|
||||||
v-on:edit="() => (item.text ? richEditStatement(index) : {})"
|
|
||||||
></TextBox>
|
|
||||||
</span>
|
|
||||||
</q-page-container>
|
|
||||||
|
|
||||||
<q-footer reveal elevated class="bg-grey-8 text-white">
|
<div v-for="(item, index) in richTextStatements" style="display: flex">
|
||||||
<q-toolbar>
|
<TextBox
|
||||||
<q-toolbar-title>
|
:value="item"
|
||||||
<div>Status</div>
|
v-on:edit="() => (item.text ? richEditStatement(index) : {})"
|
||||||
</q-toolbar-title>
|
v-on:remove="() => removeRichTextBox(index)"
|
||||||
</q-toolbar>
|
v-on:move="(x, y) => moveRichTextBox(index, x, y)"
|
||||||
</q-footer>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<q-dialog v-model="imageModal">
|
||||||
|
<q-card autogrow style="min-width: 25em;">
|
||||||
|
<q-input autogrow v-model="imageURL" />
|
||||||
|
<q-card-actions align="right" class="text-primary">
|
||||||
|
<q-btn flat label="Cancel" v-close-popup></q-btn>
|
||||||
|
<q-btn flat label="Save" @click="imageUpdateValue" v-close-popup></q-btn>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<div v-for="(item, index) in images" style="display: flex">
|
||||||
|
<ImageBox
|
||||||
|
:value="item"
|
||||||
|
v-on:edit="() => (item.url ? imageEditStatement(index) : {})"
|
||||||
|
v-on:remove="() => removeimageBox(index)"
|
||||||
|
v-on:move="(x, y) => moveImageBox(index, x, y)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</q-page-container>
|
||||||
</q-layout>
|
</q-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@import url("https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&display=swap");
|
||||||
|
|
||||||
#editor {
|
#editor {
|
||||||
background-image: url(../assets/grid.svg);
|
background-image: url(../assets/grid.svg);
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
padding-top: 0px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
46
src/pages/Home.vue
Normal file
46
src/pages/Home.vue
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import Login from '../components/Login.vue'
|
||||||
|
|
||||||
|
defineProps<{ msg: string }>()
|
||||||
|
|
||||||
|
const show = ref<boolean>(true)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-layout>
|
||||||
|
<h1>{{ msg }}</h1>
|
||||||
|
<transition
|
||||||
|
appear
|
||||||
|
enter-active-class="animated fadeInUp"
|
||||||
|
leave-active-class="animated fadeOutUp"
|
||||||
|
mode="out-in"
|
||||||
|
>
|
||||||
|
<q-btn color="primary" text-color="white" @click="show = !show" v-if="show">Start</q-btn>
|
||||||
|
<div class="login" v-else>
|
||||||
|
<q-card square bordered class="q-pa-lg shadow-1">
|
||||||
|
<Login />
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</q-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
button {
|
||||||
|
background-color: #4484c4;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 32px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 32px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
max-width: 30em;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
66
src/pages/Listings.vue
Normal file
66
src/pages/Listings.vue
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {onMounted, ref} from 'vue'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
|
interface PageRecord {
|
||||||
|
pageId: number|string,
|
||||||
|
title: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages = ref<PageRecord[]>([])
|
||||||
|
const columns = ref([
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
field: 'title',
|
||||||
|
label: 'Title',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const loadPages = async () => {
|
||||||
|
const response = await fetch(`/api/editor/pages`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = (await response.json()) as unknown as any
|
||||||
|
if ( !result.success ) {
|
||||||
|
alert('Unable to load pages: ' + result?.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
pages.value = result.data.records.map((row: any) => {
|
||||||
|
return {
|
||||||
|
pageId: row.pageId,
|
||||||
|
title: JSON.parse(row.serialData).title || 'New Page',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(loadPages)
|
||||||
|
|
||||||
|
const onRowClick = (_: unknown, row: PageRecord) => {
|
||||||
|
router.push({ path: `/Editor/${row.pageId}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
const onNewPageClick = () => {
|
||||||
|
router.push('/Editor')
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div style="width: 100%">
|
||||||
|
<q-btn icon="add" style="margin-bottom: 10px" @click="onNewPageClick">New Page</q-btn>
|
||||||
|
<q-table
|
||||||
|
style="width: 100%"
|
||||||
|
title="My Pages"
|
||||||
|
:columns="columns"
|
||||||
|
:rows="pages"
|
||||||
|
row-key="pageId"
|
||||||
|
hide-bottom
|
||||||
|
:pagination="{ rowsPerPage: 10000 }"
|
||||||
|
@row-click="onRowClick"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useAuth0 } from '@auth0/auth0-vue';
|
|
||||||
|
|
||||||
defineProps<{ msg: string }>()
|
|
||||||
|
|
||||||
const { loginWithRedirect } = useAuth0();
|
|
||||||
|
|
||||||
const login = () => {
|
|
||||||
loginWithRedirect();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<h1>{{ msg }}</h1>
|
|
||||||
|
|
||||||
<button @click="login">Log in</button>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
button {
|
|
||||||
background-color: #215b8a; /* Green */
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
padding: 15px 32px;
|
|
||||||
text-align: center;
|
|
||||||
text-decoration: none;
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 32px;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,40 +1,43 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {MathPage} from '../support/page'
|
import { MathPage } from '../support/page'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import Statement from '../components/Statement.vue'
|
import Statement from '../components/Statement.vue'
|
||||||
import {MathStatement} from '../support/parse'
|
import { MathStatement } from '../support/parse'
|
||||||
import {onMounted, ref} from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import Katex from '../components/Katex.vue'
|
import Katex from '../components/Katex.vue'
|
||||||
|
import { checkLoggedIn, loggedOut } from '../support/auth'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
const page = new MathPage(uuidv4())
|
const page = new MathPage(uuidv4())
|
||||||
const stmt1Id = page.addRaw('x = y+3/4')
|
const stmt1Id = page.addRaw('x = y+3/4')
|
||||||
const stmt2Id = page.addRaw('y = 9')
|
const stmt2Id = page.addRaw('y = 9')
|
||||||
const evaluation = page.evaluate()
|
const evaluation = page.evaluate()
|
||||||
|
|
||||||
const stmt = page.getStatement(stmt1Id)
|
const stmt = page.getStatement(stmt1Id)
|
||||||
console.log({page, stmt1Id})
|
console.log({ page, stmt1Id })
|
||||||
|
|
||||||
let editModal = ref(false)
|
let editModal = ref(false)
|
||||||
let editExpression = ref('')
|
let editExpression = ref('')
|
||||||
let editPreview = ref(MathStatement.temp(''))
|
let editPreview = ref(MathStatement.temp(''))
|
||||||
let activeStatement!: MathStatement
|
let activeStatement!: MathStatement
|
||||||
|
|
||||||
const editStatement = (stmt: MathStatement) => {
|
const editStatement = (stmt: MathStatement) => {
|
||||||
console.log('editing statement', stmt, editModal)
|
console.log('editing statement', stmt, editModal)
|
||||||
activeStatement = stmt
|
activeStatement = stmt
|
||||||
editPreview.value = MathStatement.temp(stmt.raw)
|
editPreview.value = MathStatement.temp(stmt.raw)
|
||||||
editModal.value = true
|
editModal.value = true
|
||||||
editExpression.value = stmt.raw
|
editExpression.value = stmt.raw
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = ref(uuidv4())
|
||||||
|
const updateEditRender = () => {
|
||||||
|
const previewStmt = MathStatement.temp(editExpression.value)
|
||||||
|
if (previewStmt.isValid()) {
|
||||||
|
editPreview.value = MathStatement.temp(editExpression.value)
|
||||||
|
key.value = uuidv4()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let key = ref(uuidv4())
|
|
||||||
const updateEditRender = () => {
|
|
||||||
const previewStmt = MathStatement.temp(editExpression.value)
|
|
||||||
if ( previewStmt.isValid() ) {
|
|
||||||
editPreview.value = MathStatement.temp(editExpression.value)
|
|
||||||
key.value = uuidv4()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -43,7 +46,7 @@
|
|||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<div style="display: flex; justify-content: center">
|
<div style="display: flex; justify-content: center">
|
||||||
<Katex :statement="editPreview" :key="key"/>
|
<Katex :statement="editPreview" :key="key" />
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
$primary : #1976D2
|
$primary : #553564
|
||||||
$secondary : #26A69A
|
$secondary : #008e80
|
||||||
$accent : #9C27B0
|
$accent : #9C27B0
|
||||||
|
|
||||||
$dark : #1D1D1D
|
$dark : #1D1D1D
|
||||||
|
// $dark-page: #333333;
|
||||||
|
|
||||||
|
|
||||||
$positive : #21BA45
|
$positive : #21BA45
|
||||||
$negative : #C10015
|
$negative : #C10015
|
||||||
$info : #31CCEC
|
$info : #7da9b2
|
||||||
$warning : #F2C037
|
$warning : #F2C037
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import Home from './pages/Login.vue'
|
import Home from './pages/Home.vue'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@@ -17,6 +17,15 @@ const routes = [
|
|||||||
name: 'Editor',
|
name: 'Editor',
|
||||||
component: () => import(/* webpackChunkName: "Editor" */ './pages/Editor.vue'),
|
component: () => import(/* webpackChunkName: "Editor" */ './pages/Editor.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/editor/:pageId',
|
||||||
|
component: () => import(/* webpackChunkName: "Editor" */ './pages/Editor.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/listings',
|
||||||
|
name: 'Listings',
|
||||||
|
component: () => import(/* webpackChunkName: "Listings" */ './pages/Listings.vue'),
|
||||||
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
10
src/support/auth.ts
Normal file
10
src/support/auth.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
let isLoggedIn = false
|
||||||
|
export const checkLoggedIn = () => {
|
||||||
|
return isLoggedIn
|
||||||
|
}
|
||||||
|
export const loggedIn = () => {
|
||||||
|
isLoggedIn = true
|
||||||
|
}
|
||||||
|
export const loggedOut = () => {
|
||||||
|
isLoggedIn = false
|
||||||
|
}
|
||||||
2
src/support/const.ts
Normal file
2
src/support/const.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const stepX = 5
|
||||||
|
export const stepY = 5
|
||||||
@@ -2,25 +2,47 @@ import {MathStatement} from './parse'
|
|||||||
import * as math from 'mathjs'
|
import * as math from 'mathjs'
|
||||||
import {DepGraph} from 'dependency-graph'
|
import {DepGraph} from 'dependency-graph'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import {EvaluationResult, Maybe, StatementID, VariableName} from '../types'
|
import {EvaluationResult, hasOwnProperty, Maybe, StatementID, VariableName} from './types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for a page containing multiple interrelated mathematical statements.
|
* Wrapper for a page containing multiple interrelated mathematical statements.
|
||||||
*/
|
*/
|
||||||
export class MathPage {
|
export class MathPage {
|
||||||
/** The statements on the page. */
|
/** The statements on the page. */
|
||||||
protected statements: Record<StatementID, MathStatement> = {}
|
statements: Record<StatementID, MathStatement> = {}
|
||||||
|
|
||||||
|
static deserialize(vals: [string, [StatementID, string, number, number][]]) {
|
||||||
|
const inst = new this(vals[0])
|
||||||
|
|
||||||
|
for ( const row of vals[1] ) {
|
||||||
|
inst.statements[row[0]] = MathStatement.deserialize(row)
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
/** Unique page ID. */
|
/** Unique page ID. */
|
||||||
public readonly id: string,
|
public readonly id: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
serialize(): [string, [StatementID, string, number, number][]] {
|
||||||
|
return [
|
||||||
|
this.id,
|
||||||
|
Object.values(this.statements).map(x => x.serialize()),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
/** Get all defined statements. */
|
/** Get all defined statements. */
|
||||||
getStatements(): MathStatement[] {
|
getStatements(): MathStatement[] {
|
||||||
return Object.values(this.statements)
|
return Object.values(this.statements)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Remove a statement from the math page. */
|
||||||
|
removeStatement(id: StatementID) {
|
||||||
|
delete this.statements[id]
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a statement by ID if it exists. */
|
/** Get a statement by ID if it exists. */
|
||||||
getStatement(id: StatementID): Maybe<MathStatement> {
|
getStatement(id: StatementID): Maybe<MathStatement> {
|
||||||
return this.statements[id]
|
return this.statements[id]
|
||||||
@@ -77,6 +99,12 @@ export class MathPage {
|
|||||||
dependencies(): DepGraph<MathStatement> {
|
dependencies(): DepGraph<MathStatement> {
|
||||||
const graph = new DepGraph<MathStatement>()
|
const graph = new DepGraph<MathStatement>()
|
||||||
const defined: Record<VariableName, MathStatement> = this.definers()
|
const defined: Record<VariableName, MathStatement> = this.definers()
|
||||||
|
const definedFunctions: Record<VariableName, MathStatement> = {}
|
||||||
|
|
||||||
|
for ( const sym of this.functions() ) {
|
||||||
|
const node = sym.parse() as math.FunctionAssignmentNode
|
||||||
|
definedFunctions[node.name as VariableName] = sym
|
||||||
|
}
|
||||||
|
|
||||||
for ( const statement of Object.values(this.statements) ) {
|
for ( const statement of Object.values(this.statements) ) {
|
||||||
graph.addNode(statement.id, statement)
|
graph.addNode(statement.id, statement)
|
||||||
@@ -84,6 +112,12 @@ export class MathPage {
|
|||||||
|
|
||||||
for ( const statement of Object.values(this.statements) ) {
|
for ( const statement of Object.values(this.statements) ) {
|
||||||
for ( const symbol of statement.uses() ) {
|
for ( const symbol of statement.uses() ) {
|
||||||
|
const functionProvider = definedFunctions[symbol.name as VariableName]
|
||||||
|
if ( functionProvider ) {
|
||||||
|
graph.addDependency(statement.id, functionProvider.id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const provider = defined[symbol.name as VariableName]
|
const provider = defined[symbol.name as VariableName]
|
||||||
if ( !provider ) {
|
if ( !provider ) {
|
||||||
throw new Error('No provider for undefined symbol: ' + symbol.name)
|
throw new Error('No provider for undefined symbol: ' + symbol.name)
|
||||||
@@ -96,11 +130,51 @@ export class MathPage {
|
|||||||
return graph
|
return graph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true if the given variable name is a function definition. */
|
||||||
|
isFunctionKey(name: VariableName): boolean {
|
||||||
|
return this.functions()
|
||||||
|
.some(stmt => {
|
||||||
|
const node = stmt.parse() as math.FunctionAssignmentNode
|
||||||
|
return node.name === name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get all the statements defining functions. */
|
||||||
|
functions(): MathStatement[] {
|
||||||
|
return Object.values(this.statements)
|
||||||
|
.filter(x => x.isFunctionDeclaration())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Look up a function statement by name, if it exists. */
|
||||||
|
getFunctionByName(name: string): MathStatement|undefined {
|
||||||
|
for ( const fn of this.functions() ) {
|
||||||
|
const node = fn.parse() as math.FunctionAssignmentNode
|
||||||
|
if ( node.name === name ) {
|
||||||
|
return fn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Look up a function statement by name, if it exists. */
|
||||||
|
getFunctionByNameOrFail(name: string): MathStatement {
|
||||||
|
const fn = this.getFunctionByName(name)
|
||||||
|
if ( !fn ) {
|
||||||
|
throw new Error('Unable to find function with name: ' + name)
|
||||||
|
}
|
||||||
|
return fn
|
||||||
|
}
|
||||||
|
|
||||||
/** Evaluate the current state of the page and get the result. */
|
/** Evaluate the current state of the page and get the result. */
|
||||||
evaluate(): EvaluationResult {
|
evaluate(): EvaluationResult {
|
||||||
const evaluations: Record<StatementID, any> = {}
|
const evaluations: Record<StatementID, any> = {}
|
||||||
const scope: Record<VariableName, any> = {}
|
const scope: Record<VariableName, any> = {}
|
||||||
const graph = this.dependencies()
|
const graph = this.dependencies()
|
||||||
|
const definers = this.definers()
|
||||||
|
|
||||||
|
for ( const stmt of this.functions() ) {
|
||||||
|
const node = stmt.parse() as math.FunctionAssignmentNode
|
||||||
|
scope[node.name as VariableName] = stmt.parse().evaluate()
|
||||||
|
}
|
||||||
|
|
||||||
for ( const node of graph.overallOrder() ) {
|
for ( const node of graph.overallOrder() ) {
|
||||||
const stmt = this.statements[node as StatementID]
|
const stmt = this.statements[node as StatementID]
|
||||||
@@ -109,8 +183,19 @@ export class MathPage {
|
|||||||
.evaluate(scope)
|
.evaluate(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nonFunctionalScope: Record<VariableName, any> = {}
|
||||||
|
for ( const key in scope ) {
|
||||||
|
if ( !hasOwnProperty(scope, key) ) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( definers[key as VariableName] ) {
|
||||||
|
nonFunctionalScope[key as VariableName] = scope[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
variables: scope,
|
variables: nonFunctionalScope,
|
||||||
statements: evaluations,
|
statements: evaluations,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as math from 'mathjs'
|
import * as math from 'mathjs'
|
||||||
import katex from 'katex'
|
import katex from 'katex'
|
||||||
import {HTMLString, LaTeXString, StatementID} from '../types'
|
import {HTMLString, LaTeXString, StatementID} from './types'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import {v4 as uuidv4} from 'uuid'
|
||||||
|
|
||||||
/** Base class for walks over MathNode trees. */
|
/** Base class for walks over MathNode trees. */
|
||||||
@@ -117,6 +117,7 @@ export class SymbolWalk extends MathNodeWalk<math.SymbolNode[]> {
|
|||||||
|
|
||||||
walkFunctionAssignmentNode(node: math.FunctionAssignmentNode): math.SymbolNode[] {
|
walkFunctionAssignmentNode(node: math.FunctionAssignmentNode): math.SymbolNode[] {
|
||||||
return this.walk(node.expr)
|
return this.walk(node.expr)
|
||||||
|
.filter(sym => !node.params.includes(sym.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
walkFunctionNode(node: math.FunctionNode): math.SymbolNode[] {
|
walkFunctionNode(node: math.FunctionNode): math.SymbolNode[] {
|
||||||
@@ -263,14 +264,33 @@ export class MathStatement {
|
|||||||
return new MathStatement(uuidv4() as StatementID, raw)
|
return new MathStatement(uuidv4() as StatementID, raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static deserialize(vals: [StatementID, string, number, number]) {
|
||||||
|
return new this(...vals)
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
/** Unique ID of this statement. */
|
/** Unique ID of this statement. */
|
||||||
public readonly id: StatementID,
|
public readonly id: StatementID,
|
||||||
|
|
||||||
/** The raw statement input by the user. */
|
/** The raw statement input by the user. */
|
||||||
public readonly raw: string,
|
public raw: string,
|
||||||
|
|
||||||
|
/** The x position in the grid. */
|
||||||
|
public x: number = 0,
|
||||||
|
|
||||||
|
/** The y position in the grid. */
|
||||||
|
public y: number = 0,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
serialize(): [StatementID, string, number, number] {
|
||||||
|
return [
|
||||||
|
this.id,
|
||||||
|
this.raw,
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
/** Parse the raw statement to an AST. */
|
/** Parse the raw statement to an AST. */
|
||||||
parse(): math.MathNode {
|
parse(): math.MathNode {
|
||||||
return math.parse(this.raw)
|
return math.parse(this.raw)
|
||||||
@@ -338,4 +358,12 @@ export class MathStatement {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDeclaration(): boolean {
|
||||||
|
return this.defines().length > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
isFunctionDeclaration(): boolean {
|
||||||
|
return math.isFunctionAssignmentNode(this.parse())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,3 +91,75 @@ export interface EvaluationResult {
|
|||||||
variables: Record<VariableName, any>
|
variables: Record<VariableName, any>
|
||||||
statements: Record<StatementID, any>
|
statements: Record<StatementID, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class RichTextBox {
|
||||||
|
static deserialize(vals: [string, number, number]) {
|
||||||
|
return new this(...vals)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public text: string = '',
|
||||||
|
public x: number = 0,
|
||||||
|
public y: number = 0,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
serialize(): [string, number, number] {
|
||||||
|
return [
|
||||||
|
this.text,
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class ImageContainer {
|
||||||
|
static deserialize(vals: [string, number, number]) {
|
||||||
|
return new this(...vals)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public url: string = '',
|
||||||
|
public x: number = 0,
|
||||||
|
public y: number = 0,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
serialize(): [string, number, number] {
|
||||||
|
return [
|
||||||
|
this.url,
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class ChartBox {
|
||||||
|
static deserialize(vals: [string, number, number, number, number, number]) {
|
||||||
|
return new this(...vals)
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
|
constructor(
|
||||||
|
public fnName: string,
|
||||||
|
public minX: number,
|
||||||
|
public maxX: number,
|
||||||
|
public stepX: number = 1,
|
||||||
|
public x: number = 0,
|
||||||
|
public y: number = 0,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
serialize(): [string, number, number, number, number, number] {
|
||||||
|
return [
|
||||||
|
this.fnName,
|
||||||
|
this.minX,
|
||||||
|
this.maxX,
|
||||||
|
this.stepX,
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user