Revert settings screen menu to simple mode to allow extending it

This commit is contained in:
Arik Fraimovich 2016-10-09 13:15:02 +03:00
parent 14e024bca8
commit 459a25bedd
2 changed files with 16 additions and 46 deletions

View File

@ -120,36 +120,6 @@
}
});
directives.directive('rdTabs', ['$location', function ($location) {
return {
restrict: 'E',
scope: {
tabsCollection: '=',
selectedTab: '='
},
template: '<ul class="tab-nav bg-white"><li ng-class="{active: tab==selectedTab}" ng-repeat="tab in tabsCollection"><a href="{{basePath}}#{{tab.key}}">{{tab.name}}</a></li></ul>',
replace: true,
link: function ($scope, element, attrs) {
$scope.basePath = $location.path().substring(1);
$scope.selectTab = function (tabKey) {
$scope.selectedTab = _.find($scope.tabsCollection, function (tab) {
return tab.key == tabKey;
});
}
$scope.$watch(function () {
return $location.hash()
}, function (hash) {
if (hash) {
$scope.selectTab($location.hash());
} else {
$scope.selectTab($scope.tabsCollection[0].key);
}
});
}
}
}]);
// From: http://jsfiddle.net/joshdmiller/NDFHg/
directives.directive('editInPlace', function () {
return {
@ -484,22 +454,16 @@
transclude: true,
templateUrl: '/views/directives/settings_screen.html',
controller: ['$scope', function(scope) {
scope.tabs = [];
scope.usersPage = _.string.startsWith($location.path(), '/users');
scope.groupsPage = _.string.startsWith($location.path(), '/groups');
scope.dsPage = _.string.startsWith($location.path(), '/data_sources');
scope.destinationsPage = _.string.startsWith($location.path(), '/destinations');
scope.snippetsPage = _.string.startsWith($location.path(), '/query_snippets');
if (currentUser.hasPermission('admin')) {
scope.tabs.push({name: 'Data Sources', path: 'data_sources'});
}
if (currentUser.hasPermission('list_users')) {
scope.tabs.push({name: 'Users', path: 'users'});
scope.tabs.push({name: 'Groups', path: 'groups'});
}
if (currentUser.hasPermission('admin')) {
scope.tabs.push({name: 'Alert Destinations', path: 'destinations'});
}
scope.tabs.push({name: "Query Snippets", path: "query_snippets"});
scope.showGroupsLink = currentUser.hasPermission('list_users');
scope.showUsersLink = currentUser.hasPermission('list_users');
scope.showDsLink = currentUser.hasPermission('admin');
scope.showDestinationsLink = currentUser.hasPermission('admin');
}]
}
}]);

View File

@ -3,7 +3,13 @@
<div class="container">
<div class="container bg-white p-5">
<tab-nav tabs="tabs"></tab-nav>
<ul class="tab-nav">
<li ng-class="{'active': dsPage }" ng-if="showDsLink"><a href="data_sources">Data Sources</a></li>
<li ng-class="{'active': usersPage }" ng-if="showUsersLink"><a href="users">Users</a></li>
<li ng-class="{'active': groupsPage }" ng-if="showGroupsLink"><a href="groups">Groups</a></li>
<li ng-class="{'active': destinationsPage }" ng-if="showDestinationsLink"><a href="destinations">Alert Destinations</a></li>
<li ng-class="{'active': snippetsPage }"><a href="query_snippets">Query Snippets</a></li>
</ul>
<div ng-transclude>