##// END OF EJS Templates
utils: added get_es_info function
utils: added get_es_info function

File last commit:

r149:d50fb8e1
r159:61d79e6b
Show More
admin-groups-create-view.js
146 lines | 5.1 KiB | application/javascript | JavascriptLexer
license: change the license to Apache 2.0
r112 // Copyright 2010 - 2017 RhodeCode GmbH and the AppEnlight project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
project: initial commit
r0
components: admin panel componentized
r85 angular.module('appenlight.components.adminGroupsCreateView', [])
.component('adminGroupsCreateView', {
templateUrl: 'components/views/admin-groups-create-view/admin-groups-create-view.html',
controller: AdminGroupsCreateViewController
});
project: initial commit
r0
components: admin panel componentized
r85 AdminGroupsCreateViewController.$inject = ['$state', 'groupsResource', 'groupsPropertyResource', 'sectionViewResource'];
project: initial commit
r0
components: admin panel componentized
r85 function AdminGroupsCreateViewController($state, groupsResource, groupsPropertyResource, sectionViewResource) {
project: initial commit
r0 console.debug('AdminGroupsCreateController');
var vm = this;
frontend: angular 1.7.7
r147 vm.$onInit = function () {
vm.$state = $state;
vm.loading = {
group: false,
resource_permissions: false,
users: false
};
project: initial commit
r0
frontend: angular 1.7.7
r147 vm.form = {
autocompleteUser: '',
}
project: initial commit
r0
frontend: angular 1.7.7
r147 if (typeof $state.params.groupId !== 'undefined') {
vm.loading.group = true;
var groupId = $state.params.groupId;
vm.group = groupsResource.get({groupId: groupId}, function (data) {
vm.loading.group = false;
});
project: initial commit
r0
frontend: angular 1.7.7
r147 vm.resource_permissions = groupsPropertyResource.query(
{groupId: groupId, key: 'resource_permissions'}, function (data) {
vm.loading.resource_permissions = false;
var tmpObj = {
'group': {
'application': {},
'dashboard': {}
}
};
_.each(data, function (item) {
console.log(item);
var section = tmpObj[item.type][item.resource_type];
if (typeof section[item.resource_id] == 'undefined') {
section[item.resource_id] = {
self: item,
permissions: []
}
project: initial commit
r0 }
frontend: angular 1.7.7
r147 section[item.resource_id].permissions.push(item.perm_name);
project: initial commit
r0
frontend: angular 1.7.7
r147 });
console.log(tmpObj)
vm.resourcePermissions = tmpObj;
project: initial commit
r0 });
frontend: angular 1.7.7
r147 vm.users = groupsPropertyResource.query(
{groupId: groupId, key: 'users'}, function (data) {
vm.loading.users = false;
}, function () {
vm.loading.users = false;
});
} else {
var groupId = null;
}
project: initial commit
r0
}
var formResponse = function (response) {
if (response.status === 422) {
setServerValidation(vm.groupForm, response.data);
}
vm.loading.group = false;
};
vm.createGroup = function () {
vm.loading.group = true;
frontend: fixes
r149 var groupId = $state.params.groupId;
project: initial commit
r0 if (groupId) {
groupsResource.update({groupId: vm.group.id}, vm.group, function (data) {
setServerValidation(vm.groupForm);
vm.loading.group = false;
}, formResponse);
frontend: angular 1.7.7
r147 } else {
project: initial commit
r0 groupsResource.save(vm.group, function (data) {
$state.go('admin.group.update', {groupId: data.id});
}, formResponse);
}
};
vm.removeUser = function (user) {
frontend: fixes
r149 var groupId = $state.params.groupId;
project: initial commit
r0 groupsPropertyResource.delete(
{groupId: groupId, key: 'users', user_name: user.user_name},
function (data) {
vm.loading.users = false;
vm.users = _.filter(vm.users, function (item) {
return item != user;
});
}, function () {
vm.loading.users = false;
});
};
vm.addUser = function () {
frontend: fixes
r149 var groupId = $state.params.groupId;
project: initial commit
r0 groupsPropertyResource.save(
{groupId: groupId, key: 'users'},
{user_name: vm.form.autocompleteUser},
function (data) {
vm.loading.users = false;
vm.users.push(data);
vm.form.autocompleteUser = '';
}, function () {
vm.loading.users = false;
});
}
vm.searchUsers = function (searchPhrase) {
console.log(searchPhrase);
return sectionViewResource.query({
section: 'users_section',
view: 'search_users',
'user_name': searchPhrase
}).$promise.then(function (data) {
frontend: angular 1.7.7
r147 return _.map(data, function (item) {
return item.user;
project: initial commit
r0 });
frontend: angular 1.7.7
r147 });
project: initial commit
r0 }
};