[web] website mgmt (testing not ready
This commit is contained in:
parent
a8a9d46c8b
commit
c9fd753cfa
|
@ -1,2 +1,3 @@
|
|||
.navbar-text Hosting
|
||||
li
|
||||
a(ui-sref="app.host.index",ui-sref-active="active") Home
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -8,7 +8,6 @@ angular.module('warehost')
|
|||
count: config.table.count
|
||||
}, { dataset: [] });
|
||||
alert.set({});
|
||||
$scope.list = {};
|
||||
$scope.obj = {};
|
||||
$scope.invitor = {};
|
||||
|
||||
|
|
|
@ -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()")
|
||||
|
|
|
@ -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'}
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
};
|
||||
});
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
};
|
||||
});
|
|
@ -18,7 +18,7 @@
|
|||
<link rel="stylesheet" href="bower_components/ng-table/dist/ng-table.css" />
|
||||
<!-- endbower -->
|
||||
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="bower_components/bootswatch/lumen/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" />
|
||||
<script src="bower_components/ng-table/dist/ng-table.min.css"></script>
|
||||
<!-- endbuild -->
|
||||
<!-- build:css({.tmp,public}) app/app.css -->
|
||||
|
@ -54,6 +54,8 @@
|
|||
<script src="app/main.js"></script>
|
||||
<script src="app/settings.js"></script>
|
||||
<script src="app/web/index.js"></script>
|
||||
<script src="app/web/list.js"></script>
|
||||
<script src="app/web/menu.js"></script>
|
||||
<script src="components/alert.js"></script>
|
||||
<script src="components/config.js"></script>
|
||||
<script src="components/session.js"></script>
|
||||
|
|
|
@ -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())
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
Reference in New Issue