From 822e7fe3fefd542d2f650164c086ca12b875b429 Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Sat, 22 Oct 2016 21:34:20 +0200 Subject: [PATCH] [host] add web and mail --- public/app/app.styl | 2 +- public/app/host/admin/domain.jade | 5 +- public/app/host/domain.jade | 5 +- public/app/host/index.js | 18 +++++++ public/app/host/mail.jade | 47 ++++++++++++++++++ public/app/host/mail.js | 53 +++++++++++++++++++++ public/app/host/web.jade | 79 +++++++++++++++++++++++++++++++ public/app/host/web.js | 49 +++++++++++++++++++ public/app/user.jade | 7 +++ public/index.html | 4 +- 10 files changed, 261 insertions(+), 8 deletions(-) create mode 100644 public/app/host/mail.jade create mode 100644 public/app/host/mail.js create mode 100644 public/app/host/web.jade create mode 100644 public/app/host/web.js diff --git a/public/app/app.styl b/public/app/app.styl index 1082a0c..469f2e9 100644 --- a/public/app/app.styl +++ b/public/app/app.styl @@ -1,5 +1,5 @@ .navbar-brand - padding 13.5px 15px 12.5px + padding 4.5px 15px 2.5px > img display inline diff --git a/public/app/host/admin/domain.jade b/public/app/host/admin/domain.jade index c7ba026..1e7d0b7 100644 --- a/public/app/host/admin/domain.jade +++ b/public/app/host/admin/domain.jade @@ -29,11 +29,10 @@ 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") + a(ng-if="item.mail && !item.isEditing && item.active",ui-sref="app.host.mail({domainid:item.ID})") span.glyphicon.glyphicon-envelope(aria-hidden="true") | Mail - |   - a(ng-if="item.web && !item.isEditing && item.active") + a(ng-if="item.web && !item.isEditing && item.active",ui-sref="app.host.web({domainid:item.ID})") span.glyphicon.glyphicon-globe(aria-hidden="true") | Web td(data-title="'Option'") diff --git a/public/app/host/domain.jade b/public/app/host/domain.jade index 24b6544..947bb06 100644 --- a/public/app/host/domain.jade +++ b/public/app/host/domain.jade @@ -49,11 +49,10 @@ 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") + a(ng-if="item.mail && !item.isEditing && item.active",ui-sref="app.host.mail({domainid:item.ID})") span.glyphicon.glyphicon-envelope(aria-hidden="true") | Mail - |   - a(ng-if="item.web && !item.isEditing && item.active") + a(ng-if="item.web && !item.isEditing && item.active",ui-sref="app.host.web({domainid:item.ID})") 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 391042a..c351b71 100644 --- a/public/app/host/index.js +++ b/public/app/host/index.js @@ -39,6 +39,24 @@ angular.module('warehost') } } }) + .state('app.host.web', { + url:'/domain/:domainid/web', + views:{ + '@app':{ + templateUrl: 'app/host/web.html', + controller:'WebDomainHostCtrl' + } + } + }) + .state('app.host.mail', { + url:'/domain/:domainid/mail', + views:{ + '@app':{ + templateUrl: 'app/host/mail.html', + controller:'MailDomainHostCtrl' + } + } + }) .state('app.host.database', { url:'/database', views:{ diff --git a/public/app/host/mail.jade b/public/app/host/mail.jade new file mode 100644 index 0000000..0d03006 --- /dev/null +++ b/public/app/host/mail.jade @@ -0,0 +1,47 @@ +.container + h1 Mail + a.btn.btn-default(ng-click="isAdding=true") + span.glyphicon.glyphicon-plus + form.well(ng-submit="add()",name="addform",ng-if="isAdding") + .form-group + label(for="name") Name + .input-group + input.form-control(id="name",name="name",ng-model="obj.name") + span.input-group-addon @{{domain.fqdn}} + .form-group + ui-select(ng-model="obj.login",theme="bootstrap") + ui-select-match {{$select.selected.username}} + ui-select-choices(repeat="item in loginlist | filter: $select.search") + div(ng-bind-html="item.username | highlight: $select.search") + button.btn.btn-primary(type="submit") + span.glyphicon.glyphicon-floppy-disk + | Save + table.table.table-bordered(ng-table="tableParams") + tr(ng-hide='group.$hideRows',ng-repeat="item in $data") + td(data-title="'Mail-Adresse'") + span(ng-if="!item.isEditing") {{item.name}}@{{item.domain.fqdn}} + h4(ng-if="item.isEditing") {{item.name}}@{{item.domain.fqdn}} + form(name="myform",ng-if="item.isEditing") + .form-group + label(for="name") Name + .input-group + input.form-control(id="name",name="name",ng-model="item.name") + span.input-group-addon @{{item.domain.fqdn}} + .form-group + ui-select(ng-model="item.login",theme="bootstrap") + ui-select-match {{$select.selected.username}} + ui-select-choices(repeat="i in loginlist | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") + button.btn.btn-primary(type="submit",ng-click="edit(item)") + span.glyphicon.glyphicon-floppy-disk + | Save + td(data-title="'Postfach'") + span(ng-repeat="i in loginlist",ng-if="i.ID == item.login.Int64") {{i.username}} + 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/mail.js b/public/app/host/mail.js new file mode 100644 index 0000000..242afb5 --- /dev/null +++ b/public/app/host/mail.js @@ -0,0 +1,53 @@ +'use strict'; + +angular.module('warehost') + .controller('MailDomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http,$stateParams){ + $scope.tableParams = new NgTableParams({ + sorting: { 'name': 'asc' }, + total: 0, + count: config.table.count + }, { dataset: [] }); + alert.set({}); + $scope.obj = {}; + $scope.domain = {}; + $scope.loginlist = []; + + function resetObj(){ + $scope.obj = {}; + } + function load(){ + $http.get(config.api+'/user').then(function(res){ + $scope.loginlist = res.data.data; + $http.get(config.api+'/host/domain/'+$stateParams.domainid).then(function(res){ + $scope.domain = res.data.data; + $http.get(config.api+'/host/domain/'+$stateParams.domainid+'/mail').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/'+$stateParams.domainid+'/mail/'+a.ID,a).then(submitresult); + }; + $scope.delete = function(a){ + $http.delete(config.api+'/host/domain/'+$stateParams.domainid+'/mail/'+a.ID).then(submitresult); + }; + $scope.add = function(){ + $http.post(config.api+'/host/domain/'+$stateParams.domainid+'/mail',$scope.obj).then(submitresult); + }; + + }); diff --git a/public/app/host/web.jade b/public/app/host/web.jade new file mode 100644 index 0000000..2b7121e --- /dev/null +++ b/public/app/host/web.jade @@ -0,0 +1,79 @@ +.container + h1 Web + a.btn.btn-default(ng-click="isAdding=true") + span.glyphicon.glyphicon-plus + form.well(ng-submit="add()",name="addform",ng-if="isAdding") + .form-group + label(for="subdomain") Subdomain + .input-group + input.form-control(id="subdomain",name="subdomain",ng-model="obj.subdomain") + span.input-group-addon .{{domain.fqdn}} + .form-group + label + input(type="checkbox",ng-model="obj.php") + | PHP + .form-group + label + input(type="checkbox",ng-model="obj.ssl") + | SSL + .form-group + label + input(type="checkbox",ng-model="obj.sslredirect") + | SSL-Redirect + .form-group + label(for="redirect") Redirect + input.form-control(id="redirect",name="redirect",ng-model="obj.redirect") + .form-group + label(for="proxy") Proxy + input.form-control(id="proxy",name="proxy",ng-model="obj.proxy") + button.btn.btn-primary(type="submit") + span.glyphicon.glyphicon-floppy-disk + | Save + table.table.table-bordered(ng-table="tableParams") + tr(ng-hide='group.$hideRows',ng-repeat="item in $data") + td(data-title="'Domain'") + span(ng-if="!item.isEditing") + span(ng-if="item.subdomain != ''") {{item.subdomain}}. + | {{item.domain.fqdn}} + h4(ng-if="item.isEditing") {{item.subdomain}}.{{item.domain.fqdn}} + form(name="myform",ng-if="item.isEditing") + .form-group + label(for="subdomain") Subdomain + .input-group + input.form-control(id="subdomain",name="subdomain",ng-model="item.subdomain") + span.input-group-addon .{{item.domain.fqdn}} + .form-group + label + input(type="checkbox",ng-model="item.php") + | PHP + .form-group + label + input(type="checkbox",ng-model="item.ssl") + | SSL + .form-group + label + input(type="checkbox",ng-model="item.sslredirect") + | SSL-Redirect + .form-group + label(for="redirect") Redirect + input.form-control(id="redirect",name="redirect",ng-model="item.redirect") + .form-group + label(for="proxy") Proxy + input.form-control(id="proxy",name="proxy",ng-model="item.proxy") + button.btn.btn-primary(type="submit",ng-click="edit(item)") + span.glyphicon.glyphicon-floppy-disk + | Save + td(data-title="'Options'") + span.glyphicon.glyphicon-cd(ng-if="item.php") + span.glyphicon.glyphicon-lock(ng-if="item.ssl") + span.glyphicon.glyphicon-share(ng-if="item.sslredirect") + span.glyphicon.glyphicon-share-alt(ng-if="item.redirect") + span.glyphicon.glyphicon-send(ng-if="item.proxy") + 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/web.js b/public/app/host/web.js new file mode 100644 index 0000000..324bd77 --- /dev/null +++ b/public/app/host/web.js @@ -0,0 +1,49 @@ +'use strict'; + +angular.module('warehost') + .controller('WebDomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http,$stateParams){ + $scope.tableParams = new NgTableParams({ + sorting: { 'subdomain': 'asc' }, + total: 0, + count: config.table.count + }, { dataset: [] }); + alert.set({}); + $scope.obj = {}; + $scope.domain = {}; + + function resetObj(){ + $scope.obj = {}; + } + function load(){ + $http.get(config.api+'/host/domain/'+$stateParams.domainid).then(function(res){ + $scope.domain = res.data.data; + $http.get(config.api+'/host/domain/'+$stateParams.domainid+'/web').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/'+$stateParams.domainid+'/web/'+a.ID,a).then(submitresult); + }; + $scope.delete = function(a){ + $http.delete(config.api+'/host/domain/'+$stateParams.domainid+'/web/'+a.ID).then(submitresult); + }; + $scope.add = function(){ + $http.post(config.api+'/host/domain/'+$stateParams.domainid+'/web',$scope.obj).then(submitresult); + }; + + }); diff --git a/public/app/user.jade b/public/app/user.jade index 4da1dd1..8a08d93 100644 --- a/public/app/user.jade +++ b/public/app/user.jade @@ -31,10 +31,17 @@ .form-group(ng-class="{'has-error': (item.newPassword != item.repeatPassword && myform.repeatPassword.$dirty)}") label(for="repeatPassword") Again Password input.form-control(id="repeatPassword",type="password",name="repeatPassword",ng-model="item.repeatPassword") + .form-group + label + input(type="checkbox",ng-model="item.active") + | Active .form-group label input(type="checkbox",ng-model="item.superadmin") | Administrator + td(data-title="'Active'", filter="{'active': 'components/ngfilter-boolean.html'}") + span.glyphicon.glyphicon-ok(ng-if="item.active") + span.glyphicon.glyphicon-remove(ng-if="!item.active") td(data-title="'Administrator'", filter="{'superadmin': 'components/ngfilter-boolean.html'}") span.glyphicon.glyphicon-ok(ng-if="item.superadmin") span.glyphicon.glyphicon-remove(ng-if="!item.superadmin") diff --git a/public/index.html b/public/index.html index d484568..bf5986d 100644 --- a/public/index.html +++ b/public/index.html @@ -22,7 +22,7 @@ - + @@ -64,7 +64,9 @@ + +