11 Commits

Author SHA1 Message Date
Manuel Romero
d742a4ff2f More to admin provisions 2020-05-10 12:44:45 +02:00
Manuel Romero
990b0d80e3 Fix 2020-05-10 11:57:23 +02:00
Manuel Romero
2d512b49be Disable scenario property 2020-05-10 11:50:35 +02:00
Manuel Romero
61b57d5bc7 Setting isExternalAccess from UI 2020-05-08 16:27:54 +02:00
Manuel Romero
8f48cfbc69 lastLogin 2020-05-07 17:43:31 +02:00
Manuel Romero
9cee830fd4 Admin enhance 2020-05-07 17:18:19 +02:00
Manuel Romero
4f481fd88f vmtypes endpoint 2020-05-07 12:32:21 +02:00
Manuel Romero
2faf109353 disksize default 2020-05-07 12:21:09 +02:00
Manuel Romero
19a0fa715e 128 as minimum disk size 2020-05-07 12:10:54 +02:00
Manuel Romero
2e194b72b8 display disk size on UI 2020-05-07 12:06:02 +02:00
Manuel Romero
039a13bd30 set disk size from UI 2020-05-07 11:56:14 +02:00
24 changed files with 164 additions and 64 deletions

View File

@@ -9,5 +9,5 @@
<link rel="stylesheet" href="styles.529f751cbb5308365172.css"></head>
<body>
<app-root></app-root>
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.e4269137677fbcdfe029.js" defer></script></body>
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.ab99167120bc660b9a38.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "qmi-cloud",
"version": "1.0.12",
"version": "1.0.13",
"scripts": {
"start": "node -r esm server/server.js",
"dev": "nodemon -r esm server/server.js",

View File

@@ -28,6 +28,10 @@ const provisionSchema = new mongoose.Schema({
logFile: String,
outputs: Object,
path: String,
isExternalAccess: {
type: Boolean,
default: false
},
isDestroyed: {
type: Boolean,
default: false

View File

@@ -32,6 +32,10 @@ const scenarioSchema = new mongoose.Schema({
type: Boolean,
default: false
},
isDisabled: {
type: Boolean,
default: false
},
title: {
type: String,
requred: true

View File

@@ -21,7 +21,10 @@ const userSchema = new mongoose.Schema({
role: {
type: String,
default: "user"
}
},
lastLogin: {
type: Date
},
});

View File

@@ -100,10 +100,12 @@ passport.use(new OIDCStrategy({
user = await db.user.add({
"oid": profile.oid,
"upn": profile.upn,
"displayName": profile.displayName
"displayName": profile.displayName,
"lastLogin": new Date()
});
return done(null, user);
}
db.user.update(user._id, {"lastLogin": new Date()});
return done(null, user);
});
});

View File

@@ -32,6 +32,7 @@ router.get('/', passport.ensureAuthenticated, async (req, res, next) => {
if (req.user.role === "user") {
filter.isAdminOnly = false;
}
filter.isDisabled = filter.isDisabled || false;
const result = await db.scenario.get(filter);
return res.json(result);
@@ -42,7 +43,7 @@ router.get('/', passport.ensureAuthenticated, async (req, res, next) => {
/**
* @swagger
* /scenarios:
* /scenarios/vmtypes:
* get:
* description: Get scenarios VM Types
* summary: Get scenarios VM Types

View File

@@ -47,11 +47,21 @@ function _buildExec( exec, provision ) {
exec.push(`vm_type_${key}=${provision.vmImage[key].vmType}`);
}
if (provision.vmImage[key].diskSizeGb) {
exec.push('-var');
exec.push(`disk_size_gb_${key}=${provision.vmImage[key].diskSizeGb}`);
}
if (provision.vmImage[key].version) {
exec.push('-var');
exec.push(`image_reference_${key}=${provision.vmImage[key].version.image}`);
}
}
}
if (provision.isExternalAccess) {
exec.push('-var');
exec.push(`is_external_access=${provision.isExternalAccess}`);
}
return exec;

View File

@@ -24,7 +24,7 @@
<b>Product version: </b> <span>{{item.value.version.name}}</span>
</div>
<div *ngIf="item.value.vmType" >
<b>Instance Type: </b> <span>{{item.value.vmType}}</span> <span *ngIf="item.value.nodeCount">( {{item.value.nodeCount}} nodes )</span>
<b>Instance Type: </b> <span>{{item.value.vmType}} </span> <span *ngIf="item.value.diskSizeGb">( {{item.value.diskSizeGb}} GiB on disk ) </span> <span *ngIf="item.value.nodeCount">( {{item.value.nodeCount}} nodes )</span>
</div>
</div>
<h5 *ngIf="info.outputs" class="info-subtitle">Connection resources</h5>

View File

@@ -6,37 +6,57 @@
</button>
<h4 class="modal-title w-100 font-weight-bold">New provision</h4>
</div>
<div class="modal-body">
<h5>{{scenario.title}}</h5>
<div class="modal-body" style="max-height: 650px; overflow: auto;">
<!--<h5>{{scenario.title}}</h5>-->
<div class="md-form">
<div *ngFor="let server of scenario.availableProductVersions">
<div>
<div>Purpose: (*)</div>
<textarea [(ngModel)]="sendData.description" type="text" class="md-textarea form-control" rows="1" mdbInput placeholder="Short description or Salesforce opportunity"></textarea>
</div>
</div>
<section *ngIf="scenario.isExternal" style="padding: 20px 0px; margin: 0px 20px">
<mdb-checkbox [default]="false" (change)="checkOnchange($event)">Enable External Access</mdb-checkbox>
</section>
<section *ngIf="!scenario.isExternal" style="padding: 20px 0px; margin: 0px 20px">
<mdb-checkbox [default]="false" (change)="checkOnchange($event)" [disabled]="true"><span style="color:#ccc">Enable External Access</span><br><i><mdb-icon fas icon="exclamation-triangle"></mdb-icon> This scenario only allows access from VPN</i></mdb-checkbox>
</section>
<div style="padding-top: 10px" class="md-form" >
<div *ngFor="let server of scenario.availableProductVersions" style="margin-bottom: 15px;">
<h5 style="font-weight: 600; margin-bottom: 0px;">- {{server.product}}</h5>
<div *ngIf="server.versions && server.versions.length">
<div >
<label>Product version for {{server.product}}: (*)</label>
<label>Product version: (*)</label>
</div>
<select id="pversion" class="browser-default custom-select" [(ngModel)]="selectedProductVersion[server.index]">
<select id="pversion" class="browser-default custom-select custom-select-sm" [(ngModel)]="selectedProductVersion[server.index]">
<option *ngFor="let v of server.versions" [value]="v.name">{{v.name}}</option>
</select>
</div>
<div>
<label>VM size for {{server.product}}: (*)</label>
<label>VM type: (*)</label>
</div>
<select id="vmtype" class="browser-default custom-select" [(ngModel)]="selectedVmType[server.index]">
<select id="vmtype" class="browser-default custom-select custom-select-sm" [(ngModel)]="selectedVmType[server.index]">
<option *ngFor="let item of vmTypes" [value]="item.type">{{item.type}} ({{item.desc}})</option>
</select>
<div>
<label>Disk size (GiB): (*)</label>
</div>
<select class="browser-default custom-select custom-select-sm" [(ngModel)]="selectedDiskSizeGb[server.index]">
<option *ngFor="let item of [128,250,500,750,1000]" [value]="item">{{item}}</option>
</select>
<div *ngIf="server.nodeCount">
<label>Num. nodes: (*)</label>
</div>
<select *ngIf="scenario.nodeCount" id="pnodes" class="browser-default custom-select" [(ngModel)]="selectedNodeCount[server.index]">
<select *ngIf="scenario.nodeCount" class="browser-default custom-select custom-select-sm" [(ngModel)]="selectedNodeCount[server.index]">
<option *ngFor="let item of [1,2,3,4,5,6]" [value]="item">{{item}}</option>
</select>
</div>
<div style="padding-top: 20px;">
<div>Set purpose (short description): (*)</div>
<textarea [(ngModel)]="sendData.description" type="text" class="md-textarea form-control" rows="2" mdbInput></textarea>
</div>
</div>
</div>
<div class="modal-footer d-flex justify-content-center">
<button mdbBtn color="dark-green" size="sm" outline="true" class="waves-effect" mdbWavesEffect (click)="modalRef.hide()">Cancel</button>
<button mdbBtn color="dark-green" class="waves-light" size="sm" mdbWavesEffect (click)="confirm();">Create</button>

View File

@@ -1,3 +1,12 @@
label {
position: relative;
}
.md-form {
margin-top: 0px;
margin-bottom: 0px;
}
::placeholder {
color: #ccc;
}

View File

@@ -15,11 +15,13 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
shortDesc: string;
sendData = {
description: "",
servers: null
servers: null,
isExternalAccess: false,
};
selectedProductVersion: any = {};
selectedVmType: any = {};
selectedNodeCount: any = {};
selectedDiskSizeGb: any = {};
vmTypesSub: Subscription;
vmTypes: any;
servers: any = {};
@@ -39,6 +41,9 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
if ( server.nodeCount ) {
this.selectedNodeCount[server.index] = server.nodeCount;
}
this.selectedDiskSizeGb[server.index] = server.diskSizeGbDefault || 500;
if ( server.versions && server.versions.length ) {
let lastIndex = server.versions.length - 1;
this.selectedProductVersion[server.index] = server.productVersionDefault? server.productVersionDefault : server.versions[lastIndex].name;
@@ -72,6 +77,10 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
this.sendData.servers[key].nodeCount = this.selectedNodeCount[key];
}
if ( this.selectedDiskSizeGb[key] ) {
this.sendData.servers[key].diskSizeGb = this.selectedDiskSizeGb[key];
}
this.scenario.availableProductVersions.forEach(server => {
server.versions.forEach(v=> {
if (v.name === this.selectedProductVersion[key]){
@@ -80,8 +89,14 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
})
});
}
this.action.next(this.sendData);
console.log("sendData", this.sendData);
//this.action.next(this.sendData);
this.modalRef.hide();
}
checkOnchange($event) {
console.log("Checked?", $event.checked);
this.sendData.isExternalAccess = $event.checked;
}
}

View File

@@ -1,18 +1,19 @@
<p>
<mdb-icon fas icon="globe-americas" size="lg" class="grey-text pr-1" aria-hidden="true"></mdb-icon>Scenario with External Access available
<span *ngIf="user && (user.role === 'admin' || user.role === 'superadmin')"><mdb-icon fas icon="user-secret" size="lg" class="ml-5 grey-text pr-1" aria-hidden="true"></mdb-icon>Only Administrators can see</span>
</p>
<div class="md-form">
<mdb-icon fas icon="search" aria-hidden="true"></mdb-icon>
<input type="search" [(ngModel)]="searchText" class="ml-2" placeholder="Search text">
</div>
<p>
<mdb-icon fas icon="globe-americas" size="lg" class="grey-text pr-1" aria-hidden="true"></mdb-icon>Scenario with External Access
<span *ngIf="user && (user.role === 'admin' || user.role === 'superadmin')"><mdb-icon fas icon="user-secret" size="lg" class="ml-5 grey-text pr-1" aria-hidden="true"></mdb-icon>Only Administrators can see</span>
</p>
<div class="flexcontainer">
<mdb-card class="qmicard" *ngFor="let s of scenarios | filter: searchText">
<!--Card content-->
<div class="card-badge">
<mdb-icon *ngIf="s.isExternal" fas icon="globe-americas" size="lg" class="grey-text" aria-hidden="true" mdbTooltip="External Access" placement="top"></mdb-icon>
<mdb-icon *ngIf="s.isExternal" fas icon="globe-americas" size="lg" class="grey-text" aria-hidden="true" mdbTooltip="External Access available" placement="top"></mdb-icon>
<mdb-icon *ngIf="s.isAdminOnly" fas icon="user-secret" size="lg" class="grey-text" aria-hidden="true" mdbTooltip="Only Administrators can see" placement="top"></mdb-icon>
</div>
<mdb-card-header>

View File

@@ -40,7 +40,6 @@ export class ScenariosComponent implements OnInit, OnDestroy {
ngOnDestroy() {}
openNewProvisionConfirmModal(scenario) {
console.log("scenario", scenario);
var modalRef = this.modalService.show(NewProvisionConfirmComponent, {
class: 'modal-md modal-notify',
containerClass: '',
@@ -54,16 +53,13 @@ export class ScenariosComponent implements OnInit, OnDestroy {
const postData = {
scenario: scenario.name,
description: data.description
description: data.description,
isExternalAccess: data.isExternalAccess
};
if ( data.servers ) {
if ( data.servers ) {
postData["vmImage"] = data.servers;
}
console.log("postData", postData);
this._provisionsService.newProvision(postData, this.user._id).subscribe( res => {
console.log("Done!", res);

View File

@@ -16,23 +16,29 @@
<table mdbTable #tableEl="mdbTable" stickyHeader="true" hover="true" class="z-depth-1 table table-sm">
<thead class="sticky-top">
<tr>
<th>Date</th>
<th>Type</th>
<th>Message</th>
<th style="width: 155px;">Date</th>
<th>Type</th>
<th>ProvisionID</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of elements; let i = index">
<th *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"
scope="row">{{item.created | date: 'MMM dd, yyyy - H:mm'}}</th>
<th *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"
scope="row">{{item.type}}</th>
scope="row">{{item.created | date: 'MMM dd, yyyy - H:mm'}}</th>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">
<span style="text-transform: capitalize;" class="badge" [ngClass]="{'badge-warning': item.type.indexOf('warning') !== -1, 'badge-secondary': item.type.indexOf('warning') === -1}">
{{item.type.replace("warning", "")}}
</span>
</td>
<th *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{item.provision}}</th>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{item.message}}</td>
</tr>
</tbody>
<tfoot class="grey lighten-5 w-100">
<tr>
<td colspan="3">
<td colspan="4">
<mdb-table-pagination [tableEl]="tableEl" [searchDataSource]="elements"></mdb-table-pagination>
</td>
</tr>

View File

@@ -0,0 +1,3 @@
.table td, .table th {
vertical-align: middle;
}

View File

@@ -25,7 +25,8 @@
<th [mdbTableSort]="elements" sortBy="created" >Prov. Date <mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="user.displayName">User <mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="scenario">Scenario <mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="statusVms">Status VMs (Running time)<mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="isExternalAccess">Ext. Access? <mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="statusVms">VMs (Running time)<mdb-icon fas icon="sort"></mdb-icon></th>
<th [mdbTableSort]="elements" sortBy="status">Status <mdb-icon fas icon="sort"></mdb-icon></th>
<th style="border-left:2px solid #ccc;">DestroyID</th>
<th>Dest. Date</th>
@@ -41,6 +42,7 @@
<td (click)="openInfoModal(provision)" *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.created | date: 'MMM dd, yyyy - H:mm'}}</td>
<td (click)="openInfoModal(provision)" *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" class="ell" title="{{provision.path}}" >{{provision.user.displayName}}</td>
<td (click)="openInfoModal(provision)"*ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.scenario}}</td>
<td style="text-align: center;" (click)="openInfoModal(provision)"*ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)"><mdb-icon *ngIf="provision.isExternalAccess" fas icon="check"></mdb-icon></td>
<td (click)="openInfoModal(provision)" *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
<span>
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-success': provision.statusVms === 'Running', 'badge-warning': provision.statusVms === 'Stopped' || provision.statusVms === 'Stopping' || provision.statusVms === 'Starting'}">{{provision.statusVms}}</span>
@@ -93,6 +95,9 @@
<button style="margin-right: 3px;" title="Remove entry" *ngIf="provision.isDestroyed && provision.destroy.status === 'destroyed'" (click)="openConfirmDeleteModal(provision);" class="lui-button lui-text-danger">
<span class="lui-icon lui-icon--bin" aria-hidden="true"></span>
</button>
<button style="margin-right: 3px;" title="Extend Running VMs 4 days" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Running'" (click)="extend(provision)" class="lui-button">
+4d
</button>
</td>
</tr>
</tbody>

View File

@@ -21,6 +21,10 @@
}
}
tr:hover {
.table tr:hover {
cursor: pointer;
}
.table td {
vertical-align: middle;
}

View File

@@ -310,4 +310,17 @@ export class TableProvisionsAdminComponent implements OnInit, OnDestroy, AfterVi
this.refreshData();
}
extend(provision) : void {
this._provisionsService.extend(provision._id.toString(), provision.user._id).subscribe( res => {
provision.countExtend = res.countExtend;
provision.timeRunning = res.timeRunning;
provision.runningFrom = res.runningFrom;
this._provisionsService.timeRunning(provision);
this._alertService.showAlert({
type: 'alert-primary',
text: `Running period extended another ${this._provisionsService.RUNNING_PERIOD} days (from now) for provision '${provision.scenario}'`
});
})
}
}

View File

@@ -13,6 +13,7 @@
<th>IsAdminOnly</th>
<th>IsExternal</th>
<th>IsWafPolicyAppGw</th>
<th>IsDisabled</th>
<th>NewImageName(gen)</th>
</tr>
@@ -27,6 +28,7 @@
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isAdminOnly" [default]="false" (change)="FieldsChange(item, 'isAdminOnly', $event)"></mdb-checkbox></td>
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isExternal" [default]="false" (change)="FieldsChange(item, 'isExternal', $event)"></mdb-checkbox></td>
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isWafPolicyAppGw" [default]="false" (change)="FieldsChange(item, 'isWafPolicyAppGw', $event)"></mdb-checkbox></td>
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isDisabled" [default]="false" (change)="FieldsChange(item, 'isDisabled', $event)"></mdb-checkbox></td>
<td contenteditable="true" (keyup)="changeValue(item._id, 'newImageName', $event)" (blur)="updateList(item, 'newImageName', $event)" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{item.newImageName}}</td>
</tr>

View File

@@ -17,30 +17,37 @@
<thead class="sticky-top">
<tr>
<th>Id</th>
<th [mdbTableSort]="elements" sortBy="created">Created <mdb-icon fas icon="sort"></mdb-icon></th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th></th>
<th style="text-align: center;">Is Admin?</th>
<th [mdbTableSort]="elements" sortBy="lastLogin">LastLogin <mdb-icon fas icon="sort"></mdb-icon></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let user of elements; let i = index">
<tr mdbTableCol *ngFor="let user of elements; let i = index">
<th *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"
scope="row">{{user._id}}</th>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{user.created | date: 'MMM dd, yyyy - H:mm'}}</td>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{user.displayName}}</td>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{user.upn}}</td>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><span *ngIf="user.role">{{user.role}}</span></td>
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><span>{{user.role}}</span></td>
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">
<mdb-checkbox *ngIf="user.role !== 'superadmin' && currentUser && currentUser._id.toString() !== user._id.toString()" [checked]="user.role === 'admin' || user.role === 'superadmin'" [default]="false" (change)="FieldsChange(user, $event)"></mdb-checkbox>
</td>
<!--<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">
<div *ngIf="currentUser && currentUser._id.toString() !== user._id.toString()">
<button *ngIf="user.role !== 'admin' && user.role !== 'superadmin'" class="lui-button" (click)="setAdmin(user)">Set Admin</button>
<button *ngIf="user.role === 'admin'" class="lui-button" (click)="removeAdmin(user)">Remove Admin</button>
</div>
</td>
</td>-->
<td *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><span *ngIf="user.lastLogin">{{user.lastLogin | date: 'MMM dd, yyyy - H:mm'}}</span></td>
</tr>
</tbody>
<tfoot class="grey lighten-5 w-100">
<tr>
<td colspan="5">
<td colspan="6">
<mdb-table-pagination [tableEl]="tableEl" [searchDataSource]="elements"></mdb-table-pagination>
</td>
</tr>

View File

@@ -0,0 +1,3 @@
.table td {
vertical-align: middle;
}

View File

@@ -47,6 +47,9 @@ export class TableUsersComponent implements OnInit, AfterViewInit {
this.searchText = "";
var usersSub = this._usersService.getUsers().subscribe( res => {
usersSub.unsubscribe();
res.results.forEach(u=>{
u.lastLogin = u.lastLogin || u.created;
});
this.elements = res.results;
this.loading = false;
this._initElements();
@@ -84,22 +87,11 @@ export class TableUsersComponent implements OnInit, AfterViewInit {
});
}
setAdmin(user) : void {
this._usersService.updateUser(user._id, {"role": "admin"}).subscribe( res1 => {
this._usersService.getUsers().subscribe( res => {
this.elements = res.results;
this._initElements();
});
})
}
removeAdmin(user) : void {
this._usersService.updateUser(user._id, {"role": "user"}).subscribe( res1 => {
this._usersService.getUsers().subscribe( res => {
this.elements = res.results;
this._initElements();
});
})
FieldsChange(user: any, value:any) {
var patchData = {"role": value.checked? "admin": "user"};
this._usersService.updateUser(user._id, patchData).subscribe( res1 => {
user.role = res1.role;
});
}
}