From 588d3bd77e0d56b03d7527779550ace512f16f56 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Tue, 26 May 2020 22:10:20 -0400 Subject: [PATCH 1/7] CopyWebpackPlugin Vulnerability Upgrade fix - resolves dev build breaking --- package-lock.json | 527 ++++++++++++++++++++++++++++++++++------------ package.json | 2 +- webpack.common.js | 158 +++++++------- 3 files changed, 475 insertions(+), 212 deletions(-) diff --git a/package-lock.json b/package-lock.json index 96cea26..8afb445 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3148,6 +3148,32 @@ "@material/feature-targeting": "^3.1.0" } }, + "@nodelib/fs.scandir": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", + "integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.3", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz", + "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz", + "integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.3", + "fastq": "^1.6.0" + } + }, "@types/babel__core": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz", @@ -3708,18 +3734,9 @@ } }, "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "^1.0.1" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true }, "array-unique": { @@ -5173,24 +5190,97 @@ "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, "cacache": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", - "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", - "dev": true, - "requires": { - "bluebird": "^3.5.1", - "chownr": "^1.0.1", - "glob": "^7.1.2", - "graceful-fs": "^4.1.11", - "lru-cache": "^4.1.1", - "mississippi": "^2.0.0", - "mkdirp": "^0.5.1", - "move-concurrently": "^1.0.1", + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.0.3.tgz", + "integrity": "sha512-bc3jKYjqv7k4pWh7I/ixIjfcjPul4V4jme/WbjvwGS5LzoPL/GzXr4C5EgPNLO/QEZl9Oi61iGitYEdwcrwLCQ==", + "dev": true, + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "glob": "^7.1.4", + "infer-owner": "^1.0.4", + "lru-cache": "^5.1.1", + "minipass": "^3.1.1", + "minipass-collect": "^1.0.2", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.2", + "mkdirp": "^1.0.3", + "move-file": "^2.0.0", + "p-map": "^4.0.0", "promise-inflight": "^1.0.1", - "rimraf": "^2.6.2", - "ssri": "^5.2.4", - "unique-filename": "^1.1.0", - "y18n": "^4.0.0" + "rimraf": "^3.0.2", + "ssri": "^8.0.0", + "tar": "^6.0.2", + "unique-filename": "^1.1.1" + }, + "dependencies": { + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "requires": { + "yallist": "^3.0.2" + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "p-map": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", + "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "tar": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.2.tgz", + "integrity": "sha512-Glo3jkRtPcvpDlAs/0+hozav78yoXKFr+c4wgw62NNMO3oo4AaJdCo21Uu7lcwr55h39W2XD1LMERc64wtbItg==", + "dev": true, + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.0", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + } } }, "cache-base": { @@ -5663,98 +5753,155 @@ "dev": true }, "copy-webpack-plugin": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.6.0.tgz", - "integrity": "sha512-Y+SQCF+0NoWQryez2zXn5J5knmr9z/9qSQt7fbL78u83rxmigOy8X5+BFn8CFSuX+nKT8gpYwJX68ekqtQt6ZA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-6.0.1.tgz", + "integrity": "sha512-tcbZnGtQ70b4vtYGUNg8uUYri/80H1On3AC+wPsVOKSj7xbDinYuxAZPAeI3/3hxjjuwoGTHN5BeSksQ4kGUTw==", "dev": true, "requires": { - "cacache": "^10.0.4", - "find-cache-dir": "^1.0.0", - "globby": "^7.1.1", - "is-glob": "^4.0.0", - "loader-utils": "^1.1.0", - "minimatch": "^3.0.4", - "p-limit": "^1.0.0", - "serialize-javascript": "^1.4.0" + "cacache": "^15.0.3", + "fast-glob": "^3.2.2", + "find-cache-dir": "^3.3.1", + "glob-parent": "^5.1.1", + "globby": "^11.0.0", + "loader-utils": "^2.0.0", + "normalize-path": "^3.0.0", + "p-limit": "^2.3.0", + "schema-utils": "^2.6.6", + "serialize-javascript": "^3.0.0", + "webpack-sources": "^1.4.3" }, "dependencies": { + "ajv": { + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", + "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", + "dev": true + }, "find-cache-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", - "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", "dev": true, "requires": { "commondir": "^1.0.1", - "make-dir": "^1.0.0", - "pkg-dir": "^2.0.0" + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" } }, "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" } }, - "locate-path": { + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "loader-utils": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", "dev": true, "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" } }, "make-dir": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", "dev": true, "requires": { - "pify": "^3.0.0" + "semver": "^6.0.0" } }, "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "requires": { - "p-try": "^1.0.0" + "p-try": "^2.0.0" } }, "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "^2.2.0" } }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "requires": { - "find-up": "^2.1.0" + "find-up": "^4.0.0" } + }, + "schema-utils": { + "version": "2.6.6", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.6.6.tgz", + "integrity": "sha512-wHutF/WPSbIi9x6ctjGGk2Hvl0VOz5l3EKEuKbjPlB30mKZUzb9A5k9yEXRX3pwyqVLPvpfZZEllaFq/M718hA==", + "dev": true, + "requires": { + "ajv": "^6.12.0", + "ajv-keywords": "^3.4.1" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true } } }, @@ -6135,12 +6282,20 @@ } }, "dir-glob": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.2.2.tgz", - "integrity": "sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, "requires": { - "path-type": "^3.0.0" + "path-type": "^4.0.0" + }, + "dependencies": { + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + } } }, "discontinuous-range": { @@ -6990,6 +7145,74 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, + "fast-glob": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.2.tgz", + "integrity": "sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -7000,6 +7223,15 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fastq": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", + "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "fb-watchman": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.0.tgz", @@ -8077,31 +8309,17 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, "globby": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", - "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.0.tgz", + "integrity": "sha512-iuehFnR3xu5wBBtm4xi0dMe92Ob87ufyu/dHwpDYfbcpYpIbrO5OnS8M1vWvrBhSGEJ3/Ecj7gnX76P8YxpPEg==", "dev": true, "requires": { - "array-union": "^1.0.1", - "dir-glob": "^2.0.0", - "glob": "^7.1.2", - "ignore": "^3.3.5", - "pify": "^3.0.0", - "slash": "^1.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", - "dev": true - } + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" } }, "globule": { @@ -8498,9 +8716,9 @@ "dev": true }, "ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", + "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", "dev": true }, "ignore-by-default": { @@ -9550,9 +9768,9 @@ } }, "jquery": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", - "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "js-base64": { "version": "2.5.2", @@ -10192,6 +10410,12 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "merge2": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.3.0.tgz", + "integrity": "sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==", + "dev": true + }, "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", @@ -10333,22 +10557,22 @@ "minipass": "^3.0.0" } }, - "mississippi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", - "integrity": "sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw==", + "minizlib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.0.tgz", + "integrity": "sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==", "dev": true, "requires": { - "concat-stream": "^1.5.0", - "duplexify": "^3.4.2", - "end-of-stream": "^1.1.0", - "flush-write-stream": "^1.0.0", - "from2": "^2.1.0", - "parallel-transform": "^1.1.0", - "pump": "^2.0.1", - "pumpify": "^1.3.3", - "stream-each": "^1.1.0", - "through2": "^2.0.0" + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "mixin-deep": { @@ -10404,6 +10628,23 @@ "run-queue": "^1.0.3" } }, + "move-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/move-file/-/move-file-2.0.0.tgz", + "integrity": "sha512-cdkdhNCgbP5dvS4tlGxZbD+nloio9GIimP57EjqFhwLcMjnU+XJKAZzlmg/TN/AK1LuNAdTSvm3CPPP4Xkv0iQ==", + "dev": true, + "requires": { + "path-exists": "^4.0.0" + }, + "dependencies": { + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + } + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -11350,6 +11591,12 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -12312,6 +12559,12 @@ "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -12353,6 +12606,12 @@ "is-promise": "^2.1.0" } }, + "run-parallel": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", + "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", + "dev": true + }, "run-queue": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", @@ -12589,9 +12848,9 @@ } }, "serialize-javascript": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.7.0.tgz", - "integrity": "sha512-ke8UG8ulpFOxO8f8gRYabHQe/ZntKlcig2Mp+8+URDP1D8vJZ0KUt7LYo07q25Z/+JVSgpr/cui9PIp5H6/+nA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.0.0.tgz", + "integrity": "sha512-skZcHYw2vEX4bw90nAr2iTTsz6x2SrHEnfxgKYmZlvJYBEZrvbKtobJWlQ20zczKb3bsHHXXTYt48zBA7ni9cw==", "dev": true }, "serve-static": { @@ -13000,12 +13259,12 @@ } }, "ssri": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.3.0.tgz", - "integrity": "sha512-XRSIPqLij52MtgoQavH/x/dU1qVKtWUAAZeOHsR9c2Ddi4XerFy3mc1alf+dLJKl9EUIm/Ht+EowFkTUOA6GAQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.0.tgz", + "integrity": "sha512-aq/pz989nxVYwn16Tsbj1TqFpD5LLrQxHf5zaHuieFV+R0Bbr4y8qUsOA45hXT/N4/9UNXTarBjnjVmjSOVaAA==", "dev": true, "requires": { - "safe-buffer": "^5.1.1" + "minipass": "^3.1.1" } }, "stack-utils": { diff --git a/package.json b/package.json index 7fa2cdd..ea8a259 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "@babel/preset-react": "^7.9.4", "babel-eslint": "^10.1.0", - "copy-webpack-plugin": "^4.1.1", + "copy-webpack-plugin": "^6.0.1", "css-loader": "^2.1.0", "file-loader": "^3.0.1", "html-webpack-plugin": "^3.2.0", diff --git a/webpack.common.js b/webpack.common.js index 5e8ea76..a3002af 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -6,85 +6,89 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const CircularDependencyPlugin = require("circular-dependency-plugin"); module.exports = { - entry: "./src/app.js", - module: { - rules: [{ - test: /(\.jsx|\.js)$/, - exclude: /(node_modules|bower_components)/, - // When using with transpiling loaders (like babel-loader), make sure they are in correct order (bottom to top). - // Otherwise files will be check after being processed by babel-loader - use: [{ - loader: "babel-loader", - query: { - presets: ["@babel/preset-env", "@babel/react"], - plugins: ["@babel/plugin-proposal-object-rest-spread", ["babel-plugin-root-import", { "rootPathSuffix": "src" }]] - } + entry: "./src/app.js", + module: { + rules: [{ + test: /(\.jsx|\.js)$/, + exclude: /(node_modules|bower_components)/, + // When using with transpiling loaders (like babel-loader), make sure they are in correct order (bottom to top). + // Otherwise files will be check after being processed by babel-loader + use: [{ + loader: "babel-loader", + query: { + presets: ["@babel/preset-env", "@babel/react"], + plugins: ["@babel/plugin-proposal-object-rest-spread", ["babel-plugin-root-import", { "rootPathSuffix": "src" }]] + } + }, + { + loader: "eslint-loader", + options: { + quiet: true + } + } + ] }, { - loader: "eslint-loader", - options: { - quiet: true - } + test: /\.css$/, + use: ["style-loader", "css-loader"] + }, + { + test: /\.scss$/, + use: ["style-loader", + "css-loader", + { + loader: "sass-loader", + options: { + sourceMap: true, + includePaths: glob.sync( + path.join(__dirname, "**/node_modules/@material") + ).map((dir) => path.dirname(dir)), + }, + } + ] + }, + { + test: /\.(png|svg|jpg|gif)$/, + use: [{ + loader: 'url-loader', + options: { + limit: 8000, // Convert images < 8kb to base64 strings + name: 'images/[hash]-[name].[ext]' + } + }] } ] - }, - { - test: /\.css$/, - use: ["style-loader", "css-loader"] - }, - { - test: /\.scss$/, - use: ["style-loader", - "css-loader", - { - loader: "sass-loader", - options: { - sourceMap: true, - includePaths: glob.sync( - path.join(__dirname, "**/node_modules/@material") - ).map((dir) => path.dirname(dir)), - }, - } - ] - }, - { - test: /\.(png|svg|jpg|gif)$/, - use: [{ - loader: 'url-loader', - options: { - limit: 8000, // Convert images < 8kb to base64 strings - name: 'images/[hash]-[name].[ext]' - } - }] - } - ] - }, - plugins: [ - new CopyWebpackPlugin([{ - from: "./translations/**/*" - }]), - new CopyWebpackPlugin([{ - from: "./img/**/*" - }]), - new CircularDependencyPlugin({ - exclude: /a\.js|node_modules/, - failOnError: true //change to false when debugging to fix these circular dependencies - }), - new HtmlWebpackPlugin({ - title: "Real Time Map", - template: "./index-template.ejs", - favicon: "./favicon.png" - }), - new webpack.NamedModulesPlugin() - ], - resolve: { - alias: { - actions: path.resolve(__dirname, "src", "actions"), - components: path.resolve(__dirname, "src", "components"), - constants: path.resolve(__dirname, "src", "constants"), - global: path.resolve(__dirname, "src", "components", "global"), - services: path.resolve(__dirname, "src", "services"), - utils: path.resolve(__dirname, "src", "utils") - } - }, + }, + plugins: [ + new CopyWebpackPlugin({ + patterns: [ + { from: "./translations/**/*" } + ] + }), + new CopyWebpackPlugin({ + patterns: [ + { from: "./img/**/*" } + ] + }), + new CircularDependencyPlugin({ + exclude: /a\.js|node_modules/, + failOnError: true //change to false when debugging to fix these circular dependencies + }), + new HtmlWebpackPlugin({ + title: "Real Time Map", + template: "./index-template.ejs", + favicon: "./favicon.png" + }), + new webpack.NamedModulesPlugin() + ], + resolve: { + alias: { + actions: path.resolve(__dirname, "src", "actions"), + components: path.resolve(__dirname, "src", "components"), + constants: path.resolve(__dirname, "src", "constants"), + global: path.resolve(__dirname, "src", "components", "global"), + services: path.resolve(__dirname, "src", "services"), + utils: path.resolve(__dirname, "src", "utils") + } + }, }; From fab6334204e33e9cc9a84d8956fefd24ee13aaa3 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Tue, 26 May 2020 23:26:29 -0400 Subject: [PATCH 2/7] Added 'server' login info to userInfo object and MyGeotab state to apiConfig object so integrations can use Geotab Page State Methods --- src/app-helper.js | 57 +++++++++++++++++++------------------ src/app.js | 44 ++++++++++++++-------------- src/dataStore/api-config.js | 27 ++++++++++-------- 3 files changed, 67 insertions(+), 61 deletions(-) diff --git a/src/app-helper.js b/src/app-helper.js index 119520a..8e7006a 100644 --- a/src/app-helper.js +++ b/src/app-helper.js @@ -14,47 +14,50 @@ import { mapModel } from "../src/components/map/map-model"; import storage from "./dataStore"; import { initView } from "./index"; import { - apiConfig, - userInfo + apiConfig, + userInfo } from "./dataStore/api-config"; import { - resetAnimationOnFocus, - resetTransitionAnimation + resetAnimationOnFocus, + resetTransitionAnimation } - from "./utils/helper"; + from "./utils/helper"; export function initBeforeLogin() { - initDateKeeper(); + initDateKeeper(); } -export function loginToSession(api) { - apiConfig.api = api; - return new Promise(resolve => { - apiConfig.api.getSession(session => { - userInfo.setUserInfo(session.userName, session.database, session.sessionId); - resolve(); - }); - }); +export function loginToSession(api, state) { + apiConfig.api = api; + apiConfig.state = state; + return new Promise(resolve => { + apiConfig.api.getSession((session, server) => { + userInfo.setUserInfo(session.userName, session.database, session.sessionId, server); + resolve(); + }); + }); }; export function initAfterLogin() { - storage.dateKeeper$.resume(); - initView(); - layerModel.initLayers(); - mapModel.locateUserAndSetView(); - resetAnimationOnFocus(); + storage.dateKeeper$.resume(); + initView(); + layerModel.initLayers(); + mapModel.locateUserAndSetView(); + resetAnimationOnFocus(); - initRealTimeFeedRunner(); - initHistoricalFeedRunner(); + initRealTimeFeedRunner(); + initHistoricalFeedRunner(); } export function handleBlur() { - storage.dateKeeper$.pause(); - console.log("Blurred!"); + storage.dateKeeper$.pause(); + console.log("Blurred!"); } -export function handleFocus() { - storage.dateKeeper$.resume(); - resetTransitionAnimation(); - console.log("Focused!"); +export function handleFocus(api, state) { + apiConfig.api = api; + apiConfig.state = state; + storage.dateKeeper$.resume(); + resetTransitionAnimation(); + console.log("Focused!"); } diff --git a/src/app.js b/src/app.js index 63b80ad..40aeb7c 100644 --- a/src/app.js +++ b/src/app.js @@ -1,39 +1,39 @@ import { - initBeforeLogin, - initAfterLogin, - loginToSession, - handleFocus, - handleBlur + initBeforeLogin, + initAfterLogin, + loginToSession, + handleFocus, + handleBlur } from "./app-helper"; import { - geotabStandAlone + geotabStandAlone } from "./utils/stand-alone/geotab"; if (typeof geotab === "undefined") { - window.geotab = geotabStandAlone; + window.geotab = geotabStandAlone; } geotab.addin.realTimeMap = function realTimeMapAddIn() { - return { - initialize(api, state, callback) { + return { + initialize(api, state, callback) { - initBeforeLogin(); + initBeforeLogin(); - loginToSession(api).then(() => { + loginToSession(api, state).then(() => { - initAfterLogin(); - callback(); + initAfterLogin(); + callback(); - }); - }, + }); + }, - focus() { - handleFocus(); - }, + focus(api, state) { + handleFocus(api, state); + }, - blur() { - handleBlur(); - } - }; + blur() { + handleBlur(); + } + }; }; \ No newline at end of file diff --git a/src/dataStore/api-config.js b/src/dataStore/api-config.js index 65471ee..9b14655 100644 --- a/src/dataStore/api-config.js +++ b/src/dataStore/api-config.js @@ -1,19 +1,22 @@ -import { LOGRECORD, EXCEPTIONEVENT } from '../constants/feed-type-names'; +import { LOGRECORD, EXCEPTIONEVENT } from "../constants/feed-type-names"; export const apiConfig = { - api: undefined, - feedTypesToGet: [LOGRECORD, EXCEPTIONEVENT], - resultsLimit: 60000, + api: undefined, + state: undefined, + feedTypesToGet: [LOGRECORD, EXCEPTIONEVENT], + resultsLimit: 60000, }; export const userInfo = { - userName: "", - database: "", - sessionId: "", + userName: "", + database: "", + sessionId: "", + server: "", - setUserInfo: (user, db, session) => { - userInfo.userName = user; - userInfo.database = db; - userInfo.sessionId = session; - } + setUserInfo: (user, db, session, server) => { + userInfo.userName = user; + userInfo.database = db; + userInfo.sessionId = session; + userInfo.server = server; + } }; \ No newline at end of file From 068fa739728c0b49a33f2b593081483f1dc437a7 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Tue, 26 May 2020 23:32:18 -0400 Subject: [PATCH 3/7] Moved Standalone Logout button to top-left screen on map, so it no longer obstructs the ConfigView Panel --- styles/components/map.scss | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/styles/components/map.scss b/styles/components/map.scss index 02be85f..0098ce4 100644 --- a/styles/components/map.scss +++ b/styles/components/map.scss @@ -116,17 +116,17 @@ background-color: #f2dede; } -#RTM-LogoutButton{ - cursor: pointer; - border-radius: 3px; - border: 1px solid #c5dbec; - background-color: #e8f3fd; - color: #25477b; - text-decoration: none; - line-height: 18px; - z-index: 1001; - - position: absolute; - right:3px; - top:6px; +#RTM-LogoutButton { + cursor: pointer; + border-radius: 3px; + border: 1px solid #c5dbec; + background-color: #e8f3fd; + color: #25477b; + text-decoration: none; + line-height: 18px; + z-index: 1001; + + position: absolute; + left:3px; + top:0px; } \ No newline at end of file From 19dedec3662e827333f62ffbbe052106f06354e4 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Tue, 26 May 2020 23:43:22 -0400 Subject: [PATCH 4/7] User usability improvement: Vehicles Tab as default in ConfigView panel. Will see fare more use by customers than Exceptions Tab --- .../configuration/configuration-view.js | 138 +++++++++--------- .../exception-config/exceptions-tab.js | 62 ++++---- .../vehicles-config/vehicles-tab.js | 62 ++++---- styles/components/config-panel.scss | 5 +- 4 files changed, 133 insertions(+), 134 deletions(-) diff --git a/src/components/configuration/configuration-view.js b/src/components/configuration/configuration-view.js index 879091d..fc4a38d 100644 --- a/src/components/configuration/configuration-view.js +++ b/src/components/configuration/configuration-view.js @@ -8,81 +8,81 @@ import { exceptionSearch } from "./exception-config/exception-search"; import { deviceSearch } from "./vehicles-config/vehicle-search"; export class ConfigView extends React.Component { - constructor(props) { - super(props); - this.state = { - exceptionsSearchList: [], - statuses: [], - devices: [], - exceptionDisplayList: [], - statusDisplayList: [], - vehicleDisplayList: [] - }; - this.setExceptions = this.setExceptions.bind(this); - this.setExceptionsList = this.setExceptionsList.bind(this); - this.setStatusList = this.setStatusList.bind(this); - this.setVehicleList = this.setVehicleList.bind(this); - this.setStatuses = this.setStatuses.bind(this); - this.setDevices = this.setDevices.bind(this); - } + constructor(props) { + super(props); + this.state = { + exceptionsSearchList: [], + statuses: [], + devices: [], + exceptionDisplayList: [], + statusDisplayList: [], + vehicleDisplayList: [] + }; + this.setExceptions = this.setExceptions.bind(this); + this.setExceptionsList = this.setExceptionsList.bind(this); + this.setStatusList = this.setStatusList.bind(this); + this.setVehicleList = this.setVehicleList.bind(this); + this.setStatuses = this.setStatuses.bind(this); + this.setDevices = this.setDevices.bind(this); + } - setExceptions(props) { - this.setState({ exceptionsSearchList: props }); - } + setExceptions(props) { + this.setState({ exceptionsSearchList: props }); + } - setExceptionsList(props) { - this.setState({ exceptionDisplayList: props }); - } + setExceptionsList(props) { + this.setState({ exceptionDisplayList: props }); + } - setStatusList(props) { - this.setState({ statusDisplayList: props }); - } + setStatusList(props) { + this.setState({ statusDisplayList: props }); + } - setVehicleList(props) { - this.setState({ vehicleDisplayList: props }); - } + setVehicleList(props) { + this.setState({ vehicleDisplayList: props }); + } - setStatuses(props) { - this.setState({ statuses: props }); - } + setStatuses(props) { + this.setState({ statuses: props }); + } - setDevices(props) { - this.setState({ devices: props }); - } + setDevices(props) { + this.setState({ devices: props }); + } - componentDidMount() { - exceptionSearch.init(this.setExceptions); - diagnosticSearch.init(this.setStatuses); - deviceSearch.init(this.setDevices); - exceptionSearch.loadSavedExceptionConfig(this.setExceptionsList); - diagnosticSearch.loadSavedStatusConfig(this.setStatusList); - deviceSearch.loadSavedDeviceConfig(this.setVehicleList); - initCollapse(); - } + componentDidMount() { + exceptionSearch.init(this.setExceptions); + diagnosticSearch.init(this.setStatuses); + deviceSearch.init(this.setDevices); + exceptionSearch.loadSavedExceptionConfig(this.setExceptionsList); + diagnosticSearch.loadSavedStatusConfig(this.setStatusList); + deviceSearch.loadSavedDeviceConfig(this.setVehicleList); + initCollapse(); + } - render() { - return ( -
-
-
- - - -
-
-
- ); - } + render() { + return ( +
+
+
+ + + +
+
+
+ ); + } } diff --git a/src/components/configuration/exception-config/exceptions-tab.js b/src/components/configuration/exception-config/exceptions-tab.js index 262933b..9061350 100644 --- a/src/components/configuration/exception-config/exceptions-tab.js +++ b/src/components/configuration/exception-config/exceptions-tab.js @@ -6,38 +6,38 @@ import { ExceptionListComponent } from "./exception-list-component"; import { ExceptionToggleButtons } from "./exception-toggle-buttons"; export const ExceptionsTab = props => ( -
- -
- -
-

Selected Exceptions:

-
- -
-
+
+ +
+

Selected Exceptions:

+
+ +
+
-
-
-
-
    - -
-
-
+
+
+
+
    + +
+
+
+
-
-
+
); diff --git a/src/components/configuration/vehicles-config/vehicles-tab.js b/src/components/configuration/vehicles-config/vehicles-tab.js index 317d951..160bbb6 100644 --- a/src/components/configuration/vehicles-config/vehicles-tab.js +++ b/src/components/configuration/vehicles-config/vehicles-tab.js @@ -5,37 +5,37 @@ import { VehicleToggleButtons } from "./vehicle-toggle-buttons"; import { VehicleListComponent } from "./vehicle-list-component"; export const VehiclesTab = props => ( -
- -
- -
-

Selected Vehicles:

-
- -
+
+ +
+

Selected Vehicles:

+
+ +
+
+
+
+
+
    + +
+
+
+
-
-
-
-
    - -
-
-
-
-
-
+
); diff --git a/styles/components/config-panel.scss b/styles/components/config-panel.scss index 8472bf3..27f4437 100644 --- a/styles/components/config-panel.scss +++ b/styles/components/config-panel.scss @@ -269,11 +269,10 @@ overflow: hidden; } -#vehicle-tab { +#status-tab { display: none; } - -#status-tab { +#exception-tab { display: none; } From 10ca3a80fc5ad9716eea5c9c1618738a371f115c Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Fri, 29 May 2020 10:38:54 -0400 Subject: [PATCH 5/7] Replaced JS alerts() with UI-compliant showSnackBar() notifications --- .../vehicles-config/vehicle-search.js | 425 +++++++++--------- .../controls/date-time-model/date-time.js | 201 +++++---- src/components/map/map-model.js | 131 +++--- 3 files changed, 379 insertions(+), 378 deletions(-) diff --git a/src/components/configuration/vehicles-config/vehicle-search.js b/src/components/configuration/vehicles-config/vehicle-search.js index 81014e0..1d65b9e 100644 --- a/src/components/configuration/vehicles-config/vehicle-search.js +++ b/src/components/configuration/vehicles-config/vehicle-search.js @@ -2,237 +2,238 @@ import { fromEvent } from "rxjs"; import { map, debounceTime } from "rxjs/operators"; import { markerList } from "../../../dataStore/map-data"; import { getDevicesInGroups, createGroupsByNameCall, createDeviceByNameCall, makeAPIMultiCall, getBlobStorage, saveBlobStorage, setBlobStorage } from "../../../services/api/helpers"; +import { showSnackBar } from "../../../components/snackbar/snackbar"; import storage from "../../../dataStore"; import layerModel from "../../map/layers"; export const deviceSearch = { - shown: true, - deviceResultsCache: {}, - selectedIDS: {}, - - get searchInput() { - return document.getElementById("RTM-vehicle-search-bar"); - }, - - init(mapPropsToComponent) { - // Init rxjs debounce search. - const searchInputObservable = fromEvent(deviceSearch.searchInput, "input").pipe(map(i => i.currentTarget.value)); - const debouncedInput = searchInputObservable.pipe(debounceTime(250)); - debouncedInput.subscribe((searchInput) => deviceSearch.buildSearchList(searchInput, mapPropsToComponent)); - }, - - loadSavedDeviceConfig(mapPropsToComponent) { - - return getBlobStorage().then(val => { - if (val.length === 0) { return; } - const cachedDevices = JSON.parse(val[0].data); - - if (cachedDevices.configData.Vehicle) { - deviceSearch.selectedIDS = cachedDevices.configData.Vehicle; - deviceSearch.applyFilter(); - deviceSearch.buildDeviceDisplayList(mapPropsToComponent); - } - }); - }, - - buildSearchList(searchInput, mapPropsToComponent) { - - const nameSearchMultiCall = [ - createDeviceByNameCall(searchInput), - createGroupsByNameCall(searchInput) - ]; - - return makeAPIMultiCall(nameSearchMultiCall).then(results => { - // deviceList = results[0]; - results[0] - .map(deviceSearch.saveDeviceDataToCache); - // groupList = results[1]; - results[1] - .map(deviceSearch.saveGroupDataToCache); - mapPropsToComponent(Object.values(deviceSearch.deviceResultsCache)); - }); - - }, - - saveDeviceDataToCache(deviceData) { - const data = {}; - ["id", "name", "groups"].forEach(prop => data[prop] = deviceData[prop]); - data.visible = true; - deviceSearch.deviceResultsCache[data.name] = data; - return data; - }, - - saveGroupDataToCache(deviceData) { - const data = {}; - ["id", "name", "color"].forEach(prop => data[prop] = deviceData[prop]); - data.visible = true; - data.name += " (Group)"; - - deviceSearch.deviceResultsCache[data.name] = data; - return data; - }, - - buildDeviceDisplayList(mapPropsToComponent) { - deviceSearch.mapPropsToComponent = mapPropsToComponent; - mapPropsToComponent(Object.values(deviceSearch.selectedIDS) - .filter(device => device.id && device.name)); - }, - - handleItemSelected(event, mapPropsToComponent) { - event.preventDefault(); - deviceSearch.saveSelectedValue(mapPropsToComponent); - }, - - saveSelectedValue(mapPropsToComponent) { - - const { value } = deviceSearch.searchInput; - if (!deviceSearch.deviceResultsCache.hasOwnProperty(value)) { - return; - } - - const deviceData = deviceSearch.deviceResultsCache[value]; - deviceData.visible = true; - const { - id, - name, - groups, - color, - visible - } = deviceData; - - if (color) { //It's a group - deviceSearch.selectedIDS[id] = { id, name, color, visible }; - } - else { - deviceSearch.selectedIDS[id] = { id, name, groups, visible }; - } - - deviceSearch.searchInput.value = ""; - deviceSearch.saveConfig(mapPropsToComponent); - return deviceData; - }, - - deleteItemFromdeviceList(id, mapPropsToComponent) { - delete deviceSearch.selectedIDS[id]; - deviceSearch.saveConfig(mapPropsToComponent); - }, - - deleteAllItems(mapPropsToComponent) { - deviceSearch.selectedIDS = {}; - deviceSearch.saveConfig(mapPropsToComponent); - }, - - saveConfig(mapPropsToComponent) { - storage.setBlobStorageObj ? setBlobStorage("Vehicle", deviceSearch.selectedIDS) : saveBlobStorage("Vehicle", deviceSearch.selectedIDS); - - deviceSearch.applyFilter(); - deviceSearch.buildDeviceDisplayList(mapPropsToComponent); - }, - - applyFilter() { - _getDeviceList(deviceSearch.selectedIDS).then(() => { - _applyDeviceFilter(Object.keys(storage.selectedDevices)); - }); - }, - showAll(mapPropsToComponent) { - Object.values(deviceSearch.selectedIDS) - .forEach(selectedDevice => - selectedDevice.visible = true - ); - deviceSearch.saveConfig(mapPropsToComponent); - }, - hideAll(mapPropsToComponent) { - Object.values(deviceSearch.selectedIDS) - .forEach(selectedDevice => - selectedDevice.visible = false - ); - deviceSearch.saveConfig(mapPropsToComponent); - }, - toggleDeviceVisibility(id, mapPropsToComponent) { - const selectedDevice = deviceSearch.selectedIDS[id]; - selectedDevice.visible = !selectedDevice.visible; - deviceSearch.saveConfig(mapPropsToComponent); - }, - zoomIntoDevice(id) { - const deviceMarker = markerList[id]; - if (deviceMarker) { - const newZoomLevel = Math.max(Math.min(storage.map.getZoom() + 1, 18), 15); - storage.map.flyTo(deviceMarker.currentlatLng, newZoomLevel); - } else { - alert("Sorry, no current day data for selected vehicle."); - } - } + shown: true, + deviceResultsCache: {}, + selectedIDS: {}, + + get searchInput() { + return document.getElementById("RTM-vehicle-search-bar"); + }, + + init(mapPropsToComponent) { + // Init rxjs debounce search. + const searchInputObservable = fromEvent(deviceSearch.searchInput, "input").pipe(map(i => i.currentTarget.value)); + const debouncedInput = searchInputObservable.pipe(debounceTime(250)); + debouncedInput.subscribe((searchInput) => deviceSearch.buildSearchList(searchInput, mapPropsToComponent)); + }, + + loadSavedDeviceConfig(mapPropsToComponent) { + + return getBlobStorage().then(val => { + if (val.length === 0) { return; } + const cachedDevices = JSON.parse(val[0].data); + + if (cachedDevices.configData.Vehicle) { + deviceSearch.selectedIDS = cachedDevices.configData.Vehicle; + deviceSearch.applyFilter(); + deviceSearch.buildDeviceDisplayList(mapPropsToComponent); + } + }); + }, + + buildSearchList(searchInput, mapPropsToComponent) { + + const nameSearchMultiCall = [ + createDeviceByNameCall(searchInput), + createGroupsByNameCall(searchInput) + ]; + + return makeAPIMultiCall(nameSearchMultiCall).then(results => { + // deviceList = results[0]; + results[0] + .map(deviceSearch.saveDeviceDataToCache); + // groupList = results[1]; + results[1] + .map(deviceSearch.saveGroupDataToCache); + mapPropsToComponent(Object.values(deviceSearch.deviceResultsCache)); + }); + + }, + + saveDeviceDataToCache(deviceData) { + const data = {}; + ["id", "name", "groups"].forEach(prop => data[prop] = deviceData[prop]); + data.visible = true; + deviceSearch.deviceResultsCache[data.name] = data; + return data; + }, + + saveGroupDataToCache(deviceData) { + const data = {}; + ["id", "name", "color"].forEach(prop => data[prop] = deviceData[prop]); + data.visible = true; + data.name += " (Group)"; + + deviceSearch.deviceResultsCache[data.name] = data; + return data; + }, + + buildDeviceDisplayList(mapPropsToComponent) { + deviceSearch.mapPropsToComponent = mapPropsToComponent; + mapPropsToComponent(Object.values(deviceSearch.selectedIDS) + .filter(device => device.id && device.name)); + }, + + handleItemSelected(event, mapPropsToComponent) { + event.preventDefault(); + deviceSearch.saveSelectedValue(mapPropsToComponent); + }, + + saveSelectedValue(mapPropsToComponent) { + + const { value } = deviceSearch.searchInput; + if (!deviceSearch.deviceResultsCache.hasOwnProperty(value)) { + return; + } + + const deviceData = deviceSearch.deviceResultsCache[value]; + deviceData.visible = true; + const { + id, + name, + groups, + color, + visible + } = deviceData; + + if (color) { //It's a group + deviceSearch.selectedIDS[id] = { id, name, color, visible }; + } + else { + deviceSearch.selectedIDS[id] = { id, name, groups, visible }; + } + + deviceSearch.searchInput.value = ""; + deviceSearch.saveConfig(mapPropsToComponent); + return deviceData; + }, + + deleteItemFromdeviceList(id, mapPropsToComponent) { + delete deviceSearch.selectedIDS[id]; + deviceSearch.saveConfig(mapPropsToComponent); + }, + + deleteAllItems(mapPropsToComponent) { + deviceSearch.selectedIDS = {}; + deviceSearch.saveConfig(mapPropsToComponent); + }, + + saveConfig(mapPropsToComponent) { + storage.setBlobStorageObj ? setBlobStorage("Vehicle", deviceSearch.selectedIDS) : saveBlobStorage("Vehicle", deviceSearch.selectedIDS); + + deviceSearch.applyFilter(); + deviceSearch.buildDeviceDisplayList(mapPropsToComponent); + }, + + applyFilter() { + _getDeviceList(deviceSearch.selectedIDS).then(() => { + _applyDeviceFilter(Object.keys(storage.selectedDevices)); + }); + }, + showAll(mapPropsToComponent) { + Object.values(deviceSearch.selectedIDS) + .forEach(selectedDevice => + selectedDevice.visible = true + ); + deviceSearch.saveConfig(mapPropsToComponent); + }, + hideAll(mapPropsToComponent) { + Object.values(deviceSearch.selectedIDS) + .forEach(selectedDevice => + selectedDevice.visible = false + ); + deviceSearch.saveConfig(mapPropsToComponent); + }, + toggleDeviceVisibility(id, mapPropsToComponent) { + const selectedDevice = deviceSearch.selectedIDS[id]; + selectedDevice.visible = !selectedDevice.visible; + deviceSearch.saveConfig(mapPropsToComponent); + }, + zoomIntoDevice(id) { + const deviceMarker = markerList[id]; + if (deviceMarker) { + const newZoomLevel = Math.max(Math.min(storage.map.getZoom() + 1, 18), 15); + storage.map.flyTo(deviceMarker.currentlatLng, newZoomLevel); + } else { + showSnackBar("Sorry, no current day data for selected vehicle."); + } + } }; export function _getDeviceList(selectedIDs) { - storage.selectedDevices = {}; - return Promise.all(Object.values(selectedIDs).map(data => { - const { - id, - color, - visible - } = data; - if (!visible) { - return Promise.resolve("done"); - } - - if (color) { //It's a group - return getDevicesInGroups([{ id }]).then(devices => - devices.forEach(device => { - const { - id, - name, - groups - } = device; - storage.selectedDevices[id] = { id, name, groups, visible: true }; - }) - ); - - } - else { - storage.selectedDevices[id] = data; - return Promise.resolve("done"); - } - })); + storage.selectedDevices = {}; + return Promise.all(Object.values(selectedIDs).map(data => { + const { + id, + color, + visible + } = data; + if (!visible) { + return Promise.resolve("done"); + } + + if (color) { //It's a group + return getDevicesInGroups([{ id }]).then(devices => + devices.forEach(device => { + const { + id, + name, + groups + } = device; + storage.selectedDevices[id] = { id, name, groups, visible: true }; + }) + ); + + } + else { + storage.selectedDevices[id] = data; + return Promise.resolve("done"); + } + })); } window.addDeviceToFilter = (id, name = "Go Device") => { - deviceSearch.selectedIDS[id] = { id, name, visible: true }; - deviceSearch.saveConfig(deviceSearch.mapPropsToComponent); - openPopup(); + deviceSearch.selectedIDS[id] = { id, name, visible: true }; + deviceSearch.saveConfig(deviceSearch.mapPropsToComponent); + openPopup(); }; export function _applyDeviceFilter(deviceIDS) { - // console.log(deviceIDS); - layerModel.hideAllLayers(); + // console.log(deviceIDS); + layerModel.hideAllLayers(); - if (deviceIDS.length === 0) { - layerModel.showLayer("movingLayer"); - return; - } + if (deviceIDS.length === 0) { + layerModel.showLayer("movingLayer"); + return; + } - const layerName = "Filter"; + const layerName = "Filter"; - if (!layerModel.layerList.hasOwnProperty(layerName)) { - layerModel.createNewLayer(layerName); - } + if (!layerModel.layerList.hasOwnProperty(layerName)) { + layerModel.createNewLayer(layerName); + } - layerModel.layerList[layerName].clearLayers(); - layerModel.showLayer(layerName); + layerModel.layerList[layerName].clearLayers(); + layerModel.showLayer(layerName); - deviceIDS.forEach(deviceID => { - const deviceMarker = markerList[deviceID]; - if (deviceMarker) { - deviceMarker.setLayer(layerName); - } - }); + deviceIDS.forEach(deviceID => { + const deviceMarker = markerList[deviceID]; + if (deviceMarker) { + deviceMarker.setLayer(layerName); + } + }); } function openPopup() { - const collapseButton = document.getElementsByClassName("collapsible"); - const vehicleTab = document.getElementById("RTM-VehicleTitle"); - if (!collapseButton[0].classList.contains("active")) { - collapseButton[0].click(); - vehicleTab.click(); - } + const collapseButton = document.getElementsByClassName("collapsible"); + const vehicleTab = document.getElementById("RTM-VehicleTitle"); + if (!collapseButton[0].classList.contains("active")) { + collapseButton[0].click(); + vehicleTab.click(); + } } diff --git a/src/components/controls/date-time-model/date-time.js b/src/components/controls/date-time-model/date-time.js index c8dc087..d672ec2 100644 --- a/src/components/controls/date-time-model/date-time.js +++ b/src/components/controls/date-time-model/date-time.js @@ -4,145 +4,144 @@ import { showSnackBar } from "../../snackbar/snackbar"; export const dateTimeModel = { - get dateInput() { - return document.getElementById("dateInputBox"); - }, + get dateInput() { + return document.getElementById("dateInputBox"); + }, - get startTimeInput() { - return document.getElementById("timeRangeStart"); - }, + get startTimeInput() { + return document.getElementById("timeRangeStart"); + }, - get currentTimeInput() { - return document.getElementById("currentTimeInput"); - }, + get currentTimeInput() { + return document.getElementById("currentTimeInput"); + }, - initDateTimeInput() { + initDateTimeInput() { - this.setDefaultDateValue(); - this.setDefaultStartTimeValue(); - this.setDefaultCurrentTimeValue(); + this.setDefaultDateValue(); + this.setDefaultStartTimeValue(); + this.setDefaultCurrentTimeValue(); - this.dateInput.addEventListener("keyup", this.onDateEntered.bind(this)); - this.startTimeInput.addEventListener("keyup", this.onStartTimeEntered.bind(this)); - this.currentTimeInput.addEventListener("keyup", this.onCurrentTimeEntered.bind(this)); + this.dateInput.addEventListener("keyup", this.onDateEntered.bind(this)); + this.startTimeInput.addEventListener("keyup", this.onStartTimeEntered.bind(this)); + this.currentTimeInput.addEventListener("keyup", this.onCurrentTimeEntered.bind(this)); - this.dateInput.addEventListener("change", onChange); - this.startTimeInput.addEventListener("change", onChange); - this.currentTimeInput.addEventListener("change", onChange); + this.dateInput.addEventListener("change", onChange); + this.startTimeInput.addEventListener("change", onChange); + this.currentTimeInput.addEventListener("change", onChange); - storage.dateKeeper$.subscribe(this.updateCurrentSecond.bind(this)); - }, + storage.dateKeeper$.subscribe(this.updateCurrentSecond.bind(this)); + }, - setDefaultDateValue() { - this.dateInput.value = new Date(storage.currentTime).toLocaleDateString("en-CA"); - }, + setDefaultDateValue() { + this.dateInput.value = new Date(storage.currentTime).toLocaleDateString("en-CA"); + }, - setDefaultStartTimeValue() { - this.startTimeInput.value = new Date(storage.timeRangeStart).toLocaleTimeString("en-GB"); - }, + setDefaultStartTimeValue() { + this.startTimeInput.value = new Date(storage.timeRangeStart).toLocaleTimeString("en-GB"); + }, - setDefaultCurrentTimeValue() { - this.currentTimeInput.value = new Date(storage.currentTime).toLocaleTimeString("en-GB"); - }, + setDefaultCurrentTimeValue() { + this.currentTimeInput.value = new Date(storage.currentTime).toLocaleTimeString("en-GB"); + }, - updateCurrentSecond(currentSecond) { + updateCurrentSecond(currentSecond) { - if (this.dateInput && document.activeElement != this.dateInput) { - this.setDefaultDateValue(); - } + if (this.dateInput && document.activeElement != this.dateInput) { + this.setDefaultDateValue(); + } - if (this.startTimeInput && document.activeElement != this.startTimeInput) { - this.setDefaultStartTimeValue(); - } + if (this.startTimeInput && document.activeElement != this.startTimeInput) { + this.setDefaultStartTimeValue(); + } - if (this.currentTimeInput && document.activeElement != this.currentTimeInput) { - this.currentTimeInput.value = new Date(currentSecond).toLocaleTimeString("en-GB"); - } - }, + if (this.currentTimeInput && document.activeElement != this.currentTimeInput) { + this.currentTimeInput.value = new Date(currentSecond).toLocaleTimeString("en-GB"); + } + }, - onDateEntered(event) { - if (!checkRightKeyEntered(event)) { - return; - } + onDateEntered(event) { + if (!checkRightKeyEntered(event)) { + return; + } - // this.dateInput.blur(); - const selectedTime = new Date(this.dateInput.value + " " + this.currentTimeInput.value); + // this.dateInput.blur(); + const selectedTime = new Date(this.dateInput.value + " " + this.currentTimeInput.value); - if (checkDateInFuture(selectedTime)) { - this.setDefaultDateValue(); - } else { - this.dateInput.value = selectedTime.toLocaleDateString("en-CA"); - this.applyAndUpdate(selectedTime.getTime()); - } - }, + if (checkDateInFuture(selectedTime)) { + this.setDefaultDateValue(); + } else { + this.dateInput.value = selectedTime.toLocaleDateString("en-CA"); + this.applyAndUpdate(selectedTime.getTime()); + } + }, - onStartTimeEntered(event) { - if (!checkRightKeyEntered(event)) { - return; - } + onStartTimeEntered(event) { + if (!checkRightKeyEntered(event)) { + return; + } - this.startTimeInput.blur(); - const selectedTime = new Date(this.dateInput.value + " " + this.startTimeInput.value); + this.startTimeInput.blur(); + const selectedTime = new Date(this.dateInput.value + " " + this.startTimeInput.value); - if (checkDateInFuture(selectedTime)) { - this.setDefaultStartTimeValue(); + if (checkDateInFuture(selectedTime)) { + this.setDefaultStartTimeValue(); - } else { - const newTime = selectedTime.getTime(); - storage.timeRangeStart = newTime; - if (newTime > storage.currentTime) { - storage.currentTime = newTime; + } else { + const newTime = selectedTime.getTime(); + storage.timeRangeStart = newTime; + if (newTime > storage.currentTime) { + storage.currentTime = newTime; + } + this.applyAndUpdate(storage.currentTime); } - this.applyAndUpdate(storage.currentTime); - } - }, + }, - onCurrentTimeEntered(event) { - if (!checkRightKeyEntered(event)) { - return; - } + onCurrentTimeEntered(event) { + if (!checkRightKeyEntered(event)) { + return; + } - this.currentTimeInput.blur(); - const selectedTime = new Date(this.dateInput.value + " " + this.currentTimeInput.value); + this.currentTimeInput.blur(); + const selectedTime = new Date(this.dateInput.value + " " + this.currentTimeInput.value); - if (checkDateInFuture(selectedTime)) { - this.setDefaultCurrentTimeValue(); + if (checkDateInFuture(selectedTime)) { + this.setDefaultCurrentTimeValue(); - } else { - const newTime = selectedTime.getTime(); - if (newTime < storage.timeRangeStart) { - storage.timeRangeStart = newTime; + } else { + const newTime = selectedTime.getTime(); + if (newTime < storage.timeRangeStart) { + storage.timeRangeStart = newTime; + } + this.applyAndUpdate(newTime); } - this.applyAndUpdate(newTime); - } - }, - - applyAndUpdate(newTime) { - this.updateCurrentSecond(newTime); - storage.dateKeeper$.setNewTime(newTime); - } + }, + + applyAndUpdate(newTime) { + this.updateCurrentSecond(newTime); + storage.dateKeeper$.setNewTime(newTime); + } }; function checkRightKeyEntered(event) { - event.preventDefault(); - // Number 13 is the "Enter" key on the keyboard - return (event.keyCode === 13); + event.preventDefault(); + // Number 13 is the "Enter" key on the keyboard + return (event.keyCode === 13); } function checkDateInFuture(selectedTime) { - const liveDate = new Date(getLiveTime()); + const liveDate = new Date(getLiveTime()); - if (selectedTime > liveDate) { - alert("Selected date is in future!"); - //Snackbar notificaiton - return true; - } + if (selectedTime > liveDate) { + showSnackBar("Selected date is in future!"); + return true; + } - return false; + return false; } export function onChange() { - showSnackBar("Please hit Enter to apply your changes!"); + showSnackBar("Please hit Enter to apply your changes!"); }; \ No newline at end of file diff --git a/src/components/map/map-model.js b/src/components/map/map-model.js index 848a025..21068b5 100644 --- a/src/components/map/map-model.js +++ b/src/components/map/map-model.js @@ -3,86 +3,87 @@ import { userAPI } from "../../services/api/user-api"; import { userInfo } from "../../dataStore/api-config"; import storage from "../../dataStore"; import { resetTransitionAnimation } from "../../utils/helper"; +import { showSnackBar } from "../snackbar/snackbar"; let MAPBOX; try { - MAPBOX = require("../../../map-box-token.key.json"); + MAPBOX = require("../../../map-box-token.key.json"); } catch (ex) { - MAPBOX = { - ACCESS_TOKEN: false - }; + MAPBOX = { + ACCESS_TOKEN: false + }; } export const mapModel = { - handleMapCreated(element) { - storage.map = new L.Map(element, { - doubleClickZoom: false, - markerZoomAnimation: false, - worldCopyJump: true - }); - if (MAPBOX && MAPBOX.ACCESS_TOKEN) { - mapModel.addMapBoxTileLayer(storage.map); - } - else { - mapModel.addOSMTileLayer(storage.map); - } + handleMapCreated(element) { + storage.map = new L.Map(element, { + doubleClickZoom: false, + markerZoomAnimation: false, + worldCopyJump: true + }); + if (MAPBOX && MAPBOX.ACCESS_TOKEN) { + mapModel.addMapBoxTileLayer(storage.map); + } + else { + mapModel.addOSMTileLayer(storage.map); + } - storage.map.on("mousedown", () => { - storage.map.closePopup(); - }); - storage.map.on("zoom", resetTransitionAnimation); + storage.map.on("mousedown", () => { + storage.map.closePopup(); + }); + storage.map.on("zoom", resetTransitionAnimation); - // set to default location if user does not allow locating. - const defautLocation = [43.515391, -79.684085]; - storage.map.setView(defautLocation, 12); - }, + // set to default location if user does not allow locating. + const defautLocation = [43.515391, -79.684085]; + storage.map.setView(defautLocation, 12); + }, - addMapBoxTileLayer: map => { - L.tileLayer(`https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=${MAPBOX.ACCESS_TOKEN}`, { - attribution: "Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox", - minZoom: storage.minZoom, - maxZoom: storage.maxZoom, - id: "mapbox.streets", - accessToken: MAPBOX.ACCESS_TOKEN - }).addTo(map); - }, + addMapBoxTileLayer: map => { + L.tileLayer(`https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=${MAPBOX.ACCESS_TOKEN}`, { + attribution: "Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox", + minZoom: storage.minZoom, + maxZoom: storage.maxZoom, + id: "mapbox.streets", + accessToken: MAPBOX.ACCESS_TOKEN + }).addTo(map); + }, - addOSMTileLayer(map) { - L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { - attribution: '© OpenStreetMap', - subdomains: ["a", "b", "c"], - minZoom: storage.minZoom, - maxZoom: storage.maxZoom, - }).addTo(map); - }, + addOSMTileLayer(map) { + L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { + attribution: '© OpenStreetMap', + subdomains: ["a", "b", "c"], + minZoom: storage.minZoom, + maxZoom: storage.maxZoom, + }).addTo(map); + }, - locateUserAndSetView() { - storage.map.locate({ setView: true, maxZoom: 12 }); - }, + locateUserAndSetView() { + storage.map.locate({ setView: true, maxZoom: 12 }); + }, - setMapToCompanyAddress() { - return userAPI.getUserInfo(userInfo.userName) - .then(result => { - userAPI.getCoordinatesFromAddress(result[0].companyAddress) - .then(result => - mapModel.mapSetView(L.latLng(result[0].y, result[0].x)) - ) - .catch(() => mapModel.mapSetView([])); - }) - .catch(() => alert("Server is unavailable, please try again later.")); - }, + setMapToCompanyAddress() { + return userAPI.getUserInfo(userInfo.userName) + .then(result => { + userAPI.getCoordinatesFromAddress(result[0].companyAddress) + .then(result => + mapModel.mapSetView(L.latLng(result[0].y, result[0].x)) + ) + .catch(() => mapModel.mapSetView([])); + }) + .catch(() => showSnackBar("Server is unavailable, please try again later.")); + }, - mapSetView(latlng) { - if (latlng.length === 0) { - storage.map.setView([43.515228, -79.683523], 12); - console.warn("Default location set to user location."); - } - else { - storage.map.setView(latlng, 12); - console.warn(`Location set to: ${latlng}`); - } - } + mapSetView(latlng) { + if (latlng.length === 0) { + storage.map.setView([43.515228, -79.683523], 12); + console.warn("Default location set to user location."); + } + else { + storage.map.setView(latlng, 12); + console.warn(`Location set to: ${latlng}`); + } + } }; From a146a3d8737b377c724edae53aaae04fbef53e50 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Fri, 29 May 2020 14:44:10 -0400 Subject: [PATCH 6/7] Added Vehicle Name to Map markers - Helps customers identify which vehicle to click on a crowded map --- src/components/map/popups/marker-popup.js | 272 +++++++++++----------- 1 file changed, 141 insertions(+), 131 deletions(-) diff --git a/src/components/map/popups/marker-popup.js b/src/components/map/popups/marker-popup.js index 6078bda..22e272a 100644 --- a/src/components/map/popups/marker-popup.js +++ b/src/components/map/popups/marker-popup.js @@ -3,190 +3,200 @@ import storage from "../../../dataStore"; import { devicesPropertyData } from "../../../dataStore/map-data"; import { - retrieveStatusInfo, - filterMarkerButton, - getStrongText, - getGroupsForDeviceID + retrieveStatusInfo, + filterMarkerButton, + getStrongText, + getGroupsForDeviceID } from "./popup-helpers"; const secondsBetweenUpdate = 3; export function initMarkerPopup(deviceMarker) { - const { - mapMarker, - deviceID - } = deviceMarker; - - const popup = L.popup({ - // keepInView: true, - maxHeight: 360, - className: "markerPopups", - offset: [0, 0] - }); - - popup.setContent(filterMarkerButton(deviceID) + getStrongText("Getting Data")); - - mapMarker.bindPopup(popup); - - const constructors = { - mapMarker, - popup, - deviceID, - }; - - const newMarkerPopup = { - ...markerPopupModel, - ...constructors - }; - - mapMarker.on("popupopen", () => { - newMarkerPopup.resetAnimation(); - newMarkerPopup.keepPopupCentered(); - newMarkerPopup.nextUpdateTick = Number.POSITIVE_INFINITY; - newMarkerPopup.updatePopup(); - }); - - newMarkerPopup.setTransitionAnimation(); - deviceMarker.popupModel = newMarkerPopup; + const { + mapMarker, + deviceID + } = deviceMarker; + + const popup = L.popup({ + // keepInView: true, + maxHeight: 360, + className: "markerPopups", + offset: [0, 0] + }); + + popup.setContent(filterMarkerButton(deviceID) + getStrongText("Getting Data")); + + mapMarker.bindPopup(popup); + + const constructors = { + mapMarker, + popup, + deviceID, + }; + + const newMarkerPopup = { + ...markerPopupModel, + ...constructors + }; + + mapMarker.on("popupopen", () => { + newMarkerPopup.resetAnimation(); + newMarkerPopup.keepPopupCentered(); + newMarkerPopup.nextUpdateTick = Number.POSITIVE_INFINITY; + newMarkerPopup.updatePopup(); + }); + + mapMarker.on("mouseover", () => { + mapMarker.unbindTooltip(); + if (!mapMarker.isPopupOpen()) { + if (typeof storage.selectedDevices[deviceID] !== "undefined") { + const devObj = storage.selectedDevices[deviceID]; + mapMarker.bindTooltip(devObj.name).openTooltip(); + } + } + }); + + newMarkerPopup.setTransitionAnimation(); + deviceMarker.popupModel = newMarkerPopup; } export const markerPopupModel = { - mapMarker: undefined, - popup: undefined, - deviceID: undefined, - nextUpdateTick: Number.POSITIVE_INFINITY, + mapMarker: undefined, + popup: undefined, + deviceID: undefined, + nextUpdateTick: Number.POSITIVE_INFINITY, - updatePopup(speed) { + updatePopup(speed) { - if (!this.mapMarker.isPopupOpen()) { - return; - } + if (!this.mapMarker.isPopupOpen()) { + return; + } - this.setTransitionAnimation(); - this.keepPopupCentered(); + this.setTransitionAnimation(); + this.keepPopupCentered(); - this.nextUpdateTick++; - const ticksBetweenUpdate = 1000 / storage.dateKeeper$.getPeriod() * secondsBetweenUpdate; + this.nextUpdateTick++; + const ticksBetweenUpdate = 1000 / storage.dateKeeper$.getPeriod() * secondsBetweenUpdate; - if (this.nextUpdateTick >= ticksBetweenUpdate) { - this.nextUpdateTick = 0; - this.updatePopupContent(speed); - } - }, + if (this.nextUpdateTick >= ticksBetweenUpdate) { + this.nextUpdateTick = 0; + this.updatePopupContent(speed); + } + }, - updatePopupContent(speed) { + updatePopupContent(speed) { - const dataPromises = [ - getGroupsForDeviceID(this.deviceID), - retrieveStatusInfo(this.deviceID) - ]; + const dataPromises = [ + getGroupsForDeviceID(this.deviceID), + retrieveStatusInfo(this.deviceID) + ]; - Promise.all(dataPromises).then(val => { + Promise.all(dataPromises).then(val => { - const groupsData = val[0]; - const statusData = val[1]; + const groupsData = val[0]; + const statusData = val[1]; - const { - name - } = devicesPropertyData[this.deviceID]; + const { + name + } = devicesPropertyData[this.deviceID]; - this.popup.setContent(createMarkerPopupText(this.deviceID, groupsData, speed, name, statusData)); + this.popup.setContent(createMarkerPopupText(this.deviceID, groupsData, speed, name, statusData)); - this.setTransitionAnimation(); - this.keepPopupCentered(); - }); + this.setTransitionAnimation(); + this.keepPopupCentered(); + }); - }, + }, - setTransitionAnimation() { - const period = storage.dateKeeper$.getPeriod(); - const element = this.popup.getElement(); - if (element && !element.style[L.DomUtil.TRANSITION] && period > 150) { - element.style[L.DomUtil.TRANSITION] = `transform ${period / 1000}s linear`; - } - }, + setTransitionAnimation() { + const period = storage.dateKeeper$.getPeriod(); + const element = this.popup.getElement(); + if (element && !element.style[L.DomUtil.TRANSITION] && period > 150) { + element.style[L.DomUtil.TRANSITION] = `transform ${period / 1000}s linear`; + } + }, - resetAnimation() { - const element = this.popup.getElement(); - if (element) { - element.style[L.DomUtil.TRANSITION] = ""; - } - }, + resetAnimation() { + const element = this.popup.getElement(); + if (element) { + element.style[L.DomUtil.TRANSITION] = ""; + } + }, - keepPopupCentered() { + keepPopupCentered() { - const latLng = this.mapMarker.getLatLng(); - const duration = storage.dateKeeper$.getPeriod() / 1000; + const latLng = this.mapMarker.getLatLng(); + const duration = storage.dateKeeper$.getPeriod() / 1000; - storage.map.panTo(latLng, { - duration, - animate: true, - easeLinearity: 1, - noMoveStart: true - }); - } + storage.map.panTo(latLng, { + duration, + animate: true, + easeLinearity: 1, + noMoveStart: true + }); + } }; export function createMarkerPopupText(deviceID, groups, speed, name, statusData) { - const popTextFactory = []; + const popTextFactory = []; - const cleanedName = name.replace("'", "\\'"); - popTextFactory.push(filterMarkerButton(deviceID, cleanedName)); - popTextFactory.push(getStrongText(cleanedName)); + const cleanedName = name.replace("'", "\\'"); + popTextFactory.push(filterMarkerButton(deviceID, cleanedName)); + popTextFactory.push(getStrongText(cleanedName)); - popTextFactory.push(createGroupNamesDiv(groups)); - popTextFactory.push(createSpeedRow(speed)); - popTextFactory.push(createStatusDataDiv(statusData)); - return popTextFactory.filter(Boolean).join(""); + popTextFactory.push(createGroupNamesDiv(groups)); + popTextFactory.push(createSpeedRow(speed)); + popTextFactory.push(createStatusDataDiv(statusData)); + return popTextFactory.filter(Boolean).join(""); } export function createGroupNamesDiv(groups) { - if (groups) { - const groupNameList = Object.values(groups).map(group => group.name).filter(Boolean); - if (groupNameList.length) { - return `

${groupNameList.join()}

`; - } - } + if (groups) { + const groupNameList = Object.values(groups).map(group => group.name).filter(Boolean); + if (groupNameList.length) { + return `

${groupNameList.join()}

`; + } + } } export function createStatusDataDiv(statusData) { - let statusDiv = ""; + let statusDiv = ""; - if (statusData && Object.keys(statusData).length > 0) { + if (statusData && Object.keys(statusData).length > 0) { - statusDiv += '

' + getStrongText("Status Data:"); + statusDiv += '

' + getStrongText("Status Data:"); - const statusIDs = Object.keys(statusData); - statusIDs.sort(); + const statusIDs = Object.keys(statusData); + statusIDs.sort(); - statusIDs - .map(statusID => statusData[statusID]) - .map(createStatusDataRow) - .forEach(row => statusDiv += row); + statusIDs + .map(statusID => statusData[statusID]) + .map(createStatusDataRow) + .forEach(row => statusDiv += row); - statusDiv += "

"; - } + statusDiv += "

"; + } - return statusDiv; + return statusDiv; } export function createStatusDataRow(statusRow) { - const { - name, - data, - cleanedUnitOfMeasure - } = statusRow; + const { + name, + data, + cleanedUnitOfMeasure + } = statusRow; - return `
${name}: ${data} ${cleanedUnitOfMeasure}`; + return `
${name}: ${data} ${cleanedUnitOfMeasure}`; } export function createSpeedRow(speed) { - if (speed) { - return `Speed: ${speed} km/h`; - } + if (speed) { + return `Speed: ${speed} km/h`; + } } From b5389f3fc7d6a5d849223ce83d51d9c9f223dab1 Mon Sep 17 00:00:00 2001 From: Lance Mitchell Date: Tue, 15 Sep 2020 09:53:15 -0400 Subject: [PATCH 7/7] Exclude historical devices from vehicle search --- .../configuration/vehicles-config/vehicle-search.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/configuration/vehicles-config/vehicle-search.js b/src/components/configuration/vehicles-config/vehicle-search.js index 1d65b9e..3fa5382 100644 --- a/src/components/configuration/vehicles-config/vehicle-search.js +++ b/src/components/configuration/vehicles-config/vehicle-search.js @@ -46,7 +46,12 @@ export const deviceSearch = { return makeAPIMultiCall(nameSearchMultiCall).then(results => { // deviceList = results[0]; results[0] - .map(deviceSearch.saveDeviceDataToCache); + .map(devObj => { + // Exclude historical devices + if (devObj.serialNumber !== "000-000-0000") { + deviceSearch.saveDeviceDataToCache(devObj); + } + }); // groupList = results[1]; results[1] .map(deviceSearch.saveGroupDataToCache);