Commit 7d156b14 authored by Marcin Prusinski's avatar Marcin Prusinski
Browse files

Merge pull request #43 in MEL/melodic-frontend from rc2.5 to master

* commit '5c27de43':
  changes for byon nodes
  fix removing model from list after upload all
parents 7fab984c 5c27de43
......@@ -63,7 +63,7 @@
<th mat-header-cell *matHeaderCellDef mat-sort-header>SSH connection</th>
<td mat-cell *matCellDef="let row">
<button mat-raised-button class="ssh-button" (click)="onSshConnectionClick(row)" color="primary"
[disabled]="!userHasPermissionToSshConnection()">
[disabled]="!userHasPermissionToSshConnection(row)">
SSH connection
</button>
</td>
......
......@@ -42,15 +42,15 @@ export class VmListComponent implements OnInit {
this.locationList = locationResponse;
this.applicationService.getVmNodeList().subscribe(vmNodesResponse => {
this.vms = vmNodesResponse;
this.loadingVmListInProgress = false;
this.updateTableData();
console.log('Successfully getting VM list');
this.loadingVmListInProgress = false;
this.updateTableData();
console.log('Successfully getting VM list');
},
error1 => {
this.vms = [];
this.loadingVmListInProgress = false;
this.updateTableData();
this.snackBar.open(`Problem by getting VMs list: ${error1.error.message}`, 'Close');
this.vms = [];
this.loadingVmListInProgress = false;
this.updateTableData();
this.snackBar.open(`Problem by getting VMs list: ${error1.error.message}`, 'Close');
});
},
error1 => {
......@@ -95,34 +95,43 @@ export class VmListComponent implements OnInit {
}
getPrivateIp(vm: NodeCloudiator): string {
return vm.ipAddresses
.find(value => value.ipAddressType.toString() === IpAddressType[IpAddressType.PRIVATE_IP])
.value;
const privateIp = vm.ipAddresses
.find(value => value.ipAddressType.toString() === IpAddressType[IpAddressType.PRIVATE_IP]);
return privateIp ? privateIp.value : 'UNKNOWN';
}
getProviderName(vm: NodeCloudiator): string {
return this.cloudsList
.find(value => value.id === vm.nodeProperties.providerId)
.api.providerName;
const provider = this.cloudsList
.find(value => value.id === vm.nodeProperties.providerId);
return provider ? provider.api.providerName : 'UNKNOWN';
}
getCity(vm: NodeCloudiator): string {
const locationId = vm.originId.split('/')[0];
return this.locationList
.find(value => value.id === locationId)
.geoLocation.city;
const location = this.locationList
.find(value => value.id === locationId);
return location ? location.geoLocation.city : 'UNKNOWN';
}
userHasPermissionToSshConnection(): boolean {
return UserRole.ADMIN === UserRole[this.userService.currentUser.userRole];
userHasPermissionToSshConnection(vm: NodeCloudiator): boolean {
return (UserRole.ADMIN === UserRole[this.userService.currentUser.userRole]) && vm.loginCredential.privateKey !== null;
}
onSshConnectionClick(vm: NodeCloudiator) {
console.log(`SSH connection click for vm: ${vm.name}`);
const formattedPrivateKey = this.formatKey(vm.loginCredential.privateKey);
const webSshUrl = `${AppConfigService.settings.webSshUrl}/?hostname=${vm.publicIp}&username=${vm.loginCredential.username}` +
`&privatekey=${formattedPrivateKey}`;
window.open(webSshUrl);
let webSshUrl;
if (vm.loginCredential.privateKey) {
console.log(`Key-based SSH connection`);
const formattedPrivateKey = this.formatKey(vm.loginCredential.privateKey);
webSshUrl = `${AppConfigService.settings.webSshUrl}/?hostname=${vm.publicIp}&username=${vm.loginCredential.username}` +
`&privatekey=${formattedPrivateKey}`;
window.open(webSshUrl);
} else {
webSshUrl = `${AppConfigService.settings.webSshUrl}/?hostname=${vm.publicIp}&username=${vm.loginCredential.username}` +
`&password=${btoa(vm.loginCredential.password)}`;
console.log(`Password-based SSH connection under address: ${webSshUrl}`);
// todo add window.open(webSshUrl) after webssh fixed
}
}
private formatKey(privateKey: string): string {
......
<ng-content></ng-content>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="uploadAll()">Upload</button>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="removeAll()">Remove All</button>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="uploadAll()" [disabled]="">Upload</button>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="removeAll()" [disabled]="">Remove All
</button>
......@@ -26,6 +26,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
}
files: Array<any> = [];
uploadingInProgress = false;
@Input()
fileExtension = 'xmi';
......@@ -69,14 +70,17 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
public uploadAll() {
this.fileUploads.forEach(item => item.setUploadingInProgress());
this.uploadingInProgress = true;
this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => {
let successfullyUploadedFilesNames = '';
console.log('Files uploaded successfully');
this.uploadingInProgress = false;
const numberOfModels = this.fileUploads.length;
this.fileUploads.forEach(item => {
item.setUploadingAsFinished();
console.log(`Removing file from list: ${item.file.name}`);
item.remove();
item.removeEvent.emit(item);
for (let i = 0; i < numberOfModels; i++) {
item.remove();
}
});
let uploadXmiResponseWithSecureVariable: UploadXmiResponse;
value.forEach(uploadedXmiFileResponse => {
......@@ -104,6 +108,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
}
},
error1 => {
this.uploadingInProgress = false;
this.fileUploads.first.setUploadingAsFinished();
this.snackBar.open('Error by uploading files list', 'Close');
});
......
......@@ -43,9 +43,9 @@ export class NodeListComponent implements OnInit {
}
getProviderName(node: NodeCloudiator): string {
return this.cloudList
.find(value => value.id === node.nodeProperties.providerId)
.api.providerName;
const provider = this.cloudList
.find(value => value.id === node.nodeProperties.providerId);
return provider ? provider.api.providerName : 'UNKNOWN';
}
getPublicIp(node: NodeCloudiator): string {
......@@ -62,9 +62,9 @@ export class NodeListComponent implements OnInit {
if (node.ipAddresses === null) {
return '-';
} else {
return node.ipAddresses
.find(value => value.ipAddressType.toString() === IpAddressType[IpAddressType.PRIVATE_IP])
.value;
const privateIp = node.ipAddresses
.find(value => value.ipAddressType.toString() === IpAddressType[IpAddressType.PRIVATE_IP]);
return privateIp ? privateIp.value : 'UNKNOWN';
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment