diff --git a/bundles/org.openhab.ui.basic/gulpfile.js b/bundles/org.openhab.ui.basic/gulpfile.js index 1667955636..58e75b430b 100644 --- a/bundles/org.openhab.ui.basic/gulpfile.js +++ b/bundles/org.openhab.ui.basic/gulpfile.js @@ -33,6 +33,11 @@ .pipe(gulp.dest("./src/main/resources/web")); }); + gulp.task("tile", function() { + return gulp.src("web-src/tile.png") + .pipe(gulp.dest("./src/main/resources/web")); + }); + gulp.task("eslint", function() { return gulp.src(sources.js) .pipe(eslint({ @@ -48,5 +53,5 @@ .pipe(gulp.dest("./src/main/resources/web")); }); - gulp.task("default", gulp.parallel("css", "copyFontLibs", gulp.series("eslint", "js"))); + gulp.task("default", gulp.parallel("css", "tile", "copyFontLibs", gulp.series("eslint", "js"))); })(); diff --git a/bundles/org.openhab.ui/web/src/res/img/basicui.png b/bundles/org.openhab.ui.basic/web-src/tile.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/img/basicui.png rename to bundles/org.openhab.ui.basic/web-src/tile.png diff --git a/bundles/org.openhab.ui/web/.eslintrc.js b/bundles/org.openhab.ui/web/.eslintrc.js index d8ee6f16e5..c8011e51d4 100644 --- a/bundles/org.openhab.ui/web/.eslintrc.js +++ b/bundles/org.openhab.ui/web/.eslintrc.js @@ -31,7 +31,8 @@ module.exports = { 'ga': true, // Google Analytics 'cordova': true, '__statics': true, - 'process': true + 'process': true, + 'baseUrl': true }, // add your custom rules here diff --git a/bundles/org.openhab.ui/web/build/webpack.config.js b/bundles/org.openhab.ui/web/build/webpack.config.js index f77dd59c91..b641fcfb2b 100644 --- a/bundles/org.openhab.ui/web/build/webpack.config.js +++ b/bundles/org.openhab.ui/web/build/webpack.config.js @@ -20,7 +20,7 @@ const target = process.env.TARGET || 'web' const buildSourceMaps = process.env.SOURCE_MAPS || false const isCordova = target === 'cordova' -const apiBaseUrl = process.env.OH_APIBASE || 'http://localhost:8080' +const apiBaseUrl = process.env.OH_APIBASE || 'http://hubsibase:8080' module.exports = { mode: env, @@ -48,12 +48,15 @@ module.exports = { // compress: true, contentBase: '/www/', disableHostCheck: true, - historyApiFallback: true, + historyApiFallback: { index: '/proxypath/' }, + publicPath: '/proxypath/', + headers: { "Set-Cookie": "X-OPENHAB-BASEURL=/proxypath;" }, // watchOptions: { // poll: 1000, // }, proxy: [{ - context: ['/auth', '/rest', '/chart', '/proxy', '/icon', '/static', '/changePassword', '/createApiToken'], + context: ['/proxypath/auth', '/proxypath/rest', '/proxypath/chart', '/proxypath/proxy', '/proxypath/icon', '/proxypath/static', '/proxypath/changePassword', '/proxypath/createApiToken', '/proxypath/habpanel', '/proxypath/basicui'], + pathRewrite: { '^/proxypath' : '' }, target: apiBaseUrl }] }, @@ -204,7 +207,7 @@ module.exports = { new HtmlWebpackPlugin({ filename: './index.html', template: './src/index.html', - inject: true, + inject: false, minify: env === 'production' ? { collapseWhitespace: true, removeComments: true, @@ -219,8 +222,8 @@ module.exports = { }), new CopyWebpackPlugin([ { - from: resolvePath('src/res'), - to: resolvePath(isCordova ? 'cordova/www/res' : 'www/res') + from: resolvePath('src/images'), + to: resolvePath(isCordova ? 'cordova/www/images' : 'www/images') }, { from: resolvePath('src/manifest.json'), diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index b107de8124..4bf08aa550 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -307,6 +307,7 @@ export default { iosSwipeBack: !this.$device.ios || this.$device.cordova, auroraSwipeBack: !this.$device.ios || this.$device.cordova, pushState: true, // !this.$device.cordova + pushStateRoot: baseUrl, pushStateSeparator: '' }, // Enable panel left visibility breakpoint @@ -510,7 +511,7 @@ export default { this.cleanSession().then(() => { this.loggedIn = false this.$f7.views.main.router.navigate('/', { animate: false, clearPreviousHistory: true }) - window.location = window.location.origin + window.location = window.location.origin + baseUrl + '/' if (this.$device.cordova) { this.loginScreenOpened = true } diff --git a/bundles/org.openhab.ui/web/src/components/auth-mixin.js b/bundles/org.openhab.ui/web/src/components/auth-mixin.js index 7d9c6920ea..95c1033805 100644 --- a/bundles/org.openhab.ui/web/src/components/auth-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/auth-mixin.js @@ -31,8 +31,8 @@ export default { const payload = Utils.serializeObject({ 'grant_type': 'authorization_code', - 'client_id': window.location.origin, - 'redirect_uri': window.location.origin, + 'client_id': window.location.origin + baseUrl, + 'redirect_uri': window.location.origin + baseUrl + '/', 'code': queryParams.code, 'code_verifier': codeVerifier }) @@ -65,8 +65,8 @@ export default { const refreshToken = this.getRefreshToken() const payload = Utils.serializeObject({ 'grant_type': 'refresh_token', - 'client_id': window.location.origin, - 'redirect_uri': window.location.origin, + 'client_id': window.location.origin + baseUrl, + 'redirect_uri': window.location.origin + baseUrl + '/', 'refresh_token': refreshToken }) diff --git a/bundles/org.openhab.ui/web/src/components/widgets/system/oh-icon.vue b/bundles/org.openhab.ui/web/src/components/widgets/system/oh-icon.vue index df3857627e..c1ddbba5fd 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/system/oh-icon.vue +++ b/bundles/org.openhab.ui/web/src/components/widgets/system/oh-icon.vue @@ -89,8 +89,8 @@ export default { updateIcon () { if (!this.currentIcon) return this.$oh.media.getIcon(this.currentIcon, this.iconFormat, this.currentState).then((url) => { - if (url !== this.iconUrl) { - this.iconUrl = url + if (baseUrl + url !== this.iconUrl) { + this.iconUrl = baseUrl + url } }) } diff --git a/bundles/org.openhab.ui/web/src/css/icons.css b/bundles/org.openhab.ui/web/src/css/icons.css index f3c1e7645f..cad1ffa3b1 100644 --- a/bundles/org.openhab.ui/web/src/css/icons.css +++ b/bundles/org.openhab.ui/web/src/css/icons.css @@ -5,9 +5,9 @@ font-weight: 400; src: local('Material Icons'), local('MaterialIcons-Regular'), - url(../fonts/MaterialIcons-Regular.woff2) format('woff2'), - url(../fonts/MaterialIcons-Regular.woff) format('woff'), - url(../fonts/MaterialIcons-Regular.ttf) format('truetype'); + url("../fonts/MaterialIcons-Regular.woff2") format('woff2'), + url("../fonts/MaterialIcons-Regular.woff") format('woff'), + url("../fonts/MaterialIcons-Regular.ttf") format('truetype'); } .material-icons { font-family: 'Material Icons'; diff --git a/bundles/org.openhab.ui/web/src/res/icons/128x128.png b/bundles/org.openhab.ui/web/src/images/icons/128x128.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/128x128.png rename to bundles/org.openhab.ui/web/src/images/icons/128x128.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/144x144.png b/bundles/org.openhab.ui/web/src/images/icons/144x144.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/144x144.png rename to bundles/org.openhab.ui/web/src/images/icons/144x144.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/152x152.png b/bundles/org.openhab.ui/web/src/images/icons/152x152.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/152x152.png rename to bundles/org.openhab.ui/web/src/images/icons/152x152.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/192x192.png b/bundles/org.openhab.ui/web/src/images/icons/192x192.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/192x192.png rename to bundles/org.openhab.ui/web/src/images/icons/192x192.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/256x256.png b/bundles/org.openhab.ui/web/src/images/icons/256x256.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/256x256.png rename to bundles/org.openhab.ui/web/src/images/icons/256x256.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/512x512.png b/bundles/org.openhab.ui/web/src/images/icons/512x512.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/512x512.png rename to bundles/org.openhab.ui/web/src/images/icons/512x512.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/apple-touch-icon.png b/bundles/org.openhab.ui/web/src/images/icons/apple-touch-icon.png similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/apple-touch-icon.png rename to bundles/org.openhab.ui/web/src/images/icons/apple-touch-icon.png diff --git a/bundles/org.openhab.ui/web/src/res/icons/favicon.svg b/bundles/org.openhab.ui/web/src/images/icons/favicon.svg similarity index 100% rename from bundles/org.openhab.ui/web/src/res/icons/favicon.svg rename to bundles/org.openhab.ui/web/src/images/icons/favicon.svg diff --git a/bundles/org.openhab.ui/web/src/index.html b/bundles/org.openhab.ui/web/src/index.html index 756e93531b..38d27a0de7 100644 --- a/bundles/org.openhab.ui/web/src/index.html +++ b/bundles/org.openhab.ui/web/src/index.html @@ -21,18 +21,29 @@ <% if (process.env.TARGET === 'web') { %> - - - - + + + + <% } %> +
<% if (process.env.TARGET === 'cordova') { %> <% } %> - + diff --git a/bundles/org.openhab.ui/web/src/js/app.js b/bundles/org.openhab.ui/web/src/js/app.js index 8d2306d17b..54da7c8a6a 100644 --- a/bundles/org.openhab.ui/web/src/js/app.js +++ b/bundles/org.openhab.ui/web/src/js/app.js @@ -1,3 +1,4 @@ +import './public-path.js' import './compatibility' // Import Vue diff --git a/bundles/org.openhab.ui/web/src/js/openhab/api.js b/bundles/org.openhab.ui/web/src/js/openhab/api.js index c7a803c240..7cfdb80f3b 100644 --- a/bundles/org.openhab.ui/web/src/js/openhab/api.js +++ b/bundles/org.openhab.ui/web/src/js/openhab/api.js @@ -28,24 +28,24 @@ Framework7.request.setup({ export default { get (uri, data) { - return wrapPromise(Framework7.request.promise.json(uri, data)) + return wrapPromise(Framework7.request.promise.json(baseUrl + uri, data)) }, getPlain (uri, data, contentType) { return wrapPromise(Framework7.request.promise({ method: 'GET', - url: uri, + url: baseUrl + uri, data, processData: false, contentType: contentType || 'text/plain' })) }, post (uri, data, dataType) { - return wrapPromise(Framework7.request.promise.postJSON(uri, data, dataType)) + return wrapPromise(Framework7.request.promise.postJSON(baseUrl + uri, data, dataType)) }, postPlain (uri, data, dataType, contentType) { return wrapPromise(Framework7.request.promise({ method: 'POST', - url: uri, + url: baseUrl + uri, data, processData: false, contentType: contentType || 'text/plain', @@ -55,7 +55,7 @@ export default { put (uri, data) { return wrapPromise(Framework7.request.promise({ method: 'PUT', - url: uri, + url: baseUrl + uri, data: JSON.stringify(data), processData: false, // dataType: 'json', @@ -65,7 +65,7 @@ export default { putPlain (uri, data, dataType, contentType) { return wrapPromise(Framework7.request.promise({ method: 'PUT', - url: uri, + url: baseUrl + uri, data, processData: false, // dataType: 'json', @@ -76,13 +76,13 @@ export default { head (uri) { return wrapPromise(Framework7.request.promise({ method: 'HEAD', - url: uri + url: baseUrl + uri })) }, delete (uri, data) { return wrapPromise(Framework7.request.promise({ method: 'DELETE', - url: uri, + url: baseUrl + uri, processData: false, // dataType: 'json', contentType: 'application/json' diff --git a/bundles/org.openhab.ui/web/src/js/openhab/auth.js b/bundles/org.openhab.ui/web/src/js/openhab/auth.js index c8f2461fad..1c0cc8ce6a 100644 --- a/bundles/org.openhab.ui/web/src/js/openhab/auth.js +++ b/bundles/org.openhab.ui/web/src/js/openhab/auth.js @@ -35,10 +35,10 @@ export function authorize (setup) { sessionStorage.setItem('openhab.ui:codeVerifier', pkceChallenge.code_verifier) sessionStorage.setItem('openhab.ui:authState', authState) - window.location = '/auth' + + window.location = baseUrl + '/auth' + '?response_type=code' + - '&client_id=' + encodeURIComponent(window.location.origin) + - '&redirect_uri=' + encodeURIComponent(window.location.origin) + + '&client_id=' + encodeURIComponent(window.location.origin + baseUrl) + + '&redirect_uri=' + encodeURIComponent(window.location.origin + baseUrl + '/') + '&scope=admin' + '&code_challenge_method=S256' + '&code_challenge=' + encodeURIComponent(pkceChallenge.code_challenge) + diff --git a/bundles/org.openhab.ui/web/src/js/openhab/sse.js b/bundles/org.openhab.ui/web/src/js/openhab/sse.js index 4444b7b24b..256a7e87a1 100644 --- a/bundles/org.openhab.ui/web/src/js/openhab/sse.js +++ b/bundles/org.openhab.ui/web/src/js/openhab/sse.js @@ -53,10 +53,10 @@ function newSSEConnection (path, readyCallback, messageCallback, errorCallback) export default { connect (path, topics, messageCallback, errorCallback) { - return newSSEConnection(path, null, messageCallback, errorCallback) + return newSSEConnection(baseUrl + path, null, messageCallback, errorCallback) }, connectStateTracker (path, readyCallback, updateCallback, errorCallback) { - return newSSEConnection(path, readyCallback, updateCallback, errorCallback) + return newSSEConnection(baseUrl + path, readyCallback, updateCallback, errorCallback) }, close (client, callback) { if (!client) return diff --git a/bundles/org.openhab.ui/web/src/js/public-path.js b/bundles/org.openhab.ui/web/src/js/public-path.js new file mode 100644 index 0000000000..40ddec01d7 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/js/public-path.js @@ -0,0 +1,2 @@ +/* global __webpack_public_path__:writable */ +__webpack_public_path__ = baseUrl + '/' diff --git a/bundles/org.openhab.ui/web/src/js/routes.js b/bundles/org.openhab.ui/web/src/js/routes.js index 72409641fd..58d338c4cf 100644 --- a/bundles/org.openhab.ui/web/src/js/routes.js +++ b/bundles/org.openhab.ui/web/src/js/routes.js @@ -299,7 +299,7 @@ export default [ }, /* For Cordova */ { - path: '/res/(.*)', + path: '/images/(.*)', redirect: '/' }, { diff --git a/bundles/org.openhab.ui/web/src/manifest.json b/bundles/org.openhab.ui/web/src/manifest.json index b5104ecff0..00b5fd721e 100644 --- a/bundles/org.openhab.ui/web/src/manifest.json +++ b/bundles/org.openhab.ui/web/src/manifest.json @@ -9,32 +9,32 @@ "theme_color": "#e64a19", "icons": [ { - "src": "/res/icons/128x128.png", + "src": "images/icons/128x128.png", "sizes": "128x128", "type": "image/png" }, { - "src": "/res/icons/144x144.png", + "src": "images/icons/144x144.png", "sizes": "144x144", "type": "image/png" }, { - "src": "/res/icons/152x152.png", + "src": "images/icons/152x152.png", "sizes": "152x152", "type": "image/png" }, { - "src": "/res/icons/192x192.png", + "src": "images/icons/192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/res/icons/256x256.png", + "src": "images/icons/256x256.png", "sizes": "256x256", "type": "image/png" }, { - "src": "/res/icons/512x512.png", + "src": "images/icons/512x512.png", "sizes": "512x512", "type": "image/png" } diff --git a/bundles/org.openhab.ui/web/src/pages/about.vue b/bundles/org.openhab.ui/web/src/pages/about.vue index 9818f0007f..faa7db76bc 100644 --- a/bundles/org.openhab.ui/web/src/pages/about.vue +++ b/bundles/org.openhab.ui/web/src/pages/about.vue @@ -6,7 +6,7 @@ - +

openHAB {{ $store.state.runtimeInfo.version }}
{{ $store.state.runtimeInfo.buildString }}

diff --git a/bundles/org.openhab.ui/web/src/pages/panel-right.vue b/bundles/org.openhab.ui/web/src/pages/panel-right.vue index 1ea7f8d669..50faa0867c 100644 --- a/bundles/org.openhab.ui/web/src/pages/panel-right.vue +++ b/bundles/org.openhab.ui/web/src/pages/panel-right.vue @@ -24,7 +24,11 @@ export default { }, created () { this.$oh.api.get('/rest/ui/tiles').then((data) => { - this.apps = data + this.apps = data.map((tile) => { + tile.url = baseUrl + tile.url + tile.imageUrl = baseUrl + tile.imageUrl + return tile + }) }) } } diff --git a/bundles/org.openhab.ui/web/src/pages/profile.vue b/bundles/org.openhab.ui/web/src/pages/profile.vue index 492edd9bca..245173cfcf 100644 --- a/bundles/org.openhab.ui/web/src/pages/profile.vue +++ b/bundles/org.openhab.ui/web/src/pages/profile.vue @@ -20,7 +20,7 @@ - + {{ $t('profile.changePassword') }} @@ -77,7 +77,7 @@ - + {{ $t('profile.apiTokens.create') }} @@ -216,7 +216,7 @@ export default { this.cleanSession().then(() => { this.loggedIn = false this.$f7.views.main.router.navigate('/', { animate: false, clearPreviousHistory: true }) - window.location = window.location.origin + window.location = window.location.origin + baseUrl if (this.$device.cordova) { this.loginScreenOpened = true } @@ -224,6 +224,12 @@ export default { this.$f7.preloader.hide() this.$f7.dialog.alert(this.$t('profile.sessions.signOut.error') + err) }) + }, + changePasswordUrl () { + return baseUrl + '/changePassword' + }, + createApiTokenUrl () { + return baseUrl + '/createApiToken' } } } diff --git a/bundles/org.openhab.ui/web/src/res/img/cometvisu.png b/bundles/org.openhab.ui/web/src/res/img/cometvisu.png deleted file mode 100644 index 80247b42b0..0000000000 Binary files a/bundles/org.openhab.ui/web/src/res/img/cometvisu.png and /dev/null differ