UI: fix url handling issue. Improve timeseries table widget.
This commit is contained in:
parent
e3619ecb0c
commit
b38a4d2ff8
File diff suppressed because one or more lines are too long
@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import injectTapEventPlugin from 'react-tap-event-plugin';
|
import injectTapEventPlugin from 'react-tap-event-plugin';
|
||||||
|
import UrlHandler from './url.handler';
|
||||||
|
|
||||||
/* eslint-disable import/no-unresolved, import/default */
|
/* eslint-disable import/no-unresolved, import/default */
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ export default function AppConfig($provide,
|
|||||||
|
|
||||||
injectTapEventPlugin();
|
injectTapEventPlugin();
|
||||||
$locationProvider.html5Mode(true);
|
$locationProvider.html5Mode(true);
|
||||||
//$urlRouterProvider.otherwise('/home');
|
$urlRouterProvider.otherwise(UrlHandler);
|
||||||
storeProvider.setCaching(false);
|
storeProvider.setCaching(false);
|
||||||
|
|
||||||
$translateProvider.useSanitizeValueStrategy('sanitize');
|
$translateProvider.useSanitizeValueStrategy('sanitize');
|
||||||
|
|||||||
@ -14,9 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import Flow from '@flowjs/ng-flow/dist/ng-flow-standalone.min';
|
import Flow from '@flowjs/ng-flow/dist/ng-flow-standalone.min';
|
||||||
|
import UrlHandler from './url.handler';
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $filter, loginService, userService, $translate) {
|
export default function AppRun($rootScope, $window, $injector, $location, $log, $state, $mdDialog, $filter, loginService, userService, $translate) {
|
||||||
|
|
||||||
$window.Flow = Flow;
|
$window.Flow = Flow;
|
||||||
var frame = $window.frameElement;
|
var frame = $window.frameElement;
|
||||||
@ -36,19 +37,17 @@ export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $fi
|
|||||||
|
|
||||||
initWatchers();
|
initWatchers();
|
||||||
|
|
||||||
checkCurrentState();
|
|
||||||
|
|
||||||
function initWatchers() {
|
function initWatchers() {
|
||||||
$rootScope.unauthenticatedHandle = $rootScope.$on('unauthenticated', function (event, doLogout) {
|
$rootScope.unauthenticatedHandle = $rootScope.$on('unauthenticated', function (event, doLogout) {
|
||||||
if (doLogout) {
|
if (doLogout) {
|
||||||
$state.go('login');
|
$state.go('login');
|
||||||
} else {
|
} else {
|
||||||
checkCurrentState();
|
UrlHandler($injector, $location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.authenticatedHandle = $rootScope.$on('authenticated', function () {
|
$rootScope.authenticatedHandle = $rootScope.$on('authenticated', function () {
|
||||||
checkCurrentState();
|
UrlHandler($injector, $location);
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.forbiddenHandle = $rootScope.$on('forbidden', function () {
|
$rootScope.forbiddenHandle = $rootScope.$on('forbidden', function () {
|
||||||
@ -110,24 +109,6 @@ export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $fi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCurrentState() {
|
|
||||||
if (userService.isUserLoaded() === true) {
|
|
||||||
if (userService.isAuthenticated()) {
|
|
||||||
gotoDefaultPlace();
|
|
||||||
} else {
|
|
||||||
$state.go('login');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($rootScope.userLoadedHandle) {
|
|
||||||
$rootScope.userLoadedHandle();
|
|
||||||
}
|
|
||||||
$rootScope.userLoadedHandle = $rootScope.$on('userLoaded', function () {
|
|
||||||
$rootScope.userLoadedHandle();
|
|
||||||
checkCurrentState();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gotoDefaultPlace(params) {
|
function gotoDefaultPlace(params) {
|
||||||
userService.gotoDefaultPlace(params);
|
userService.gotoDefaultPlace(params);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export default function WidgetController($scope, $timeout, $window, $element, $q
|
|||||||
height: 0,
|
height: 0,
|
||||||
isEdit: isEdit,
|
isEdit: isEdit,
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
|
widgetConfig: widget.config,
|
||||||
settings: widget.config.settings,
|
settings: widget.config.settings,
|
||||||
units: widget.config.units || '',
|
units: widget.config.units || '',
|
||||||
decimals: angular.isDefined(widget.config.decimals) ? widget.config.decimals : 2,
|
decimals: angular.isDefined(widget.config.decimals) ? widget.config.decimals : 2,
|
||||||
|
|||||||
31
ui/src/app/url.handler.js
Normal file
31
ui/src/app/url.handler.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2016-2017 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function UrlHandler($injector, $location) {
|
||||||
|
var userService = $injector.get('userService');
|
||||||
|
if (userService.isUserLoaded() === true) {
|
||||||
|
userService.gotoDefaultPlace();
|
||||||
|
} else {
|
||||||
|
var $rootScope = $injector.get('$rootScope');
|
||||||
|
if ($rootScope.userLoadedHandle) {
|
||||||
|
$rootScope.userLoadedHandle();
|
||||||
|
}
|
||||||
|
$rootScope.userLoadedHandle = $rootScope.$on('userLoaded', function () {
|
||||||
|
$rootScope.userLoadedHandle();
|
||||||
|
UrlHandler($injector, $location);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user