Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
056964306b | ||
|
|
921ef46b06 | ||
|
|
3eed9c9b9a | ||
|
|
3e410e4eca | ||
|
|
720c2586bd |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,4 +47,5 @@ Thumbs.db
|
||||
secrets.json
|
||||
|
||||
qmi-cloud-tf-modules/
|
||||
*.pfx
|
||||
|
||||
|
||||
2
dist/qmi-cloud/index.html
vendored
2
dist/qmi-cloud/index.html
vendored
@@ -9,5 +9,5 @@
|
||||
<link rel="stylesheet" href="styles.a1477262c132edf53006.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.cc5d7fb76aa54d397727.js" defer></script><script src="main.2460133151dbe7cec73e.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.cc5d7fb76aa54d397727.js" defer></script><script src="main.fcfe19b1ff3057c062d4.js" defer></script></body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "qmi-cloud",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"scripts": {
|
||||
"start": "node -r esm server/server.js",
|
||||
"dev": "nodemon -r esm server/server.js",
|
||||
|
||||
0
server/certs/.keep
Normal file
0
server/certs/.keep
Normal file
@@ -1,13 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICAjCCAWsCFErekshtMPI0fqmz3A7nylyqZjP8MA0GCSqGSIb3DQEBCwUAMEAx
|
||||
CzAJBgNVBAYTAlVTMRMwEQYDVQQIDApTb21lLVN0YXRlMQ0wCwYDVQQKDARHRUFS
|
||||
MQ0wCwYDVQQLDARHRUFSMB4XDTIwMDExNTExMTIzNFoXDTIxMDExNDExMTIzNFow
|
||||
QDELMAkGA1UEBhMCVVMxEzARBgNVBAgMClNvbWUtU3RhdGUxDTALBgNVBAoMBEdF
|
||||
QVIxDTALBgNVBAsMBEdFQVIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALtP
|
||||
gdhWsY9kETiO1y69v3gu6AXqTz6AZm/AfLlboe03zO4XHKSmvDKI+jx6/+GuuR/u
|
||||
ZSNkJTdOszUDMKl+V2wvyAuvBotirVHXmj/5tb7zDDTMgaQwP/0w+GIxm09ED40Z
|
||||
qgXF6nCeXHFSRzej1dDxKRtp1t4QAezoB73mtm+vAgMBAAEwDQYJKoZIhvcNAQEL
|
||||
BQADgYEABgqzxUGd6PrwobXqaQKE8iHPjgR94clktM2+morAbXeV2trKhwaGDZiG
|
||||
d/ODKEk+gehnXbGWjxxIbqWyac7HQQMGZ46jbJyIo32ltbxouylquV+ZR4HvxJmi
|
||||
8h6Jd8dyGZDZv0lSTOL9525Du4eaYQA6GVCrZsoaQDwYJTo4GWM=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,15 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICWwIBAAKBgQC7T4HYVrGPZBE4jtcuvb94LugF6k8+gGZvwHy5W6HtN8zuFxyk
|
||||
prwyiPo8ev/hrrkf7mUjZCU3TrM1AzCpfldsL8gLrwaLYq1R15o/+bW+8ww0zIGk
|
||||
MD/9MPhiMZtPRA+NGaoFxepwnlxxUkc3o9XQ8SkbadbeEAHs6Ae95rZvrwIDAQAB
|
||||
AoGAY06h7sr31KgfITdKCrP7IYLs7MXvQZndtX3+Il/cl+IvukNyojDsMnbBBPPJ
|
||||
WiPCbpV79amQuaP2CzMnx5T+T6sxdhMzp1eKpYF0WrldAE9gxjfGT5xmXQb8FxLe
|
||||
yKDqf5HRU1LpMuktOoBx4i8P2RqkWE8txWg2dU+2occfNmECQQDhhD42bJnGWEko
|
||||
LRHG+jsH93/hvwn2y0xVpO57Hvaf8rWPBYaFx/4LP0/WlrR7hxWeb1miYbEXkLqg
|
||||
a+IeUndXAkEA1KEv2u7y7ZV274Miku2Ldcc6+gWynwci9WZMXKi7uY8r04wZ9PcC
|
||||
MutbSwAjbbnubBquHFkwSTzrF1m27ltLaQJAV9YgPSZzhpOgeuuC/xM7ptC5mH3G
|
||||
Lb/lTX5d/MqEmKv6F2i5iqXoxwyz1gsA5RQqUXlhWiPezCTs68rZWaIZJQJAbLN6
|
||||
o5JE3vDqPMfthO+rvCp+HBONnX8ogAwsPbKFRffLj/qvymv808s+gLkxY4cKPHnn
|
||||
SNbPuKFMDkPvISvLAQJAAsBhe8m9kuEoSPeECPOFZjG6+WlFAagODvGDVY5uZhAF
|
||||
ARkTxCGgp5hY2cXpFmU9usMPvvUJuCBAhgbWo7mszg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -120,9 +120,13 @@ app.listen(3000, () => {
|
||||
console.log(`Server listening on port 3000`)
|
||||
});
|
||||
|
||||
https.createServer({
|
||||
key: fs.readFileSync(path.resolve(__dirname, 'certs', 'fake_server.key')),
|
||||
cert: fs.readFileSync(path.resolve(__dirname, 'certs', 'fake_server.cert'))
|
||||
}, app).listen(3100, function(){
|
||||
var optionsHttps = {
|
||||
pfx: fs.readFileSync(path.resolve(__dirname, 'certs', process.env.CERT_PFX_FILENAME)),
|
||||
passphrase: process.env.CERT_PFX_PASSWORD
|
||||
};
|
||||
|
||||
https.createServer(optionsHttps, app).listen(3100, function(){
|
||||
console.log(`Secure server listening on port 3100`);
|
||||
});
|
||||
|
||||
|
||||
|
||||
19
server/shell/appgw.ps1
Normal file
19
server/shell/appgw.ps1
Normal file
@@ -0,0 +1,19 @@
|
||||
Params (
|
||||
[string] $ApplicationGatewayName,
|
||||
[string] $ApplicationGatewayResourceGroup = "AppGW_RG",
|
||||
[string] $PolicyName = "QlikSenseDefault",
|
||||
[string] $PolicyResourceGroup = "QMI-infra-vnet"
|
||||
)
|
||||
|
||||
Connect-AzAccount -Identity
|
||||
$gw = Get-AzApplicationGateway -Name $ApplicationGatewayName -ResourceGroupName $ApplicationGatewayResourceGroup
|
||||
$policy = Get-AzApplicationGatewayFirewallPolicy -Name $PolicyName -ResourceGroupName $PolicyResourceGroup
|
||||
|
||||
#Save the policy itself
|
||||
Set-AzApplicationGatewayFirewallPolicy -InputObject $policy
|
||||
|
||||
#Attach the policy to an Application Gateway
|
||||
$gw.FirewallPolicy = $policy
|
||||
|
||||
#Save the Application Gateway
|
||||
Set-AzApplicationGateway -ApplicationGateway $gw
|
||||
@@ -2,8 +2,8 @@ const db = require('../mongo.js');
|
||||
const path = require('path');
|
||||
const PROJECT_PATH = process.env.PROJECT_PATH;
|
||||
const tf = require("./docker/tf");
|
||||
const azure = require("./docker/azure");
|
||||
const sendEmail = require("../send-email.js");
|
||||
|
||||
module.exports = async function(job) {
|
||||
|
||||
const provJob = await db.provision.update(job.data.id, {
|
||||
@@ -23,6 +23,9 @@ module.exports = async function(job) {
|
||||
}).then(function(provJobUpdated) {
|
||||
// TERRAFORM APPLY
|
||||
return tf.apply(provJobUpdated, job.data.user.displayName);
|
||||
}).then(async function(mongoUpdated) {
|
||||
// Application Gateway assign policy
|
||||
return azure.appgateway(mongoUpdated);
|
||||
}).then(async function(output) {
|
||||
var status = ( output.indexOf("Error:") !== -1 )? "error" : "provisioned";
|
||||
return await db.provision.update(provJob._id, {"status": status});
|
||||
|
||||
43
server/workers/docker/azure.js
Normal file
43
server/workers/docker/azure.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const Docker = require('dockerode');
|
||||
const docker = new Docker({
|
||||
'socketPath': '/home/docker.sock'
|
||||
//'socketPath': '/var/run/docker.sock'
|
||||
});
|
||||
const fs = require("fs");
|
||||
const DOCKERIMAGE = "mcr.microsoft.com/azure-powershell";
|
||||
//const cmd = `docker run --net=host -w /myapp -v ${FOLDER}:/myapp mcr.microsoft.com/azure-powershell pwsh appgw.ps1 -ApplicationGatewayName ${appGwName}`;
|
||||
|
||||
const appgateway = function( mongoJob ) {
|
||||
|
||||
if ( mongoJob.scenario === 'azqmi-qs-sn' || mongoJob.scenario === 'azqmi-qdc-qs') {
|
||||
var provision_id = mongoJob._id.toString();
|
||||
var processStream = fs.createWriteStream(mongoJob.logFile, {flags:'a'});
|
||||
var name = 'qmi-azureps-appgw-'+provision_id;
|
||||
console.log(`AzurePS: will spin up container: ${name}`);
|
||||
|
||||
return docker.run(DOCKERIMAGE, ['pwsh', 'appgw.ps1', "-ProvisionId", provision_id ], processStream, {
|
||||
"name": name,
|
||||
"WorkingDir": "/myapp",
|
||||
"HostConfig": {
|
||||
"Binds": [
|
||||
`${mongoJob.path}/shell:/myapp`
|
||||
],
|
||||
"NetworkMode": "host"
|
||||
}
|
||||
}).then(function(data) {
|
||||
var output = data[0];
|
||||
var container = data[1];
|
||||
console.log(`AzurePS: ${name} (${container.id}) has finished with code: ${output.StatusCode}`);
|
||||
return container.remove();
|
||||
}).then(function() {
|
||||
console.log(`AzurePS: ${name} removed!`);
|
||||
return Promise.resolve(mongoJob);
|
||||
});
|
||||
|
||||
} else {
|
||||
return Promise.resolve(mongoJob);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.appgateway = appgateway;
|
||||
@@ -1,103 +1,8 @@
|
||||
<app-logs [show]="logShow" (onClose)="onLogsClose()" [type]="logstype" [selectedprov]="selectedprov"></app-logs>
|
||||
|
||||
<h1 style="margin-top: 80px;">Users</h1>
|
||||
|
||||
<div *ngIf="showInfo" class="modal-popover">
|
||||
<div class="popover-content" #popovercontent>
|
||||
<div class="lui-popover">
|
||||
<div class="lui-popover__header">
|
||||
<div class="lui-popover__title"><h4><i class="fa fa-info-circle"></i> Provision information</h4></div>
|
||||
</div>
|
||||
<div class="lui-popover__body">
|
||||
<div>
|
||||
<b>Scenario: </b> {{selectedprov._scenario[0].title}}
|
||||
</div>
|
||||
<div>
|
||||
<b>ProvisionID: </b> {{selectedprov._id}}
|
||||
</div>
|
||||
<div>
|
||||
<b>Instance Type: </b> {{selectedprov.vmType}}
|
||||
</div>
|
||||
<div *ngIf="selectedprov.nodeCount">
|
||||
<b>Number of nodes: </b> {{selectedprov.nodeCount}}
|
||||
</div>
|
||||
<h5 style="padding-top: 10px;">Connection resources</h5>
|
||||
<div *ngFor="let item of selectedprov.outputs | keyvalue">
|
||||
<b>{{item.key}}</b>
|
||||
<pre class="mypre">{{item.value}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lui-popover__footer">
|
||||
<button class="lui-button lui-popover__button" (click)="showInfo = false">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table-users *ngIf="users.length" [elements]="users"></table-users>
|
||||
|
||||
|
||||
<h1>Provisions</h1>
|
||||
<table-admin *ngIf="provisions.length" [elements]="provisions"></table-admin>
|
||||
|
||||
|
||||
<table-admin *ngIf="provisions.length" [elements]="provisions" [headElements]="headElements"></table-admin>
|
||||
|
||||
<!--
|
||||
<table class="table table-sm table-hover" style="margin-bottom: 100px; font-size: 12px;">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<td></td>
|
||||
<th colspan="6">Scenario Provision</th>
|
||||
<th colspan="3" style="border-left:2px solid #ccc;">Scenario Destroy</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>ProvisionID</th>
|
||||
<th>Prov. Date</th>
|
||||
<th>User</th>
|
||||
<th>Scenario</th>
|
||||
<th>Status VMs</th>
|
||||
<th style="width: 150px;">Status</th>
|
||||
<th style="border-left:2px solid #ccc;">DestroyID</th>
|
||||
<th>Dest. Date</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr *ngFor="let provision of provisions; let i = index">
|
||||
<td>
|
||||
<button style="margin-right: 5px;" class="lui-button" (click)="showResources($event,provision)">
|
||||
<span class="lui-icon lui-icon--info" aria-hidden="true"></span>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<a href (click)="showLogs($event, provision, 'provision')" class="lui-text-info">{{ provision._id }}</a>
|
||||
</td>
|
||||
<td>{{provision.created | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td class="ell" title="{{provision.path}}" >{{provision.user}}</td>
|
||||
<td>{{provision.scenario}}</td>
|
||||
<td>{{provision.statusVms}}</td>
|
||||
<td>
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.status === 'provisioning' || provision.status === 'initializing', 'badge-success': provision.status === 'provisioned', 'badge-danger': provision.status === 'error' }">{{provision.status}}</span>
|
||||
<span *ngIf="provision.status === 'provisioning' || provision.status === 'initializing'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
<td style="border-left:2px solid #ccc;"><a *ngIf="provision.destroyId" href (click)="showLogs($event, provision, 'destroy')" class="lui-text-info">{{provision.destroyId}}</a></td>
|
||||
<td>{{provision.dateDestroy | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td>
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.statusDestroy === 'destroying', 'badge-success': provision.statusDestroy === 'destroyed', 'badge-danger': provision.statusDestroy === 'error'}">{{provision.statusDestroy}}</span>
|
||||
<span *ngIf="provision.statusDestroy === 'destroying'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<button title="Stop Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Running'" (click)="stopVms(provision)" class="lui-button"><span class="lui-icon lui-icon--stop" aria-hidden="true"></span></button>
|
||||
<button title="Start Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Stopped'" (click)="startVms(provision)" class="lui-button"><span class="lui-icon lui-icon--run" aria-hidden="true"></span></button>
|
||||
<button title="Destroy provision" *ngIf="!provision.isDestroyed && provision.statusDestroy !== 'destroying' && provision.status !== 'provisioning'" (click)="destroy(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--remove" aria-hidden="true"></span></button>
|
||||
<button title="Remove entry" *ngIf="provision.isDestroyed && provision.statusDestroy === 'destroyed'" (click)="del(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--bin" aria-hidden="true"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>-->
|
||||
<qmi-alert></qmi-alert>
|
||||
|
||||
@@ -1,26 +1,3 @@
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.modal-popover {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
background: rgba(0,0,0,0.5);
|
||||
.lui-popover {
|
||||
max-width: 700px;
|
||||
}
|
||||
.popover-content {
|
||||
position: relative;
|
||||
top: 10%;
|
||||
}
|
||||
.lui-popover__body {
|
||||
font-size: 14px;
|
||||
max-height: 600px;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { UsersService } from '../services/users.service';
|
||||
import { ProvisionsService } from '../services/provisions.service';
|
||||
import { Subscription, timer } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { AuthGuard } from '../services/auth.guard';
|
||||
import { ScenariosService } from '../services/scenarios.service';
|
||||
|
||||
|
||||
@@ -13,29 +12,14 @@ import { ScenariosService } from '../services/scenarios.service';
|
||||
styleUrls: ['./admin.component.scss']
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
|
||||
|
||||
|
||||
headElements = ['', 'ProvisionID', 'Prov. Date', 'User', 'Scenario', 'Status VMs', 'Status', 'DestroyID', 'Dest. Date', 'Status', ''];
|
||||
|
||||
currentUser;
|
||||
users;
|
||||
provisions;
|
||||
destroys;
|
||||
subscription: Subscription;
|
||||
logShow: boolean = false;
|
||||
logstype: String = 'provision';
|
||||
selectedprov: Object = null;
|
||||
showInfo: boolean = false;
|
||||
usersSub: Subscription;
|
||||
scenariosSub: Subscription;
|
||||
scenarios;
|
||||
|
||||
constructor( private _usersService: UsersService, private _provisionsService: ProvisionsService, private _auth: AuthGuard, private _scenariosService: ScenariosService ) {
|
||||
this._auth.getUserInfo().subscribe( value => {
|
||||
this.currentUser = value;
|
||||
});
|
||||
}
|
||||
constructor( private _usersService: UsersService, private _provisionsService: ProvisionsService, private _scenariosService: ScenariosService ) { }
|
||||
|
||||
private _fillUser(pair) {
|
||||
pair['0'].forEach(prov => {
|
||||
@@ -48,59 +32,54 @@ export class AdminComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private _getUsers() {
|
||||
|
||||
}
|
||||
|
||||
private _process(pair) : void {
|
||||
this._provisionsService.composePair(pair);
|
||||
pair[0].forEach(p=>{
|
||||
p._scenario = this.scenarios.filter(s => s.name === p.scenario);
|
||||
});
|
||||
this._fillUser(pair);
|
||||
this.destroys = pair[1];
|
||||
|
||||
if ( !this.provisions ) {
|
||||
this.provisions = pair[0];
|
||||
} else {
|
||||
this.provisions.forEach( function(p, index, object) {
|
||||
let found = pair[0].filter(a=>a._id.toString() === p._id.toString());
|
||||
if ( found.length ) {
|
||||
p.status = found[0].status;
|
||||
p.statusVms = found[0].statusVms;
|
||||
p.isDestroyed = found[0].isDestroyed;
|
||||
if (found[0].destroyId) {
|
||||
p.destroyId = found[0].destroyId;
|
||||
p.dateDestroy = found[0].dateDestroy;
|
||||
p.statusDestroy = found[0].statusDestroy;
|
||||
}
|
||||
} else {
|
||||
object.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
pair[0].forEach(function(p) {
|
||||
let found = this.provisions.filter(a=>a._id.toString() === p._id.toString());
|
||||
if (found.length === 0){
|
||||
this.provisions.unshift(p);
|
||||
pair[0].forEach(p=>{
|
||||
p._scenario = this.scenarios.filter(s => s.name === p.scenario);
|
||||
});
|
||||
this._fillUser(pair);
|
||||
this.destroys = pair[1];
|
||||
|
||||
if ( !this.provisions ) {
|
||||
this.provisions = pair[0];
|
||||
} else {
|
||||
this.provisions.forEach( function(p, index, object) {
|
||||
let found = pair[0].filter(a=>a._id.toString() === p._id.toString());
|
||||
if ( found.length ) {
|
||||
p.status = found[0].status;
|
||||
p.statusVms = found[0].statusVms;
|
||||
p.isDestroyed = found[0].isDestroyed;
|
||||
if (found[0].destroyId) {
|
||||
p.destroyId = found[0].destroyId;
|
||||
p.dateDestroy = found[0].dateDestroy;
|
||||
p.statusDestroy = found[0].statusDestroy;
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
} else {
|
||||
object.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
pair[0].forEach(function(p) {
|
||||
let found = this.provisions.filter(a=>a._id.toString() === p._id.toString());
|
||||
if (found.length === 0){
|
||||
this.provisions.unshift(p);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
this.scenariosSub = this._scenariosService.getScenarios().subscribe( res => {
|
||||
|
||||
var scenariosSub = this._scenariosService.getScenarios().subscribe( res => {
|
||||
scenariosSub.unsubscribe();
|
||||
|
||||
this.scenarios = res;
|
||||
this.scenariosSub.unsubscribe();
|
||||
|
||||
var usersSub = this._usersService.getUsers().subscribe( res => {
|
||||
usersSub.unsubscribe();
|
||||
|
||||
this.usersSub = this._usersService.getUsers().subscribe( res => {
|
||||
|
||||
this.users = res;
|
||||
this.usersSub.unsubscribe();
|
||||
|
||||
this.subscription = timer(0, 5000).pipe( switchMap(() => this._provisionsService.getCombinedProvisionsAdmin() ) ).subscribe(pair => {
|
||||
this._process(pair);
|
||||
});
|
||||
@@ -116,80 +95,9 @@ export class AdminComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
if ( this.subscription ) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
del(provision): void {
|
||||
this._provisionsService.delProvision(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
this._refresh();
|
||||
})
|
||||
}
|
||||
|
||||
destroy(provision) : void{
|
||||
this._provisionsService.newDestroy({"id": provision._id.toString()}, provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
this._refresh();
|
||||
})
|
||||
}
|
||||
|
||||
startVms(provision): void {
|
||||
this._provisionsService.startVms(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
provision.startVms = res.startVms;
|
||||
})
|
||||
}
|
||||
|
||||
stopVms(provision): void {
|
||||
this._provisionsService.stopVms(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
provision.startVms = res.startVms;
|
||||
})
|
||||
}
|
||||
|
||||
showLogs($event, provision, type): void {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
this.logstype = type;
|
||||
this.logShow = false;
|
||||
this.selectedprov = provision;
|
||||
this.logShow = true;
|
||||
}
|
||||
|
||||
onLogsClose(): void {
|
||||
this.selectedprov = null;
|
||||
this.logShow = false;
|
||||
}
|
||||
|
||||
onStartProvision(): void {
|
||||
console.log("onStartProvision");
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
setAdmin(user) : void {
|
||||
this._usersService.updateUser(user._id, {"role": "admin"}).subscribe( res1 => {
|
||||
console.log("Updated", res1);
|
||||
this._usersService.getUsers().subscribe( res => {
|
||||
this.users = res;
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
removeAdmin(user) : void {
|
||||
this._usersService.updateUser(user._id, {"role": null}).subscribe( res1 => {
|
||||
console.log("Updated", res1);
|
||||
this._usersService.getUsers().subscribe( res => {
|
||||
this.users = res;
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
showResources($event, provision): void {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
this.selectedprov = provision;
|
||||
console.log("this.selectedprov", this.selectedprov);
|
||||
this.showInfo = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
src/app/alert/alert.component.html
Normal file
13
src/app/alert/alert.component.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="qmialert" *ngIf="alert">
|
||||
<div #qmialert class="alert alert-info alert-dismissible fade show" [ngClass]="alert.type" role="alert">
|
||||
<button type="button" class="close" aria-label="Close" (click)="closeAlert()">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h5 class="alert-heading">
|
||||
<span *ngIf="alert.type === 'alert-warning'" class="fa fa-warning"></span>
|
||||
<span *ngIf="alert.type === 'alert-primary'" class="fa fa-info-circle"></span>
|
||||
<span> {{alert.text}}</span>
|
||||
</h5>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
9
src/app/alert/alert.component.scss
Normal file
9
src/app/alert/alert.component.scss
Normal file
@@ -0,0 +1,9 @@
|
||||
.qmialert {
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
}
|
||||
32
src/app/alert/alert.component.ts
Normal file
32
src/app/alert/alert.component.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
||||
import { AlertService } from '../services/alert.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'qmi-alert',
|
||||
templateUrl: './alert.component.html',
|
||||
styleUrls: ['./alert.component.scss']
|
||||
})
|
||||
export class AlertComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild('qmialert', { static: true }) alertEl: ElementRef;
|
||||
subscription: Subscription;
|
||||
alert : any = null;
|
||||
|
||||
constructor(private _alertService: AlertService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscription = this._alertService.getAlertEmitter().subscribe(function(data){
|
||||
this.alert = data;
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
closeAlert() {
|
||||
this.alert = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import { MyHttpInterceptor } from './interceptors/http.interceptor';
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { TableAdminComponent } from './tables/table-admin.component';
|
||||
import { TableUsersComponent } from './tables/table-users.component';
|
||||
import { AlertComponent } from './alert/alert.component';
|
||||
import { AlertService } from './services/alert.service';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@@ -34,7 +36,8 @@ import { TableUsersComponent } from './tables/table-users.component';
|
||||
AdminComponent,
|
||||
PopoverconfirmComponent,
|
||||
TableAdminComponent,
|
||||
TableUsersComponent
|
||||
TableUsersComponent,
|
||||
AlertComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@@ -49,6 +52,7 @@ import { TableUsersComponent } from './tables/table-users.component';
|
||||
ProvisionsService,
|
||||
ScenariosService,
|
||||
UsersService,
|
||||
AlertService,
|
||||
AuthGuard
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
|
||||
@@ -1,42 +1,10 @@
|
||||
<app-logs [show]="logShow" (onClose)="onLogsClose()" [type]="logstype" [selectedprov]="selectedprov"></app-logs>
|
||||
<div style="margin-top: 80px;">
|
||||
<h1>Scenarios</h1>
|
||||
<app-scenarios (onStartProvision)="onStartProvision()"></app-scenarios>
|
||||
<app-scenarios (onStartProvision)="onStartProvision($event)"></app-scenarios>
|
||||
</div>
|
||||
|
||||
<div *ngIf="showInfo" class="modal-popover">
|
||||
<div class="popover-content" #popovercontent>
|
||||
<div class="lui-popover">
|
||||
<div class="lui-popover__header">
|
||||
<div class="lui-popover__title"><h4><i class="fa fa-info-circle"></i> Provision information</h4></div>
|
||||
</div>
|
||||
<div class="lui-popover__body">
|
||||
<div>
|
||||
<b>Scenario: </b> {{selectedprov._scenario[0].title}}
|
||||
</div>
|
||||
<div>
|
||||
<b>ProvisionID: </b> {{selectedprov._id}}
|
||||
</div>
|
||||
<div>
|
||||
<b>Instance Type: </b> {{selectedprov.vmType}}
|
||||
</div>
|
||||
<div *ngIf="selectedprov.nodeCount">
|
||||
<b>Number of nodes: </b> {{selectedprov.nodeCount}}
|
||||
</div>
|
||||
<h5 style="padding-top: 10px;">Connection resources</h5>
|
||||
<div *ngFor="let item of selectedprov.outputs | keyvalue">
|
||||
<b>{{item.key}}</b>
|
||||
<pre class="mypre">{{item.value}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lui-popover__footer">
|
||||
<button class="lui-button lui-popover__button" (click)="showInfo = false">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 100px;">
|
||||
<div style="margin-top: 40px; margin-bottom: 100px;">
|
||||
<h1>Provisions</h1>
|
||||
<h3 style="border-bottom: 1px solid #ccc;">Running</h3>
|
||||
<div *ngIf="provisions && provisions.length" class="flexcontainer">
|
||||
@@ -141,5 +109,38 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf="showInfo" class="modal-popover">
|
||||
<div class="popover-content" #popovercontent>
|
||||
<div class="lui-popover">
|
||||
<div class="lui-popover__header">
|
||||
<div class="lui-popover__title"><h4><i class="fa fa-info-circle"></i> Provision information</h4></div>
|
||||
</div>
|
||||
<div class="lui-popover__body">
|
||||
<div>
|
||||
<b>Scenario: </b> {{selectedprov._scenario[0].title}}
|
||||
</div>
|
||||
<div>
|
||||
<b>ProvisionID: </b> {{selectedprov._id}}
|
||||
</div>
|
||||
<div>
|
||||
<b>Instance Type: </b> {{selectedprov.vmType}}
|
||||
</div>
|
||||
<div *ngIf="selectedprov.nodeCount">
|
||||
<b>Number of nodes: </b> {{selectedprov.nodeCount}}
|
||||
</div>
|
||||
<h5 style="padding-top: 10px;">Connection resources</h5>
|
||||
<div *ngFor="let item of selectedprov.outputs | keyvalue">
|
||||
<b>{{item.key}}</b>
|
||||
<pre class="mypre">{{item.value}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lui-popover__footer">
|
||||
<button class="lui-button lui-popover__button" (click)="showInfo = false">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<qmi-alert></qmi-alert>
|
||||
@@ -4,6 +4,7 @@ import { Subscription, timer} from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { AuthGuard } from '../services/auth.guard';
|
||||
import { ScenariosService } from '../services/scenarios.service';
|
||||
import { AlertService } from '../services/alert.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -26,7 +27,7 @@ export class ProvisionsComponent implements OnInit {
|
||||
showInfo: boolean = false;
|
||||
scenarios;
|
||||
|
||||
constructor(private _provisionsService: ProvisionsService, private _scenariosService: ScenariosService, private _auth: AuthGuard) {
|
||||
constructor(private _alertService: AlertService, private _provisionsService: ProvisionsService, private _scenariosService: ScenariosService, private _auth: AuthGuard) {
|
||||
this._auth.getUserInfo().subscribe( value => {
|
||||
this._userId = value? value._id : null;
|
||||
});
|
||||
@@ -75,24 +76,40 @@ export class ProvisionsComponent implements OnInit {
|
||||
del(provision): void {
|
||||
this._provisionsService.delProvision(provision._id.toString(), this._userId).subscribe( res => {
|
||||
this._refresh();
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Provision entry '${provision.scenario}' was deleted from your history`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
destroy(provision) : void{
|
||||
this._provisionsService.newDestroy({"id": provision._id.toString()}, this._userId).subscribe( res => {
|
||||
this._refresh();
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Provision of scenario '${provision.scenario}' is going to be destroyed`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
startVms(provision) : void {
|
||||
this._provisionsService.startVms(provision._id.toString(), this._userId).subscribe( res => {
|
||||
provision.statusVms = res.statusVms;
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Starting all VMs for scenario '${provision.scenario}'...`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
stopVms(provision) : void {
|
||||
this._provisionsService.stopVms(provision._id.toString(), this._userId).subscribe( res => {
|
||||
provision.statusVms = res.statusVms;
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Starting all VMs for scenario '${provision.scenario}'...`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
@@ -117,11 +134,12 @@ export class ProvisionsComponent implements OnInit {
|
||||
this.logShow = false;
|
||||
}
|
||||
|
||||
onStartProvision(): void {
|
||||
console.log("onStartProvision");
|
||||
onStartProvision(scenario): void {
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Scenario '${scenario.name}' is going to be provisioned. Scroll down to your Provisions to watch out progress.`
|
||||
});
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
@Output() onStartProvision = new EventEmitter();
|
||||
@Output() onStartProvision = new EventEmitter<object>();
|
||||
|
||||
_userId;
|
||||
scenarios;
|
||||
@@ -53,7 +53,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
|
||||
console.log("Provision scenario", scenario);
|
||||
this._provisionsService.newProvision({"scenario": scenario.name, "vmType": scenario.selectedVmType, "nodeCount": scenario.selectedNodeCount}, this._userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
this.onStartProvision.emit();
|
||||
this.onStartProvision.emit(scenario);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
27
src/app/services/alert.service.ts
Normal file
27
src/app/services/alert.service.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Injectable, EventEmitter } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AlertService {
|
||||
|
||||
alertEmitter = new EventEmitter();
|
||||
|
||||
constructor() { }
|
||||
to;
|
||||
|
||||
showAlert(alert) : void {
|
||||
this.alertEmitter.emit(alert);
|
||||
if ( this.to ) {
|
||||
clearTimeout(this.to);
|
||||
}
|
||||
this.to = setTimeout (function(){
|
||||
this.alertEmitter.emit(null);
|
||||
}.bind(this), 5000);
|
||||
}
|
||||
|
||||
getAlertEmitter(): EventEmitter<any> {
|
||||
return this.alertEmitter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +1,94 @@
|
||||
<div class="md-form">
|
||||
<input type="text" class="form-control" [(ngModel)]="searchText" (keyup)="searchItems()" id="search-input"
|
||||
mdbInput>
|
||||
<label for="search-input">Search</label>
|
||||
<app-logs [show]="logShow" (onClose)="onLogsClose()" [type]="logstype" [selectedprov]="selectedprov"></app-logs>
|
||||
<div *ngIf="showInfo" class="modal-popover">
|
||||
<div class="popover-content" #popovercontent>
|
||||
<div class="lui-popover">
|
||||
<div class="lui-popover__header">
|
||||
<div class="lui-popover__title"><h4><i class="fa fa-info-circle"></i> Provision information</h4></div>
|
||||
</div>
|
||||
<div class="lui-popover__body">
|
||||
<div>
|
||||
<b>Scenario: </b> {{selectedprov._scenario[0].title}}
|
||||
</div>
|
||||
<div>
|
||||
<b>ProvisionID: </b> {{selectedprov._id}}
|
||||
</div>
|
||||
<div>
|
||||
<b>Instance Type: </b> {{selectedprov.vmType}}
|
||||
</div>
|
||||
<div *ngIf="selectedprov.nodeCount">
|
||||
<b>Number of nodes: </b> {{selectedprov.nodeCount}}
|
||||
</div>
|
||||
<h5 style="padding-top: 10px;">Connection resources</h5>
|
||||
<div *ngFor="let item of selectedprov.outputs | keyvalue">
|
||||
<b>{{item.key}}</b>
|
||||
<pre class="mypre">{{item.value}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lui-popover__footer">
|
||||
<button class="lui-button lui-popover__button" (click)="showInfo = false">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table mdbTable #tableEl="mdbTable" stickyHeader="true" hover="true" class="z-depth-1 table-sm">
|
||||
<thead class="sticky-top">
|
||||
<tr>
|
||||
<!--<th *ngFor="let head of headElements; let i = index" [mdbTableSort]="elements" [sortBy]="headElements[i]"
|
||||
scope="col">{{head}} <mdb-icon fas icon="sort"></mdb-icon>
|
||||
</th>-->
|
||||
<th *ngFor="let head of headElements; let i = index" scope="col">{{head}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody #row>
|
||||
<tr mdbTableCol *ngFor="let provision of elements; let i = index">
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<button style="margin-right: 5px;" class="lui-button" (click)="showResources($event,provision)">
|
||||
<span class="lui-icon lui-icon--info" aria-hidden="true"></span>
|
||||
</button>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<a href (click)="showLogs($event, provision, 'provision')" class="lui-text-info">{{ provision._id }}</a>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.created | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" class="ell" title="{{provision.path}}" >{{provision.user}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.scenario}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.statusVms}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.status === 'provisioning' || provision.status === 'initializing', 'badge-success': provision.status === 'provisioned', 'badge-danger': provision.status === 'error' }">{{provision.status}}</span>
|
||||
<span *ngIf="provision.status === 'provisioning' || provision.status === 'initializing'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" style="border-left:2px solid #ccc;"><a *ngIf="provision.destroyId" href (click)="showLogs($event, provision, 'destroy')" class="lui-text-info">{{provision.destroyId}}</a></td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" >{{provision.dateDestroy | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.statusDestroy === 'destroying', 'badge-success': provision.statusDestroy === 'destroyed', 'badge-danger': provision.statusDestroy === 'error'}">{{provision.statusDestroy}}</span>
|
||||
<span *ngIf="provision.statusDestroy === 'destroying'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<!--<td><span *ngIf="provision.isDestroyed" class="lui-icon lui-icon--tick lui-text-success"></span></td>-->
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<button title="Stop Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Running'" (click)="stopVms(provision)" class="lui-button"><span class="lui-icon lui-icon--stop" aria-hidden="true"></span></button>
|
||||
<button title="Start Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Stopped'" (click)="startVms(provision)" class="lui-button"><span class="lui-icon lui-icon--run" aria-hidden="true"></span></button>
|
||||
<button title="Destroy provision" *ngIf="!provision.isDestroyed && provision.statusDestroy !== 'destroying' && provision.status !== 'provisioning'" (click)="destroy(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--remove" aria-hidden="true"></span></button>
|
||||
<button title="Remove entry" *ngIf="provision.isDestroyed && provision.statusDestroy === 'destroyed'" (click)="del(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--bin" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
|
||||
<div class="md-form">
|
||||
<input type="text" class="form-control" [(ngModel)]="searchText" (keyup)="searchItems()" id="search-input"
|
||||
mdbInput>
|
||||
<label for="search-input">Search</label>
|
||||
</div>
|
||||
<table mdbTable #tableEl="mdbTable" stickyHeader="true" hover="true" class="z-depth-1 table-sm">
|
||||
<thead class="sticky-top">
|
||||
<tr>
|
||||
<!--<th *ngFor="let head of headElements; let i = index" [mdbTableSort]="elements" [sortBy]="headElements[i]"
|
||||
scope="col">{{head}} <mdb-icon fas icon="sort"></mdb-icon>
|
||||
</th>-->
|
||||
<th *ngFor="let head of headElements; let i = index" scope="col">{{head}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody #row>
|
||||
<tr mdbTableCol *ngFor="let provision of elements; let i = index">
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<button style="margin-right: 5px;" class="lui-button" (click)="showResources($event,provision)">
|
||||
<span class="lui-icon lui-icon--info" aria-hidden="true"></span>
|
||||
</button>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<a href (click)="showLogs($event, provision, 'provision')" class="lui-text-info">{{ provision._id }}</a>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.created | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" class="ell" title="{{provision.path}}" >{{provision.user}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.scenario}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">{{provision.statusVms}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.status === 'provisioning' || provision.status === 'initializing', 'badge-success': provision.status === 'provisioned', 'badge-danger': provision.status === 'error' }">{{provision.status}}</span>
|
||||
<span *ngIf="provision.status === 'provisioning' || provision.status === 'initializing'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" style="border-left:2px solid #ccc;"><a *ngIf="provision.destroyId" href (click)="showLogs($event, provision, 'destroy')" class="lui-text-info">{{provision.destroyId}}</a></td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)" >{{provision.dateDestroy | date: 'MMM dd, yyyy - H:mm'}}</td>
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<span style="text-transform: capitalize;" class="badge badge-secondary" [ngClass]="{'badge-warning': provision.statusDestroy === 'destroying', 'badge-success': provision.statusDestroy === 'destroyed', 'badge-danger': provision.statusDestroy === 'error'}">{{provision.statusDestroy}}</span>
|
||||
<span *ngIf="provision.statusDestroy === 'destroying'" class="spinner-border spinner-border-sm text-warning" role="status">
|
||||
<span class="sr-only"></span>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<!--<td><span *ngIf="provision.isDestroyed" class="lui-icon lui-icon--tick lui-text-success"></span></td>-->
|
||||
<td *ngIf="pagingIsDisabled || (i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex)">
|
||||
<button title="Stop Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Running'" (click)="stopVms(provision)" class="lui-button"><span class="lui-icon lui-icon--stop" aria-hidden="true"></span></button>
|
||||
<button title="Start Vms" *ngIf="!provision.isDestroyed && provision.status === 'provisioned' && provision.statusVms === 'Stopped'" (click)="startVms(provision)" class="lui-button"><span class="lui-icon lui-icon--run" aria-hidden="true"></span></button>
|
||||
<button title="Destroy provision" *ngIf="!provision.isDestroyed && provision.statusDestroy !== 'destroying' && provision.status !== 'provisioning'" (click)="destroy(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--remove" aria-hidden="true"></span></button>
|
||||
<button title="Remove entry" *ngIf="provision.isDestroyed && provision.statusDestroy === 'destroyed'" (click)="del(provision)" class="lui-button lui-text-danger"><span class="lui-icon lui-icon--bin" aria-hidden="true"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot class="grey lighten-5 w-100">
|
||||
<tr *ngIf="!pagingIsDisabled">
|
||||
<td colspan="11">
|
||||
<mdb-table-pagination [tableEl]="tableEl" paginationAlign="" [searchDataSource]="elements"></mdb-table-pagination>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot class="grey lighten-5 w-100">
|
||||
<tr *ngIf="!pagingIsDisabled">
|
||||
<td colspan="11">
|
||||
<mdb-table-pagination [tableEl]="tableEl" paginationAlign="" [searchDataSource]="elements"></mdb-table-pagination>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.modal-popover {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
background: rgba(0,0,0,0.5);
|
||||
.lui-popover {
|
||||
max-width: 700px;
|
||||
}
|
||||
.popover-content {
|
||||
position: relative;
|
||||
top: 10%;
|
||||
}
|
||||
.lui-popover__body {
|
||||
font-size: 14px;
|
||||
max-height: 600px;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Component, OnInit, ElementRef, HostListener, AfterViewInit, ViewChild, ChangeDetectorRef, Input } from '@angular/core';
|
||||
import { MdbTableDirective, MdbTablePaginationComponent } from 'angular-bootstrap-md';
|
||||
import { ProvisionsService } from '../services/provisions.service';
|
||||
import { AlertService } from '../services/alert.service';
|
||||
@Component({
|
||||
selector: 'table-admin',
|
||||
templateUrl: './table-admin.component.html',
|
||||
@@ -11,15 +13,19 @@ export class TableAdminComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('row', { static: true }) row: ElementRef;
|
||||
|
||||
@Input() elements;
|
||||
@Input() headElements;
|
||||
headElements = ['', 'ProvisionID', 'Prov. Date', 'User', 'Scenario', 'Status VMs', 'Status', 'DestroyID', 'Dest. Date', 'Status', ''];
|
||||
|
||||
searchText: string = '';
|
||||
previous: string;
|
||||
pagingIsDisabled: Boolean = true;
|
||||
selectedprov: Object = null;
|
||||
showInfo: boolean = false;
|
||||
logShow: boolean = false;
|
||||
logstype: String = 'provision';
|
||||
|
||||
maxVisibleItems: number = 15;
|
||||
|
||||
constructor(private cdRef: ChangeDetectorRef) {}
|
||||
constructor(private _alertService: AlertService, private cdRef: ChangeDetectorRef, private _provisionsService: ProvisionsService) {}
|
||||
|
||||
@HostListener('input') oninput() {
|
||||
this.mdbTablePagination.searchText = this.searchText;
|
||||
@@ -60,4 +66,71 @@ export class TableAdminComponent implements OnInit, AfterViewInit {
|
||||
this.mdbTablePagination.calculateLastItemIndex();
|
||||
});
|
||||
}
|
||||
|
||||
showResources($event, provision): void {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
this.selectedprov = provision;
|
||||
console.log("this.selectedprov", this.selectedprov);
|
||||
this.showInfo = true;
|
||||
}
|
||||
|
||||
showLogs($event, provision, type): void {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
this.logstype = type;
|
||||
this.logShow = false;
|
||||
this.selectedprov = provision;
|
||||
this.logShow = true;
|
||||
}
|
||||
|
||||
onLogsClose(): void {
|
||||
this.selectedprov = null;
|
||||
this.logShow = false;
|
||||
}
|
||||
|
||||
startVms(provision): void {
|
||||
var sub = this._provisionsService.startVms(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
provision.startVms = res.startVms;
|
||||
sub.unsubscribe();
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Starting all VMs for scenario '${provision.scenario}'...`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
stopVms(provision): void {
|
||||
var sub = this._provisionsService.stopVms(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
provision.startVms = res.startVms;
|
||||
sub.unsubscribe();
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Starting all VMs for scenario '${provision.scenario}'...`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
del(provision): void {
|
||||
this._provisionsService.delProvision(provision._id.toString(), provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Provision entry '${provision.scenario}' was deleted`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
destroy(provision) : void{
|
||||
this._provisionsService.newDestroy({"id": provision._id.toString()}, provision.userId).subscribe( res => {
|
||||
console.log("Done!", res);
|
||||
this._alertService.showAlert({
|
||||
type: 'alert-primary',
|
||||
text: `Provision of scenario '${provision.scenario}' is going to be destroyed`
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { MdbTablePaginationComponent, MdbTableDirective } from 'angular-bootstrap-md';
|
||||
|
||||
import { Component, OnInit, ViewChild, HostListener, AfterViewInit, ChangeDetectorRef, Input } from '@angular/core';
|
||||
import { AuthGuard } from '../services/auth.guard';
|
||||
import { UsersService } from '../services/users.service';
|
||||
|
||||
@Component({
|
||||
selector: 'table-users',
|
||||
@@ -14,20 +16,30 @@ export class TableUsersComponent implements OnInit, AfterViewInit {
|
||||
searchText: string = '';
|
||||
maxVisibleItems: number = 8;
|
||||
|
||||
currentUser;
|
||||
|
||||
@Input() elements;
|
||||
|
||||
@HostListener('input') oninput() {
|
||||
this.mdbTablePagination.searchText = this.searchText;
|
||||
}
|
||||
|
||||
constructor(private cdRef: ChangeDetectorRef) { }
|
||||
constructor(private cdRef: ChangeDetectorRef, private _usersService: UsersService, private _auth: AuthGuard) {
|
||||
this._auth.getUserInfo().subscribe( value => {
|
||||
this.currentUser = value;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
private _initElements(): void {
|
||||
this.mdbTable.setDataSource(this.elements);
|
||||
this.elements = this.mdbTable.getDataSource();
|
||||
this.previous = this.mdbTable.getDataSource();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this._initElements();
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.mdbTablePagination.setMaxVisibleItemsNumberTo(this.maxVisibleItems);
|
||||
|
||||
@@ -57,4 +69,25 @@ export class TableUsersComponent implements OnInit, AfterViewInit {
|
||||
this.mdbTablePagination.calculateLastItemIndex();
|
||||
});
|
||||
}
|
||||
|
||||
setAdmin(user) : void {
|
||||
this._usersService.updateUser(user._id, {"role": "admin"}).subscribe( res1 => {
|
||||
console.log("Updated", res1);
|
||||
this._usersService.getUsers().subscribe( res => {
|
||||
this.elements = res;
|
||||
this._initElements();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
removeAdmin(user) : void {
|
||||
this._usersService.updateUser(user._id, {"role": "user"}).subscribe( res1 => {
|
||||
console.log("Updated", res1);
|
||||
this._usersService.getUsers().subscribe( res => {
|
||||
this.elements = res;
|
||||
this._initElements();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user