From e3df788f05c4ba408df5e2742921c01b281479ec Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Thu, 17 Nov 2016 23:16:35 +0100 Subject: [PATCH] fix #12: mail forward - mail ist ready --- public/app/host/mail.jade | 47 ++++++++++++++++++++++++++++++--------- public/app/host/mail.js | 11 +++++++++ public/app/host/web.jade | 33 +++++++++++++++++++++++++++ public/app/host/web.js | 44 +++++++++++++++++++++++++++++++----- 4 files changed, 120 insertions(+), 15 deletions(-) diff --git a/public/app/host/mail.jade b/public/app/host/mail.jade index 3fc22b7..09b4e21 100644 --- a/public/app/host/mail.jade +++ b/public/app/host/mail.jade @@ -8,11 +8,23 @@ .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") + .form-group + label Inbox + .input-group + ui-select(ng-model="obj.login") + ui-select-match + span(ng-repeat="i in loginlist",ng-show="i.ID == $select.selected.ID") {{i.username}} + ui-select-choices(repeat="i.ID as i in loginlist | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") + span.input-group-btn + button.btn.btn-default(type="button",ng-click="obj.login = undefined") + span.glyphicon.glyphicon-trash + .form-group + label Forwards + ui-select(ng-model="obj.forwards",multiple,tagging="newMail") + ui-select-match {{$item.to}} + ui-select-choices(repeat="i in obj.forwards") + div(ng-bind-html="i.to | highlight: $select.search") button.btn.btn-primary(type="submit") span.glyphicon.glyphicon-floppy-disk | Save @@ -28,15 +40,30 @@ 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") + label Inbox + .input-group + ui-select(ng-model="item.login") + ui-select-match + span(ng-repeat="i in loginlist",ng-show="i.ID == $select.selected.ID") {{i.username}} + ui-select-choices(repeat="i.ID as i in loginlist | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") + span.input-group-btn + button.btn.btn-default(type="button",ng-click="item.login = undefined") + span.glyphicon.glyphicon-trash + .form-group + label Forwards + ui-select(ng-model="item.forwards",multiple,tagging="newMail") + ui-select-match {{$item.to}} + ui-select-choices(repeat="i in item.forwards") + div(ng-bind-html="i.to | highlight: $select.search") button.btn.btn-primary(type="submit",ng-click="edit(item)") span.glyphicon.glyphicon-floppy-disk | Save - td(data-title="'Postfach'") + td(data-title="'Inbox'") span(ng-repeat="i in loginlist",ng-if="i.ID == item.login") {{i.username}} + td(data-title="'Forwards'") + ul + li(ng-repeat="i in item.forwards") {{i.to}} td(data-title="'Option'") .btn-group.btn-group-xs span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing") diff --git a/public/app/host/mail.js b/public/app/host/mail.js index 242afb5..3fe8965 100644 --- a/public/app/host/mail.js +++ b/public/app/host/mail.js @@ -50,4 +50,15 @@ angular.module('warehost') $http.post(config.api+'/host/domain/'+$stateParams.domainid+'/mail',$scope.obj).then(submitresult); }; + $scope.newMail = function(to){ + if(/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(to)){ + return { + ID: null, + mail: null, + to: to + }; + } + return null; + }; + }); diff --git a/public/app/host/web.jade b/public/app/host/web.jade index 2b7121e..a32ccce 100644 --- a/public/app/host/web.jade +++ b/public/app/host/web.jade @@ -26,6 +26,19 @@ .form-group label(for="proxy") Proxy input.form-control(id="proxy",name="proxy",ng-model="obj.proxy") + // + .form-group + label FTP Access + ui-select(ng-model="obj.ftpaccess",multiple,on-select="newUser(obj.ftpaccess, $model)") + ui-select-match {{$item.login.username}} + ui-select-choices(repeat="i in loginlist | afterKeyID:obj.ftpaccess:'login' | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") + .form-group + label HTTP Access + ui-select(ng-model="obj.httpaccess",multiple,on-select="newUser(obj.httpaccess, $model)") + ui-select-match {{$item.login.username}} + ui-select-choices(repeat="i in loginlist | afterKeyID:obj.httpaccess:'login' | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") button.btn.btn-primary(type="submit") span.glyphicon.glyphicon-floppy-disk | Save @@ -60,9 +73,29 @@ .form-group label(for="proxy") Proxy input.form-control(id="proxy",name="proxy",ng-model="item.proxy") + // + .form-group + label FTP Access + ui-select(ng-model="item.ftpaccess",multiple,on-select="newUser(item.ftpaccess, $model)") + ui-select-match {{$item.login.username}} + ui-select-choices(repeat="i in loginlist | afterKeyID:obj.ftpaccess:'login' | filter: $select.search") + div(ng-bind-html="i.username | highlight: $select.search") + .form-group + label HTTP Access + ui-select(ng-model="item.httpaccess",multiple,on-select="newUser(item.httpaccess, $model)") + ui-select-match {{$item.login.username}} + ui-select-choices(repeat="i in loginlist | afterKeyID:obj.httpaccess:'login' | 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="'FTPAccess'") + ul + li(ng-repeat="i in item.ftpaccess") {{i.login.username}} + td(data-title="'HTTPAccess'") + ul + li(ng-repeat="i in item.httpaccess") {{i.login.username}} td(data-title="'Options'") span.glyphicon.glyphicon-cd(ng-if="item.php") span.glyphicon.glyphicon-lock(ng-if="item.ssl") diff --git a/public/app/host/web.js b/public/app/host/web.js index 324bd77..62aef0a 100644 --- a/public/app/host/web.js +++ b/public/app/host/web.js @@ -1,6 +1,23 @@ 'use strict'; angular.module('warehost') + .filter('afterKeyID',function(){ + return function(collection,list,key){ + var output = [], + keys = []; + angular.forEach(list, function(item) { + if(item[key] !== undefined){ + keys.push(item[key].ID); + } + }); + angular.forEach(collection, function(item) { + if(keys.indexOf(item.ID)){ + output.push(item); + } + }); + return output; + }; + }) .controller('WebDomainHostCtrl',function(session,config,alert,NgTableParams,$rootScope,$scope,$http,$stateParams){ $scope.tableParams = new NgTableParams({ sorting: { 'subdomain': 'asc' }, @@ -10,16 +27,20 @@ angular.module('warehost') alert.set({}); $scope.obj = {}; $scope.domain = {}; + $scope.loginlist = []; 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}); + $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+'/web').then(function(res){ + session.set(res); + $scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length}); + }); }); }); } @@ -45,5 +66,18 @@ angular.module('warehost') $scope.add = function(){ $http.post(config.api+'/host/domain/'+$stateParams.domainid+'/web',$scope.obj).then(submitresult); }; + $scope.newUser = function(list, $model){ + var ids= []; + list.forEach(function(item, i) { + if(item.login === undefined){ + list[i] = {login: $model}; + } + if(ids.indexOf(list[i].login.ID) < 0){ + ids.push(list[i].login.ID); + }else{ + list.splice(i); + } + }); + }; });