sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
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.
warehost-frontend/public/app/host/mail.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-10-22 21:34:20 +02:00
'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);
};
2016-11-17 23:16:35 +01:00
$scope.newMail = function(to){
if(/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(to)){
return {
ID: null,
mail: null,
to: to
};
}
return null;
};
2016-10-22 21:34:20 +02:00
});