43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
angular.module('warehost')
|
||
|
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
|
||
|
$scope.tableParams = new NgTableParams({
|
||
|
sorting: { 'invited.username': 'asc' },
|
||
|
total: 0,
|
||
|
count: config.table.count
|
||
|
}, { dataset: [] });
|
||
|
alert.set({});
|
||
|
$scope.obj = {};
|
||
|
|
||
|
function resetObj(){
|
||
|
$scope.obj = {};
|
||
|
}
|
||
|
function load(){
|
||
|
$http.get(config.api+'/web/'+$stateParams.websiteid+'/page').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;
|
||
|
}
|
||
|
}
|
||
|
resetObj();
|
||
|
load();
|
||
|
|
||
|
$scope.edit = function(a){
|
||
|
$http.put(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID,a.website).then(submitresult);
|
||
|
};
|
||
|
$scope.delete = function(a){
|
||
|
$http.delete(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID).then(submitresult);
|
||
|
};
|
||
|
$scope.add = function(){
|
||
|
$http.post(config.api+'/web/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
|
||
|
};
|
||
|
});
|