Skip to content

Commit

Permalink
addet resources
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jan 31, 2019
1 parent 0227be9 commit ad490c0
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 0 deletions.
106 changes: 106 additions & 0 deletions src/app/facility_manager/resources/resources.component.html
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>&nbsp;Ram [GB]</th>
<td>&nbsp;{{openStackApprovedTotalRam}}</td>
<td>&nbsp;{{openStackWFCTotalRam}}</td>
<td>&nbsp;{{simpleVmTotalRam}}</td>
<td>&nbsp;{{totalRam}}</td>
</tr>
<tr>
<th>&nbsp;Cores</th>
<td>&nbsp;{{openStackApprovedTotalCores}}</td>
<td>&nbsp;{{openStackWFCTotalCores}}</td>
<td>&nbsp;{{simpleVmTotalCores}}</td>
<td>&nbsp;{{totalCores}}</td>
</tr>
<tr>
<th>&nbsp;Vms</th>
<td>&nbsp;{{openStackApprovedTotalVms}}</td>
<td>&nbsp;{{openStackWFCTotalVms}}</td>
<td>&nbsp;{{simpleVmTotalVms}}</td>
<td>&nbsp;{{totalVms}}</td>
</tr>
<tr>
<th>&nbsp;Volumes</th>
<td>&nbsp;{{openStackApprovedTotalVolumeCounter}}</td>
<td>&nbsp;{{openStackWFCTotalVolumeCounter}}</td>
<td>&nbsp;{{simpleVmTotalVolumeCounter}}</td>
<td>&nbsp;{{totalVolumeCounter}}</td>
</tr>
<tr>
<th>&nbsp;Volumes Storage [GB]</th>
<td>&nbsp;{{openStackApprovedTotalVolumeLimit}}</td>
<td>&nbsp;{{openStackWFCTotalVolumeLimit}}</td>
<td>&nbsp;{{simpleVmTotalVolumeLimit}}</td>
<td>&nbsp;{{totalVolumeLimit}}</td>
</tr>
<tr>
<th>&nbsp;Object Storage [GB]</th>
<td>&nbsp;{{openStackApprovedTotalObjectStorage}}</td>
<td>&nbsp;{{openStackWFCTotalObjectStorage}}</td>
<td>&nbsp;</td>
<td>&nbsp;{{totalObjectStorage}}</td>
</tr>
<tr>
<th>&nbsp;FPGA</th>
<td>&nbsp;{{openStackApprovedTotalFPGA}}</td>
<td>&nbsp;{{openStackWFCTotalFPGA}}</td>
<td>&nbsp;</td>
<td>&nbsp;{{totalFPGA}}</td>
</tr>
<tr>
<th>&nbsp;GPU</th>
<td>&nbsp;{{openStackApprovedTotalGPU}}</td>
<td>&nbsp;{{openStackWFCTotalGPU}}</td>
<td>&nbsp;</td>
<td>&nbsp;{{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 src/app/facility_manager/resources/resources.component.spec.ts
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 src/app/facility_manager/resources/resources.component.ts
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() {
}


}

0 comments on commit ad490c0

Please sign in to comment.