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-10-17 12:50:31 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('warehost')
|
2016-10-17 23:43:14 +02:00
|
|
|
.controller('DomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http){
|
2016-10-17 12:50:31 +02:00
|
|
|
$scope.tableParams = new NgTableParams({
|
|
|
|
sorting: { 'fqdn': 'asc' },
|
|
|
|
total: 0,
|
|
|
|
count: config.table.count
|
|
|
|
}, { dataset: [] });
|
|
|
|
alert.set({});
|
|
|
|
$scope.obj = {};
|
|
|
|
|
|
|
|
function resetObj(){
|
|
|
|
$scope.obj = {};
|
|
|
|
}
|
|
|
|
function load(){
|
|
|
|
$http.get(config.api+'/host/domain').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();
|
2016-10-17 23:43:14 +02:00
|
|
|
$rootScope.$on('warehost.session',load);
|
|
|
|
|
|
|
|
$scope.edit = function(a){
|
|
|
|
$http.patch(config.api+'/host/domain/'+a.ID,a).then(submitresult);
|
|
|
|
};
|
|
|
|
$scope.delete = function(a){
|
|
|
|
$http.delete(config.api+'/host/domain/'+a.ID).then(submitresult);
|
|
|
|
};
|
|
|
|
$scope.add = function(){
|
|
|
|
$http.post(config.api+'/host/domain',$scope.obj).then(submitresult);
|
|
|
|
};
|
2016-10-17 12:50:31 +02:00
|
|
|
|
|
|
|
});
|