From d876f1a76ef413445d7af20cb48bcd3fc234fadc Mon Sep 17 00:00:00 2001 From: Tim Dykes Date: Wed, 28 Jan 2026 11:53:19 +1100 Subject: [PATCH 1/6] missing button action (#287) --- static/pages/tasking.html | 1 + 1 file changed, 1 insertion(+) diff --git a/static/pages/tasking.html b/static/pages/tasking.html index 4b8e7b82..bacd4bd6 100644 --- a/static/pages/tasking.html +++ b/static/pages/tasking.html @@ -1548,6 +1548,7 @@ - `; + + `; const btn = c.querySelector(".btn"); L.DomEvent.on(btn, "click", (ev) => { @@ -2285,6 +2375,8 @@ function VM() { if (this._collapsed) document.body.classList.add("sidebar-collapsed"); L.DomEvent.disableClickPropagation(c); + + this._container = c; return c; } @@ -2296,14 +2388,13 @@ function VM() { const layersDrawer = new LayersDrawer(); layersDrawer.addTo(map); - - - setTimeout(() => { - const tl = map._controlCorners.topleft; - const ld = tl.querySelector(".layers-drawer"); - const st = tl.querySelector(".leaflet-control.sidebar-toggle"); - if (ld && st) ld.insertAdjacentElement("beforebegin", st); + // force ordering: place directly under zoom buttons + const zoom = document.querySelector('.leaflet-control-zoom'); + const toggle = document.querySelector('.sidebar-toggle'); + if (zoom && toggle) { + zoom.parentNode.insertBefore(toggle, zoom.nextSibling); + } }, 0); diff --git a/src/pages/tasking/utils/geocode.js b/src/pages/tasking/utils/geocode.js new file mode 100644 index 00000000..c064b81c --- /dev/null +++ b/src/pages/tasking/utils/geocode.js @@ -0,0 +1,48 @@ +// AwsLambdaGeocoderProvider.js +export class AwsLambdaGeocoderProvider { + constructor({ endpoint, fetchOptions } = {}) { + this.endpoint = endpoint.replace(/\/$/, ''); + this.fetchOptions = fetchOptions; // optional: headers, credentials, etc. + } + + // leaflet-geosearch calls: provider.search({ query: string }) + async search({ query }) { + if (!query || !query.trim()) return []; + + const url = new URL(this.endpoint); + url.searchParams.set('q', query.trim()); + + const res = await fetch(url.toString(), { + method: 'GET', + ...this.fetchOptions, + }); + + if (!res.ok) { + const body = await res.text().catch(() => ''); + throw new Error(`Geocode failed (${res.status}): ${body}`); + } + + const json = await res.json(); + const items = Array.isArray(json?.results) ? json.results : []; + + return items + .map((r) => { + const place = r; + const pt = place?.Position; // [lon, lat] + const lon = Array.isArray(pt) ? Number(pt[0]) : NaN; + const lat = Array.isArray(pt) ? Number(pt[1]) : NaN; + const label = place?.Address?.Label || ''; + + if (!Number.isFinite(lat) || !Number.isFinite(lon) || !label) return null; + + return { + x: lon, + y: lat, + label, + // bounds optional; omit unless you compute one + raw: r, + }; + }) + .filter(Boolean); + } +} diff --git a/static/manifest.json b/static/manifest.json index a124e13a..43f1dfdc 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -90,7 +90,8 @@ "https://*.ses.nsw.gov.au/Jobs/Sectors*", "https://*.ses.nsw.gov.au/Jobs/*/Edit", "https://*.ses.nsw.gov.au/Jobs", - "https://*.ses.nsw.gov.au/Jobs/Create" + "https://*.ses.nsw.gov.au/Jobs/Create", + "https://*.ses.nsw.gov.au/Jobs/Create?*" ], "js": ["contentscripts/jobs/view.js"] }, diff --git a/static/pages/tasking.html b/static/pages/tasking.html index bacd4bd6..2ba091ed 100644 --- a/static/pages/tasking.html +++ b/static/pages/tasking.html @@ -15,7 +15,8 @@
-
+
Teams ()
@@ -648,7 +649,8 @@
-
+
Incidents ()
@@ -3151,6 +3153,19 @@
+ + + + +
diff --git a/styles/pages/tasking.css b/styles/pages/tasking.css index 997618b3..698635e2 100644 --- a/styles/pages/tasking.css +++ b/styles/pages/tasking.css @@ -4,8 +4,9 @@ @import url('~bootstrap5/dist/css/bootstrap.css'); @import url('~leaflet-minimap/dist/Control.MiniMap.min.css'); @import url('leaflet/dist/leaflet.css'); - @import url('leaflet.polylinemeasure/Leaflet.PolylineMeasure.css'); +@import url('leaflet-geosearch/dist/geosearch.css'); + html { height: 100%; @@ -1070,6 +1071,14 @@ tr.job:hover { cursor: unset !important; } +/* Window Alerts */ +.alert { +overflow-wrap: anywhere; +text-overflow: ellipsis; +white-space: normal; +overflow: hidden; +} + /* Alerts control */ .leaflet-control.alerts { pointer-events: auto; @@ -2168,3 +2177,19 @@ input[type='search']::-ms-clear { color: var(--bs-secondary-color) !important; font-size: 13px; } + +.leaflet-control-geosearch form { + left: 40px !important; +} + + +.leaflet-control-geosearch .results { + margin-bottom: 5px !important; +} + + +.geo-spinner { + background: rgb(0, 0, 0); + border-radius: 50%; + padding: 4px; +} \ No newline at end of file From 2785a896693cba1c79a3c0a788ef816904056b9a Mon Sep 17 00:00:00 2001 From: Tim Dykes Date: Mon, 2 Feb 2026 14:02:22 +1100 Subject: [PATCH 5/6] Remove asbestos (#291) * removed all asbestos code * URL cleanup * Change the flow trigger --- .github/workflows/publish_dev.yml | 2 +- src/background.js | 225 +-------------- src/contentscripts/jobs/create.js | 44 +-- src/contentscripts/jobs/edit.js | 269 ++++++++---------- src/contentscripts/jobs/view.js | 51 +--- src/injectscripts/jobs/create.js | 64 ----- src/injectscripts/jobs/edit.js | 200 +++++-------- src/injectscripts/jobs/view.js | 74 +---- src/lib/sesasbestos.js | 102 ------- .../tasking/components/mapContextMenu.js | 16 +- static/manifest.json | 3 - 11 files changed, 191 insertions(+), 859 deletions(-) delete mode 100644 src/lib/sesasbestos.js diff --git a/.github/workflows/publish_dev.yml b/.github/workflows/publish_dev.yml index 80b3fc14..d93707a9 100644 --- a/.github/workflows/publish_dev.yml +++ b/.github/workflows/publish_dev.yml @@ -1,6 +1,6 @@ name: Publish Dev Preview to Chrome Store on: - push: + workflow_run: branches: - 'master-dev' jobs: diff --git a/src/background.js b/src/background.js index d00ac3da..089b750e 100644 --- a/src/background.js +++ b/src/background.js @@ -91,20 +91,7 @@ chrome.webNavigation.onHistoryStateUpdated.addListener((details) => { chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { - if (request.type === 'asbestos') { - checkAsbestosRegister( - request.address, - function (result, colour, bool, url) { - sendResponse({ - result: result, - colour: colour, - resultbool: bool, - requrl: url, - }); - }, - ); - return true; - } else if (request.type === 'API_TOKEN_UPDATE') { + if (request.type === 'API_TOKEN_UPDATE') { let key = 'beaconAPIToken-' + request.host; chrome.storage.local .set({ key: JSON.stringify(request.token) }) @@ -728,212 +715,4 @@ function fetchEssentialEnergyOutages(callback) { }; callback(response); }); -} - -function checkAsbestosRegister(inAddressObject, cb) { - var AddressParts = /^(.+)\s(.+)$/.exec(inAddressObject.Street); - if (!inAddressObject.Flat) inAddressObject.Flat = ''; - var formAddress = - 'https://www.fairtrading.nsw.gov.au/loose-fill-asbestos-insulation-register?' + - 'unit=' + - encodeURI(inAddressObject.Flat) + - '&' + - 'number=' + - encodeURI(inAddressObject.StreetNumber) + - '&' + - 'street=' + - encodeURI(AddressParts[1]) + - '&' + - 'suburb=' + - encodeURI(inAddressObject.Locality) + - '&' + - 'type=' + - encodeURI(AddressParts[2]) + - '&'; - - console.log('loading cache'); - chrome.storage.local.get(['lighthouseFTCache']).then((ftCache) => { - console.log(ftCache); - - var needToWriteChange = false; - if (ftCache.length) { - //walk the cache and clean it up first - - var foundinCache = false; - ftCache.forEach(function (item) { - if (item.url == formAddress) { - console.log('found url in the cache'); - foundinCache = true; - console.log( - 'cache is ' + - (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 + - 'mins old', - ); - if ( - (new Date().getTime() - new Date(item.timestamp).getTime()) / - 1000 / - 60 < - 4320 - ) { - //3 days - //its in the cache - console.log('using it'); - processResult(item.result); - } else { - //oooooold - console.log('cached item is stale. fetching new result'); - ftCache.splice(ftCache.indexOf(item), 1); //remove this item from the cache - needToWriteChange = true; - pullFTRegister(function (result) { - if (result != 0) { - //dont cache error results - var cacheItem = {}; - cacheItem.url = formAddress; - cacheItem.timestamp = new Date().toString(); - cacheItem.result = result; - ftCache.push(cacheItem); - needToWriteChange = true; - } - //return result - processResult(result); - }); - } - } else { - if ( - (new Date().getTime() - new Date(item.timestamp).getTime()) / - 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', - ); - ftCache.splice(ftCache.indexOf(item), 1); //remove this item from the cache - needToWriteChange = true; - } - } - }); - - if (foundinCache == false) { - console.log('did not find url in the cache'); - pullFTRegister(function (result) { - if (result != 0) { - //dont cache error results - var cacheItem = {}; - cacheItem.url = formAddress; - cacheItem.timestamp = new Date().toString(); - cacheItem.result = result; - ftCache.push(cacheItem); - needToWriteChange = true; - } - //return result - processResult(result); - }); - } - } else { - //there is no cache so make one - console.log('no cache object. creating a new one'); - ftCache = []; - pullFTRegister(function (result) { - if (result != 0) { - //dont cache error results - var cacheItem = {}; - cacheItem.url = formAddress; - cacheItem.timestamp = new Date().toString(); - cacheItem.result = result; - ftCache.push(cacheItem); - needToWriteChange = true; - } - //return result - processResult(result); - }); - } - - //if we never call processResult we should write the changes out here. - if (needToWriteChange) { - console.log('writing out lighthouseFTCache'); - localStorage.setItem('lighthouseFTCache', JSON.stringify(ftCache)); - } - - function processResult(result) { - switch (result) { - case 0: //error - console.log('Error searching'); - cb( - "Error Searching The Asbestos Register", - '', - false, - formAddress, - ); - break; - case 1: //positive/found - console.log('On the Register'); - cb( - inAddressObject.PrettyAddress + - " was FOUND on the loose fill insulation asbestos register", - 'red', - true, - formAddress, - ); - break; - case 2: //negative/not found - console.log('Not the Register'); - cb( - inAddressObject.PrettyAddress + ' was not found on any register.', - '', - false, - formAddress, - ); - break; - } - if (needToWriteChange) { - needToWriteChange = false; - console.log('writing out lighthouseFTCache'); - chrome.storage.local - .set({ lighthouseFTCache: JSON.stringify(ftCache) }) - .then(() => { - console.log('lighthouseFTCache is set'); - }); - } - } - - function pullFTRegister(cb) { - cb(2) //error out until FT fix their register - // fetch(formAddress) - // .then((resp) => { - // if (resp.ok) { - // resp.text().then((txt) => { - // if ( - // !/No\sMatch\sFound/.test(txt) && - // !/Confirmed\sMatch/.test(txt) - // ) { - // cb(0); //error - // } - // if (/Confirmed\sMatch/.test(txt)) { - // cb(1); //found - // } - // if (/No\sMatch\sFound/.test(txt)) { - // cb(2); //not found - // } - // }); - // } else { - // cb(0); //error - // } - // }) - // .catch(() => { - // cb(0); //fetch error - // }); - } - - - }); -} +} \ No newline at end of file diff --git a/src/contentscripts/jobs/create.js b/src/contentscripts/jobs/create.js index c2bc3673..3b17a497 100644 --- a/src/contentscripts/jobs/create.js +++ b/src/contentscripts/jobs/create.js @@ -23,22 +23,7 @@ window.addEventListener("message", function(event) { } } - if (event.data.type && (event.data.type == "FROM_PAGE_FTASBESTOS_SEARCH")) { - chrome.runtime.sendMessage({type: "asbestos", address: event.data.address}, function(response) { - if (response.resultbool == false) - { - response.requrl = '' - } else { - window.postMessage({ type: "FROM_LH_ASBESTOS", result: true }, "*"); - } - asbestosBoxColor(response.result,response.colour,response.requrl) - }); - } else if (event.data.type && (event.data.type == "FROM_PAGE_SESASBESTOS_RESULT")) { - window.postMessage({ type: "FROM_LH_ASBESTOS", result: true }, "*"); - asbestosBoxColor(event.data.address.PrettyAddress+" was FOUND on the SES asbestos register.",'red','') - - - } else if (event.data.type && (event.data.type == "FROM_PAGE_LHQ_DISTANCE")) { + if (event.data.type && (event.data.type == "FROM_PAGE_LHQ_DISTANCE")) { if (distanceDebounceTimeout) { clearTimeout(distanceDebounceTimeout); } @@ -232,22 +217,6 @@ window.addEventListener("message", function(event) { } }, false); -function asbestosBoxColor(text, color, url) { - $('#asbestos-register-text').html(text); - if (url != '') - { - console.log("got url") - $('#asbestos-register-box').css('cursor','pointer'); - $('#asbestos-register-box').click(function(){ - window.open(url) - }) - } - if (color != "") { - $('#asbestos-register-box')[0].style.color = "white" - $('#asbestos-register-box').css({'background' :'linear-gradient(transparent 8px, '+color+' -10px','margin-left':'17px'}); - } -} - let myAvailability = (