From 60bf5f779670dc40880023d699e63126feab05c0 Mon Sep 17 00:00:00 2001 From: Tim Dykes Date: Thu, 13 Nov 2025 13:57:17 +1100 Subject: [PATCH 01/61] Tasking WIP into dev (#218) * boostrap upgrade broke team summary. This restores bootstrap 4 and adds an alias for bootstrap 5 * first push - new tasking dashboard * New features * New features * moved map to vm made a new vm just for map * refactored out the mapvm * map popups have their own view models now * starting to flesh out the popups UI new UI for popups. refactor all the models * Map with a capital M wtf is mac doing with this * Add fit bound button to job pop * removed leaflet-responsive-popup back to normal popups * missed a bad import * ffs and another * redoing the setup screen. this one isnt horrible unit search at the top, both results boxes below * new config page with dropdown for HQ search * All sorts of new stuff New pulse marker for unclaimed New icons New refacactor of colours New incident menu * linter fix * UX Overlays Legend updates Notification overlays * linter fix * small refactor * only untask warn on active * extension for opsLog for single entry * ICEMS unack alerts and fixed legend * layer draw prototype * started making transport NSW api code * lots of code cleanup * team and job list sorting on column header press * opslog filters. sticky row headers on jobs and teams * draggable row fixes. focus on job button * linter fix * only deploy on dev branch --- .github/workflows/publish_dev.yml | 4 +- package-lock.json | 76 +- package.json | 5 +- src/background.js | 334 +++--- src/contentscripts/all.js | 169 +-- src/injectscripts/all.js | 259 ++-- src/pages/lib/shared_token_code.js | 81 +- src/pages/tasking/components/alerts.js | 196 +++ src/pages/tasking/components/asset_icon.js | 42 + src/pages/tasking/components/asset_popup.js | 91 ++ src/pages/tasking/components/job_icon.js | 149 +++ src/pages/tasking/components/job_popup.js | 142 +++ src/pages/tasking/components/legend.js | 97 ++ src/pages/tasking/main.js | 1067 +++++++++++++++++ src/pages/tasking/mapLayers/common.js | 16 + src/pages/tasking/markers/assetMarker.js | 169 +++ src/pages/tasking/markers/jobMarker.js | 203 ++++ src/pages/tasking/models/Address.js | 18 + src/pages/tasking/models/Asset.js | 64 + src/pages/tasking/models/Entity.js | 12 + src/pages/tasking/models/Job.js | 356 ++++++ src/pages/tasking/models/OpsLogEntry.js | 152 +++ src/pages/tasking/models/Tag.js | 7 + src/pages/tasking/models/Tasking.js | 143 +++ src/pages/tasking/models/Team.js | 218 ++++ src/pages/tasking/resize.js | 142 +++ src/pages/tasking/utils/chromeRunTime.js | 10 + src/pages/tasking/utils/common.js | 23 + src/pages/tasking/utils/jobTypesToUI.js | 54 + src/pages/tasking/utils/popup_dom_utils.js | 27 + src/pages/tasking/viewmodels/AssetPopUp.js | 162 +++ src/pages/tasking/viewmodels/Config.js | 154 +++ src/pages/tasking/viewmodels/JobPopUp.js | 291 +++++ src/pages/tasking/viewmodels/Map.js | 122 ++ src/pages/tasking/viewmodels/OpsLogModalVM.js | 136 +++ src/pages/teamsummary.js | 1 - src/shared/BeaconClient.js | 5 +- src/shared/BeaconClient/asset.js | 13 +- src/shared/BeaconClient/entities.js | 55 + src/shared/BeaconClient/job.js | 169 ++- src/shared/BeaconClient/json.js | 6 +- src/shared/BeaconClient/notifications.js | 21 + src/shared/BeaconClient/operationslog.js | 21 + src/shared/BeaconClient/tasking.js | 27 + src/shared/BeaconClient/team.js | 11 +- static/pages/tasking.html | 748 ++++++++++++ .../pages/vendors/rrose/.github/FUNDING.yml | 12 + static/pages/vendors/rrose/.gitignore | 2 + static/pages/vendors/rrose/LICENSE.txt | 14 + static/pages/vendors/rrose/README.md | 46 + static/pages/vendors/rrose/bower.json | 29 + .../pages/vendors/rrose/leaflet.rrose-src.js | 115 ++ static/pages/vendors/rrose/leaflet.rrose.css | 139 +++ styles/pages/tasking.css | 910 ++++++++++++++ 54 files changed, 7086 insertions(+), 449 deletions(-) create mode 100644 src/pages/tasking/components/alerts.js create mode 100644 src/pages/tasking/components/asset_icon.js create mode 100644 src/pages/tasking/components/asset_popup.js create mode 100644 src/pages/tasking/components/job_icon.js create mode 100644 src/pages/tasking/components/job_popup.js create mode 100644 src/pages/tasking/components/legend.js create mode 100644 src/pages/tasking/main.js create mode 100644 src/pages/tasking/mapLayers/common.js create mode 100644 src/pages/tasking/markers/assetMarker.js create mode 100644 src/pages/tasking/markers/jobMarker.js create mode 100644 src/pages/tasking/models/Address.js create mode 100644 src/pages/tasking/models/Asset.js create mode 100644 src/pages/tasking/models/Entity.js create mode 100644 src/pages/tasking/models/Job.js create mode 100644 src/pages/tasking/models/OpsLogEntry.js create mode 100644 src/pages/tasking/models/Tag.js create mode 100644 src/pages/tasking/models/Tasking.js create mode 100644 src/pages/tasking/models/Team.js create mode 100644 src/pages/tasking/resize.js create mode 100644 src/pages/tasking/utils/chromeRunTime.js create mode 100644 src/pages/tasking/utils/common.js create mode 100644 src/pages/tasking/utils/jobTypesToUI.js create mode 100644 src/pages/tasking/utils/popup_dom_utils.js create mode 100644 src/pages/tasking/viewmodels/AssetPopUp.js create mode 100644 src/pages/tasking/viewmodels/Config.js create mode 100644 src/pages/tasking/viewmodels/JobPopUp.js create mode 100644 src/pages/tasking/viewmodels/Map.js create mode 100644 src/pages/tasking/viewmodels/OpsLogModalVM.js create mode 100644 src/shared/BeaconClient/entities.js create mode 100644 src/shared/BeaconClient/notifications.js create mode 100644 src/shared/BeaconClient/tasking.js create mode 100644 static/pages/tasking.html create mode 100644 static/pages/vendors/rrose/.github/FUNDING.yml create mode 100644 static/pages/vendors/rrose/.gitignore create mode 100644 static/pages/vendors/rrose/LICENSE.txt create mode 100644 static/pages/vendors/rrose/README.md create mode 100644 static/pages/vendors/rrose/bower.json create mode 100644 static/pages/vendors/rrose/leaflet.rrose-src.js create mode 100644 static/pages/vendors/rrose/leaflet.rrose.css create mode 100644 styles/pages/tasking.css diff --git a/.github/workflows/publish_dev.yml b/.github/workflows/publish_dev.yml index c3a6d834..80b3fc14 100644 --- a/.github/workflows/publish_dev.yml +++ b/.github/workflows/publish_dev.yml @@ -2,7 +2,7 @@ name: Publish Dev Preview to Chrome Store on: push: branches: - - '**' + - 'master-dev' jobs: lintandpublish: name: Publish Dev @@ -26,5 +26,5 @@ jobs: client-id: ${{ secrets.CHROMESTORE_CLIENT_ID }} client-secret: ${{ secrets.CHROMESTORE_CLIENT_SECRET }} refresh-token: ${{ secrets.CHROMESTORE_REFRESH_TOKEN }} - publish: false + publish: true glob: true \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9a712663..236ff8ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,8 @@ "@babel/runtime": "^7.27.0", "@fortawesome/fontawesome-free": "^5.15.4", "@tmcw/togeojson": "^5.7.0", - "bootstrap": "^5.0.0", + "bootstrap": "^4.6.2", + "bootstrap5": "npm:bootstrap@^5.3.8", "chroma-js": "^2.4.2", "crossfilter": "^1.3.12", "dc": "^4.2.7", @@ -24,7 +25,7 @@ "jsx-dom-factory": "^1.2.0", "knockout": "^3.5.1", "knockout-secure-binding": "^0.5.5", - "leaflet": "^1.7.1", + "leaflet": "^1.9.4", "leaflet-easybutton": "^2.4.0", "leaflet-fullscreen": "git+https://github.com/Leaflet/Leaflet.fullscreen.git", "leaflet-routing-machine": "^3.2.12", @@ -2153,7 +2154,6 @@ "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", - "license": "MIT", "peer": true, "funding": { "type": "opencollective", @@ -3039,16 +3039,42 @@ "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==" }, "node_modules/bootstrap": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.0.0.tgz", - "integrity": "sha512-tmhPET9B9qCl8dCofvHeiIhi49iBt0EehmIsziZib65k1erBW1rHhj2s/2JsuQh5Pq+xz2E9bEbzp9B7xHG+VA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/bootstrap" - }, + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.2.tgz", + "integrity": "sha512-51Bbp/Uxr9aTuy6ca/8FbFloBUJZLHwnhTcnjIeRn2suQWsWzcuJhGjKDB5eppVte/8oCdOL3VuwxvZDUggwGQ==", + "deprecated": "This version of Bootstrap is no longer supported. Please upgrade to the latest version.", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], "peerDependencies": { - "@popperjs/core": "^2.9.2" + "jquery": "1.9.1 - 3", + "popper.js": "^1.16.1" + } + }, + "node_modules/bootstrap5": { + "name": "bootstrap", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", + "integrity": "sha512-HP1SZDqaLDPwsNiqRqi5NcP0SSXciX2s9E+RyqJIIqGo+vJeN5AJVM98CXmW/Wux0nQ5L7jeWUdplCEf0Ee+tg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "peerDependencies": { + "@popperjs/core": "^2.11.8" } }, "node_modules/brace-expansion": { @@ -6333,6 +6359,17 @@ "node": "*" } }, + "node_modules/popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", + "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -6469,9 +6506,9 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" @@ -7353,10 +7390,9 @@ "integrity": "sha512-STSHX/L5nI9WTLv6wrzJbAPbO7OIISX83KFBh2GVbX1Uz/vgZOU/ANn/8iV6t35yMTpoPzzO+3OQid3mifE0CA==" }, "node_modules/tmp": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz", - "integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==", - "license": "MIT", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", + "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", "engines": { "node": ">=14.14" } @@ -7969,4 +8005,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 97e850ed..17d74059 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "@babel/runtime": "^7.27.0", "@fortawesome/fontawesome-free": "^5.15.4", "@tmcw/togeojson": "^5.7.0", - "bootstrap": "^5.0.0", + "bootstrap": "^4.6.2", + "bootstrap5": "npm:bootstrap@^5.3.8", "chroma-js": "^2.4.2", "crossfilter": "^1.3.12", "dc": "^4.2.7", @@ -48,7 +49,7 @@ "jsx-dom-factory": "^1.2.0", "knockout": "^3.5.1", "knockout-secure-binding": "^0.5.5", - "leaflet": "^1.7.1", + "leaflet": "^1.9.4", "leaflet-easybutton": "^2.4.0", "leaflet-fullscreen": "git+https://github.com/Leaflet/Leaflet.fullscreen.git", "leaflet-routing-machine": "^3.2.12", diff --git a/src/background.js b/src/background.js index 700bfa97..5676b6b8 100644 --- a/src/background.js +++ b/src/background.js @@ -37,42 +37,43 @@ const ausgridBaseUrl = 'https://www.ausgrid.com.au/'; const hazardWatchUrl = 'https://feed.firesnearme.hazards.rfs.nsw.gov.au/'; //external libs +var activeTabForTaskingRemote = null //Catch nativation changes in REACT app myAvailability //CAUTION - DONT USE INJECTS HERE AS THEY WILL STACK UP chrome.webNavigation.onHistoryStateUpdated.addListener((details) => { -// Regex for a 36-char UUID (8-4-4-4-12 hex digits) -const uuidRegex = /[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/; - -// Match only the exact path “/requests/out-of-area-activations/” -const activationPathRegex = new RegExp(`^/requests/out-of-area-activations/${uuidRegex.source}$`); - -try { - const { pathname } = new URL(details.url); - if (activationPathRegex.test(pathname)) { - chrome.scripting.executeScript({ - target: { tabId: details.tabId }, - files: ["myAvailability/contentscripts/requests/out-of-area-activations.js"] - }); + // Regex for a 36-char UUID (8-4-4-4-12 hex digits) + const uuidRegex = /[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/; + + // Match only the exact path “/requests/out-of-area-activations/” + const activationPathRegex = new RegExp(`^/requests/out-of-area-activations/${uuidRegex.source}$`); + + try { + const { pathname } = new URL(details.url); + if (activationPathRegex.test(pathname)) { + chrome.scripting.executeScript({ + target: { tabId: details.tabId }, + files: ["myAvailability/contentscripts/requests/out-of-area-activations.js"] + }); + } + } catch (e) { + // invalid URL — skip } -} catch (e) { - // invalid URL — skip -} -// Match only the exact path “/messages?” -const messagesPathRegex = new RegExp(`^/messages(.*)$`); + // Match only the exact path “/messages?” + const messagesPathRegex = new RegExp(`^/messages(.*)$`); -try { - const { pathname } = new URL(details.url); - if (messagesPathRegex.test(pathname)) { - chrome.scripting.executeScript({ - target: { tabId: details.tabId }, - files: ["myAvailability/contentscripts/messages/messages.js"] - }); + try { + const { pathname } = new URL(details.url); + if (messagesPathRegex.test(pathname)) { + chrome.scripting.executeScript({ + target: { tabId: details.tabId }, + files: ["myAvailability/contentscripts/messages/messages.js"] + }); + } + } catch (e) { + // invalid URL — skip } -} catch (e) { - // invalid URL — skip -} }); @@ -152,6 +153,23 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { sendResponse(data); }); return true; + } else if (request.type === 'tasking-register-for-remote') { + activeTabForTaskingRemote = sender.tab.id + console.log("Registered tab for tasking remote:", activeTabForTaskingRemote) + console.log(sender.tab) + return true; + } else if (request.type === 'tasking-openURL') { + console.log("Sending tasking remote command to tab:", activeTabForTaskingRemote) + chrome.tabs.update(activeTabForTaskingRemote, { url: request.url }, function () { + if (chrome.runtime.lastError) { + console.error("Error sending tasking remote command:", chrome.runtime.lastError); + sendResponse({ error: 'Failed to send tasking remote command', message: chrome.runtime.lastError.message }); + } else { + console.log("Tasking remote command sent"); + sendResponse({ success: true }); + } + }); + return true; } }); @@ -162,9 +180,11 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { * @param url url on S3 */ function pullmyAvailOOAACSV(url, cb) { - fetch(url, { headers: { - 'Accept': 'application/octet-stream', - }}).then(response => response.text()) + fetch(url, { + headers: { + 'Accept': 'application/octet-stream', + } + }).then(response => response.text()) .then((text) => { cb(text) }); @@ -186,21 +206,21 @@ function fetchRfsIncidents(callback) { callback(json) }) } else { - // error - var response = { - error: 'Request failed', - httpCode: 'resp not ok', - }; - callback(response); - } -}).catch(() => { - // error - var response = { + // error + var response = { error: 'Request failed', - httpCode: 'fetch error', + httpCode: 'resp not ok', }; callback(response); -}) + } + }).catch(() => { + // error + var response = { + error: 'Request failed', + httpCode: 'fetch error', + }; + callback(response); + }) } /** @@ -213,10 +233,10 @@ function fetchRfsIncidents(callback) { function fetchTransportResource(path, callback, apiKey) { console.info('fetching transport resource: ' + path); - fetch(`${transportFeed}${path}`,{ + fetch(`${transportFeed}${path}`, { headers: { - "Authorization": `apikey ${apiKey}`, - }, + "Authorization": `apikey ${apiKey}`, + }, }).then((resp) => { if (resp.ok) { resp.json().then((json) => { @@ -224,21 +244,21 @@ function fetchTransportResource(path, callback, apiKey) { callback(json) }) } else { - // error - var response = { - error: 'Request failed', - httpCode: 'resp not ok', - }; - callback(response); - } -}).catch(() => { - // error - var response = { + // error + var response = { error: 'Request failed', - httpCode: 'fetch error', + httpCode: 'resp not ok', }; callback(response); -}) + } + }).catch(() => { + // error + var response = { + error: 'Request failed', + httpCode: 'fetch error', + }; + callback(response); + }) } /** @@ -254,7 +274,7 @@ function fetchHelicopterLocations(params, callback) { .then((resp) => { if (resp.ok) { resp.json().then((json) => { - console.info('sending back helicopter locations'); + console.info('sending back helicopter locations'); callback(json); }); } else { @@ -288,26 +308,26 @@ function fetchHazardWatch(callback) { .then((resp) => { if (resp.ok) { resp.json().then((json) => { - console.info('sending hazard watch'); - callback(json); - }); - } else { - // error - var response = { - error: 'Request failed', - httpCode: 'error', - }; - callback(response); - } - }) - .catch(() => { + console.info('sending hazard watch'); + callback(json); + }); + } else { // error var response = { error: 'Request failed', httpCode: 'error', }; callback(response); - }); + } + }) + .catch(() => { + // error + var response = { + error: 'Request failed', + httpCode: 'error', + }; + callback(response); + }); } /** @@ -365,85 +385,85 @@ function fetchAusgridOutages(callback) { fetch(`${ausgridBaseUrl}webapi/OutageMapData/GetCurrentUnplannedOutageMarkersAndPolygons?bottomleft.lat=-33.45170&bottomleft.lng=148.76319&topright.lat=-32.56033&topright.lng=153.66859&zoom=9`, { method: "GET", headers: { - "Content-Type": "application/json", - } + "Content-Type": "application/json", + } }).then((resp) => { if (resp.ok) { resp.json().then((result) => { let ausgridGeoJson = { - type: 'FeatureCollection', - features: [], - }; - - result.forEach(function (item) { - //build up some geojson from normal JSON - var feature = {}; - feature.geometry = {}; - feature.geometry.type = 'GeometryCollection'; - feature.geometry.geometries = []; - - //make a polygon from each set - var polygon = {}; - polygon.type = 'Polygon'; - polygon.coordinates = []; - - var ords = []; - if (item.Polygons.length > 0) { - item.Polygons[0].Coords.forEach(function (point) { - ords.push([point.lng, point.lat]); - }); - ords.push([ - item.Polygons[0].Coords[0].lng, - item.Polygons[0].Coords[0].lat, - ]); //push the first item again at the end to complete the polygon - } - - polygon.coordinates.push(ords); - - feature.geometry.geometries.push(polygon); - - var point = {}; - point.type = 'Point'; - point.coordinates = []; - point.coordinates.push( - item.MarkerLocation.lng, - item.MarkerLocation.lat, - ); - - feature.geometry.geometries.push(point); - - feature.owner = 'Ausgrid'; - feature.type = 'Feature'; - feature.properties = {}; - feature.properties.numberCustomerAffected = item.CustomersAffectedText; - feature.properties.incidentId = item.WebId; - feature.properties.reason = item.Cause; - feature.properties.status = item.Status; - feature.properties.type = 'Outage'; - feature.properties.startDateTime = item.StartDateTime; - feature.properties.endDateTime = item.EstRestTime; - - ausgridGeoJson.features.push(feature); + type: 'FeatureCollection', + features: [], + }; - }); - callback(ausgridGeoJson); + result.forEach(function (item) { + //build up some geojson from normal JSON + var feature = {}; + feature.geometry = {}; + feature.geometry.type = 'GeometryCollection'; + feature.geometry.geometries = []; + + //make a polygon from each set + var polygon = {}; + polygon.type = 'Polygon'; + polygon.coordinates = []; + + var ords = []; + if (item.Polygons.length > 0) { + item.Polygons[0].Coords.forEach(function (point) { + ords.push([point.lng, point.lat]); + }); + ords.push([ + item.Polygons[0].Coords[0].lng, + item.Polygons[0].Coords[0].lat, + ]); //push the first item again at the end to complete the polygon + } + + polygon.coordinates.push(ords); + + feature.geometry.geometries.push(polygon); + + var point = {}; + point.type = 'Point'; + point.coordinates = []; + point.coordinates.push( + item.MarkerLocation.lng, + item.MarkerLocation.lat, + ); + + feature.geometry.geometries.push(point); + + feature.owner = 'Ausgrid'; + feature.type = 'Feature'; + feature.properties = {}; + feature.properties.numberCustomerAffected = item.CustomersAffectedText; + feature.properties.incidentId = item.WebId; + feature.properties.reason = item.Cause; + feature.properties.status = item.Status; + feature.properties.type = 'Outage'; + feature.properties.startDateTime = item.StartDateTime; + feature.properties.endDateTime = item.EstRestTime; + + ausgridGeoJson.features.push(feature); + + }); + callback(ausgridGeoJson); }) } else { - // error - var response = { - error: 'Request failed', - httpCode: 'error', - }; - callback(response); - } -}).catch(() => { - // error - var response = { + // error + var response = { error: 'Request failed', httpCode: 'error', }; callback(response); -}) + } + }).catch(() => { + // error + var response = { + error: 'Request failed', + httpCode: 'error', + }; + callback(response); + }) } /** @@ -627,15 +647,15 @@ function checkAsbestosRegister(inAddressObject, cb) { foundinCache = true; console.log( 'cache is ' + - (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 + - 'mins old', + (new Date().getTime() - new Date(item.timestamp).getTime()) / + 1000 / + 60 + + 'mins old', ); if ( (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 < + 1000 / + 60 < 4320 ) { //3 days @@ -664,19 +684,19 @@ function checkAsbestosRegister(inAddressObject, cb) { } else { if ( (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 > + 1000 / + 60 > 4320 ) { //3 days console.log( 'cleaning stale cache item ' + - item.url + - ' age:' + - (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 + - 'mins old', + item.url + + ' age:' + + (new Date().getTime() - new Date(item.timestamp).getTime()) / + 1000 / + 60 + + 'mins old', ); ftCache.splice(ftCache.indexOf(item), 1); //remove this item from the cache needToWriteChange = true; @@ -740,7 +760,7 @@ function checkAsbestosRegister(inAddressObject, cb) { console.log('On the Register'); cb( inAddressObject.PrettyAddress + - " was FOUND on the loose fill insulation asbestos register", + " was FOUND on the loose fill insulation asbestos register", 'red', true, formAddress, @@ -795,6 +815,6 @@ function checkAsbestosRegister(inAddressObject, cb) { // }); } - + }); } diff --git a/src/contentscripts/all.js b/src/contentscripts/all.js index 0845b601..f1a2df8f 100644 --- a/src/contentscripts/all.js +++ b/src/contentscripts/all.js @@ -1,5 +1,4 @@ -if (location.origin.indexOf("beacon.ses.nsw.gov.au") != -1) -{ +if (location.origin.indexOf("beacon.ses.nsw.gov.au") != -1) { var inject = require('../lib/inject.js'); var $ = require('jquery'); require('../pages/lib/shared_chrome_code.js'); @@ -8,107 +7,109 @@ if (location.origin.indexOf("beacon.ses.nsw.gov.au") != -1) var DOM = require('jsx-dom-factory').default; - let version = 'v'+chrome.manifest.version_name+' '+(chrome.manifest.name.includes("Development") ? "Development" : "Production") + let version = 'v' + chrome.manifest.version_name + ' ' + (chrome.manifest.name.includes("Development") ? "Development" : "Production") console.log(`%c Lighthouse extension ${version} version`, "color: #ffffff; background: #363636; padding: 0 3px;"); - - + // inject JS that is to run on every page in page context inject('all.js'); -// inject all.css - browserify-css takes care of this -require('../styles/all.css'); + // inject all.css - browserify-css takes care of this + require('../styles/all.css'); + + //set the extension code var into the head + // var s = document.createElement('script'); + // s.setAttribute('type', 'text/javascript'); + // s.innerHTML = "var lighthouseUrl = \"" + chrome.runtime.getURL("") + "\";\n var lighthouseEnviroment = \"" +(chrome.manifest.name.includes("Development") ? "Development" : "Production")+"\";\n"; + //(document.head || document.documentElement).appendChild(s) -//set the extension code var into the head -// var s = document.createElement('script'); -// s.setAttribute('type', 'text/javascript'); -// s.innerHTML = "var lighthouseUrl = \"" + chrome.runtime.getURL("") + "\";\n var lighthouseEnviroment = \"" +(chrome.manifest.name.includes("Development") ? "Development" : "Production")+"\";\n"; -//(document.head || document.documentElement).appendChild(s) -window.addEventListener("message", function(event) { - // We only accept messages from ourselves or the extension - if (event.source != window) - return; + window.addEventListener("message", function (event) { + // We only accept messages from ourselves or the extension + if (event.source != window) + return; if (event.data.type && (event.data.type == "LIGHTHOUSE_URL")) { - window.postMessage({type: 'RETURN_LIGHTHOUSE_URL', url: chrome.runtime.getURL(""), lighthouseEnviroment: (chrome.manifest.name.includes("Development") ? "Development" : "Production")}) + window.postMessage({ type: 'RETURN_LIGHTHOUSE_URL', url: chrome.runtime.getURL(""), lighthouseEnviroment: (chrome.manifest.name.includes("Development") ? "Development" : "Production") }) } else if (event.data.type && (event.data.type == "FETCH_COLLECTION")) { - chrome.storage.sync.get([event.data.name+'-'+location.hostname], function (data){ //append hostname so that storage is specific to host (trainbeacon/production/preview) - window.postMessage({type: 'RETURN_COLLECTION', name: event.data.name, dataresult: data[event.data.name+'-'+location.hostname]}, '*'); //return object can be removed (name+lostname) - }) - } else if (event.data.type && (event.data.type == "SAVE_COLLECTION")) { - chrome.storage.sync.get([event.data.name+'-'+location.hostname], function (existingdata){ - let items; - try { - items = JSON.parse(existingdata[event.data.name+'-'+location.hostname]) - } catch (e) - { - items = [] - } - items.push(JSON.parse(event.data.newdata)) + chrome.storage.sync.get([event.data.name + '-' + location.hostname], function (data) { //append hostname so that storage is specific to host (trainbeacon/production/preview) + window.postMessage({ type: 'RETURN_COLLECTION', name: event.data.name, dataresult: data[event.data.name + '-' + location.hostname] }, '*'); //return object can be removed (name+lostname) + }) + } else if (event.data.type && (event.data.type == "SAVE_COLLECTION")) { + chrome.storage.sync.get([event.data.name + '-' + location.hostname], function (existingdata) { + let items; + try { + items = JSON.parse(existingdata[event.data.name + '-' + location.hostname]) + } catch (e) { + items = [] + } + items.push(JSON.parse(event.data.newdata)) - chrome.storage.sync.set({[event.data.name+'-'+location.hostname]:JSON.stringify(items)}, function (_data){ - window.postMessage({type: 'RETURN_COLLECTION', name: event.data.name, dataresult: JSON.stringify(items)}, '*'); + chrome.storage.sync.set({ [event.data.name + '-' + location.hostname]: JSON.stringify(items) }, function (_data) { + window.postMessage({ type: 'RETURN_COLLECTION', name: event.data.name, dataresult: JSON.stringify(items) }, '*'); + }) }) - }) - } else if (event.data.type && (event.data.type == "DELETE_COLLECTION")) { - chrome.storage.sync.get([event.data.name+'-'+location.hostname], function (existingdata){ - let items; - try { - items = JSON.parse(existingdata[event.data.name+'-'+location.hostname]) - } catch (e) - { - items = [] - } - items.forEach(function(item) { - if (event.data.target == JSON.stringify(item)) { - items.splice(items.indexOf(item), 1) + } else if (event.data.type && (event.data.type == "DELETE_COLLECTION")) { + chrome.storage.sync.get([event.data.name + '-' + location.hostname], function (existingdata) { + let items; + try { + items = JSON.parse(existingdata[event.data.name + '-' + location.hostname]) + } catch (e) { + items = [] } + items.forEach(function (item) { + if (event.data.target == JSON.stringify(item)) { + items.splice(items.indexOf(item), 1) + } + }) + chrome.storage.sync.set({ [event.data.name + '-' + location.hostname]: JSON.stringify(items) }, function (_data) { + window.postMessage({ type: 'RETURN_COLLECTION', name: event.data.name, dataresult: JSON.stringify(items) }, '*'); + }) }) - chrome.storage.sync.set({[event.data.name+'-'+location.hostname]:JSON.stringify(items)}, function (_data){ - window.postMessage({type: 'RETURN_COLLECTION', name: event.data.name, dataresult: JSON.stringify(items)}, '*'); + } else if (event.data.type && (event.data.type == "PURGE_COLLECTION")) { + chrome.storage.sync.remove([event.data.name + '-' + location.hostname]) + chrome.storage.local.clear(function () { + // do nothing + }); + } else if (event.data.type && (event.data.type == "FROM_PAGE_UPDATE_API_TOKEN")) { + chrome.storage.local.set({ ['beaconAPIToken-' + event.data.host]: JSON.stringify({ token: event.data.token, expdate: event.data.tokenexp }) }, function () { + console.log('local data set - beaconAPIToken'); }) - }) - } else if (event.data.type && (event.data.type == "PURGE_COLLECTION")) { - chrome.storage.sync.remove([event.data.name+'-'+location.hostname]) - chrome.storage.local.clear(function() { - // do nothing - }); - } else if (event.data.type && (event.data.type == "FROM_PAGE_UPDATE_API_TOKEN")) { - chrome.storage.local.set({['beaconAPIToken-'+event.data.host]:JSON.stringify({token:event.data.token,expdate:event.data.tokenexp})}, function (){ - console.log('local data set - beaconAPIToken') - }) - } -}, false); - - - $(document).ready(function(){ - - // Map Mouse Eating Stopper - if (location.pathname != "/Jobs/SituationalAwareness") { - let $map; - if( ( $map = $('#map') ).length && ('#map_zoom_slider',$map).length ){ - var $mapblock = $( -
-
Click to zoom or move map
-
- ); - - $mapblock - .click(function(e){ - $(this).hide(); - e.stopPropagation(); + } else if (event.data.type && (event.data.type == "FROM_PAGE_REGISTER_TASKING_REMOTE")) { + chrome.runtime.sendMessage({ type: 'tasking-register-for-remote' }, function () { + console.log('Registered tab for Tasking Remote Control'); }); + } + }, false); - $('#map') - .append($mapblock) - .mouseleave(function(_e) { - $mapblock.show(); - }); + + $(document).ready(function () { + + // Map Mouse Eating Stopper + if (location.pathname != "/Jobs/SituationalAwareness") { + let $map; + if (($map = $('#map')).length && ('#map_zoom_slider', $map).length) { + var $mapblock = $( +
+
Click to zoom or move map
+
+ ); + + $mapblock + .click(function (e) { + $(this).hide(); + e.stopPropagation(); + }); + + $('#map') + .append($mapblock) + .mouseleave(function (_e) { + $mapblock.show(); + }); + } } - } -}); + }); } diff --git a/src/injectscripts/all.js b/src/injectscripts/all.js index 2e1b9355..3675dae3 100644 --- a/src/injectscripts/all.js +++ b/src/injectscripts/all.js @@ -10,11 +10,12 @@ window.postMessage( ); -document.addEventListener('keydown', function(event) { + +document.addEventListener('keydown', function (event) { if (event.ctrlKey && event.shiftKey && event.key.toLowerCase() === 'l') { - event.preventDefault(); // Prevents the default action (e.g., focusing on the address bar) - layout.createRadioEntry(); - // Add your custom logic here + event.preventDefault(); // Prevents the default action (e.g., focusing on the address bar) + layout.createRadioEntry(); + // Add your custom logic here } }); @@ -71,48 +72,60 @@ whenWeAreReady(function () {