This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2016-09-11 18:40:03 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('warehost')
|
|
|
|
.controller('PermissionWebCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){
|
|
|
|
$scope.tableParams = new NgTableParams({
|
2016-10-17 12:50:31 +02:00
|
|
|
sorting: { 'login.username': 'asc' },
|
2016-09-11 18:40:03 +02:00
|
|
|
total: 0,
|
|
|
|
count: config.table.count
|
|
|
|
}, { dataset: [] });
|
|
|
|
alert.set({});
|
|
|
|
$scope.obj = {};
|
|
|
|
$scope.loginlist = [];
|
|
|
|
|
|
|
|
function resetObj(){
|
|
|
|
$scope.obj = {};
|
|
|
|
}
|
|
|
|
function load(){
|
2016-10-11 20:50:30 +02:00
|
|
|
$http.get(config.api+'/user').then(function(res){
|
2016-09-11 18:40:03 +02:00
|
|
|
$scope.loginlist = res.data.data;
|
|
|
|
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/permission').then(function(res){
|
|
|
|
session.set(res);
|
|
|
|
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function submitresult(res){
|
|
|
|
session.set(res);
|
|
|
|
alert.set(res);
|
|
|
|
if(res.data.data){
|
|
|
|
resetObj();
|
|
|
|
$scope.isAdding = false;
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resetObj();
|
|
|
|
load();
|
|
|
|
|
|
|
|
$scope.delete = function(a){
|
|
|
|
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+a.login.ID).then(submitresult);
|
|
|
|
};
|
|
|
|
$scope.add = function(){
|
|
|
|
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+$scope.obj.login.ID,{}).then(submitresult);
|
|
|
|
};
|
|
|
|
});
|