Added Docker stuff.
This commit is contained in:
65
admin/components/users/users.component.js
Normal file
65
admin/components/users/users.component.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Edited by: Nermin Jukan, 63150367
|
||||
* Date: 21. 05. 2018
|
||||
* Modifications: Added a delete users function on lines 31-40.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('sloDialectsAdmin')
|
||||
.component('users', {
|
||||
templateUrl: 'components/users/users.template.html',
|
||||
controller: ['$http', '$location', 'AuthenticationService',
|
||||
function UsersController($http, $location, AuthenticationService) {
|
||||
|
||||
var vm = this;
|
||||
vm.go = go;
|
||||
|
||||
vm.user = AuthenticationService.GetCredentials();
|
||||
vm.user.admin = isAdmin(vm.user.username);
|
||||
|
||||
|
||||
//vm.users = [];
|
||||
|
||||
getUsers();
|
||||
|
||||
function isAdmin(username) {
|
||||
//console.log(username);
|
||||
$http.post('../api/admin/', {username: username}).then(function (result) {
|
||||
//console.log(result.data);
|
||||
vm.user.admin = result.data.is_admin;
|
||||
//console.log(vm.user.admin);
|
||||
}, function (error) {
|
||||
console.log('Error retrieving admin rights', error);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO
|
||||
function getUsers() {
|
||||
$http.get('../api/users').then(function (result) {
|
||||
vm.users = result.data;
|
||||
}, function (error) {
|
||||
console.log('Error getting users', error);
|
||||
});
|
||||
}
|
||||
|
||||
vm.delete = function (id, name) {
|
||||
if (confirm("Ali ste prepričani, da želite izbrisati uporabnika " + name + "?")) {
|
||||
$http.delete('../api/users/'+id).then(function(result){
|
||||
console.log(result.data);
|
||||
getUsers();
|
||||
}, function(error){
|
||||
console.log('Error deleting entry:', error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function go(path) {
|
||||
$location.path(path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}]
|
||||
});
|
||||
45
admin/components/users/users.template.html
Normal file
45
admin/components/users/users.template.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!---
|
||||
* Edited by: Nermin Jukan, 63150367
|
||||
* Date: 16. 05. 2018
|
||||
* Modifications: Added a new table header in line 33, inserted a delete-'izbrisi' link, that deletes a user.
|
||||
|
||||
--->
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="toolbar" style="left:0px;">
|
||||
<button type="button" ng-click="$ctrl.go('/')" class="btn btn-default">Nazaj</button>
|
||||
<button type="button" ng-click="$ctrl.go('/login')" class="btn btn-warning">Odjava</button>
|
||||
</div>
|
||||
<h1>Uporabniški računi</h1>
|
||||
<div class="toolbar">
|
||||
<button type="button" ng-if="$ctrl.user.admin == 1" ng-click="$ctrl.go('/user')" class="btn btn-primary save">Dodaj uporabnika</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr bgcolor='#CCCCCC'>
|
||||
<th>#</th>
|
||||
<th>Ime in priimek</th>
|
||||
<th>Uporabniško ime</th>
|
||||
<th title="Lahko dodaja in briše uporabnike">Skrbnik</th>
|
||||
<th ng-if="$ctrl.user.admin == 1">Upravljanje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="user in $ctrl.users">
|
||||
<td>{{ $index + 1 }}</td>
|
||||
<td>{{user.name}}</td>
|
||||
<td>{{user.username}}</td>
|
||||
<td>{{(user.is_admin == 1) ? 'da' : 'ne'}}</td>
|
||||
<td ng-if="$ctrl.user.admin == 1"><a href="" ng-if="user.username !== $ctrl.user.username && $ctrl.user.admin == 1" ng-click="$ctrl.delete(user.id, user.name)">Izbriši</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user