diff --git a/public/app/host/menu.jade b/public/app/host/menu.jade
index 1ec5818..d6f94fe 100644
--- a/public/app/host/menu.jade
+++ b/public/app/host/menu.jade
@@ -1,2 +1,3 @@
+.navbar-text Hosting
li
a(ui-sref="app.host.index",ui-sref-active="active") Home
diff --git a/public/app/invites.jade b/public/app/invites.jade
index 5165a6c..81695ed 100644
--- a/public/app/invites.jade
+++ b/public/app/invites.jade
@@ -24,7 +24,7 @@
td(data-title="'Username'", filter="{'invited.username': 'text'}")
span(ng-if="!item.isEditing") {{item.invited.username}}
h4(ng-if="item.isEditing") Username: {{item.invited.username}}
- form(ng-submit="submit(obj)",name="myform",ng-if="item.isEditing")
+ form(name="myform",ng-if="item.isEditing")
.form-group(ng-if="session.login.superadmin",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.invited.username")
diff --git a/public/app/invites.js b/public/app/invites.js
index 0028f0d..9d5bd27 100644
--- a/public/app/invites.js
+++ b/public/app/invites.js
@@ -8,7 +8,6 @@ angular.module('warehost')
count: config.table.count
}, { dataset: [] });
alert.set({});
- $scope.list = {};
$scope.obj = {};
$scope.invitor = {};
diff --git a/public/app/main.jade b/public/app/main.jade
index 18ae41c..1f1a0b6 100644
--- a/public/app/main.jade
+++ b/public/app/main.jade
@@ -18,12 +18,12 @@
| Apps
span.caret
ul.dropdown-menu
- li(ng-if="modules.indexOf('web')>-1",ui-sref="app.web.index")
- a(nav navbar-nav) Websites
- li(ng-if="modules.indexOf('host')>-1",ui-sref="app.host.index")
- a(nav navbar-nav) Hosting
+ li(ng-if="modules.indexOf('web')>-1")
+ a(ui-sref="app.web.index") Websites
+ li(ng-if="modules.indexOf('host')>-1")
+ a(ui-sref="app.host.index") Hosting
li(ng-if="modules.indexOf('test')>-1")
- a(nav navbar-nav) Testing
+ a Testing
li.dropdown
a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false")
span.glyphicon.glyphicon-user
@@ -43,7 +43,7 @@
span.glyphicon.glyphicon-cog
| Settings
li
- a(ng-click="logout()")
+ a(href="",ng-click="logout()")
span.glyphicon.glyphicon-log-out
| Logout
form.navbar-form.navbar-right(ng-if="!session.login.active",ng-submit="login()")
diff --git a/public/app/web/index.js b/public/app/web/index.js
index fa968c2..d68d821 100644
--- a/public/app/web/index.js
+++ b/public/app/web/index.js
@@ -5,18 +5,22 @@ angular.module('warehost')
.state('app.web', {
url:'/web',
views:{
- 'menu':{templateUrl:'app/web/menu.html'}
+ 'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
}
})
.state('app.web.index', {
url:'/',
views:{
'@app':{
- templateUrl: 'app/home.html',
- controller:function(alert){
- alert.set({});
- }
+ templateUrl: 'app/web/list.html',
+ controller:'ListWebCtrl'
}
}
+ })
+ .state('app.webS', {
+ url:'/web/:websiteid',
+ views:{
+ 'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
+ }
});
}]);
diff --git a/public/app/web/list.jade b/public/app/web/list.jade
new file mode 100644
index 0000000..ac8f1e8
--- /dev/null
+++ b/public/app/web/list.jade
@@ -0,0 +1,30 @@
+.container
+ h1 Websites
+ div (where you are involved)
+ 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/list.js b/public/app/web/list.js
new file mode 100644
index 0000000..49dd033
--- /dev/null
+++ b/public/app/web/list.js
@@ -0,0 +1,44 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('ListWebCtrl',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/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/web/menu.jade b/public/app/web/menu.jade
index 0f141a7..b8caca1 100644
--- a/public/app/web/menu.jade
+++ b/public/app/web/menu.jade
@@ -1,2 +1,18 @@
-li
- a(ui-sref="app.web.index",ui-sref-active="active") Home
+.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({websiteid:item.website.ID})") {{item.website.name}}
+li(ng-if="website.name")
+ a Menu
+li(ng-if="website.name")
+ a Seiten
+li(ng-if="website.name")
+ a Permissions
diff --git a/public/app/web/menu.js b/public/app/web/menu.js
new file mode 100644
index 0000000..9e1e604
--- /dev/null
+++ b/public/app/web/menu.js
@@ -0,0 +1,29 @@
+'use strict';
+
+angular.module('warehost')
+ .controller('MenuWebCtrl',function(session,config,alert,$scope,$rootScope,$http,$stateParams){
+ alert.set({});
+ $scope.list = {};
+ $scope.website = {};
+ function load(){
+ $http.get(config.api+'/web/involve').then(function(res){
+ session.set(res);
+ alert.set(res);
+ $scope.list = res.data.data
+ for(var key in res.data.data){
+ var item = res.data.data[key];
+ if(item.website.ID == $stateParams.websiteid){
+ $scope.website = item.website;
+ }
+ }
+ });
+ }
+ load();
+ $rootScope.$on('warehost.web.website.update',load);
+ $scope.add = function(){
+ $http.post(config.api+'/web/website',{name:prompt("Name:")}).then(function(res){
+ session.set(res);
+ $rootScope.$broadcast('warehost.web.website.update');
+ });
+ };
+ });
diff --git a/public/index.html b/public/index.html
index 08daf6b..54941f2 100644
--- a/public/index.html
+++ b/public/index.html
@@ -18,7 +18,7 @@
-
+
@@ -54,6 +54,8 @@
+
+
diff --git a/tests/modul/web.coffee b/tests/modul/web.coffee
index 1167cc4..d08688a 100644
--- a/tests/modul/web.coffee
+++ b/tests/modul/web.coffee
@@ -7,6 +7,7 @@ config = require('../config')
module.exports = ()->
describe('web',->
+ websiteid = -1;
describe('involve',->
it('-> not logged in',(done)->
request({method: 'GET',uri:config.ADDRESS+"/web/involve"},(err,res,body)->
@@ -33,32 +34,134 @@ module.exports = ()->
)
)
)
- describe('add website',->
- it('-> not logged in',(done)->
- request({method: 'POST',uri:config.ADDRESS+"/web/website"},(err,res,body)->
- expect(err).to.be.null
- expect(res.statusCode).to.be.equal(200)
- if(typeof body == "string")
- body = JSON.parse(body)
- expect(body.error).to.not.be.undefined
- expect(body.data).to.be.false
- done()
- )
- )
- it('-> validate',(done)->
- lib.login({username:'test_used',password:'test'},(j,login)->
- request({method: 'POST',uri:config.ADDRESS+"/web/website",json:{
- name: "FireSystem"
- },jar:j},(err,res,body)->
+ describe('website',->
+ describe('add',->
+ it('-> not logged in',(done)->
+ request({method: 'POST',uri:config.ADDRESS+"/web/website"},(err,res,body)->
expect(err).to.be.null
expect(res.statusCode).to.be.equal(200)
if(typeof body == "string")
body = JSON.parse(body)
- expect(body.error).to.be.undefined
- expect(body.data).to.be.true
+ expect(body.error).to.not.be.undefined
+ expect(body.data).to.be.false
done()
)
)
+ it('-> validate',(done)->
+ lib.login({username:'test_used',password:'test'},(j,login)->
+ request({method: 'POST',uri:config.ADDRESS+"/web/website",json:{
+ name: "Test-Pls-Delete"
+ },jar:j},(err,res,body)->
+ expect(err).to.be.null
+ expect(res.statusCode).to.be.equal(200)
+ if(typeof body == "string")
+ body = JSON.parse(body)
+ expect(body.error).to.be.undefined
+ expect(body.data).to.be.true
+ done()
+ )
+ )
+ )
+ )
+ describe('edit',->
+ it('-> not logged in',(done)->
+ request({method: 'PUT',uri:config.ADDRESS+"/web/website/"+websiteid,json:{
+ name: "Test-Pls-Delete2"
+ }},(err,res,body)->
+ expect(err).to.be.null
+ expect(res.statusCode).to.be.equal(200)
+ if(typeof body == "string")
+ body = JSON.parse(body)
+ expect(body.error).to.not.be.undefined
+ expect(body.data).to.be.false
+ done()
+ )
+ )
+ it('-> not involved',(done)->
+ lib.login((j,login)->
+ request({method: 'PUT',uri:config.ADDRESS+"/web/website"+websiteid,json:{
+ name: "Test-Pls-Delete2"
+ },jar:j},(err,res,body)->
+ expect(err).to.be.null
+ expect(res.statusCode).to.be.equal(200)
+ if(typeof body == "string")
+ body = JSON.parse(body)
+ expect(body.error).to.be.undefined
+ expect(body.data).to.be.true
+ done()
+ )
+ )
+ )
+ it('-> validate',(done)->
+ lib.login({username:'test_used',password:'test'},(j,login)->
+ request({method: 'PUT',uri:config.ADDRESS+"/web/website"+websiteid,json:{
+ name: "Test-Pls-Delete2"
+ },jar:j},(err,res,body)->
+ expect(err).to.be.null
+ expect(res.statusCode).to.be.equal(200)
+ if(typeof body == "string")
+ body = JSON.parse(body)
+ expect(body.error).to.be.undefined
+ expect(body.data).to.be.true
+ done()
+ )
+ )
+ )
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
+ )
+ )
+ describe('permissions',->
+ describe('add',->
+ it('-> try',(done)->done())
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
+ )
+ )
+ describe('domain',->
+ describe('add',->
+ it('-> try',(done)->done())
+ )
+ describe('edit',->
+ it('-> try',(done)->done())
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
+ )
+ )
+ describe('page',->
+ describe('add',->
+ it('-> try',(done)->done())
+ )
+ describe('edit',->
+ it('-> try',(done)->done())
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
+ )
+ )
+ describe('menu',->
+ describe('add',->
+ it('-> try',(done)->done())
+ )
+ describe('edit',->
+ it('-> try',(done)->done())
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
+ )
+ )
+ describe('media',->
+ describe('add',->
+ it('-> try',(done)->done())
+ )
+ describe('edit',->
+ it('-> try',(done)->done())
+ )
+ describe('delete',->
+ it('-> try',(done)->done())
)
)
)