Skip to content

Commit

Permalink
Fix setting editor in insecure context. Support different API port
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesread committed Jan 30, 2024
1 parent 036d3b1 commit 1f6b393
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/js/firmware/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function ajaxRequest (params) {

let isSuccessful = true

const url = new URL(window.location.protocol + '//' + window.location.hostname + ":8080/api/" + params.url)
const url = new URL(window.location.protocol + '//' + window.location.hostname + ":" + window.location.port + "/api/" + params.url)

if (typeof (params.method) !== 'undefined') {
fetchParams.method = params.method
Expand Down
17 changes: 12 additions & 5 deletions src/js/modules/webcomponents/GlobalSettingsEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ export class GlobalSettingsEditor extends HTMLElement {
setupServiceWorkerInfo() {
this.txtSwInfo = this.querySelector("#swInfo")

if (navigator.serviceWorker.controller === null) {
this.txtSwInfo.innerText = " Service worker controller is null :("
this.btnGetVersion = this.querySelector("#getSwVersion")

if (!("serviceWorker" in navigator)) {
this.txtSwInfo.innerText = " Service workers are not supported in your browser. "
this.txtSwInfo.classList += "error"
this.btnGetVersion.disabled = true
} else {
this.txtSwInfo.innerText = " Service worker controller is setup. "
if (navigator.serviceWorker.controller === null) {
this.txtSwInfo.innerText = " Service worker controller is null :("
this.btnGetVersion.disabled = true
} else {
this.txtSwInfo.innerText = " Service worker controller is setup. "
}
}

this.btnGetVersion = this.querySelector("#getSwVersion")
this.btnGetVersion.onclick = () => {
console.log("req")
navigator.serviceWorker.controller.postMessage("reqGetVersion")
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ ul#taskList {
margin: 1em;
}

.notification.good {
.good {
border: 2px solid green;
background-color: lightgreen;
}

.notification.error {
.error {
border: 2px solid red;
background-color: salmon;
}
Expand Down

0 comments on commit 1f6b393

Please sign in to comment.