From 4d71a05d2ae3488a99a741afadf6866b002c6504 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 3 Mar 2017 21:53:02 -0500 Subject: [PATCH] organization pages and routing --- src/app/config.js | 12 +++++++++--- src/app/global/mainController.js | 2 -- src/app/global/sideNavController.js | 13 ++++++++++++- .../organizationPeopleController.js | 6 ++++++ ...shboard.html => organizationDashboard.html} | 0 .../organization/views/organizationPeople.html | 16 ++++++++++++++++ src/app/services/apiService.js | 1 + src/app/services/authService.js | 12 ++++++++++++ src/app/settings/settingsController.js | 2 +- src/app/settings/views/settings.html | 2 +- src/app/views/organizationLayout.html | 18 ++++++++++++++---- src/app/views/userLayout.html | 4 ++-- src/index.html | 1 + 13 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 src/app/organization/organizationPeopleController.js rename src/app/organization/views/{dashboard.html => organizationDashboard.html} (100%) create mode 100644 src/app/organization/views/organizationPeople.html diff --git a/src/app/config.js b/src/app/config.js index 04ba60b80a..9426d7816a 100644 --- a/src/app/config.js +++ b/src/app/config.js @@ -121,10 +121,16 @@ angular abstract: true }) .state('backend.org.dashboard', { - url: '^/organization/:id', - templateUrl: 'app/organization/views/dashboard.html', + url: '^/organization/:orgId', + templateUrl: 'app/organization/views/organizationDashboard.html', controller: 'organizationDashboardController', - data: { pageTitle: 'Org Dash' } + data: { pageTitle: 'Organization Dashboard' } + }) + .state('backend.org.people', { + url: '/organization/:orgId/people', + templateUrl: 'app/organization/views/organizationPeople.html', + controller: 'organizationPeopleController', + data: { pageTitle: 'Organization People' } }) // Frontend diff --git a/src/app/global/mainController.js b/src/app/global/mainController.js index 31c8fa2fb2..6f5bdb8f9d 100644 --- a/src/app/global/mainController.js +++ b/src/app/global/mainController.js @@ -4,7 +4,6 @@ angular .controller('mainController', function ($scope, $state, authService, appSettings, toastr) { var vm = this; vm.bodyClass = ''; - vm.userProfile = null; vm.searchVaultText = null; vm.version = appSettings.version; @@ -27,7 +26,6 @@ angular $scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) { vm.searchVaultText = null; - vm.userProfile = authService.getUserProfile(); if (toState.data.bodyClass) { vm.bodyClass = toState.data.bodyClass; diff --git a/src/app/global/sideNavController.js b/src/app/global/sideNavController.js index 4d41c06c9a..575c5759ff 100644 --- a/src/app/global/sideNavController.js +++ b/src/app/global/sideNavController.js @@ -1,6 +1,17 @@ angular .module('bit.global') - .controller('sideNavController', function ($scope, $state) { + .controller('sideNavController', function ($scope, $state, authService, apiService) { $scope.$state = $state; + $scope.params = $state.params; + + if ($state.includes('backend.user')) { + $scope.userProfile = authService.getUserProfile(); + } + else if ($state.includes('backend.org')) { + $scope.orgProfile = {}; + apiService.organizations.get({ id: $state.params.orgId }, function (response) { + $scope.orgProfile.name = response.Name; + }); + } }); diff --git a/src/app/organization/organizationPeopleController.js b/src/app/organization/organizationPeopleController.js new file mode 100644 index 0000000000..528277b723 --- /dev/null +++ b/src/app/organization/organizationPeopleController.js @@ -0,0 +1,6 @@ +angular + .module('bit.organization') + + .controller('organizationPeopleController', function ($scope) { + + }); diff --git a/src/app/organization/views/dashboard.html b/src/app/organization/views/organizationDashboard.html similarity index 100% rename from src/app/organization/views/dashboard.html rename to src/app/organization/views/organizationDashboard.html diff --git a/src/app/organization/views/organizationPeople.html b/src/app/organization/views/organizationPeople.html new file mode 100644 index 0000000000..dddacd19c3 --- /dev/null +++ b/src/app/organization/views/organizationPeople.html @@ -0,0 +1,16 @@ +
+

+ People + users for your organization +

+
+
+
+
+

Users

+
+
+ Some data +
+
+
diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index 257f3f4646..830a723839 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -31,6 +31,7 @@ _service.organizations = $resource(_apiUri + '/organizations/:id', {}, { get: { method: 'GET', params: { id: '@id' } }, + getExtended: { url: _apiUri + '/organizations/:id/extended', method: 'GET', params: { id: '@id' } }, list: { method: 'GET', params: {} }, post: { method: 'POST', params: {} }, put: { method: 'POST', params: { id: '@id' } }, diff --git a/src/app/services/authService.js b/src/app/services/authService.js index 5c3bf2c3db..ddb06ff206 100644 --- a/src/app/services/authService.js +++ b/src/app/services/authService.js @@ -86,6 +86,18 @@ angular twoFactorEnabled: profile.TwoFactorEnabled, culture: profile.Culture }; + + if (profile.Organizations) { + var orgs = []; + for (var i = 0; i < profile.Organizations.length; i++) { + orgs.push({ + id: profile.Organizations[i].Id, + name: profile.Organizations[i].Name + }); + } + + _userProfile.organizations = orgs; + } } _service.isAuthenticated = function () { diff --git a/src/app/settings/settingsController.js b/src/app/settings/settingsController.js index ce37a12ec7..2ecb52308b 100644 --- a/src/app/settings/settingsController.js +++ b/src/app/settings/settingsController.js @@ -71,7 +71,7 @@ }; $scope.viewOrganization = function (id) { - $state.go('backend.org.dashboard', { id: id }); + $state.go('backend.org.dashboard', { orgId: id }); }; $scope.twoFactor = function () { diff --git a/src/app/settings/views/settings.html b/src/app/settings/views/settings.html index 1bb9547493..ce7b8e9f9e 100644 --- a/src/app/settings/views/settings.html +++ b/src/app/settings/views/settings.html @@ -37,7 +37,7 @@
- User Image -