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/web/page.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-09-11 18:40:03 +02:00
'use strict';
angular.module('warehost')
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
2016-09-27 11:44:48 +02:00
$scope.data = [];
2016-09-11 18:40:03 +02:00
alert.set({});
$scope.obj = {};
function resetObj(){
$scope.obj = {};
}
function load(){
2017-02-26 15:48:12 +01:00
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){
session.set(res);
$scope.data = res.data.data;
2016-09-11 18:40:03 +02:00
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
2016-09-27 11:44:48 +02:00
load();
2016-09-11 18:40:03 +02:00
}
}
resetObj();
load();
$rootScope.$on('warehost.session',load);
2016-09-11 18:40:03 +02:00
$scope.edit = function(a){
2016-09-27 11:44:48 +02:00
$scope.obj = a;
2016-09-11 18:40:03 +02:00
};
$scope.add = function(){
2016-09-27 11:44:48 +02:00
$scope.obj = {};
2016-10-11 20:50:30 +02:00
};
2016-09-27 11:44:48 +02:00
$scope.save = function(){
if($scope.obj.ID){
$http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult);
2016-09-27 11:44:48 +02:00
}else{
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
}
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+a.ID).then(submitresult);
2016-09-11 18:40:03 +02:00
};
});