-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
src/app/facility_manager/resources/resources.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<div *ngIf="isLoaded==false" class="loader"></div> | ||
|
||
<div *ngIf="isLoaded" class="animated fadeIn" ng-app style="width: 100%"> | ||
<div class="row"> | ||
<!--/.col--> | ||
<h1 *ngIf="selectedFacility">Projects Overview: {{selectedFacility['Facility']}} | ||
|
||
|
||
</h1> | ||
<div class="card" style="width: 100%"> | ||
<div class="card-header"> | ||
<i class="fa fa-align-justify"></i> Resources | ||
|
||
</div> | ||
<div><select [(ngModel)]="selectedFacility" | ||
(ngModelChange)="isLoaded=false;onChangeSelectedFacility($event);" | ||
class="form-control" name="selectedFacility"> | ||
<option *ngFor=" let facility of managerFacilities" [ngValue]="facility"> | ||
{{facility['Facility']}} | ||
</option> | ||
|
||
</select></div> | ||
|
||
<div id="contentToConvert" class="card-block" style="width: 100%"> | ||
|
||
|
||
<table class="table table-responsive table-striped table-bordered table" | ||
style="width: 100%"> | ||
<thead> | ||
<th colspan="5"><h1>Facility: {{selectedFacility['Facility']}}</h1></th> | ||
</thead> | ||
<thead> | ||
<th></th> | ||
<th>Approved OpenStack</th> | ||
<th>Wait for Confirmation OpenStack</th> | ||
<th>Simple VM</th> | ||
<th>Total</th> | ||
</thead> | ||
<tbody> | ||
|
||
<tr> | ||
<th> Ram [GB]</th> | ||
<td> {{openStackApprovedTotalRam}}</td> | ||
<td> {{openStackWFCTotalRam}}</td> | ||
<td> {{simpleVmTotalRam}}</td> | ||
<td> {{totalRam}}</td> | ||
</tr> | ||
<tr> | ||
<th> Cores</th> | ||
<td> {{openStackApprovedTotalCores}}</td> | ||
<td> {{openStackWFCTotalCores}}</td> | ||
<td> {{simpleVmTotalCores}}</td> | ||
<td> {{totalCores}}</td> | ||
</tr> | ||
<tr> | ||
<th> Vms</th> | ||
<td> {{openStackApprovedTotalVms}}</td> | ||
<td> {{openStackWFCTotalVms}}</td> | ||
<td> {{simpleVmTotalVms}}</td> | ||
<td> {{totalVms}}</td> | ||
</tr> | ||
<tr> | ||
<th> Volumes</th> | ||
<td> {{openStackApprovedTotalVolumeCounter}}</td> | ||
<td> {{openStackWFCTotalVolumeCounter}}</td> | ||
<td> {{simpleVmTotalVolumeCounter}}</td> | ||
<td> {{totalVolumeCounter}}</td> | ||
</tr> | ||
<tr> | ||
<th> Volumes Storage [GB]</th> | ||
<td> {{openStackApprovedTotalVolumeLimit}}</td> | ||
<td> {{openStackWFCTotalVolumeLimit}}</td> | ||
<td> {{simpleVmTotalVolumeLimit}}</td> | ||
<td> {{totalVolumeLimit}}</td> | ||
</tr> | ||
<tr> | ||
<th> Object Storage [GB]</th> | ||
<td> {{openStackApprovedTotalObjectStorage}}</td> | ||
<td> {{openStackWFCTotalObjectStorage}}</td> | ||
<td> </td> | ||
<td> {{totalObjectStorage}}</td> | ||
</tr> | ||
<tr> | ||
<th> FPGA</th> | ||
<td> {{openStackApprovedTotalFPGA}}</td> | ||
<td> {{openStackWFCTotalFPGA}}</td> | ||
<td> </td> | ||
<td> {{totalFPGA}}</td> | ||
</tr> | ||
<tr> | ||
<th> GPU</th> | ||
<td> {{openStackApprovedTotalGPU}}</td> | ||
<td> {{openStackWFCTotalGPU}}</td> | ||
<td> </td> | ||
<td> {{totalFPGA}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</div> | ||
<button (click)="captureScreen()">Download PDF</button> | ||
<!-- DivTable.com --> | ||
</div> | ||
<!--/.col--> | ||
</div> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/facility_manager/resources/resources.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ResourcesComponent } from './resources.component'; | ||
|
||
describe('ResourcesComponent', () => { | ||
let component: ResourcesComponent; | ||
let fixture: ComponentFixture<ResourcesComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ResourcesComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ResourcesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
136 changes: 136 additions & 0 deletions
136
src/app/facility_manager/resources/resources.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {FacilityService} from "../../api-connector/facility.service"; | ||
|
||
import * as jspdf from 'jspdf'; | ||
|
||
import html2canvas from 'html2canvas'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-resources', | ||
templateUrl: './resources.component.html', | ||
styleUrls: ['./resources.component.scss'], | ||
providers: [FacilityService] | ||
|
||
}) | ||
export class ResourcesComponent implements OnInit { | ||
|
||
public managerFacilities: [string, number][]; | ||
/** | ||
* Chosen facility. | ||
*/ | ||
public selectedFacility: [string, number]; | ||
|
||
isLoaded = false; | ||
|
||
simpleVmTotalRam = 0; | ||
simpleVmTotalCores = 0; | ||
simpleVmTotalVms = 0; | ||
simpleVmTotalVolumeLimit = 0; | ||
simpleVmTotalVolumeCounter = 0; | ||
|
||
openStackApprovedTotalRam = 0; | ||
openStackApprovedTotalCores = 0; | ||
openStackApprovedTotalVms = 0; | ||
openStackApprovedTotalVolumeLimit = 0; | ||
openStackApprovedTotalVolumeCounter = 0; | ||
openStackApprovedTotalObjectStorage = 0; | ||
openStackApprovedTotalFPGA = 0; | ||
openStackApprovedTotalGPU = 0; | ||
|
||
openStackWFCTotalRam = 0; | ||
openStackWFCTotalCores = 0; | ||
openStackWFCTotalVms = 0; | ||
openStackWFCTotalVolumeLimit = 0; | ||
openStackWFCTotalVolumeCounter = 0; | ||
openStackWFCTotalObjectStorage = 0; | ||
openStackWFCTotalFPGA = 0; | ||
openStackWFCTotalGPU = 0; | ||
totalRam = 0; | ||
totalCores = 0; | ||
totalVms = 0; | ||
totalVolumeLimit = 0; | ||
totalVolumeCounter = 0; | ||
totalObjectStorage = 0; | ||
totalFPGA = 0; | ||
totalGPU = 0; | ||
|
||
|
||
constructor(private facilityService: FacilityService) { | ||
this.facilityService.getManagerFacilities().subscribe(result => { | ||
this.managerFacilities = result; | ||
this.selectedFacility = this.managerFacilities[0]; | ||
this.getSelectedFacilityResources() | ||
|
||
|
||
}) | ||
} | ||
|
||
public getSelectedFacilityResources() { | ||
this.facilityService.getFacilityResources(this.selectedFacility['FacilityId']).subscribe(res => { | ||
this.simpleVmTotalRam = res['simpleVmApplications']['totalRam']; | ||
this.simpleVmTotalCores = res['simpleVmApplications']['totalCores']; | ||
this.simpleVmTotalVms = res['simpleVmApplications']['totalVms']; | ||
this.simpleVmTotalVolumeLimit = res['simpleVmApplications']['totalVolumeLimit']; | ||
this.simpleVmTotalVolumeCounter = res['simpleVmApplications']['totalVolumeCounter']; | ||
|
||
this.openStackApprovedTotalRam = res['approvedOpenStackApplications']['totalRam']; | ||
this.openStackApprovedTotalCores = res['approvedOpenStackApplications']['totalCores']; | ||
this.openStackApprovedTotalVms = res['approvedOpenStackApplications']['totalVms']; | ||
this.openStackApprovedTotalVolumeLimit = res['approvedOpenStackApplications']['totalVolumeLimit']; | ||
this.openStackApprovedTotalVolumeCounter = res['approvedOpenStackApplications']['totalVolumeCounter']; | ||
this.openStackApprovedTotalObjectStorage = res['approvedOpenStackApplications']['totalObjectStorage']; | ||
this.openStackApprovedTotalFPGA = res['approvedOpenStackApplications']['totalFPGA']; | ||
this.openStackApprovedTotalGPU = res['approvedOpenStackApplications']['totalGPU']; | ||
|
||
this.openStackWFCTotalRam = res['wfcOpenStackApplications']['totalRam']; | ||
this.openStackWFCTotalCores = res['wfcOpenStackApplications']['totalCores']; | ||
this.openStackWFCTotalVms = res['wfcOpenStackApplications']['totalVms']; | ||
this.openStackWFCTotalVolumeLimit = res['wfcOpenStackApplications']['totalVolumeLimit']; | ||
this.openStackWFCTotalVolumeCounter = res['wfcOpenStackApplications']['totalVolumeCounter']; | ||
this.openStackWFCTotalObjectStorage = res['wfcOpenStackApplications']['totalObjectStorage']; | ||
this.openStackWFCTotalFPGA = res['wfcOpenStackApplications']['totalFPGA']; | ||
this.openStackWFCTotalGPU = res['wfcOpenStackApplications']['totalGPU']; | ||
|
||
this.totalRam = res['total']['totalRam']; | ||
this.totalCores = res['total']['totalCores']; | ||
this.totalVms = res['total']['totalVms']; | ||
this.totalVolumeLimit = res['total']['totalVolumeLimit']; | ||
this.totalVolumeCounter = res['total']['totalVolumeCounter']; | ||
this.totalObjectStorage = res['total']['totalObjectStorage']; | ||
this.totalFPGA = res['total']['totalFPGA']; | ||
this.totalGPU = res['total']['totalGPU']; | ||
|
||
this.isLoaded = true; | ||
}) | ||
|
||
} | ||
|
||
|
||
public captureScreen() { | ||
var data = document.getElementById('contentToConvert'); | ||
html2canvas(data).then(canvas => { | ||
// Few necessary setting options | ||
var imgWidth = 208; | ||
var pageHeight = 295; | ||
var imgHeight = canvas.height * imgWidth / canvas.width; | ||
var heightLeft = imgHeight; | ||
|
||
const contentDataURL = canvas.toDataURL('image/png') | ||
let pdf = new jspdf('p', 'mm', 'a4'); // A4 size page of PDF | ||
var position = 0; | ||
pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight) | ||
pdf.save(this.selectedFacility['Facility'] + '.pdf'); // Generated PDF | ||
}); | ||
} | ||
|
||
|
||
onChangeSelectedFacility(value) { | ||
this.getSelectedFacilityResources() | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
|
||
} |