From bd2f5b6698934c5dde5277db63931c663ac53b3f Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Mon, 17 Oct 2016 23:43:14 +0200 Subject: [PATCH] [host] add modify and delete of database and domain --- public/app/host/database.jade | 22 ++++++++++++++++++++-- public/app/host/database.js | 12 +++++++++++- public/app/host/domain.jade | 32 ++++++++++++++++++++++++++++++-- public/app/host/domain.js | 13 ++++++++++++- public/app/host/menu.js | 3 ++- public/app/invite.js | 7 ++++--- public/app/user.js | 5 +++-- public/app/web/domain.js | 3 ++- public/app/web/list.js | 3 ++- public/app/web/menu.js | 1 + public/app/web/page.js | 3 ++- public/app/web/permission.js | 3 ++- public/app/web/webmenu.js | 7 ++++--- public/components/session.js | 4 ++++ 14 files changed, 99 insertions(+), 19 deletions(-) diff --git a/public/app/host/database.jade b/public/app/host/database.jade index bbfedbc..d1e5861 100644 --- a/public/app/host/database.jade +++ b/public/app/host/database.jade @@ -4,8 +4,11 @@ span.glyphicon.glyphicon-plus form.well(ng-submit="add()",name="addform",ng-if="isAdding") .form-group - label(for="domain") Domain - input.form-control(id="domain",name="domain",ng-model="obj.domain",ng-minlength="3") + label(for="password") Password + input.form-control(id="password",name="password",ng-model="obj.password",ng-minlength="3") + .form-group + label(for="comment") Comment + input.form-control(id="comment",name="comment",ng-model="obj.comment") button.btn.btn-primary(type="submit") span.glyphicon.glyphicon-floppy-disk | Save @@ -13,10 +16,25 @@ tr(ng-hide='group.$hideRows',ng-repeat="item in $data") td(data-title="'Database/User'") span(ng-if="!item.isEditing") warehost_user{{item.profil}}_db{{item.ID}} + h4(ng-if="item.isEditing") Database: warehost_user{{item.profil}}_db{{item.ID}} + form(name="myform",ng-if="item.isEditing") + .form-group + label(for="password") Password + input.form-control(id="password",name="password",ng-model="item.password",ng-minlength="3") + .form-group + label(for="comment") Comment + input.form-control(id="comment",name="comment",ng-model="item.comment") + button.btn.btn-primary(type="submit",ng-click="edit(item)") + span.glyphicon.glyphicon-floppy-disk + | Save td(data-title="'Kommentar'") span.glyphicon.glyphicon-lock(ng-if="item.password") span(ng-if="!item.isEditing") {{item.comment}} td(data-title="'Option'") .btn-group.btn-group-xs + span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing") + span.glyphicon.glyphicon-pencil + span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing") + span.glyphicon.glyphicon-remove-circle span.btn.btn-default(ng-click="delete(item)") span.glyphicon.glyphicon-trash diff --git a/public/app/host/database.js b/public/app/host/database.js index 2559453..94c7ea8 100644 --- a/public/app/host/database.js +++ b/public/app/host/database.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('DatabaseHostCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){ + .controller('DatabaseHostCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){ $scope.tableParams = new NgTableParams({ sorting: { 'ID': 'asc' }, total: 0, @@ -30,5 +30,15 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); + $scope.edit = function(obj){ + $http.patch(config.api+'/host/database/'+obj.ID,obj).then(submitresult); + }; + $scope.delete = function(obj){ + $http.delete(config.api+'/host/database/'+obj.ID).then(submitresult); + }; + $scope.add = function(){ + $http.post(config.api+'/host/database',$scope.obj).then(submitresult); + }; }); diff --git a/public/app/host/domain.jade b/public/app/host/domain.jade index fecf50b..8d33ffe 100644 --- a/public/app/host/domain.jade +++ b/public/app/host/domain.jade @@ -6,6 +6,14 @@ .form-group label(for="domain") Domain input.form-control(id="domain",name="domain",ng-model="obj.fqdn",ng-minlength="3") + .form-group + label + input(type="checkbox",ng-model="obj.web") + | Web + .form-group + label + input(type="checkbox",ng-model="obj.mail") + | Mail button.btn.btn-primary(type="submit") span.glyphicon.glyphicon-floppy-disk | Save @@ -13,15 +21,35 @@ tr(ng-hide='group.$hideRows',ng-repeat="item in $data") td(data-title="'Domain'") span(ng-if="!item.isEditing") {{item.fqdn}} + h4(ng-if="item.isEditing") Domain: {{item.fqdn}} + form(name="myform",ng-if="item.isEditing") + .form-group + label(for="domain") Domain + input.form-control(id="domain",name="domain",ng-model="item.fqdn",ng-minlength="3") + .form-group + label + input(type="checkbox",ng-model="item.web") + | Web + .form-group + label + input(type="checkbox",ng-model="item.mail") + | Mail + button.btn.btn-primary(type="submit",ng-click="edit(item)") + span.glyphicon.glyphicon-floppy-disk + | Save td(data-title="'Funktions'") - a(ng-if="item.mail") + a(ng-if="item.mail && !item.isEditing") span.glyphicon.glyphicon-envelope(aria-hidden="true") | Mail |   - a(ng-if="item.web") + a(ng-if="item.web && !item.isEditing") span.glyphicon.glyphicon-globe(aria-hidden="true") | Web td(data-title="'Option'") .btn-group.btn-group-xs + span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing") + span.glyphicon.glyphicon-pencil + span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing") + span.glyphicon.glyphicon-remove-circle span.btn.btn-default(ng-click="delete(item)") span.glyphicon.glyphicon-trash diff --git a/public/app/host/domain.js b/public/app/host/domain.js index 9bac7ad..2e29e8b 100644 --- a/public/app/host/domain.js +++ b/public/app/host/domain.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('DomainHostCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){ + .controller('DomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http){ $scope.tableParams = new NgTableParams({ sorting: { 'fqdn': 'asc' }, total: 0, @@ -30,5 +30,16 @@ angular.module('warehost') } resetObj(); load(); + $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); + }; }); diff --git a/public/app/host/menu.js b/public/app/host/menu.js index 54f95cf..bb5fc5a 100644 --- a/public/app/host/menu.js +++ b/public/app/host/menu.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('MenuHostCtrl',function(session,config,alert,$scope,$http){ + .controller('MenuHostCtrl',function(session,config,alert,$scope,$rootScope,$http){ $scope.profil = {}; alert.set({}); function load(){ @@ -11,5 +11,6 @@ angular.module('warehost') }); } load(); + $rootScope.$on('warehost.session',load); }); diff --git a/public/app/invite.js b/public/app/invite.js index 17cf03f..62693d2 100644 --- a/public/app/invite.js +++ b/public/app/invite.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('InviteCtrl',function(session,config,alert,NgTableParams,$scope,$http){ + .controller('InviteCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){ $scope.tableParams = new NgTableParams({ sorting: { 'invited.username': 'asc' }, total: 0, @@ -39,10 +39,11 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $scope.edit = function(a){ a.invited.password = a.newPassword; - $http.put(config.api+'/user/'+a.invited.ID,a.invited).then(submitresult); + $http.patch(config.api+'/user/'+a.invited.ID,a.invited).then(submitresult); }; $scope.delete = function(a){ $http.delete(config.api+'/user/'+a.invited.ID).then(submitresult); @@ -51,6 +52,6 @@ angular.module('warehost') $http.post(config.api+'/invite',$scope.obj).then(submitresult); }; $scope.toggleAdmin = function(){ - $http.put(config.api+'/invitor').then(submitresult); + $http.patch(config.api+'/invitor').then(submitresult); }; }); diff --git a/public/app/user.js b/public/app/user.js index 7ea6a7e..1737ac8 100644 --- a/public/app/user.js +++ b/public/app/user.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('UserCtrl',function(session,config,alert,NgTableParams,$scope,$http){ + .controller('UserCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){ $scope.tableParams = new NgTableParams({ sorting: { 'invited.username': 'asc' }, total: 0, @@ -31,10 +31,11 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $scope.edit = function(a){ a.password = a.newPassword; - $http.put(config.api+'/user/'+a.ID,a).then(submitresult); + $http.patch(config.api+'/user/'+a.ID,a).then(submitresult); }; $scope.delete = function(a){ $http.delete(config.api+'/user/'+a.ID).then(submitresult); diff --git a/public/app/web/domain.js b/public/app/web/domain.js index 8fa8007..d89339e 100644 --- a/public/app/web/domain.js +++ b/public/app/web/domain.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('DomainWebCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){ + .controller('DomainWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){ $scope.tableParams = new NgTableParams({ total: 0, count: config.table.count @@ -29,6 +29,7 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $scope.delete = function(a){ $http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/domain/'+a.name).then(submitresult); diff --git a/public/app/web/list.js b/public/app/web/list.js index 6cf0475..8ee0e4e 100644 --- a/public/app/web/list.js +++ b/public/app/web/list.js @@ -30,10 +30,11 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $rootScope.$on('warehost.web.website.update',load); $scope.edit = function(a){ - $http.put(config.api+'/web/website/'+a.website.ID,a.website).then(submitresult); + $http.patch(config.api+'/web/website/'+a.website.ID,a.website).then(submitresult); }; $scope.delete = function(a){ $http.delete(config.api+'/web/website/'+a.website.ID).then(submitresult); diff --git a/public/app/web/menu.js b/public/app/web/menu.js index 891a6a8..77bb52a 100644 --- a/public/app/web/menu.js +++ b/public/app/web/menu.js @@ -19,6 +19,7 @@ angular.module('warehost') }); } load(); + $rootScope.$on('warehost.session',load); $rootScope.$on('warehost.web.website.update',load); $scope.add = function(){ $http.post(config.api+'/web/website',{name:window.prompt('Name:')}).then(function(res){ diff --git a/public/app/web/page.js b/public/app/web/page.js index 97e4f11..9184e7a 100644 --- a/public/app/web/page.js +++ b/public/app/web/page.js @@ -28,6 +28,7 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $scope.edit = function(a){ $scope.obj = a; @@ -37,7 +38,7 @@ angular.module('warehost') }; $scope.save = function(){ if($scope.obj.ID){ - $http.put(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult); + $http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult); }else{ $http.post(config.api+'/web/website/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult); } diff --git a/public/app/web/permission.js b/public/app/web/permission.js index 270c9d7..2aeb89b 100644 --- a/public/app/web/permission.js +++ b/public/app/web/permission.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('PermissionWebCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){ + .controller('PermissionWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){ $scope.tableParams = new NgTableParams({ sorting: { 'login.username': 'asc' }, total: 0, @@ -34,6 +34,7 @@ angular.module('warehost') } resetObj(); load(); + $rootScope.$on('warehost.session',load); $scope.delete = function(a){ $http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+a.login.ID).then(submitresult); diff --git a/public/app/web/webmenu.js b/public/app/web/webmenu.js index 5a0546c..4e035d5 100644 --- a/public/app/web/webmenu.js +++ b/public/app/web/webmenu.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('warehost') - .controller('WebmenuWebCtrl',function(session,config,alert,$scope,$stateParams,$http){ + .controller('WebmenuWebCtrl',function(session,config,alert,$scope,$rootScope,$stateParams,$http){ $scope.data = []; alert.set({}); @@ -23,7 +23,7 @@ angular.module('warehost') }else{ $scope.obj.parentid = {Int64: 0, Valid: false}; } - $http.put(config.api+'/web/website/'+$stateParams.websiteid+'/menu/'+$scope.obj.ID,$scope.obj).then(submitresult); + $http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/menu/'+$scope.obj.ID,$scope.obj).then(submitresult); } }; @@ -41,13 +41,14 @@ angular.module('warehost') } } load(); + $rootScope.$on('warehost.session',load); $scope.edit = function(a){ $scope.obj = a.$modelValue; }; $scope.save = function(){ if($scope.obj.ID){ - $http.put(config.api+'/web/website/'+$stateParams.websiteid+'/menu/'+$scope.obj.ID,$scope.obj).then(submitresult); + $http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/menu/'+$scope.obj.ID,$scope.obj).then(submitresult); }else{ $http.post(config.api+'/web/website/'+$stateParams.websiteid+'/menu',$scope.obj).then(submitresult); } diff --git a/public/components/session.js b/public/components/session.js index 7484f70..7841a57 100644 --- a/public/components/session.js +++ b/public/components/session.js @@ -6,6 +6,10 @@ angular.module('session', []) return $rootScope.session; }, set: function (res){ + /* + if($rootScope.session != undefined && $rootScope.session.profil == undefined && res.data.session != undefined){ + $rootScope.$broadcast('warehost.session'); + }*/ $rootScope.session = res.data.session; } };