From e1139d0fc0fe47ec113a2539bd16f3334ae1a857 Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Tue, 18 Oct 2016 20:33:55 +0200 Subject: [PATCH] [host] make domain and database admin accessable --- public/app/host/admin/database.jade | 29 ++++++++++++++++++ public/app/host/admin/database.js | 41 +++++++++++++++++++++++++ public/app/host/admin/domain.jade | 46 +++++++++++++++++++++++++++++ public/app/host/admin/domain.js | 42 ++++++++++++++++++++++++++ public/app/host/database.jade | 4 +-- public/app/host/domain.jade | 17 +++++++++-- public/app/host/index.js | 37 ++++++++++++++++++++++- public/app/host/menu.jade | 33 +++++++++++++++------ public/app/main.jade | 2 +- public/app/web/menu.jade | 41 ++++++++++++------------- public/index.html | 2 ++ 11 files changed, 258 insertions(+), 36 deletions(-) create mode 100644 public/app/host/admin/database.jade create mode 100644 public/app/host/admin/database.js create mode 100644 public/app/host/admin/domain.jade create mode 100644 public/app/host/admin/domain.js diff --git a/public/app/host/admin/database.jade b/public/app/host/admin/database.jade new file mode 100644 index 0000000..cbce563 --- /dev/null +++ b/public/app/host/admin/database.jade @@ -0,0 +1,29 @@ +.container + h1 Database + table.table.table-bordered(ng-table="tableParams") + tr(ng-hide='group.$hideRows',ng-repeat="item in $data") + td(data-title="'User'", filter="{'profil.login.username': 'text'}") {{item.profil.login.username}} + td(data-title="'Database/User'") + span(ng-if="!item.isEditing") warehost_user{{item.profil.ID}}_db{{item.ID}} + h4(ng-if="item.isEditing") Database: warehost_user{{item.profil.ID}}_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/admin/database.js b/public/app/host/admin/database.js new file mode 100644 index 0000000..6a19b39 --- /dev/null +++ b/public/app/host/admin/database.js @@ -0,0 +1,41 @@ +'use strict'; + +angular.module('warehost') + .controller('DatabaseAdminHostCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){ + $scope.tableParams = new NgTableParams({ + sorting: { 'ID': 'asc' }, + total: 0, + count: config.table.count + }, { dataset: [] }); + alert.set({}); + $scope.obj = {}; + + function resetObj(){ + $scope.obj = {}; + } + function load(){ + $http.get(config.api+'/host/database?filter=all').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(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); + }; + }); diff --git a/public/app/host/admin/domain.jade b/public/app/host/admin/domain.jade new file mode 100644 index 0000000..c7ba026 --- /dev/null +++ b/public/app/host/admin/domain.jade @@ -0,0 +1,46 @@ +.container + h1 Domains + table.table.table-bordered(ng-table="tableParams") + tr(ng-hide='group.$hideRows',ng-repeat="item in $data") + td(data-title="'User'", filter="{'profil.login.username': 'text'}") {{item.profil.login.username}} + td(data-title="'Domain'", filter="{'fqdn': 'text'}") + 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.active") + | Active + .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="'Active'", filter="{'active': 'components/ngfilter-boolean.html'}") + span.glyphicon.glyphicon-ok(aria-hidden="true",ng-if="item.active") + span.glyphicon.glyphicon-lock(aria-hidden="true",ng-if="!item.active") + td(data-title="'Funktions'") + a(ng-if="item.mail && !item.isEditing && item.active") + span.glyphicon.glyphicon-envelope(aria-hidden="true") + | Mail + |   + a(ng-if="item.web && !item.isEditing && item.active") + 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/admin/domain.js b/public/app/host/admin/domain.js new file mode 100644 index 0000000..a98ac91 --- /dev/null +++ b/public/app/host/admin/domain.js @@ -0,0 +1,42 @@ +'use strict'; + +angular.module('warehost') + .controller('DomainAdminHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http){ + $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?filter=all').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/'+a.ID,a).then(submitresult); + }; + $scope.delete = function(a){ + $http.delete(config.api+'/host/domain/'+a.ID).then(submitresult); + }; + + }); diff --git a/public/app/host/database.jade b/public/app/host/database.jade index d1e5861..456689a 100644 --- a/public/app/host/database.jade +++ b/public/app/host/database.jade @@ -15,8 +15,8 @@ table.table.table-bordered(ng-table="tableParams") 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}} + span(ng-if="!item.isEditing") warehost_user{{item.profil.ID}}_db{{item.ID}} + h4(ng-if="item.isEditing") Database: warehost_user{{item.profil.ID}}_db{{item.ID}} form(name="myform",ng-if="item.isEditing") .form-group label(for="password") Password diff --git a/public/app/host/domain.jade b/public/app/host/domain.jade index 8d33ffe..24b6544 100644 --- a/public/app/host/domain.jade +++ b/public/app/host/domain.jade @@ -6,6 +6,10 @@ .form-group label(for="domain") Domain input.form-control(id="domain",name="domain",ng-model="obj.fqdn",ng-minlength="3") + .form-group(ng-if="session.login.superadmin") + label + input(type="checkbox",ng-model="obj.active") + | Active .form-group label input(type="checkbox",ng-model="obj.web") @@ -19,13 +23,17 @@ | Save table.table.table-bordered(ng-table="tableParams") tr(ng-hide='group.$hideRows',ng-repeat="item in $data") - td(data-title="'Domain'") + td(data-title="'Domain'", filter="{'fqdn': 'text'}") 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(ng-if="session.login.superadmin") + label + input(type="checkbox",ng-model="item.active") + | Active .form-group label input(type="checkbox",ng-model="item.web") @@ -37,12 +45,15 @@ button.btn.btn-primary(type="submit",ng-click="edit(item)") span.glyphicon.glyphicon-floppy-disk | Save + td(data-title="'Active'", filter="{'active': 'components/ngfilter-boolean.html'}") + span.glyphicon.glyphicon-ok(aria-hidden="true",ng-if="item.active") + span.glyphicon.glyphicon-lock(aria-hidden="true",ng-if="!item.active") td(data-title="'Funktions'") - a(ng-if="item.mail && !item.isEditing") + a(ng-if="item.mail && !item.isEditing && item.active") span.glyphicon.glyphicon-envelope(aria-hidden="true") | Mail |   - a(ng-if="item.web && !item.isEditing") + a(ng-if="item.web && !item.isEditing && item.active") span.glyphicon.glyphicon-globe(aria-hidden="true") | Web td(data-title="'Option'") diff --git a/public/app/host/index.js b/public/app/host/index.js index 8fcef75..5fcb33d 100644 --- a/public/app/host/index.js +++ b/public/app/host/index.js @@ -1,4 +1,4 @@ -'use strict'; + 'use strict'; angular.module('warehost') .config(['$stateProvider',function ($stateProvider) { $stateProvider @@ -47,5 +47,40 @@ angular.module('warehost') controller:'DatabaseHostCtrl' } } + }) + .state('app.host.A', { + url:'/admin', + views:{ + '@app':{ + templateUrl: 'app/admin.html', + } + } + }) + .state('app.host.A.profil', { + url:'/profil', + views:{ + '@app':{ + templateUrl: 'app/host/admin/domain.html', + controller:'DomainAdminHostCtrl' + } + } + }) + .state('app.host.A.domain', { + url:'/domain', + views:{ + '@app':{ + templateUrl: 'app/host/admin/domain.html', + controller:'DomainAdminHostCtrl' + } + } + }) + .state('app.host.A.database', { + url:'/database', + views:{ + '@app':{ + templateUrl: 'app/host/admin/database.html', + controller:'DatabaseAdminHostCtrl' + } + } }); }]); diff --git a/public/app/host/menu.jade b/public/app/host/menu.jade index ff15e1c..d9b9706 100644 --- a/public/app/host/menu.jade +++ b/public/app/host/menu.jade @@ -1,9 +1,24 @@ -.navbar-text Hosting -li - a(ui-sref="app.host.index",ui-sref-active="active") Home -li(ng-if='!profil.ID') - a(ui-sref="app.host.signup",ui-sref-active="active") Signup -li(ng-if='profil.ID') - a(ui-sref="app.host.domain",ui-sref-active="active") Domains -li(ng-if='profil.ID') - a(ui-sref="app.host.database",ui-sref-active="active") Databases +ui.nav.navbar-nav + .navbar-text Hosting + li + a(ui-sref="app.host.index",ui-sref-active="active") Home + li(ng-if='!profil.ID') + a(ui-sref="app.host.signup",ui-sref-active="active") Signup + li(ng-if='profil.ID') + a(ui-sref="app.host.domain",ui-sref-active="active") Domains + li(ng-if='profil.ID') + a(ui-sref="app.host.database",ui-sref-active="active") Databases + +ui.nav.navbar-nav.navbar-right + li.dropdown(ng-if="session.login.superadmin") + a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false") + span.glyphicon.glyphicon-console + | Admin + span.caret + ul.dropdown-menu + li + a(ui-sref="app.host.A.profil") Profiles + li + a(ui-sref="app.host.A.domain") Domains + li + a(ui-sref="app.host.A.database") Databases diff --git a/public/app/main.jade b/public/app/main.jade index fde5cf3..a0e2f9f 100644 --- a/public/app/main.jade +++ b/public/app/main.jade @@ -10,7 +10,6 @@ span.icon-bar span.icon-bar .navbar-collapse.collapse(uib-collapse="!isOpen") - ui.nav.navbar-nav(ui-view="menu") ui.nav.navbar-nav.navbar-right(ng-if="session.login.active") li.dropdown(ng-if="modules.length>0") a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false") @@ -55,6 +54,7 @@ .input-group-btn button.btn.btn-default(type="submit") span.glyphicon.glyphicon-log-in + div(ui-view="menu") div(style="margin-top:53px;") .container(ng-if="error.msg") .alert.alert-danger(style="margin-top:20px;") {{error.msg}} diff --git a/public/app/web/menu.jade b/public/app/web/menu.jade index 5ccb7e3..3abef51 100644 --- a/public/app/web/menu.jade +++ b/public/app/web/menu.jade @@ -1,20 +1,21 @@ -.navbar-text Website -li.dropdown - a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false") {{website.name||'Websites'}} - span.caret - ul.dropdown-menu - li - a(ui-sref="app.web.index",ui-sref-active="active") Alle - li - a(href="",ng-click="add()") Add - li.dropdown-header Websites: - li(ng-repeat="item in list") - a(ui-sref="app.webS.page({websiteid:item.website.ID})") {{item.website.name}} -li(ng-if="website.name") - a(ui-sref="app.webS.menu({websiteid:website.ID})") Menu -li(ng-if="website.name") - a(ui-sref="app.webS.page({websiteid:website.ID})") Pages -li(ng-if="website.name") - a(ui-sref="app.webS.domain({websiteid:website.ID})") Domains -li(ng-if="website.name") - a(ui-sref="app.webS.permission({websiteid:website.ID})") Permissions +ui.nav.navbar-nav + .navbar-text Website + li.dropdown + a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false") {{website.name||'Websites'}} + span.caret + ul.dropdown-menu + li + a(ui-sref="app.web.index",ui-sref-active="active") Alle + li + a(href="",ng-click="add()") Add + li.dropdown-header Websites: + li(ng-repeat="item in list") + a(ui-sref="app.webS.page({websiteid:item.website.ID})") {{item.website.name}} + li(ng-if="website.name") + a(ui-sref="app.webS.menu({websiteid:website.ID})") Menu + li(ng-if="website.name") + a(ui-sref="app.webS.page({websiteid:website.ID})") Pages + li(ng-if="website.name") + a(ui-sref="app.webS.domain({websiteid:website.ID})") Domains + li(ng-if="website.name") + a(ui-sref="app.webS.permission({websiteid:website.ID})") Permissions diff --git a/public/index.html b/public/index.html index baeb535..01b036e 100644 --- a/public/index.html +++ b/public/index.html @@ -58,6 +58,8 @@ + +