Merge branch 'master-3.0' into enhancement/1323

This commit is contained in:
Jeremy Grossmann 2022-07-13 00:06:13 +02:00 committed by GitHub
commit 6dcacbaa85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 240 additions and 37 deletions

View File

@ -279,6 +279,7 @@ import { AddImageDialogComponent } from './components/image-manager/add-image-di
import { DeleteAllImageFilesDialogComponent } from './components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component';
import { UploadingProcessbarComponent } from './common/uploading-processbar/uploading-processbar.component';
import { ExportPortableProjectComponent } from './components/export-portable-project/export-portable-project.component';
import { NodesMenuConfirmationDialogComponent } from './components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component';
@NgModule({
declarations: [
@ -474,6 +475,7 @@ import { ExportPortableProjectComponent } from './components/export-portable-pro
DeleteAllImageFilesDialogComponent,
UploadingProcessbarComponent,
ExportPortableProjectComponent,
NodesMenuConfirmationDialogComponent,
],
imports: [
BrowserModule,

View File

@ -1,4 +1,4 @@
<p>Image Uploading please wait .... {{uploadProgress}}%</p>
<p>{{upload_file_type}} Uploading please wait .... {{uploadProgress}}%</p>
<div class="row proccessBar-row ">
<div class="col-md-9 proccessBar-col">
<mat-progress-bar mode="determinate" [value]="uploadProgress" aria-valuemin="0" aria-valuemax="100">

View File

@ -13,7 +13,7 @@ import { UploadServiceService } from './upload-service.service';
export class UploadingProcessbarComponent implements OnInit {
uploadProgress: number = 0
subscription: Subscription;
upload_file_type:string
constructor(
@Inject(MAT_SNACK_BAR_DATA) public data,
private _snackRef: MatSnackBarRef<UploadingProcessbarComponent>,
@ -21,6 +21,8 @@ export class UploadingProcessbarComponent implements OnInit {
) { }
ngOnInit() {
this.upload_file_type = this.data.upload_file_type
debugger
this.subscription = this._US.currentCount.subscribe((count:number) => {
this.uploadProgress = count;
if (this.uploadProgress === 100 || this.uploadProgress == null ) {

View File

@ -158,6 +158,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
this.uploader.uploadItem(itemToUpload);
this.snackBar.openFromComponent(UploadingProcessbarComponent, {
panelClass: 'uplaoding-file-snackabar',
data:{upload_file_type:'Image'}
});
}
@ -275,7 +276,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
cancelUploading() {
this.uploader.clearQueue();
this.uploadServiceService.processBarCount(null)
this.toasterService.warning('Image upload cancelled');
this.toasterService.warning('File upload cancelled');
// this.uploadServiceService.cancelFileUploading(false)
// window.location.reload()

View File

@ -129,6 +129,7 @@ export class AddIouTemplateComponent implements OnInit, OnDestroy {
this.uploader.uploadItem(itemToUpload);
this.snackBar.openFromComponent(UploadingProcessbarComponent, {
panelClass: 'uplaoding-file-snackabar',
data:{upload_file_type:'Image'}
});
}
@ -136,7 +137,7 @@ export class AddIouTemplateComponent implements OnInit, OnDestroy {
cancelUploading() {
this.uploader.clearQueue();
this.uploadServiceService.processBarCount(100)
this.toasterService.warning('Image upload cancelled');
this.toasterService.warning('File upload cancelled');
// this.uploadServiceService.cancelFileUploading(false)
// window.location.reload()
}

View File

@ -157,7 +157,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers =[{name:'Authorization',value:'Bearer ' + this.server.authToken}])
this.uploader.uploadItem(itemToUpload);
this.snackBar.openFromComponent(UploadingProcessbarComponent,{panelClass: 'uplaoding-file-snackabar',});
this.snackBar.openFromComponent(UploadingProcessbarComponent,{panelClass: 'uplaoding-file-snackabar', data:{upload_file_type:'Image'}});
}
cancelUploading() {

View File

@ -429,7 +429,7 @@ export class NewTemplateDialogComponent implements OnInit {
cancelUploading() {
this.uploaderImage.clearQueue();
this.uploadServiceService.processBarCount(null)
this.toasterService.warning('Image upload cancelled');
this.toasterService.warning('File upload cancelled');
this.uploadServiceService.cancelFileUploading(false)
}
@ -728,6 +728,7 @@ export class NewTemplateDialogComponent implements OnInit {
openSnackBar() {
this.snackBar.openFromComponent(UploadingProcessbarComponent, {
panelClass: 'uplaoding-file-snackabar',
data:{upload_file_type:'Image'}
});
}

View File

@ -0,0 +1,13 @@
<div class="row">
<div class="col-md-12">
<h5 class="heading-txt">Confirm {{ confirmActionData.actionType}} All</h5>
</div>
</div>
<mat-divider></mat-divider>
<mat-dialog-content>
<p class="text-padding">Are you sure you want to {{confirmActionData.actionType}} all devices?</p>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>No</button>
<button mat-button (click)="confirmAction()" cdkFocusInitial>Yes</button>
</mat-dialog-actions>

View File

@ -0,0 +1,19 @@
.close-btn{
height: 30px;
width: 30px;
margin-left: 10px;
margin-bottom:10px
}
.close-icon{
font-size: 15px;
}
.text-padding{
padding: 15px 0 0 0;
}
.mat-dialog-actions {
min-height: 31px;
}
.heading-txt{
text-transform: capitalize;
}

View File

@ -0,0 +1,44 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { NodesMenuConfirmationDialogComponent } from './nodes-menu-confirmation-dialog.component';
describe('NodesMenuConfirmationDialogComponent', () => {
let component: NodesMenuConfirmationDialogComponent;
let fixture: ComponentFixture<NodesMenuConfirmationDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports:[
MatIconModule,
MatToolbarModule,
MatMenuModule,
MatCheckboxModule,
MatDialogModule,
MatSnackBarModule,
],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: {} },
{ provide: MatDialogRef, useValue: {} },
],
declarations: [ NodesMenuConfirmationDialogComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NodesMenuConfirmationDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,27 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-nodes-menu-confirmation-dialog',
templateUrl: './nodes-menu-confirmation-dialog.component.html',
styleUrls: ['./nodes-menu-confirmation-dialog.component.scss'],
})
export class NodesMenuConfirmationDialogComponent implements OnInit {
confirmActionData = {
actionType: 'start',
isAction:false
};
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<NodesMenuConfirmationDialogComponent>
) {}
ngOnInit(): void {
this.confirmActionData.actionType = this.data;
}
confirmAction() {
this.confirmActionData.isAction = true
this.dialogRef.close(this.confirmActionData);
}
}

View File

@ -12,7 +12,7 @@
matTooltip="Start/Resume all nodes"
matTooltipClass="custom-tooltip"
mat-icon-button
(click)="startNodes()"
(click)="confirmControlsActions('start')"
class="menu-button"
>
<mat-icon>play_arrow</mat-icon>
@ -21,7 +21,7 @@
matTooltip="Suspend all nodes"
matTooltipClass="custom-tooltip"
mat-icon-button
(click)="suspendNodes()"
(click)="confirmControlsActions('suspend')"
class="menu-button"
>
<mat-icon>pause</mat-icon>
@ -30,7 +30,7 @@
matTooltip="Stop all nodes"
matTooltipClass="custom-tooltip"
mat-icon-button
(click)="stopNodes()"
(click)="confirmControlsActions('stop')"
class="menu-button"
>
<mat-icon>stop</mat-icon>
@ -39,9 +39,19 @@
matTooltip="Reload all nodes"
matTooltipClass="custom-tooltip"
mat-icon-button
(click)="reloadNodes()"
(click)="confirmControlsActions('reload')"
class="menu-button"
>
<mat-icon>replay</mat-icon>
</button>
<button
matTooltip="Reset all console connections"
matTooltipClass="custom-tooltip"
mat-icon-button
(click)="confirmControlsActions('reset')"
class="menu-button"
>
<mat-icon>compare_arrows</mat-icon>
</button>
</div>

View File

@ -1,14 +1,16 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { MapSettingsService } from '../../../services/mapsettings.service';
import { MatDialog } from '@angular/material/dialog';
import { ElectronService } from 'ngx-electron';
import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource';
import { Project } from '../../../models/project';
import { Server } from '../../../models/server';
import { MapSettingsService } from '../../../services/mapsettings.service';
import { NodeService } from '../../../services/node.service';
import { NodeConsoleService } from '../../../services/nodeConsole.service';
import { ServerService } from '../../../services/server.service';
import { SettingsService } from '../../../services/settings.service';
import { ToasterService } from '../../../services/toaster.service';
import { NodeConsoleService } from '../../../services/nodeConsole.service';
import { NodesMenuConfirmationDialogComponent } from './nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component';
@Component({
selector: 'app-nodes-menu',
@ -28,7 +30,8 @@ export class NodesMenuComponent {
private serverService: ServerService,
private settingsService: SettingsService,
private mapSettingsService: MapSettingsService,
private electronService: ElectronService
private electronService: ElectronService,
private dialog: MatDialog
) {}
async startConsoleForAllNodes() {
@ -83,4 +86,34 @@ export class NodesMenuComponent {
this.toasterService.success('All nodes successfully reloaded');
});
}
resetNodes() {
this.nodeService.resetAllNodes(this.server, this.project).subscribe(() => {
this.toasterService.success('Successfully reset all console connections');
});
}
public confirmControlsActions(type) {
const dialogRef = this.dialog.open(NodesMenuConfirmationDialogComponent, {
width: '500px',
maxHeight: '200px',
autoFocus: false,
disableClose: true,
data: type,
});
dialogRef.afterClosed().subscribe((confirmAction_result) => {
if (confirmAction_result.isAction && confirmAction_result.actionType == 'start') {
this.startNodes();
} else if (confirmAction_result.isAction && confirmAction_result.actionType == 'stop') {
this.stopNodes();
} else if (confirmAction_result.isAction && confirmAction_result.actionType == 'reload') {
this.reloadNodes();
} else if (confirmAction_result.isAction && confirmAction_result.actionType == 'suspend') {
this.suspendNodes();
} else {
this.resetNodes()
}
});
}
}

View File

@ -139,11 +139,11 @@
</button>
<button mat-menu-item (click)="exportProject()">
<mat-icon>call_made</mat-icon>
<span>Export portable project</span>
<span>Export project</span>
</button>
<button mat-menu-item (click)="importProject()">
<mat-icon>call_received</mat-icon>
<span>Import portable project</span>
<span>Import project</span>
</button>
<button mat-menu-item (click)="closeProject()">
<mat-icon>close</mat-icon>

View File

@ -951,6 +951,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
}
importProject() {
debugger
let uuid: string = '';
const dialogRef = this.dialog.open(ImportProjectDialogComponent, {
width: '400px',
@ -963,9 +964,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
uuid = projectId;
});
dialogRef.afterClosed().subscribe(() => {
dialogRef.afterClosed().subscribe((isCancel:boolean) => {
subscription.unsubscribe();
if (uuid) {
if (uuid && !isCancel) {
this.bottomSheet.open(NavigationDialogComponent);
let bottomSheetRef = this.bottomSheet._openedBottomSheetRef;
bottomSheetRef.instance.projectMessage = 'imported project';

View File

@ -38,7 +38,7 @@
<button class="delete-button" [hidden]="!isDeleteVisible">
<mat-icon color="primary" (click)="onDeleteClick()" class="delete-icon">clear</mat-icon>
</button>
<div mat-dialog-actions>
<div mat-dialog-actions align="end">
<button mat-button (click)="onNoClick()" color="accent">Cancel</button>
<button
mat-button
@ -54,13 +54,13 @@
</form>
</div>
<div [hidden]="!isFirstStepCompleted">
<div class="progress">
<!-- <div class="progress">
<div class="progress-bar" role="progressbar" [ngStyle]="{ width: uploader.progress + '%' }"></div>
</div>
<div class="result-message-box">
</div> -->
<div class="">
<span>{{ resultMessage }}</span>
</div>
<div mat-dialog-actions>
<div mat-dialog-actions align="end">
<button
mat-button
[disabled]="!isFinishEnabled"

View File

@ -18,6 +18,10 @@ import { Project } from '../../../models/project';
import { Server } from '../../../models/server';
import { ProjectService } from '../../../services/project.service';
import { ImportProjectDialogComponent } from './import-project-dialog.component';
import { ToasterService } from '../../../services/toaster.service';
import { MockedToasterService } from '../../../services/toaster.service.spec';
import { MatSnackBarModule } from '@angular/material/snack-bar';
export class MockedProjectService {
public projects: Project[] = [
@ -62,6 +66,7 @@ describe('ImportProjectDialogComponent', () => {
let server: Server;
let debugElement: DebugElement;
let fileSelectDirective: FileSelectDirective;
let mockedToasterService = new MockedToasterService()
let dialogRef = {
close: jasmine.createSpy('close'),
@ -77,6 +82,7 @@ describe('ImportProjectDialogComponent', () => {
MatDialogModule,
MatFormFieldModule,
MatInputModule,
MatSnackBarModule,
NoopAnimationsModule,
FileUploadModule,
FormsModule,
@ -87,6 +93,8 @@ describe('ImportProjectDialogComponent', () => {
{ provide: MatDialogRef, useValue: dialogRef },
{ provide: MAT_DIALOG_DATA, useValue: [] },
{ provide: ProjectService, useClass: MockedProjectService },
{ provide: ToasterService, useValue: mockedToasterService },
],
declarations: [ImportProjectDialogComponent],
}).compileComponents();

View File

@ -1,6 +1,7 @@
import { Component, EventEmitter, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ToasterService } from '../../../services/toaster.service';
import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload';
import { v4 as uuid } from 'uuid';
import { Project } from '../../../models/project';
@ -9,6 +10,9 @@ import { ServerResponse } from '../../../models/serverResponse';
import { ProjectService } from '../../../services/project.service';
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
import { ProjectNameValidator } from '../models/projectNameValidator';
import { UploadServiceService } from '../../../common/uploading-processbar/upload-service.service';
import { UploadingProcessbarComponent } from '../../../common/uploading-processbar/uploading-processbar.component';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-import-project-dialog',
@ -18,6 +22,7 @@ import { ProjectNameValidator } from '../models/projectNameValidator';
})
export class ImportProjectDialogComponent implements OnInit {
uploader: FileUploader;
uploadProgress: number = 0;
server: Server;
isImportEnabled: boolean = false;
isFinishEnabled: boolean = false;
@ -35,7 +40,11 @@ export class ImportProjectDialogComponent implements OnInit {
@Inject(MAT_DIALOG_DATA) public data: any,
private formBuilder: FormBuilder,
private projectService: ProjectService,
private projectNameValidator: ProjectNameValidator
private projectNameValidator: ProjectNameValidator,
private toasterService : ToasterService,
private uploadServiceService: UploadServiceService,
private snackBar : MatSnackBar,
) {
this.projectNameForm = this.formBuilder.group({
projectName: new FormControl(null, [Validators.required, projectNameValidator.get]),
@ -64,6 +73,16 @@ export class ImportProjectDialogComponent implements OnInit {
this.resultMessage = 'Project was imported succesfully!';
this.isFinishEnabled = true;
};
this.uploader.onProgressItem = (progress: any) => {
this.uploadProgress = progress['progress'];
this.uploadServiceService.processBarCount(this.uploadProgress)
};
this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
if (isCancel) {
this.cancelUploading()
}
})
}
get form() {
@ -96,11 +115,12 @@ export class ImportProjectDialogComponent implements OnInit {
importProject() {
const url = this.prepareUploadPath();
this.uploader.queue.forEach((elem) => (elem.url = url));
this.uploader.authToken = `Bearer ${this.server.authToken}`
this.isFirstStepCompleted = true;
const itemToUpload = this.uploader.queue[0];
this.uploader.uploadItem(itemToUpload);
this.snackBar.openFromComponent(UploadingProcessbarComponent,{panelClass: 'uplaoding-file-snackabar',data:{upload_file_type:'Project'}});
}
openConfirmationDialog(existingProject: Project) {
@ -127,11 +147,11 @@ export class ImportProjectDialogComponent implements OnInit {
onNoClick(): void {
this.uploader.cancelAll();
this.dialogRef.close();
this.dialogRef.close(false);
}
onFinishClick(): void {
this.dialogRef.close();
this.dialogRef.close(false);
}
onDeleteClick(): void {
@ -146,4 +166,14 @@ export class ImportProjectDialogComponent implements OnInit {
const projectName = this.projectNameForm.controls['projectName'].value;
return this.projectService.getUploadPath(this.server, this.uuid, projectName);
}
cancelUploading() {
this.uploader.clearQueue();
this.uploadServiceService.processBarCount(null)
this.toasterService.warning('File upload cancelled');
this.uploadServiceService.cancelFileUploading(false)
this.isFirstStepCompleted = false
this.uploader.cancelAll();
this.dialogRef.close(true);
}
}

View File

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { DockerImage } from '../models/docker/docker-image';
import { Server } from '../models/server';
@ -18,7 +19,7 @@ export class DockerService {
}
getImages(server: Server): Observable<DockerImage[]> {
return this.httpServer.get<DockerImage[]>(server, '/compute/docker/images') as Observable<DockerImage[]>;
return this.httpServer.get<DockerImage[]>(server, `/computes/${environment.compute_id}/docker/images`) as Observable<DockerImage[]>;
}
addTemplate(server: Server, dockerTemplate: any): Observable<any> {

View File

@ -55,6 +55,9 @@ export class NodeService {
reloadAll(server: Server, project: Project) {
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {});
}
resetAllNodes(server: Server, project: Project) {
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/console/reset`, {});
}
createFromTemplate(
server: Server,

View File

@ -106,7 +106,7 @@ describe('VirtualBoxService', () => {
it('should get available virtual machines', inject([VirtualBoxService], (service: VirtualBoxService) => {
service.getVirtualMachines(server).subscribe();
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/compute/virtualbox/vms`);
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/computes/${environment.compute_id}/virtualbox/vms`);
expect(req.request.method).toEqual('GET');
}));
});

View File

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { Server } from '../models/server';
import { VirtualBoxTemplate } from '../models/templates/virtualbox-template';
@ -37,6 +38,6 @@ export class VirtualBoxService {
}
getVirtualMachines(server: Server): Observable<VirtualBoxVm[]> {
return this.httpServer.get<VirtualBoxVm[]>(server, '/compute/virtualbox/vms') as Observable<VirtualBoxVm[]>;
return this.httpServer.get<VirtualBoxVm[]>(server, `/computes/${environment.compute_id}/virtualbox/vms`) as Observable<VirtualBoxVm[]>;
}
}

View File

@ -104,7 +104,7 @@ describe('VmwareService', () => {
it('should get available virtual machines', inject([VmwareService], (service: VmwareService) => {
service.getVirtualMachines(server).subscribe();
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/compute/vmware/vms`);
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/computes/${environment.compute_id}/vmware/vms`);
expect(req.request.method).toEqual('GET');
}));
});

View File

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { Server } from '../models/server';
import { VmwareTemplate } from '../models/templates/vmware-template';
@ -30,6 +31,6 @@ export class VmwareService {
}
getVirtualMachines(server: Server): Observable<VmwareVm[]> {
return this.httpServer.get<VmwareVm[]>(server, '/compute/vmware/vms') as Observable<VmwareVm[]>;
return this.httpServer.get<VmwareVm[]>(server, `/computes/${environment.compute_id}/vmware/vms`) as Observable<VmwareVm[]>;
}
}

View File

@ -2,5 +2,6 @@ export const environment = {
solarputty_download_url: '',
production: true,
electron: true,
current_version:'v3'
current_version:'v3',
compute_id:'local'
};

View File

@ -2,5 +2,6 @@ export const environment = {
production: false,
electron: true,
solarputty_download_url: '',
current_version:'v3'
current_version:'v3',
compute_id:'local'
};

View File

@ -3,5 +3,6 @@ export const environment = {
electron: false,
githubio: true,
solarputty_download_url: '',
current_version:'v3'
current_version:'v3',
compute_id:'local'
};

View File

@ -3,5 +3,6 @@ export const environment = {
electron: false,
githubio: false,
solarputty_download_url: '',
current_version:'v3'
current_version:'v3',
compute_id:'local'
};

View File

@ -7,7 +7,8 @@ export const environment = {
electron: false,
githubio: false,
solarputty_download_url: '',
current_version:'v3'
current_version:'v3',
compute_id:'local'
};
/*