diff --git a/bower.json b/bower.json
index 8218324..61e413a 100644
--- a/bower.json
+++ b/bower.json
@@ -18,6 +18,8 @@
"angular-bootstrap": "^1.3.3",
"bootstrap": "^3.3.6",
"bootswatch": "^3.3.7",
- "ng-table": "^1.0.0"
+ "ng-table": "^1.0.0",
+ "angular-ui-select": "^0.19.4",
+ "angular-sanitize": "^1.5.8"
}
}
diff --git a/public/app/admin.jade b/public/app/admin.jade
new file mode 100644
index 0000000..620ff63
--- /dev/null
+++ b/public/app/admin.jade
@@ -0,0 +1,5 @@
+div(ng-if="session.login.superadmin",ui-view="")
+div(ng-if="!session.login.superadmin")
+ .container
+ h1 No Permissions
+ .alert.alert-danger This area is only for a admins visible!
diff --git a/public/app/app.js b/public/app/app.js
index 1f7bc20..e161386 100644
--- a/public/app/app.js
+++ b/public/app/app.js
@@ -1,8 +1,10 @@
'use strict';
angular.module('warehost', [
+ 'ngSanitize',
'ui.router',
'ui.bootstrap',
+ 'ui.select',
'ngTable',
'config',
'session',
diff --git a/public/app/components/config.js b/public/app/components/config.js
deleted file mode 100644
index 181cfdc..0000000
--- a/public/app/components/config.js
+++ /dev/null
@@ -1,10 +0,0 @@
-'use strict';
-angular.module('config', [])
- .factory('config', function() {
- return {
- api: 'https://apiv2.warehost.de',
- table: {
- count: 25
- }
- };
- });
diff --git a/public/app/index.js b/public/app/index.js
index a807995..b5279a1 100644
--- a/public/app/index.js
+++ b/public/app/index.js
@@ -16,14 +16,22 @@ angular.module('warehost')
.state('app.L', {
templateUrl: 'app/loggedin.html'
})
- .state('app.L.settings', {
+ .state('app.L.setting', {
url:'/settings',
- templateUrl: 'app/settings.html',
- controller: 'SettingsCtrl'
+ templateUrl: 'app/setting.html',
+ controller: 'SettingCtrl'
})
- .state('app.L.invites', {
+ .state('app.L.invite', {
url:'/invites',
- templateUrl: 'app/invites.html',
- controller: 'InvitesCtrl'
+ templateUrl: 'app/invite.html',
+ controller: 'InviteCtrl'
+ })
+ .state('app.A', {
+ templateUrl: 'app/admin.html'
+ })
+ .state('app.A.user', {
+ url:'/user',
+ templateUrl: 'app/user.html',
+ controller: 'UserCtrl'
});
}]);
diff --git a/public/app/invites.jade b/public/app/invite.jade
similarity index 100%
rename from public/app/invites.jade
rename to public/app/invite.jade
diff --git a/public/app/invites.js b/public/app/invite.js
similarity index 84%
rename from public/app/invites.js
rename to public/app/invite.js
index 9d5bd27..17cf03f 100644
--- a/public/app/invites.js
+++ b/public/app/invite.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('warehost')
- .controller('InvitesCtrl',function(session,config,alert,NgTableParams,$scope,$http){
+ .controller('InviteCtrl',function(session,config,alert,NgTableParams,$scope,$http){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
@@ -42,10 +42,10 @@ angular.module('warehost')
$scope.edit = function(a){
a.invited.password = a.newPassword;
- $http.put(config.api+'/invite/'+a.invited.ID,a.invited).then(submitresult);
+ $http.put(config.api+'/user/'+a.invited.ID,a.invited).then(submitresult);
};
$scope.delete = function(a){
- $http.delete(config.api+'/invite/'+a.invited.ID).then(submitresult);
+ $http.delete(config.api+'/user/'+a.invited.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/invite',$scope.obj).then(submitresult);
diff --git a/public/app/main.jade b/public/app/main.jade
index 1f1a0b6..9a95997 100644
--- a/public/app/main.jade
+++ b/public/app/main.jade
@@ -31,15 +31,15 @@
span.caret
ul.dropdown-menu
li
- a(ui-sref="app.L.invites",ui-sref-active="active")
+ a(ui-sref="app.L.invite",ui-sref-active="active")
span.glyphicon.glyphicon-send
| Invites
li(ng-if="session.login.superadmin")
- a(ui-sref="app.A.admin",ui-sref-active="active")
+ a(ui-sref="app.A.user",ui-sref-active="active")
span.glyphicon.glyphicon-tasks
| User Managment
li
- a(ui-sref="app.L.settings",ui-sref-active="active")
+ a(ui-sref="app.L.setting",ui-sref-active="active")
span.glyphicon.glyphicon-cog
| Settings
li
diff --git a/public/app/settings.jade b/public/app/setting.jade
similarity index 100%
rename from public/app/settings.jade
rename to public/app/setting.jade
diff --git a/public/app/settings.js b/public/app/setting.js
similarity index 90%
rename from public/app/settings.js
rename to public/app/setting.js
index b83c14c..2cf2cee 100644
--- a/public/app/settings.js
+++ b/public/app/setting.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('warehost')
- .controller('SettingsCtrl',function(session,config,alert,$scope,$http){
+ .controller('SettingCtrl',function(session,config,alert,$scope,$http){
$scope.obj = {};
alert.set({});
$scope.submit = function(){
diff --git a/public/app/user.jade b/public/app/user.jade
new file mode 100644
index 0000000..867d393
--- /dev/null
+++ b/public/app/user.jade
@@ -0,0 +1,48 @@
+.container
+ h1 User Managment
+ a.btn.btn-default(ng-click="isAdding=true")
+ span.glyphicon.glyphicon-plus
+ form(ng-submit="add()",name="addform",ng-if="isAdding")
+ .form-group
+ label(for="username") Username
+ input.form-control(id="username",name="username",ng-model="obj.username",ng-minlength="3")
+ .form-group(ng-class="{'has-error': (error.fields.indexOf('newpassword') >= 0 || !addform.newPassword.$valid)}")
+ label(for="newPassword") New Password
+ input.form-control(id="newPassword",type="password",name="newPassword",ng-model="obj.password",ng-minlength="3")
+ .form-group(ng-class="{'has-error': (obj.password != obj.repeatPassword && addform.repeatPassword.$dirty)}")
+ label(for="repeatPassword") Again Password
+ input.form-control(id="repeatPassword",type="password",name="repeatPassword",ng-model="obj.repeatPassword")
+ 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="'#'") {{item.ID}}
+ td(data-title="'Username'", filter="{'username': 'text'}")
+ span(ng-if="!item.isEditing") {{item.username}}
+ h4(ng-if="item.isEditing") Username: {{item.username}}
+ form(name="myform",ng-if="item.isEditing")
+ .form-group(ng-class="{'has-error': (error.fields.indexOf('username') >= 0 || !myform.username.$valid)}")
+ label(for="username") Username
+ input.form-control(id="username",name="username",ng-model="item.username")
+ .form-group(ng-class="{'has-error': (error.fields.indexOf('newpassword') >= 0 || !myform.newPassword.$valid)}")
+ label(for="newPassword") New Password
+ input.form-control(id="newPassword",type="password",name="newPassword",ng-model="item.newPassword",ng-minlength="3")
+ .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.superadmin")
+ | Administrator
+ 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")
+ td(data-title="'Option'")
+ .btn-group.btn-group-xs(ng-if="item.admin || item.createat >= item.lastloginat")
+ 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/user.js b/public/app/user.js
new file mode 100644
index 0000000..7ea6a7e
--- /dev/null
+++ b/public/app/user.js
@@ -0,0 +1,45 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('UserCtrl',function(session,config,alert,NgTableParams,$scope,$http){
+ $scope.tableParams = new NgTableParams({
+ sorting: { 'invited.username': 'asc' },
+ total: 0,
+ count: config.table.count
+ }, { dataset: [] });
+ alert.set({});
+ $scope.obj = {};
+ $scope.invitor = {};
+
+ function resetObj(){
+ $scope.obj = {};
+ }
+ function load(){
+ $http.get(config.api+'/user').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){
+ load();
+ resetObj();
+ $scope.isAdding = false;
+ }
+ }
+ resetObj();
+ load();
+
+ $scope.edit = function(a){
+ a.password = a.newPassword;
+ $http.put(config.api+'/user/'+a.ID,a).then(submitresult);
+ };
+ $scope.delete = function(a){
+ $http.delete(config.api+'/user/'+a.ID).then(submitresult);
+ };
+ $scope.add = function(){
+ $http.post(config.api+'/user',$scope.obj).then(submitresult);
+ };
+ });
diff --git a/public/app/web/index.js b/public/app/web/index.js
index d68d821..16b9bfb 100644
--- a/public/app/web/index.js
+++ b/public/app/web/index.js
@@ -22,5 +22,41 @@ angular.module('warehost')
views:{
'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
}
+ })
+ .state('app.webS.menu', {
+ url:'/menu',
+ views:{
+ '@app':{
+ templateUrl: 'app/web/webmenu.html',
+ controller:'WebmenuWebCtrl'
+ }
+ }
+ })
+ .state('app.webS.domain', {
+ url:'/domain',
+ views:{
+ '@app':{
+ templateUrl: 'app/web/domain.html',
+ controller:'DomainWebCtrl'
+ }
+ }
+ })
+ .state('app.webS.page', {
+ url:'/page',
+ views:{
+ '@app':{
+ templateUrl: 'app/web/page.html',
+ controller:'PageWebCtrl'
+ }
+ }
+ })
+ .state('app.webS.permission', {
+ url:'/permission',
+ views:{
+ '@app':{
+ templateUrl: 'app/web/permission.html',
+ controller:'PermissionWebCtrl'
+ }
+ }
});
}]);
diff --git a/public/app/web/menu.jade b/public/app/web/menu.jade
index b8caca1..fd9ca5c 100644
--- a/public/app/web/menu.jade
+++ b/public/app/web/menu.jade
@@ -11,8 +11,10 @@ li.dropdown
li(ng-repeat="item in list")
a(ui-sref="app.webS({websiteid:item.website.ID})") {{item.website.name}}
li(ng-if="website.name")
- a Menu
+ a(ui-sref="app.webS.menu({websiteid:website.ID})") Menu
li(ng-if="website.name")
- a Seiten
+ a(ui-sref="app.webS.page({websiteid:website.ID})") Pages
li(ng-if="website.name")
- a Permissions
+ 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/app/web/menu.js b/public/app/web/menu.js
index d913f26..4592c03 100644
--- a/public/app/web/menu.js
+++ b/public/app/web/menu.js
@@ -12,7 +12,7 @@ angular.module('warehost')
$scope.list = res.data.data;
for(var key in res.data.data){
var item = res.data.data[key];
- if(item.website.ID === $stateParams.websiteid){
+ if(item.website.ID+"" === $stateParams.websiteid){
$scope.website = item.website;
}
}
diff --git a/public/app/web/page.jade b/public/app/web/page.jade
new file mode 100644
index 0000000..2cd066c
--- /dev/null
+++ b/public/app/web/page.jade
@@ -0,0 +1,28 @@
+.container
+ h1 Pages
+ a.btn.btn-default(ng-click="isAdding=true")
+ span.glyphicon.glyphicon-plus
+ form(ng-submit="add()",name="addform",ng-if="isAdding")
+ .form-group
+ label(for="name") Name
+ input.form-control(id="name",name="name",ng-model="obj.name",ng-minlength="3")
+ 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="'#'") {{item.website.ID}}
+ td(data-title="'Name'")
+ span(ng-if="!item.isEditing") {{item.website.name}}
+ form(name="myform",ng-if="item.isEditing")
+ .form-group(ng-class="{'has-error': (error.fields.indexOf('name') >= 0 || !myform.name.$valid)}")
+ label(for="name") Name
+ input.form-control(id="name",name="name",ng-model="item.website.name")
+ 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/web/page.js b/public/app/web/page.js
new file mode 100644
index 0000000..3453452
--- /dev/null
+++ b/public/app/web/page.js
@@ -0,0 +1,42 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
+ $scope.tableParams = new NgTableParams({
+ sorting: { 'invited.username': 'asc' },
+ total: 0,
+ count: config.table.count
+ }, { dataset: [] });
+ alert.set({});
+ $scope.obj = {};
+
+ function resetObj(){
+ $scope.obj = {};
+ }
+ function load(){
+ $http.get(config.api+'/web/'+$stateParams.websiteid+'/page').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;
+ }
+ }
+ resetObj();
+ load();
+
+ $scope.edit = function(a){
+ $http.put(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID,a.website).then(submitresult);
+ };
+ $scope.delete = function(a){
+ $http.delete(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID).then(submitresult);
+ };
+ $scope.add = function(){
+ $http.post(config.api+'/web/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
+ };
+ });
diff --git a/public/app/web/permission.jade b/public/app/web/permission.jade
new file mode 100644
index 0000000..4f3b61b
--- /dev/null
+++ b/public/app/web/permission.jade
@@ -0,0 +1,22 @@
+.container
+ h1 Permissions
+ a.btn.btn-default(ng-click="isAdding=true")
+ span.glyphicon.glyphicon-plus
+ form(ng-submit="add()",name="addform",ng-if="isAdding")
+ .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="'#'") {{item.login.ID}}
+ td(data-title="'Username'")
+ span(ng-if="!item.isEditing") {{item.login.username}}
+ td(data-title="'Option'")
+ .btn-group.btn-group-xs
+ span.btn.btn-default(ng-click="delete(item)")
+ span.glyphicon.glyphicon-trash
diff --git a/public/app/web/permission.js b/public/app/web/permission.js
new file mode 100644
index 0000000..6eaf6d4
--- /dev/null
+++ b/public/app/web/permission.js
@@ -0,0 +1,44 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('PermissionWebCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){
+ $scope.tableParams = new NgTableParams({
+ sorting: { 'invited.username': 'asc' },
+ total: 0,
+ count: config.table.count
+ }, { dataset: [] });
+ alert.set({});
+ $scope.obj = {};
+ $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+'/web/website/'+$stateParams.websiteid+'/permission').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();
+
+ $scope.delete = function(a){
+ $http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+a.login.ID).then(submitresult);
+ };
+ $scope.add = function(){
+ $http.post(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+$scope.obj.login.ID,{}).then(submitresult);
+ };
+ });
diff --git a/public/app/web/webmenu.jade b/public/app/web/webmenu.jade
new file mode 100644
index 0000000..47dafc6
--- /dev/null
+++ b/public/app/web/webmenu.jade
@@ -0,0 +1,28 @@
+.container
+ h1 Menu
+ a.btn.btn-default(ng-click="isAdding=true")
+ span.glyphicon.glyphicon-plus
+ form(ng-submit="add()",name="addform",ng-if="isAdding")
+ .form-group
+ label(for="name") Name
+ input.form-control(id="name",name="name",ng-model="obj.name",ng-minlength="3")
+ 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="'#'") {{item.website.ID}}
+ td(data-title="'Name'")
+ span(ng-if="!item.isEditing") {{item.website.name}}
+ form(name="myform",ng-if="item.isEditing")
+ .form-group(ng-class="{'has-error': (error.fields.indexOf('name') >= 0 || !myform.name.$valid)}")
+ label(for="name") Name
+ input.form-control(id="name",name="name",ng-model="item.website.name")
+ 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/web/webmenu.js b/public/app/web/webmenu.js
new file mode 100644
index 0000000..b51bc63
--- /dev/null
+++ b/public/app/web/webmenu.js
@@ -0,0 +1,44 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('WebmenuWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){
+ $scope.tableParams = new NgTableParams({
+ sorting: { 'invited.username': 'asc' },
+ total: 0,
+ count: config.table.count
+ }, { dataset: [] });
+ alert.set({});
+ $scope.obj = {};
+
+ function resetObj(){
+ $scope.obj = {};
+ }
+ function load(){
+ $http.get(config.api+'/web/involve').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){
+ $rootScope.$broadcast('warehost.web.website.update');
+ resetObj();
+ $scope.isAdding = false;
+ }
+ }
+ resetObj();
+ 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);
+ };
+ $scope.delete = function(a){
+ $http.delete(config.api+'/web/website/'+a.website.ID).then(submitresult);
+ };
+ $scope.add = function(){
+ $http.post(config.api+'/web/website',$scope.obj).then(submitresult);
+ };
+ });
diff --git a/public/app/components/alert.js b/public/components/alert.js
similarity index 100%
rename from public/app/components/alert.js
rename to public/components/alert.js
diff --git a/public/app/components/ngfilter-boolean.jade b/public/components/ngfilter-boolean.jade
similarity index 100%
rename from public/app/components/ngfilter-boolean.jade
rename to public/components/ngfilter-boolean.jade
diff --git a/public/app/components/session.js b/public/components/session.js
similarity index 100%
rename from public/app/components/session.js
rename to public/components/session.js
diff --git a/public/index.html b/public/index.html
index cfbe0e7..29b9014 100644
--- a/public/index.html
+++ b/public/index.html
@@ -19,6 +19,7 @@
+
@@ -44,21 +45,27 @@
+
+
-
-
-
-
+
-
+
+
+
+
+
+
+
+