sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This commit is contained in:
Martin Geno 2016-08-20 01:17:28 +02:00
parent cd02c1bad4
commit 238c5311e3
10 changed files with 95 additions and 7 deletions

View File

@ -17,6 +17,7 @@
"angular-ui-router": "^0.3.1", "angular-ui-router": "^0.3.1",
"angular-bootstrap": "^1.3.3", "angular-bootstrap": "^1.3.3",
"bootstrap": "^3.3.6", "bootstrap": "^3.3.6",
"bootswatch": "^3.3.7" "bootswatch": "^3.3.7",
"ng-table": "^1.0.0"
} }
} }

View File

@ -3,6 +3,7 @@
angular.module('warehost', [ angular.module('warehost', [
'ui.router', 'ui.router',
'ui.bootstrap', 'ui.bootstrap',
'ngTable',
'config', 'config',
'session', 'session',
'alert' 'alert'

View File

@ -23,6 +23,7 @@ angular.module('warehost')
}) })
.state('app.L.invites', { .state('app.L.invites', {
url:'/invites', url:'/invites',
templateUrl: 'app/invites.html' templateUrl: 'app/invites.html',
controller: 'InvitesCtrl'
}); });
}]); }]);

View File

@ -1,2 +1,28 @@
.container .container
h1 Invites h1 Invites
a.btn.btn-default
span.glyphicon.glyphicon-plus
table.table.table-bordered(ng-table="tableParams")
tr(ng-hide='group.$hideRows',ng-repeat="item in $data")
td(data-title="'#'") {{item.invited.ID}}
td(data-title="'Hostname'", 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(item)",name="myform",ng-if="item.isEditing")
.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="obj.newPassword",ng-minlength="3")
.form-group(ng-class="{'has-error': (obj.newPassword != obj.repeatPassword && myform.repeatPassword.$dirty)}")
label(for="repeatPassword") Again Password
input.form-control(id="repeatPassword",type="password",name="repeatPassword",ng-model="obj.repeatPassword")
td(data-title="'Administrator'", filter="{'admin': 'components/ngfilter-boolean.html'}")
span.glyphicon.glyphicon-ok(ng-if="item.admin")
span.glyphicon.glyphicon-remove(ng-if="!item.admin")
td(data-title="'Option'")
.btn-group.btn-group-xs(ng-if="item.admin || item.invited.createat >= item.invited.lastloginat")
span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing")
span.glyphicon.glyphicon-pencil
span.btn.btn-default(ng-click="item.isEditing = false",ng-if="item.isEditing")
span.glyphicon.glyphicon-remove-circle
span.btn.btn-default
span.glyphicon.glyphicon-trash

16
public/app/invites.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
angular.module('warehost')
.controller('InvitesCtrl',function(session,config,alert,NgTableParams,$scope,$http){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
count: config.table.count
}, { dataset: [] });
$scope.list = {};
alert.set({});
$http.get(config.api+'/invite').then(function(res){
session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
});
});

View File

@ -2,6 +2,9 @@
angular.module('config', []) angular.module('config', [])
.factory('config', function() { .factory('config', function() {
return { return {
api: 'http://[::1]:8080' api: 'http://[::1]:8080',
table: {
count: 25
}
}; };
}); });

View File

@ -0,0 +1,17 @@
div
label
input(type="radio",ng-model="params.filter()[name]",ng-value="")
|  
| None
|  
|  
label
input(type="radio",ng-model="params.filter()[name]",ng-value="true")
|  
span.glyphicon.glyphicon-ok
|  
|  
label
input(type="radio",ng-model="params.filter()[name]",ng-value="false")
|  
span.glyphicon.glyphicon-remove

View File

@ -15,10 +15,12 @@
<!-- build:css(public) app/vendor.css --> <!-- build:css(public) app/vendor.css -->
<!-- bower:css --> <!-- bower: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/paper/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootswatch/lumen/bootstrap.min.css" />
<!-- endbuild --> <!-- endbuild -->
<script src="bower_components/ng-table/dist/ng-table.min.css"></script>
<!-- build:css({.tmp,public}) app/app.css --> <!-- build:css({.tmp,public}) app/app.css -->
<link rel="stylesheet" href="app/app.css"> <link rel="stylesheet" href="app/app.css">
<!-- injector:css --> <!-- injector:css -->
@ -39,12 +41,15 @@
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script> <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script> <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/ng-table/dist/ng-table.js"></script>
<!-- endbower --> <!-- endbower -->
<script src="bower_components/ng-table/dist/ng-table.min.js"></script>
<!-- endbuild --> <!-- endbuild -->
<!-- build:js({.tmp,public}) app/app.js --> <!-- build:js({.tmp,public}) app/app.js -->
<script src="app/app.js"></script> <script src="app/app.js"></script>
<!-- injector:js --> <!-- injector:js -->
<script src="app/index.js"></script> <script src="app/index.js"></script>
<script src="app/invites.js"></script>
<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/shift/index.js"></script> <script src="app/shift/index.js"></script>

View File

@ -1,7 +1,7 @@
{ {
"ADDRESS":"http://[::1]:8080", "ADDRESS":"http://[::1]:8080",
"testdata":{ "testdata":{
"username":"root", "username":"genofire",
"password":"root" "password":"fire35911"
} }
} }

View File

@ -13,10 +13,28 @@ describe('API',->
if(typeof body == "string") if(typeof body == "string")
body = JSON.parse(body) body = JSON.parse(body)
expect(body.data).to.be.true expect(body.data).to.be.true
expect(body.error).to.be.null expect(body.error).to.be.undefined
done() done()
) )
) )
describe('invite',->
describe('list',->
it('-> validate',(done)->
lib.login((j)->
request({method: 'GET',uri:config.ADDRESS+"/invite",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)
console.log(body.data)
expect(body.error).to.be.null
expect(body.session.login).to.be.undefined
done()
)
)
)
)
)
describe('login',-> describe('login',->
it('-> wrong username',(done)-> it('-> wrong username',(done)->
request({method: 'POST',uri: config.ADDRESS+"/login",json:{ request({method: 'POST',uri: config.ADDRESS+"/login",json:{