From 4f39030ed46f8e73bb2a1b58fc39fe300c6a60b8 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Wed, 28 Aug 2024 15:24:34 -0500 Subject: [PATCH] Disabled service worker, enhanced management console. --- LICENSE.txt | 30 ++++++ index.html | 27 +++--- package-lock.json | 97 +++++++++++++++++++ package.json | 2 + public/sw.js | 13 ++- .../database/pouchdbPersistenceManager.ts | 3 +- src/integration/functions/syncDoc.ts | 5 +- src/react/pageHeader.tsx | 7 +- src/react/pageTemplate.tsx | 5 +- src/react/pages/createDiagramModal.tsx | 89 ++++++++++++++--- src/react/pages/manageDiagramsModal.tsx | 60 ++++++++---- src/react/pages/vrExperience.tsx | 72 ++++++++++---- src/react/theme.ts | 2 +- src/react/vrTemplate.tsx | 11 ++- src/react/webApp.tsx | 5 +- 15 files changed, 344 insertions(+), 84 deletions(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..03f127a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,30 @@ + +Permissions Conditions Limitations + Commercial use + Distribution + Modification + Private use + License and copyright notice + Liability + Warranty +MIT License + +Copyright (c) [2024] [Michael Mainguy] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/index.html b/index.html index 05f8d22..71a8978 100644 --- a/index.html +++ b/index.html @@ -24,17 +24,22 @@
diff --git a/package-lock.json b/package-lock.json index f8493b5..c7b8f49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "rfc4648": "^1.5.3", "round": "^2.0.1", "uint8-to-b64": "^1.0.2", + "use-pouchdb": "^2.0.2", "uuid": "^9.0.1", "websocket": "^1.0.34", "websocket-ts": "^2.1.5" @@ -1297,6 +1298,14 @@ "react": ">= 16" } }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/dom-to-image": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/@types/dom-to-image/-/dom-to-image-2.6.7.tgz", @@ -1314,6 +1323,11 @@ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, + "node_modules/@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "node_modules/@types/node": { "version": "18.19.46", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.46.tgz", @@ -1327,6 +1341,31 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==" }, + "node_modules/@types/pouchdb-core": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.15.tgz", + "integrity": "sha512-gq1Qbqn9nCaAKRRv6fRHZ4/ER+QYEwSXBZlDQcxwdbPrtZO8EhIn2Bct0AlguaSEdFcABfbaxxyQwFINkNQ9dQ==", + "dependencies": { + "@types/debug": "*", + "@types/pouchdb-find": "*" + } + }, + "node_modules/@types/pouchdb-find": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-7.3.3.tgz", + "integrity": "sha512-U7zXk67s9Ar+9Pwj5kSbuMnn8zif0AOOIPy4KRFeJ/S/Tk+mNS90soj+3OV21H8xyB7WTxjvS1JLablZC6C6ow==", + "dependencies": { + "@types/pouchdb-core": "*" + } + }, + "node_modules/@types/pouchdb-mapreduce": { + "version": "6.1.10", + "resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.10.tgz", + "integrity": "sha512-AgYVqCnaA5D7cWkWyzZVuk0137N4yZsmIQTD/i3DmuMxYYoFrtWUoQu0tbA52SpTRGdL8ubQ7JFQXzA13fA6IQ==", + "dependencies": { + "@types/pouchdb-core": "*" + } + }, "node_modules/@types/prop-types": { "version": "15.7.12", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", @@ -3180,6 +3219,16 @@ "buffer-from": "1.1.2" } }, + "node_modules/pouchdb-changes-filter": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/pouchdb-changes-filter/-/pouchdb-changes-filter-8.0.1.tgz", + "integrity": "sha512-UKgH6YRA9PnvIGHb0FuDEEqeTewgHugbbBt5vpVo0QmbWKxNiau/JiTC9mY5Hj9l7ghaIUpO0TFG95a6RXWsQA==", + "dependencies": { + "pouchdb-errors": "8.0.1", + "pouchdb-selector-core": "8.0.1", + "pouchdb-utils": "8.0.1" + } + }, "node_modules/pouchdb-collate": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/pouchdb-collate/-/pouchdb-collate-8.0.1.tgz", @@ -3190,6 +3239,28 @@ "resolved": "https://registry.npmjs.org/pouchdb-collections/-/pouchdb-collections-8.0.1.tgz", "integrity": "sha512-TlkQ2GGHJApJgL0b7bJMQcwX6eMfVenLeoK9mqHfC2fJssui+HWJJ5LYKHOWan11SeB90BQVFbO6rHN6CJQeDg==" }, + "node_modules/pouchdb-core": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/pouchdb-core/-/pouchdb-core-8.0.1.tgz", + "integrity": "sha512-Qkcmh3eoMHiKUma5Y/rH0Z7kjxXrr6p54j/WOH+TZ/RlJAchmdVY1TRfqay5CoK+8Ka0m8eibP+wD1DKZKJbDg==", + "dependencies": { + "pouchdb-changes-filter": "8.0.1", + "pouchdb-collections": "8.0.1", + "pouchdb-errors": "8.0.1", + "pouchdb-fetch": "8.0.1", + "pouchdb-merge": "8.0.1", + "pouchdb-utils": "8.0.1", + "uuid": "8.3.2" + } + }, + "node_modules/pouchdb-core/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/pouchdb-errors": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/pouchdb-errors/-/pouchdb-errors-8.0.1.tgz", @@ -3237,6 +3308,14 @@ "spark-md5": "3.0.2" } }, + "node_modules/pouchdb-merge": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/pouchdb-merge/-/pouchdb-merge-8.0.1.tgz", + "integrity": "sha512-79dw6+K7js2+/kt9u4hKOkGCnz+ov0+yft2k21n6M+ylFEQyMKuWHEZRoFWr72o1vxwjhIXhUM1PB2PIdxIh0Q==", + "dependencies": { + "pouchdb-utils": "8.0.1" + } + }, "node_modules/pouchdb-selector-core": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/pouchdb-selector-core/-/pouchdb-selector-core-8.0.1.tgz", @@ -4115,6 +4194,24 @@ } } }, + "node_modules/use-pouchdb": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/use-pouchdb/-/use-pouchdb-2.0.2.tgz", + "integrity": "sha512-V1zfglhosqJCQZ1EXpBXrgcix5IAur0MItceN9DV1bW8xztebEmS1BkJUA9ogr1DgKA/XKwVC8mS2vSWewaUZw==", + "dependencies": { + "@types/pouchdb-core": "^7.0.11", + "@types/pouchdb-find": "^7.3.0", + "@types/pouchdb-mapreduce": "^6.1.6", + "@types/react": "^18.0.14", + "fast-deep-equal": "^3.1.3", + "pouchdb-core": "^8.0.1", + "pouchdb-errors": "^8.0.1", + "pouchdb-utils": "^8.0.1" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, "node_modules/use-sidecar": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.2.tgz", diff --git a/package.json b/package.json index dbff0dd..47a0377 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.8-17", "type": "module", + "license": "MIT", "engines": { "node": ">=18.0.0" }, @@ -45,6 +46,7 @@ "loglevel": "^1.9.1", "meaningful-string": "^1.4.0", "peer-lite": "2.0.2", + "use-pouchdb": "^2.0.2", "pouchdb": "^8.0.1", "pouchdb-find": "^8.0.1", "query-string": "^8.1.0", diff --git a/public/sw.js b/public/sw.js index 40d4bc9..58c54d0 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,5 +1,5 @@ importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.1.0/workbox-sw.js'); -const VERSION = '0.0.8-18'; +const VERSION = '0.0.8-19'; const CACHE = "deepdiagram"; const IMAGEDELIVERY_CACHE = "deepdiagram-images"; const MAPTILE_CACHE = 'maptiler'; @@ -66,32 +66,35 @@ workbox.routing.registerRoute( }) ); -workbox.routing.registerRoute( +/*workbox.routing.registerRoute( new RegExp('/assets/.*'), new workbox.strategies.StaleWhileRevalidate({ cacheName: CACHE }) ); +*/ - -workbox.routing.registerRoute( +/*workbox.routing.registerRoute( new RegExp('/db/.*'), new workbox.strategies.StaleWhileRevalidate({ cacheName: CACHE }) ); + */ + workbox.routing.registerRoute( new RegExp('/.*\\.glb'), new workbox.strategies.StaleWhileRevalidate({ cacheName: CACHE }) ); +/* workbox.routing.registerRoute( new RegExp('/.*\\.css'), new workbox.strategies.StaleWhileRevalidate({ cacheName: CACHE }) ); - +*/ diff --git a/src/integration/database/pouchdbPersistenceManager.ts b/src/integration/database/pouchdbPersistenceManager.ts index 889b8af..4d6b5ef 100644 --- a/src/integration/database/pouchdbPersistenceManager.ts +++ b/src/integration/database/pouchdbPersistenceManager.ts @@ -263,12 +263,11 @@ export class PouchdbPersistenceManager { let sync = false; let current = getPath(); if (current && current != 'localdb') { - sync = true; + //sync = true; } else { current = 'localdb'; } this.db = new PouchDB(current, {auto_compaction: true}); -//await this.db.compact(); if (sync) { if (await this.setupMetadata(current)) { await this.beginSync(current); diff --git a/src/integration/functions/syncDoc.ts b/src/integration/functions/syncDoc.ts index e4159da..748aff8 100644 --- a/src/integration/functions/syncDoc.ts +++ b/src/integration/functions/syncDoc.ts @@ -45,7 +45,10 @@ export async function syncDoc(info: any, onDBRemoveObservable: Observable - + Examples @@ -25,7 +25,8 @@ export default function PageHeader() { VR Experience - + + diff --git a/src/react/pageTemplate.tsx b/src/react/pageTemplate.tsx index c7e0820..1b3dc85 100644 --- a/src/react/pageTemplate.tsx +++ b/src/react/pageTemplate.tsx @@ -1,9 +1,11 @@ -import {AppShell} from "@mantine/core"; +import {AppShell, MantineProvider} from "@mantine/core"; import PageHeader from "./pageHeader"; import React from "react"; +import {theme} from "./theme"; export default function PageTemplate(props: { children: React.ReactNode }) { return ( + @@ -11,5 +13,6 @@ export default function PageTemplate(props: { children: React.ReactNode }) { {props.children} + ) } \ No newline at end of file diff --git a/src/react/pages/createDiagramModal.tsx b/src/react/pages/createDiagramModal.tsx index c5ad437..decebf0 100644 --- a/src/react/pages/createDiagramModal.tsx +++ b/src/react/pages/createDiagramModal.tsx @@ -1,37 +1,96 @@ import {Anchor, Button, Checkbox, Group, Modal, Pill, Stack, Textarea, TextInput} from "@mantine/core"; +import {usePouch} from "use-pouchdb"; +import {useState} from "react"; +import {v4} from "uuid"; -export default function CreateDiagramModal({createOpened, setCreateOpened}) { - - const createDiagram = () => { - setCreateOpened(false); +export default function CreateDiagramModal({createOpened, closeCreate}) { + const db = usePouch(); + const [diagram, setDiagram] = useState({ + name: '', + description: '', + private: false, + encrypted: false, + invite: false + }); + const createDiagram = async () => { + let doc = null; + try { + doc = await db.get('directory') + } catch (err) { + console.error(err); + } + const id = 'diagram-' + v4(); + const newDiagram = {...diagram, _id: id} + if (!doc) { + await db.put({_id: 'directory', diagrams: [newDiagram]}); + } else { + if (doc.diagrams) { + doc.diagrams.push(newDiagram); + } else { + doc.diagrams = [newDiagram]; + } + console.log(doc); + await db.put(doc); + } + closeCreate(); } return ( - { - setCreateOpened(false) - }}> + - - - -