54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
angular.module('warehost')
|
||
|
.controller('MailDomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http,$stateParams){
|
||
|
$scope.tableParams = new NgTableParams({
|
||
|
sorting: { 'name': 'asc' },
|
||
|
total: 0,
|
||
|
count: config.table.count
|
||
|
}, { dataset: [] });
|
||
|
alert.set({});
|
||
|
$scope.obj = {};
|
||
|
$scope.domain = {};
|
||
|
$scope.loginlist = [];
|
||
|
|
||
|
function resetObj(){
|
||
|
$scope.obj = {};
|
||
|
}
|
||
|
function load(){
|
||
|
$http.get(config.api+'/user').then(function(res){
|
||
|
$scope.loginlist = res.data.data;
|
||
|
$http.get(config.api+'/host/domain/'+$stateParams.domainid).then(function(res){
|
||
|
$scope.domain = res.data.data;
|
||
|
$http.get(config.api+'/host/domain/'+$stateParams.domainid+'/mail').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();
|
||
|
$rootScope.$on('warehost.session',load);
|
||
|
|
||
|
$scope.edit = function(a){
|
||
|
$http.patch(config.api+'/host/domain/'+$stateParams.domainid+'/mail/'+a.ID,a).then(submitresult);
|
||
|
};
|
||
|
$scope.delete = function(a){
|
||
|
$http.delete(config.api+'/host/domain/'+$stateParams.domainid+'/mail/'+a.ID).then(submitresult);
|
||
|
};
|
||
|
$scope.add = function(){
|
||
|
$http.post(config.api+'/host/domain/'+$stateParams.domainid+'/mail',$scope.obj).then(submitresult);
|
||
|
};
|
||
|
|
||
|
});
|