forked from maestrano/mno-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request maestrano#40 from alexnoox/feature/dock
Refactored organisations service & Dock initialisation
- Loading branch information
Showing
10 changed files
with
86 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
angular.module 'mnoEnterpriseAngular' | ||
.controller 'ImpacController', ($scope, $log, MnoeOrganizations, ImpacDashboardsSvc, MnoeCurrentUser) -> | ||
.controller 'ImpacController', ($scope, $state, MnoeOrganizations, ImpacDashboardsSvc) -> | ||
'ngInject' | ||
|
||
MnoeCurrentUser.get().then( | ||
-> | ||
self.current_user_role = MnoeCurrentUser.user.organizations[0].current_user_role | ||
|
||
$scope.isAdminRole = -> | ||
self.current_user_role == 'Super Admin' || self.current_user_role == 'Admin' | ||
) | ||
vm = this | ||
|
||
#==================================== | ||
# Post-Initialization | ||
#==================================== | ||
$scope.$watch(MnoeOrganizations.getSelectedId, (newValue, oldValue) -> | ||
vm.isLoaded = false | ||
|
||
# Reload the dashboard | ||
ImpacDashboardsSvc.reload(true) if newValue? && oldValue? && newValue != oldValue | ||
|
||
# Fetch current organization to check if user is allowed | ||
MnoeOrganizations.get().then( | ||
-> | ||
# Impac is displayed only to admin and super admin | ||
vm.isImpacShown = (MnoeOrganizations.role.isAdmin() || MnoeOrganizations.role.isSuperAdmin()) | ||
|
||
# The user is not allowed to se impac, he is redirected | ||
if !vm.isImpacShown | ||
$state.go('home.login') | ||
|
||
vm.isLoaded = true | ||
) if newValue? | ||
) | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
<div id="impac"> | ||
<div ng-show="isAdminRole()"> | ||
<dashboard-apps-dock></dashboard-apps-dock> | ||
<dashboard-apps-dock></dashboard-apps-dock> | ||
|
||
<div id="impac" ng-show="vm.isLoaded"> | ||
<div ng-if="vm.isImpacShown"> | ||
<impac-dashboard></impac-dashboard> | ||
</div> | ||
<div ng-show="!isAdminRole()"> | ||
<span class="alert-no-admin"> | ||
<strong>Warning!</strong> | ||
<a ui-sref="home.apps" ui-sref-active="active">You are not allow to see this content. Click here to be redirected to the {{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}.</a> | ||
</span> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
angular.module 'mnoEnterpriseAngular' | ||
.controller 'LoginRouterCtrl', ($scope, MnoeCurrentUser, $window, $state) -> | ||
'ngInject' | ||
.controller 'LoginRouterCtrl', ($scope, MnoeOrganizations, $window, $state) -> | ||
|
||
$scope.init = MnoeCurrentUser.get().then( | ||
(success) -> | ||
self.current_user_role = MnoeCurrentUser.user.organizations[0].current_user_role | ||
if self.current_user_role == 'Super Admin' || self.current_user_role == 'Admin' | ||
# window.location.href = "/dashboard/#/impac" | ||
$scope.$watch(MnoeOrganizations.getSelected, (newValue) -> | ||
if newValue? | ||
# Impac! is displayed only to admin and super admin | ||
if (MnoeOrganizations.role.isAdmin() || MnoeOrganizations.role.isSuperAdmin()) | ||
$state.go('home.impac') | ||
else | ||
$state.go('home.apps') | ||
) | ||
|
||
return |