Skip to content

Commit

Permalink
Dev UI Base path fix in case of non-application root set to dev*
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
  • Loading branch information
phillip-kruger committed Jul 22, 2024
1 parent c466d16 commit 2ceb6fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ export class JsonRpc {
} else {
JsonRpc.serverUri = "ws:";
}
var currentPath = window.location.pathname;
currentPath = currentPath.substring(0, currentPath.indexOf('/dev')) + "/dev-ui";
JsonRpc.serverUri += "//" + window.location.host + currentPath + "/json-rpc-ws";
JsonRpc.serverUri += "//" + window.location.host + RouterController.getBasePath() + "/json-rpc-ws";
JsonRpc.connect();
}

Expand Down Expand Up @@ -345,4 +343,4 @@ export class JsonRpc {
JsonRpc.dispatchMessageLogEntry(Level.Info, MessageDirection.Down, jsonrpcpayload);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ export class RouterController {
return null;
}

getBasePath(){
static getBasePath(){
var base = window.location.pathname;
return base.substring(0, base.indexOf('/dev')) + "/dev-ui";
if(base.endsWith("/dev-ui")){
return base.substring(0, base.lastIndexOf('/dev-ui')) + "/dev-ui";
}else{
return base.substring(0, base.lastIndexOf('/dev-ui/')) + "/dev-ui";
}
}

getPageUrlFor(page){
return this.getBasePath() + '/' + page.id;
return RouterController.getBasePath() + '/' + page.id;
}

isExistingPath(path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ export class QwcExternalPage extends observeState(LitElement) {
height='100%'>
</object>`;
} else {
let currentPath = window.location.pathname;
currentPath = currentPath.substring(0, currentPath.indexOf('/dev'));
return html`<div class="codeBlock">
<span class="download" @click="${this._download}" title="${this._externalUrl}">
<vaadin-icon class="icon" icon="font-awesome-solid:download"></vaadin-icon>
Expand All @@ -130,4 +128,4 @@ export class QwcExternalPage extends observeState(LitElement) {
window.open(this._externalUrl, '_blank').focus();
}
}
customElements.define('qwc-external-page', QwcExternalPage);
customElements.define('qwc-external-page', QwcExternalPage);

0 comments on commit 2ceb6fb

Please sign in to comment.