##// END OF EJS Templates
uptime: rename es indices
uptime: rename es indices

File last commit:

r149:d50fb8e1
r169:9a712c12
Show More
admin-users-create-view.js
123 lines | 4.5 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.adminUsersCreateView', [])
.component('adminUsersCreateView', {
templateUrl: 'components/views/admin-users-create-view/admin-users-create-view.html',
controller: AdminUsersCreateViewController
});
project: initial commit
r0
components: admin panel componentized
r85 AdminUsersCreateViewController.$inject = ['$state', 'usersResource', 'usersPropertyResource', 'sectionViewResource', 'AeConfig'];
project: initial commit
r0
components: admin panel componentized
r85 function AdminUsersCreateViewController($state, usersResource, usersPropertyResource, sectionViewResource, AeConfig) {
console.debug('AdminUsersCreateViewController');
project: initial commit
r0 var vm = this;
frontend: angular 1.7.7
r147 vm.$onInit = function () {
vm.$state = $state;
vm.loading = {user: false};
project: initial commit
r0
frontend: angular 1.7.7
r147 if (typeof $state.params.userId !== 'undefined') {
vm.loading.user = true;
var userId = $state.params.userId;
vm.user = usersResource.get({userId: userId}, function (data) {
vm.loading.user = false;
// cast to true for angular checkbox
if (vm.user.status === 1) {
vm.user.status = true;
}
});
project: initial commit
r0
frontend: angular 1.7.7
r147 vm.resource_permissions = usersPropertyResource.query(
{userId: userId, key: 'resource_permissions'}, function (data) {
vm.loading.resource_permissions = false;
var tmpObj = {
'user': {
'application': {},
'dashboard': {}
},
'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 } else {
var userId = null;
vm.user = {
status: true
}
project: initial commit
r0 }
}
var formResponse = function (response) {
if (response.status == 422) {
setServerValidation(vm.profileForm, response.data);
}
vm.loading.user = false;
}
vm.createUser = function () {
vm.loading.user = true;
console.log('updateProfile');
frontend: fixes
r149 var userId = $state.params.userId;
project: initial commit
r0 if (userId) {
usersResource.update({userId: vm.user.id}, vm.user, function (data) {
setServerValidation(vm.profileForm);
vm.loading.user = false;
}, formResponse);
}
else {
usersResource.save(vm.user, function (data) {
$state.go('admin.user.update', {userId: data.id});
}, formResponse);
}
}
vm.generatePassword = function () {
var length = 8;
var charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
vm.gen_pass = "";
for (var i = 0, n = charset.length; i < length; ++i) {
vm.gen_pass += charset.charAt(Math.floor(Math.random() * n));
}
vm.user.user_password = '' + vm.gen_pass;
console.log('x', vm.gen_pass);
}
vm.reloginUser = function () {
sectionViewResource.get({
section: 'admin_section', view: 'relogin_user',
user_id: vm.user.id
}, function () {
window.location = AeConfig.urls.baseUrl;
});
}
};