organization pages and routing

This commit is contained in:
Kyle Spearrin 2017-03-03 21:53:02 -05:00
parent 4fdf2a98bf
commit 4d71a05d2a
13 changed files with 75 additions and 14 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
});
}
});

View File

@ -0,0 +1,6 @@
angular
.module('bit.organization')
.controller('organizationPeopleController', function ($scope) {
});

View File

@ -0,0 +1,16 @@
<section class="content-header">
<h1>
People
<small>users for your organization</small>
</h1>
</section>
<section class="content">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Users</h3>
</div>
<div class="box-body">
Some data
</div>
</div>
</section>

View File

@ -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' } },

View File

@ -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 () {

View File

@ -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 () {

View File

@ -37,7 +37,7 @@
</div>
<div class="col-sm-3 settings-photo">
<a href="http://www.gravatar.com/" target="_blank">
<img src="//www.gravatar.com/avatar/{{ main.userProfile.email | gravatar }}.jpg?s=150&d=mm"
<img src="//www.gravatar.com/avatar/{{ model.email | gravatar }}.jpg?s=150&d=mm"
class="img-rounded img-responsive" alt="User Image">
</a>
<a href="http://www.gravatar.com/" target="_blank" class="btn btn-link"

View File

@ -18,20 +18,30 @@
</nav>
</header>
<aside class="main-sidebar" ng-controller="sideNavController as sideNav">
<aside class="main-sidebar" ng-controller="sideNavController">
<section class="sidebar">
<div class="user-panel">
<div class="pull-left image">
<img src="//www.gravatar.com/avatar/{{ main.userProfile.email | gravatar }}.jpg?s=45&d=mm"
<img src="//www.gravatar.com/avatar/{{ orgProfile.name | gravatar }}.jpg?s=45&d=mm"
class="img-circle" alt="User Image">
</div>
<div class="pull-left info">
<p>{{main.userProfile.extended && main.userProfile.extended.name ? main.userProfile.extended.name : main.userProfile.email}}</p>
<p>{{orgProfile.name}}</p>
<a ui-sref="frontend.logout">Log Out</a>
</div>
</div>
<ul class="sidebar-menu">
<li class="header">ORG</li>
<li class="header">MY ORGANIZATION</li>
<li ng-class="{active: $state.is('backend.org.dashboard')}">
<a ui-sref="backend.org.dashboard({orgId: params.orgId})">
<i class="fa fa-dashboard fa-fw"></i> <span>Dashboard</span>
</a>
</li>
<li ng-class="{active: $state.is('backend.org.people')}">
<a ui-sref="backend.org.people({orgId: params.orgId})">
<i class="fa fa-users fa-fw"></i> <span>People</span>
</a>
</li>
</ul>
</section>
</aside>

View File

@ -22,11 +22,11 @@
<section class="sidebar">
<div class="user-panel">
<div class="pull-left image">
<img src="//www.gravatar.com/avatar/{{ main.userProfile.email | gravatar }}.jpg?s=45&d=mm"
<img src="//www.gravatar.com/avatar/{{ userProfile.email | gravatar }}.jpg?s=45&d=mm"
class="img-circle" alt="User Image">
</div>
<div class="pull-left info">
<p>{{main.userProfile.extended && main.userProfile.extended.name ? main.userProfile.extended.name : main.userProfile.email}}</p>
<p>{{userProfile.extended && userProfile.extended.name ? userProfile.extended.name : userProfile.email}}</p>
<a ui-sref="frontend.logout">Log Out</a>
</div>
</div>

View File

@ -122,6 +122,7 @@
<script src="app/organization/organizationModule.js"></script>
<script src="app/organization/organizationDashboardController.js"></script>
<script src="app/organization/organizationPeopleController.js"></script>
<script src="app/settings/settingsModule.js"></script>
<script src="app/settings/settingsController.js"></script>