Commit 47af95d3ed2d12cc7c1e94f102e0f2b87d4b2257

Authored by Igor Kulikov
1 parent d009009c

Dashboard load improvements.

... ... @@ -252,7 +252,7 @@ function DashboardService($rootScope, $http, $q, $location, $filter) {
252 252 if (port != 80 && port != 443) {
253 253 url += ":" + port;
254 254 }
255   - url += "/dashboards/" + dashboard.id.id + "?publicId=" + dashboard.publicCustomerId;
  255 + url += "/dashboard/" + dashboard.id.id + "?publicId=" + dashboard.publicCustomerId;
256 256 return url;
257 257 }
258 258
... ...
... ... @@ -488,7 +488,8 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, logi
488 488 } else {
489 489 return true;
490 490 }
491   - } else if (to.name === 'home.dashboards.dashboard' && allowedDashboardIds.indexOf(params.dashboardId) > -1) {
  491 + } else if ((to.name === 'home.dashboards.dashboard' || to.name === 'dashboard')
  492 + && allowedDashboardIds.indexOf(params.dashboardId) > -1) {
492 493 return false;
493 494 } else {
494 495 return true;
... ... @@ -504,10 +505,10 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, logi
504 505 var place = 'home.links';
505 506 if (currentUser.authority === 'TENANT_ADMIN' || currentUser.authority === 'CUSTOMER_USER') {
506 507 if (userHasDefaultDashboard()) {
507   - place = 'home.dashboards.dashboard';
  508 + place = $rootScope.forceFullscreen ? 'dashboard' : 'home.dashboards.dashboard';
508 509 params = {dashboardId: currentUserDetails.additionalInfo.defaultDashboardId};
509 510 } else if (isPublic()) {
510   - place = 'home.dashboards.dashboard';
  511 + place = 'dashboard';
511 512 params = {dashboardId: lastPublicDashboardId};
512 513 }
513 514 } else if (currentUser.authority === 'SYS_ADMIN') {
... ...
... ... @@ -113,7 +113,10 @@ export default function AppRun($rootScope, $window, $injector, $location, $log,
113 113 showForbiddenDialog();
114 114 } else if (to.redirectTo) {
115 115 evt.preventDefault();
116   - $state.go(to.redirectTo, params)
  116 + $state.go(to.redirectTo, params);
  117 + } else if (to.name === 'home.dashboards.dashboard' && $rootScope.forceFullscreen) {
  118 + evt.preventDefault();
  119 + $state.go('dashboard', params);
117 120 }
118 121 }
119 122 } else {
... ... @@ -138,7 +141,7 @@ export default function AppRun($rootScope, $window, $injector, $location, $log,
138 141 $rootScope.pageTitle = 'ThingsBoard';
139 142
140 143 $rootScope.stateChangeSuccessHandle = $rootScope.$on('$stateChangeSuccess', function (evt, to, params) {
141   - if (userService.isPublic() && to.name === 'home.dashboards.dashboard') {
  144 + if (userService.isPublic() && to.name === 'dashboard') {
142 145 $location.search('publicId', userService.getPublicId());
143 146 userService.updateLastPublicDashboardId(params.dashboardId);
144 147 }
... ...
... ... @@ -479,7 +479,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele
479 479 dashboardId: targetDashboardId,
480 480 state: utils.objToBase64([ stateObject ])
481 481 }
482   - $state.go('home.dashboards.dashboard', stateParams);
  482 + if ($state.current.name === 'dashboard') {
  483 + $state.go('dashboard', stateParams);
  484 + } else {
  485 + $state.go('home.dashboards.dashboard', stateParams);
  486 + }
483 487 break;
484 488 case types.widgetActionTypes.custom.value:
485 489 var customFunction = descriptor.customFunction;
... ...
... ... @@ -196,6 +196,7 @@ export default function DashboardController(types, utils, dashboardUtils, widget
196 196 vm.displayDashboardTimewindow = displayDashboardTimewindow;
197 197 vm.displayDashboardsSelect = displayDashboardsSelect;
198 198 vm.displayEntitiesSelect = displayEntitiesSelect;
  199 + vm.hideFullscreenButton = hideFullscreenButton;
199 200
200 201 vm.widgetsBundle;
201 202
... ... @@ -258,7 +259,11 @@ export default function DashboardController(types, utils, dashboardUtils, widget
258 259 dashboardId: vm.currentDashboardId
259 260 });
260 261 } else {
261   - $state.go('home.dashboards.dashboard', {dashboardId: vm.currentDashboardId});
  262 + if ($state.current.name === 'dashboard') {
  263 + $state.go('dashboard', {dashboardId: vm.currentDashboardId});
  264 + } else {
  265 + $state.go('home.dashboards.dashboard', {dashboardId: vm.currentDashboardId});
  266 + }
262 267 }
263 268 }
264 269 });
... ... @@ -805,6 +810,10 @@ export default function DashboardController(types, utils, dashboardUtils, widget
805 810 }
806 811 }
807 812
  813 + function hideFullscreenButton() {
  814 + return vm.widgetEditMode || vm.iframeMode || $rootScope.forceFullscreen || $state.current.name === 'dashboard';
  815 + }
  816 +
808 817 function onRevertWidgetEdit(widgetForm) {
809 818 if (widgetForm.$dirty) {
810 819 widgetForm.$setPristine();
... ...
... ... @@ -86,6 +86,24 @@ export default function DashboardRoutes($stateProvider) {
86 86 label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}'
87 87 }
88 88 })
  89 + .state('dashboard', {
  90 + url: '/dashboard/:dashboardId?state',
  91 + reloadOnSearch: false,
  92 + module: 'private',
  93 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
  94 + views: {
  95 + "@": {
  96 + templateUrl: dashboardTemplate,
  97 + controller: 'DashboardController',
  98 + controllerAs: 'vm'
  99 + }
  100 + },
  101 + data: {
  102 + widgetEditMode: false,
  103 + searchEnabled: false,
  104 + pageTitle: 'dashboard.dashboard'
  105 + }
  106 + })
89 107 .state('home.customers.dashboards.dashboard', {
90 108 url: '/:dashboardId?state',
91 109 reloadOnSearch: false,
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <md-content style="padding-top: 150px;" flex tb-expand-fullscreen="vm.widgetEditMode || vm.iframeMode || forceFullscreen" expand-button-id="dashboard-expand-button"
19   - hide-expand-button="vm.widgetEditMode || vm.iframeMode || forceFullscreen" expand-tooltip-direction="bottom" ng-if="vm.dashboard">
  19 + hide-expand-button="vm.hideFullscreenButton()" expand-tooltip-direction="bottom" ng-if="vm.dashboard">
20 20 <section class="tb-dashboard-toolbar" ng-show="vm.showDashboardToolbar()"
21 21 ng-class="{ 'tb-dashboard-toolbar-opened': vm.toolbarOpened, 'tb-dashboard-toolbar-closed': !vm.toolbarOpened }">
22 22 <tb-dashboard-toolbar ng-show="!vm.widgetEditMode" force-fullscreen="forceFullscreen"
... ...