From 19b775199d7d82c67476b19ad4ab6593ebd0959c Mon Sep 17 00:00:00 2001
From: "22969541+Aurelius333@users.noreply.github.com"
<22969541+Aurelius333@users.noreply.github.com>
Date: Mon, 26 Apr 2021 17:19:57 -0400
Subject: [PATCH 1/4] Add page that displays graph
---
package.json | 9 +++++
src/router/index.ts | 5 +++
src/service-worker.js | 8 ++++-
src/views/GraphPage.vue | 78 +++++++++++++++++++++++++++++++++++++++++
yarn.lock | 68 ++++++++++++++++++++++++++++++-----
5 files changed, 159 insertions(+), 9 deletions(-)
create mode 100644 src/views/GraphPage.vue
diff --git a/package.json b/package.json
index dec4cb6..dcf62be 100644
--- a/package.json
+++ b/package.json
@@ -13,9 +13,18 @@
"tests": "yarn test"
},
"dependencies": {
+ "@egjs/hammerjs": "^2.0.17",
+ "component-emitter": "^1.3.0",
"core-js": "^3.4.3",
+ "keycharm": "^0.3.1",
+ "moment": "^2.24.0",
"register-service-worker": "^1.6.2",
"room-finder": "0.3.0-beta.2",
+ "timsort": "^0.3.0",
+ "uuid": "^8.3.2",
+ "vis-data": "^7.1.2",
+ "vis-network": "^9.0.4",
+ "vis-util": "^5.0.2",
"vue": "^2.6.10",
"vue-meta": "^2.3.1",
"vue-router": "^3.1.3",
diff --git a/src/router/index.ts b/src/router/index.ts
index 3d299c2..fd0abfb 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -40,6 +40,11 @@ const routes = [
path: "/settings",
component: Settings,
},
+ {
+ path: "/graph",
+ component: () =>
+ import(/* webpackChunkName: 'graphpage' */ "@/views/GraphPage.vue"),
+ },
// fallback (client-side 404)
{
path: "*",
diff --git a/src/service-worker.js b/src/service-worker.js
index abeba66..ac1dd87 100644
--- a/src/service-worker.js
+++ b/src/service-worker.js
@@ -1,6 +1,12 @@
/* eslint-disable no-undef */
// eslint-disable-next-line no-restricted-globals, no-underscore-dangle
-workbox.precaching.precacheAndRoute(self.__precacheManifest || []);
+const precacheManifest = self.__precacheManifest || [];
+
+workbox.precaching.precacheAndRoute(
+ precacheManifest.filter(
+ (p) => !p.url.includes("graphpage") && !p.url.includes("legacy")
+ )
+);
// https://developers.google.com/web/tools/workbox/guides/common-recipes#cache_css_and_javascript_files
workbox.routing.registerRoute(
diff --git a/src/views/GraphPage.vue b/src/views/GraphPage.vue
new file mode 100644
index 0000000..3a78fcf
--- /dev/null
+++ b/src/views/GraphPage.vue
@@ -0,0 +1,78 @@
+
+
+
+ This is the graph/network used to calculate directions in Walnut.Direct
+ using Dijkstra's algorithm. It'll take a minute to load. Scroll to zoom.
+
+
Loading...
+
+
+
+
+
+
diff --git a/yarn.lock b/yarn.lock
index 6eea35d..169d53e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -892,6 +892,13 @@
debug "^3.1.0"
lodash.once "^4.1.1"
+"@egjs/hammerjs@^2.0.17":
+ version "2.0.17"
+ resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
+ integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==
+ dependencies:
+ "@types/hammerjs" "^2.0.36"
+
"@eslint/eslintrc@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.0.tgz#99cc0a0584d72f1df38b900fb062ba995f395547"
@@ -1244,6 +1251,11 @@
"@types/minimatch" "*"
"@types/node" "*"
+"@types/hammerjs@^2.0.36":
+ version "2.0.39"
+ resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.39.tgz#4be64bbacf3813c79c0dab895c6b0fdc7d5e513f"
+ integrity sha512-lYR2Y/tV2ujpk/WyUc7S0VLI0a9hrtVIN9EwnrNo5oSEJI2cK2/XrgwOQmXLL3eTulOESvh9qP6si9+DWM9cOA==
+
"@types/http-proxy@^1.17.4":
version "1.17.5"
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.5.tgz#c203c5e6e9dc6820d27a40eb1e511c70a220423d"
@@ -3448,7 +3460,7 @@ commondir@^1.0.1:
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=
-component-emitter@^1.2.1:
+component-emitter@^1.2.1, component-emitter@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
@@ -3609,7 +3621,7 @@ core-js-compat@^3.6.5, core-js-compat@^3.8.1, core-js-compat@^3.9.0:
browserslist "^4.16.3"
semver "7.0.0"
-core-js@3, core-js@^3.4.3, core-js@^3.6.5:
+core-js@3, core-js@^3.6.5:
version "3.9.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae"
integrity sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg==
@@ -3619,6 +3631,11 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==
+core-js@^3.4.3:
+ version "3.11.0"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.11.0.tgz#05dac6aa70c0a4ad842261f8957b961d36eb8926"
+ integrity sha512-bd79DPpx+1Ilh9+30aT5O1sgpQd4Ttg8oqkqi51ZzhedMM1omD2e6IOF48Z/DzDCZ2svp49tN/3vneTK6ZBkXw==
+
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -5652,7 +5669,12 @@ has-flag@^4.0.0:
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
-has-symbols@^1.0.0, has-symbols@^1.0.1, has-symbols@^1.0.2:
+has-symbols@^1.0.0, has-symbols@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8"
+ integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==
+
+has-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423"
integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==
@@ -7208,6 +7230,11 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"
+keycharm@^0.3.1:
+ version "0.3.1"
+ resolved "https://registry.yarnpkg.com/keycharm/-/keycharm-0.3.1.tgz#1de258425454752b95c4d8a6cab9ec83218670de"
+ integrity sha512-zn47Ti4FJT9zdF+YBBLWJsfKF/fYQHkrYlBeB5Ez5e2PjW7SoIxr43yehAne2HruulIoid4NKZZxO0dHBygCtQ==
+
killable@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"
@@ -7848,14 +7875,14 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"
-mkdirp@0.5.1:
+mkdirp@0.5.1, mkdirp@0.x, mkdirp@^0.5.1, mkdirp@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
dependencies:
minimist "0.0.8"
-mkdirp@0.x, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1:
+mkdirp@^0.5.3, mkdirp@^0.5.5:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
@@ -7872,6 +7899,11 @@ moment@2.24.0:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
+moment@^2.24.0:
+ version "2.29.1"
+ resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
+ integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
+
move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
@@ -9356,9 +9388,9 @@ raw-body@2.4.0:
unpipe "1.0.0"
react-is@^16.8.4:
- version "16.13.1"
- resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
- integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
+ version "16.12.0"
+ resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c"
+ integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==
react-is@^17.0.1:
version "17.0.1"
@@ -11227,6 +11259,11 @@ uuid@^3.3.2, uuid@^3.4.0:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
+uuid@^8.3.2:
+ version "8.3.2"
+ resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
+ integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
+
v8-compile-cache@^2.0.3:
version "2.3.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
@@ -11259,6 +11296,21 @@ verror@1.10.0:
core-util-is "1.0.2"
extsprintf "^1.2.0"
+vis-data@^7.1.2:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/vis-data/-/vis-data-7.1.2.tgz#b7d076ac79cb54f7c5e9c80f5b03b93cc8cc1fda"
+ integrity sha512-RPSegFxEcnp3HUEJSzhS2vBdbJ2PSsrYYuhRlpHp2frO/MfRtTYbIkkLZmPkA/Sg3pPfBlR235gcoKbtdm4mbw==
+
+vis-network@^9.0.4:
+ version "9.0.4"
+ resolved "https://registry.yarnpkg.com/vis-network/-/vis-network-9.0.4.tgz#c62d466224897070e9c1720e4d8e6e1dc479ca81"
+ integrity sha512-F/pq8yBJUuB9lNKXHhtn4GP2h91FV0c2O2nvfU34RX4VCYOlqs+mINdz+J+QkWiYhiPdlVy15gzVEzkhJ9hpaw==
+
+vis-util@^5.0.2:
+ version "5.0.2"
+ resolved "https://registry.yarnpkg.com/vis-util/-/vis-util-5.0.2.tgz#47e8a31580c0805680c43d253ac7da21501990b9"
+ integrity sha512-oPDmPc4o0uQLoKpKai2XD1DjrhYsA7MRz75Wx9KmfX84e9LLgsbno7jVL5tR0K9eNVQkD6jf0Ei8NtbBHDkF1A==
+
vm-browserify@^1.0.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
From 76c06ac1ee1513710fbe71cec57f9bc1c360f29f Mon Sep 17 00:00:00 2001
From: "22969541+Aurelius333@users.noreply.github.com"
<22969541+Aurelius333@users.noreply.github.com>
Date: Mon, 26 Apr 2021 17:27:59 -0400
Subject: [PATCH 2/4] Update message on graph page
---
src/views/GraphPage.vue | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/views/GraphPage.vue b/src/views/GraphPage.vue
index 3a78fcf..ed795a3 100644
--- a/src/views/GraphPage.vue
+++ b/src/views/GraphPage.vue
@@ -2,7 +2,8 @@
This is the graph/network used to calculate directions in Walnut.Direct
- using Dijkstra's algorithm. It'll take a minute to load. Scroll to zoom.
+ using Dijkstra's algorithm. It'll take a minute to load. Scroll to zoom if
+ you're on a computer.
Loading...
From 733af823022495538dc4c6f5a4c1a9fc76b23276 Mon Sep 17 00:00:00 2001
From: "22969541+Aurelius333@users.noreply.github.com"
<22969541+Aurelius333@users.noreply.github.com>
Date: Mon, 26 Apr 2021 17:50:12 -0400
Subject: [PATCH 3/4] Directed graph
Use double arrows for two-way edges, single arrows for one-way.
Color single arrows red and double arrows green.
---
src/views/GraphPage.vue | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/views/GraphPage.vue b/src/views/GraphPage.vue
index ed795a3..24e2844 100644
--- a/src/views/GraphPage.vue
+++ b/src/views/GraphPage.vue
@@ -41,6 +41,7 @@ export default Vue.extend({
}
for (const node in graph) {
for (const node2 in graph[node]) {
+ const isDoubled = graph[node2] && graph[node2][node];
if (
e.filter(
({ from, to }) =>
@@ -51,6 +52,8 @@ export default Vue.extend({
e.push({
from: Object.keys(graph).indexOf(node),
to: Object.keys(graph).indexOf(node2),
+ arrows: isDoubled ? "from, to" : "to",
+ color: { color: isDoubled ? "green" : "red" },
});
}
}
From 590feea15656f000fec247ae39f8d2163f5c830f Mon Sep 17 00:00:00 2001
From: "22969541+Aurelius333@users.noreply.github.com"
<22969541+Aurelius333@users.noreply.github.com>
Date: Mon, 26 Apr 2021 18:07:34 -0400
Subject: [PATCH 4/4] Show loading text
---
src/views/GraphPage.vue | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/views/GraphPage.vue b/src/views/GraphPage.vue
index 24e2844..bad6854 100644
--- a/src/views/GraphPage.vue
+++ b/src/views/GraphPage.vue
@@ -4,8 +4,9 @@
This is the graph/network used to calculate directions in Walnut.Direct
using Dijkstra's algorithm. It'll take a minute to load. Scroll to zoom if
you're on a computer.
+
Loading...
- Loading...
+
@@ -30,6 +31,7 @@ function nodeName(node: string) {
}
export default Vue.extend({
+ data: () => ({ loading: true }),
mounted() {
const { graph } = walnut;
@@ -68,7 +70,9 @@ export default Vue.extend({
const options = {
layout: { improvedLayout: false },
};
- new Network(container, data, options);
+ const network = new Network(container, data, options);
+
+ network.once("afterDrawing", () => (this.loading = false));
},
});