diff --git a/bower.json b/bower.json
index 104e7f7..8218324 100644
--- a/bower.json
+++ b/bower.json
@@ -17,6 +17,7 @@
"angular-ui-router": "^0.3.1",
"angular-bootstrap": "^1.3.3",
"bootstrap": "^3.3.6",
- "bootswatch": "^3.3.7"
+ "bootswatch": "^3.3.7",
+ "ng-table": "^1.0.0"
}
}
diff --git a/public/app/app.js b/public/app/app.js
index f855c98..1f7bc20 100644
--- a/public/app/app.js
+++ b/public/app/app.js
@@ -3,6 +3,7 @@
angular.module('warehost', [
'ui.router',
'ui.bootstrap',
+ 'ngTable',
'config',
'session',
'alert'
diff --git a/public/app/index.js b/public/app/index.js
index 81d884e..a807995 100644
--- a/public/app/index.js
+++ b/public/app/index.js
@@ -23,6 +23,7 @@ angular.module('warehost')
})
.state('app.L.invites', {
url:'/invites',
- templateUrl: 'app/invites.html'
+ templateUrl: 'app/invites.html',
+ controller: 'InvitesCtrl'
});
}]);
diff --git a/public/app/invites.jade b/public/app/invites.jade
index d6e2d40..1dba27b 100644
--- a/public/app/invites.jade
+++ b/public/app/invites.jade
@@ -1,2 +1,28 @@
.container
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
diff --git a/public/app/invites.js b/public/app/invites.js
new file mode 100644
index 0000000..671102a
--- /dev/null
+++ b/public/app/invites.js
@@ -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});
+ });
+ });
diff --git a/public/components/config.js b/public/components/config.js
index 30635e5..582a254 100644
--- a/public/components/config.js
+++ b/public/components/config.js
@@ -2,6 +2,9 @@
angular.module('config', [])
.factory('config', function() {
return {
- api: 'http://[::1]:8080'
+ api: 'http://[::1]:8080',
+ table: {
+ count: 25
+ }
};
});
diff --git a/public/components/ngfilter-boolean.jade b/public/components/ngfilter-boolean.jade
new file mode 100644
index 0000000..f6e7e87
--- /dev/null
+++ b/public/components/ngfilter-boolean.jade
@@ -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
diff --git a/public/index.html b/public/index.html
index da12357..96df75b 100644
--- a/public/index.html
+++ b/public/index.html
@@ -15,10 +15,12 @@
+
-
+
+
@@ -39,12 +41,15 @@
+
+
+
diff --git a/tests/config.json b/tests/config.json
index 9ad6245..15e0cab 100644
--- a/tests/config.json
+++ b/tests/config.json
@@ -1,7 +1,7 @@
{
"ADDRESS":"http://[::1]:8080",
"testdata":{
- "username":"root",
- "password":"root"
+ "username":"genofire",
+ "password":"fire35911"
}
}
diff --git a/tests/index.coffee b/tests/index.coffee
index 9812758..9741319 100644
--- a/tests/index.coffee
+++ b/tests/index.coffee
@@ -13,10 +13,28 @@ describe('API',->
if(typeof body == "string")
body = JSON.parse(body)
expect(body.data).to.be.true
- expect(body.error).to.be.null
+ expect(body.error).to.be.undefined
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',->
it('-> wrong username',(done)->
request({method: 'POST',uri: config.ADDRESS+"/login",json:{