Skip to content

Commit

Permalink
make habpanel work with non-root context path
Browse files Browse the repository at this point in the history
Signed-off-by: Hubert Nusser <[email protected]>
  • Loading branch information
hubsif committed Apr 5, 2022
1 parent 355df85 commit 1dcd0e9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

function getIconUrl(iconset, icon, state) {
if (iconset === 'custom-icon') {
return '/icon/' + icon + '?format=svg' + ((state) ? '&state=' + state : '');
return '../icon/' + icon + '?format=svg' + ((state) ? '&state=' + state : '');
} else if (iconset === 'custom-url') {
return icon;
}
Expand All @@ -34,7 +34,7 @@
if (set.type === 'builtin') {
return 'assets/icons/' + set.id + '/' + icon + '.svg';
} else {
return '/icon/' + icon + '?format=svg' + ((state) ? '&state=' + state : '');
return '../icon/' + icon + '?format=svg' + ((state) ? '&state=' + state : '');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

$http({
method: 'GET',
url: '/rest/services/' + SERVICE_NAME + '/config',
url: '../rest/services/' + SERVICE_NAME + '/config',
headers: headers
}).then(function (resp) {
console.log('openHAB 2 service configuration loaded');
Expand Down Expand Up @@ -77,7 +77,7 @@
OH3StorageService.getAccessToken().then(function (accessToken) {
$http({
method: 'PUT',
url: '/rest/services/' + SERVICE_NAME + '/config',
url: '../rest/services/' + SERVICE_NAME + '/config',
data: OH2ServiceConfiguration,
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + accessToken }
}).then (function (resp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
} else {
$http({
method: 'POST',
url: '/rest/auth/token',
url: '../rest/auth/token',
data: 'grant_type=refresh_token&client_id=' + window.location.origin +
'&redirect_uri=' + window.location.origin + '&refresh_token=' + refreshToken,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
Expand All @@ -49,7 +49,7 @@
if (!refreshToken) {
$rootScope.lockEditing = true;
}
$http.get('/rest/ui/components/habpanel:panelconfig').then(function (data) {
$http.get('../rest/ui/components/habpanel:panelconfig').then(function (data) {
console.log('Panel configurations loaded');
$rootScope.panelsRegistry = transformUIComponentsToPanelRegistry(data.data);
deferred.resolve($rootScope.panelsRegistry);
Expand Down Expand Up @@ -77,11 +77,11 @@
headers['Authorization'] = 'Bearer ' + accessToken
}

$http.get('/rest/ui/components/habpanel:panelconfig/' + getCurrentPanelConfig()).then(function (data) {
$http.get('../rest/ui/components/habpanel:panelconfig/' + getCurrentPanelConfig()).then(function (data) {
// update
$http({
method: 'PUT',
url: '/rest/ui/components/habpanel:panelconfig/' + getCurrentPanelConfig(),
url: '../rest/ui/components/habpanel:panelconfig/' + getCurrentPanelConfig(),
data: transformPanelConfigurationToUIComponent(getCurrentPanelConfig(), panelConfiguration),
headers: headers
}).then (function (resp) {
Expand All @@ -95,7 +95,7 @@
// assume the error is 404?
$http({
method: 'POST',
url: '/rest/ui/components/habpanel:panelconfig',
url: '../rest/ui/components/habpanel:panelconfig',
data: transformPanelConfigurationToUIComponent(getCurrentPanelConfig(), panelConfiguration),
headers: headers
}).then (function (resp) {
Expand Down Expand Up @@ -127,7 +127,7 @@

$http({
method: 'DELETE',
url: '/rest/ui/components/habpanel:panelconfig/' + id,
url: '../rest/ui/components/habpanel:panelconfig/' + id,
headers: headers
}).then (function (resp) {
console.log('Panel configuration deleted');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$timeout($rootScope.$emit('openhab-update'));
}

$http.get('/rest/items')
$http.get('../rest/items')
.then(function (data) {
if (angular.isArray(data.data)) {
console.log("Loaded " + data.data.length + " openHAB items");
Expand Down Expand Up @@ -71,7 +71,7 @@
function sendCmd(item, cmd) {
$http({
method : 'POST',
url : '/rest/items/' + item,
url : '../rest/items/' + item,
data : cmd,
headers: { 'Content-Type': 'text/plain' }
}).then(function (data) {
Expand All @@ -92,7 +92,7 @@
if (locale) {
deferred.resolve(locale);
} else {
$http.get('/rest/')
$http.get('../rest/')
.then(function (response) {
if (!response.data.locale) {
if (navigator && navigator.languages) {
Expand Down Expand Up @@ -145,7 +145,7 @@
function sendVoice(text) {
$http({
method : 'POST',
url : '/rest/voice/interpreters',
url : '../rest/voice/interpreters',
data : text,
headers: { 'Content-Type': 'text/plain' }
}).then(function (data) {
Expand All @@ -161,7 +161,7 @@

function registerEventSource() {
if (typeof(EventSource) !== "undefined") {
var source = new EventSource('/rest/events?topics=openhab/items/*/statechanged,openhab/items/*/*/statechanged,openhab/webaudio/playurl');
var source = new EventSource('../rest/events?topics=openhab/items/*/statechanged,openhab/items/*/*/statechanged,openhab/webaudio/playurl');
liveUpdatesEnabled = true;

source.onmessage = function (event) {
Expand Down Expand Up @@ -192,7 +192,7 @@
}
} else {
// fetch the new transformed state
$http.get('/rest/items/' + item.name).then(function (response) {
$http.get('../rest/items/' + item.name).then(function (response) {
if (response.data && response.data.transformedState) {
item.transformedState = response.data.transformedState;
$rootScope.$emit('openhab-update', item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
vm.progressMax = 1;
vm.progressCurrent = 1;

$http.get('/rest/habpanel/gallery/community/widgets')
$http.get('../rest/habpanel/gallery/community/widgets')
.then(function (resp) {
vm.busy = false;
if (resp.data) {
Expand Down Expand Up @@ -52,7 +52,7 @@
vm.progressMax = 1;
vm.progressCurrent = 1;

$http.get('/rest/habpanel/gallery/community/widgets/' + id)
$http.get('../rest/habpanel/gallery/community/widgets/' + id)
.then(function (resp) {
vm.galleryItemDetails = resp.data;
if (vm.galleryItemDetails.authorAvatarUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

vm.rawdata = [];
for (var i = 0; i < vm.widget.series.length; i++) {
vm.rawdata[i] = $http.get('/rest/persistence/items/' + vm.widget.series[i].item + "?starttime=" + startDate.toISOString() + (vm.widget.service ? '&serviceId=' + vm.widget.service : ''));
vm.rawdata[i] = $http.get('../rest/persistence/items/' + vm.widget.series[i].item + "?starttime=" + startDate.toISOString() + (vm.widget.service ? '&serviceId=' + vm.widget.service : ''));
}

$q.all(vm.rawdata).then(function (values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@

vm.rawdata = [];
for (var i = 0; i < vm.widget.series.length; i++) {
vm.rawdata[i] = $http.get('/rest/persistence/items/' + vm.widget.series[i].item + "?boundary=true&starttime=" + startDate.toISOString() + (vm.widget.service ? '&serviceId=' + vm.widget.service : ''));
vm.rawdata[i] = $http.get('../rest/persistence/items/' + vm.widget.series[i].item + "?boundary=true&starttime=" + startDate.toISOString() + (vm.widget.service ? '&serviceId=' + vm.widget.service : ''));
}


Expand Down

0 comments on commit 1dcd0e9

Please sign in to comment.