sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0

[web] website mgmt (testing not ready

This commit is contained in:
Martin Geno 2016-09-03 16:30:05 +02:00
parent a8a9d46c8b
commit c9fd753cfa
11 changed files with 263 additions and 35 deletions

View File

@ -1,2 +1,3 @@
.navbar-text Hosting
li li
a(ui-sref="app.host.index",ui-sref-active="active") Home a(ui-sref="app.host.index",ui-sref-active="active") Home

View File

@ -24,7 +24,7 @@
td(data-title="'Username'", filter="{'invited.username': 'text'}") td(data-title="'Username'", filter="{'invited.username': 'text'}")
span(ng-if="!item.isEditing") {{item.invited.username}} span(ng-if="!item.isEditing") {{item.invited.username}}
h4(ng-if="item.isEditing") Username: {{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)}") .form-group(ng-if="session.login.superadmin",ng-class="{'has-error': (error.fields.indexOf('username') >= 0 || !myform.username.$valid)}")
label(for="username") Username label(for="username") Username
input.form-control(id="username",name="username",ng-model="item.invited.username") input.form-control(id="username",name="username",ng-model="item.invited.username")

View File

@ -8,7 +8,6 @@ angular.module('warehost')
count: config.table.count count: config.table.count
}, { dataset: [] }); }, { dataset: [] });
alert.set({}); alert.set({});
$scope.list = {};
$scope.obj = {}; $scope.obj = {};
$scope.invitor = {}; $scope.invitor = {};

View File

@ -18,12 +18,12 @@
| Apps | Apps
span.caret span.caret
ul.dropdown-menu ul.dropdown-menu
li(ng-if="modules.indexOf('web')>-1",ui-sref="app.web.index") li(ng-if="modules.indexOf('web')>-1")
a(nav navbar-nav) Websites a(ui-sref="app.web.index") Websites
li(ng-if="modules.indexOf('host')>-1",ui-sref="app.host.index") li(ng-if="modules.indexOf('host')>-1")
a(nav navbar-nav) Hosting a(ui-sref="app.host.index") Hosting
li(ng-if="modules.indexOf('test')>-1") li(ng-if="modules.indexOf('test')>-1")
a(nav navbar-nav) Testing a Testing
li.dropdown li.dropdown
a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false") a.dropdown-toggle(data-toggle="dropdown",role="button",aria-haspopup="true",aria-expanded="false")
span.glyphicon.glyphicon-user span.glyphicon.glyphicon-user
@ -43,7 +43,7 @@
span.glyphicon.glyphicon-cog span.glyphicon.glyphicon-cog
| Settings | Settings
li li
a(ng-click="logout()") a(href="",ng-click="logout()")
span.glyphicon.glyphicon-log-out span.glyphicon.glyphicon-log-out
| Logout | Logout
form.navbar-form.navbar-right(ng-if="!session.login.active",ng-submit="login()") form.navbar-form.navbar-right(ng-if="!session.login.active",ng-submit="login()")

View File

@ -5,18 +5,22 @@ angular.module('warehost')
.state('app.web', { .state('app.web', {
url:'/web', url:'/web',
views:{ views:{
'menu':{templateUrl:'app/web/menu.html'} 'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
} }
}) })
.state('app.web.index', { .state('app.web.index', {
url:'/', url:'/',
views:{ views:{
'@app':{ '@app':{
templateUrl: 'app/home.html', templateUrl: 'app/web/list.html',
controller:function(alert){ controller:'ListWebCtrl'
alert.set({});
} }
} }
})
.state('app.webS', {
url:'/web/:websiteid',
views:{
'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
} }
}); });
}]); }]);

30
public/app/web/list.jade Normal file
View File

@ -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

44
public/app/web/list.js Normal file
View File

@ -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);
};
});

View File

@ -1,2 +1,18 @@
li .navbar-text Website
a(ui-sref="app.web.index",ui-sref-active="active") Home 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

29
public/app/web/menu.js Normal file
View File

@ -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');
});
};
});

View File

@ -18,7 +18,7 @@
<link rel="stylesheet" href="bower_components/ng-table/dist/ng-table.css" /> <link rel="stylesheet" href="bower_components/ng-table/dist/ng-table.css" />
<!-- endbower --> <!-- endbower -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" /> <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> <script src="bower_components/ng-table/dist/ng-table.min.css"></script>
<!-- endbuild --> <!-- endbuild -->
<!-- build:css({.tmp,public}) app/app.css --> <!-- build:css({.tmp,public}) app/app.css -->
@ -54,6 +54,8 @@
<script src="app/main.js"></script> <script src="app/main.js"></script>
<script src="app/settings.js"></script> <script src="app/settings.js"></script>
<script src="app/web/index.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/alert.js"></script>
<script src="components/config.js"></script> <script src="components/config.js"></script>
<script src="components/session.js"></script> <script src="components/session.js"></script>

View File

@ -7,6 +7,7 @@ config = require('../config')
module.exports = ()-> module.exports = ()->
describe('web',-> describe('web',->
websiteid = -1;
describe('involve',-> describe('involve',->
it('-> not logged in',(done)-> it('-> not logged in',(done)->
request({method: 'GET',uri:config.ADDRESS+"/web/involve"},(err,res,body)-> request({method: 'GET',uri:config.ADDRESS+"/web/involve"},(err,res,body)->
@ -33,7 +34,8 @@ module.exports = ()->
) )
) )
) )
describe('add website',-> describe('website',->
describe('add',->
it('-> not logged in',(done)-> it('-> not logged in',(done)->
request({method: 'POST',uri:config.ADDRESS+"/web/website"},(err,res,body)-> request({method: 'POST',uri:config.ADDRESS+"/web/website"},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
@ -48,7 +50,7 @@ module.exports = ()->
it('-> validate',(done)-> it('-> validate',(done)->
lib.login({username:'test_used',password:'test'},(j,login)-> lib.login({username:'test_used',password:'test'},(j,login)->
request({method: 'POST',uri:config.ADDRESS+"/web/website",json:{ request({method: 'POST',uri:config.ADDRESS+"/web/website",json:{
name: "FireSystem" name: "Test-Pls-Delete"
},jar:j},(err,res,body)-> },jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
@ -61,4 +63,105 @@ module.exports = ()->
) )
) )
) )
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())
)
)
) )