Finish merging code from master-3.0

This commit is contained in:
grossmj
2022-07-23 10:58:17 +02:00
parent c3bfad647f
commit dc94d22822
5 changed files with 19 additions and 36 deletions

View File

@ -7,8 +7,8 @@ import { MatToolbarModule } from '@angular/material/toolbar';
import { MockedProjectService } from '../../../services/project.service.spec'; import { MockedProjectService } from '../../../services/project.service.spec';
import { MockedToasterService } from '../../../services/toaster.service.spec'; import { MockedToasterService } from '../../../services/toaster.service.spec';
import { ProjectService } from '../../../services/project.service'; import { ProjectService } from '../../../services/project.service';
import { ServerService } from '../../../services/server.service'; import { ControllerService } from '../../../services/controller.service';
import { MockedServerService } from '../../../services/server.service.spec'; import { MockedControllerService } from '../../../services/controller.service.spec';
import { ToasterService } from '../../../services/toaster.service'; import { ToasterService } from '../../../services/toaster.service';
import { ConfirmationDeleteAllProjectsComponent } from './confirmation-delete-all-projects.component'; import { ConfirmationDeleteAllProjectsComponent } from './confirmation-delete-all-projects.component';
@ -16,7 +16,7 @@ import { ConfirmationDeleteAllProjectsComponent } from './confirmation-delete-al
describe('ConfirmationDeleteAllProjectsComponent', () => { describe('ConfirmationDeleteAllProjectsComponent', () => {
let component: ConfirmationDeleteAllProjectsComponent; let component: ConfirmationDeleteAllProjectsComponent;
let fixture: ComponentFixture<ConfirmationDeleteAllProjectsComponent>; let fixture: ComponentFixture<ConfirmationDeleteAllProjectsComponent>;
let mockedServerService = new MockedServerService(); let mockedControllerService = new MockedControllerService();
let mockedImageManagerService = new MockedProjectService() let mockedImageManagerService = new MockedProjectService()
let mockedToasterService = new MockedToasterService() let mockedToasterService = new MockedToasterService()
@ -30,7 +30,7 @@ describe('ConfirmationDeleteAllProjectsComponent', () => {
MatDialogModule, MatDialogModule,
], ],
providers: [ providers: [
{ provide: ServerService, useValue: mockedServerService }, { provide: ControllerService, useValue: mockedControllerService },
{ provide: ProjectService, useValue: mockedImageManagerService }, { provide: ProjectService, useValue: mockedImageManagerService },
{ provide: MAT_DIALOG_DATA, useValue: {} }, { provide: MAT_DIALOG_DATA, useValue: {} },
{ provide: MatDialogRef, useValue: {} }, { provide: MatDialogRef, useValue: {} },

View File

@ -34,7 +34,7 @@ export class ConfirmationDeleteAllProjectsComponent implements OnInit {
deleteFile() { deleteFile() {
const calls = []; const calls = [];
this.deleteData.deleteFilesPaths.forEach(project => { this.deleteData.deleteFilesPaths.forEach(project => {
calls.push(this.projectService.delete(this.deleteData.server, project.project_id).pipe(catchError(error => of(error)))) calls.push(this.projectService.delete(this.deleteData.controller, project.project_id).pipe(catchError(error => of(error))))
}); });
Observable.forkJoin(calls).subscribe(responses => { Observable.forkJoin(calls).subscribe(responses => {
this.deleteFliesDetails = responses.filter(x => x !== null) this.deleteFliesDetails = responses.filter(x => x !== null)

View File

@ -200,7 +200,7 @@ export class ProjectsComponent implements OnInit {
autoFocus: false, autoFocus: false,
disableClose: true, disableClose: true,
data: { data: {
server: this.server, controller: this.controller,
deleteFilesPaths: this.selection.selected deleteFilesPaths: this.selection.selected
} }
}); });
@ -251,7 +251,7 @@ exportSelectProject(project: Project){
maxHeight: '850px', maxHeight: '850px',
autoFocus: false, autoFocus: false,
disableClose: true, disableClose: true,
data: {serverDetails:this.server,projectDetails:this.project}, data: {controllerDetails:this.controller,projectDetails:this.project},
}); });
dialogRef.afterClosed().subscribe((isAddes: boolean) => {}); dialogRef.afterClosed().subscribe((isAddes: boolean) => {});
@ -276,8 +276,6 @@ export class ProjectDatabase {
this.dataChange.next(this.data.slice()); this.dataChange.next(this.data.slice());
} }
} }
} }
export class ProjectDataSource extends DataSource<any> { export class ProjectDataSource extends DataSource<any> {

View File

@ -19,15 +19,22 @@
</button> </button>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<button mat-menu-item (click)="goToSystemStatus()"> <button mat-menu-item
[disabled]="!controllerId"
[routerLink]="['controller', controllerId, 'systemstatus']">
<mat-icon>info</mat-icon> <mat-icon>info</mat-icon>
<span>System status</span> <span>System status</span>
</button> </button>
<button mat-menu-item (click)="goToPreferences()"> <button mat-menu-item
[disabled]="!controllerId"
[routerLink]="['controller', controllerId, 'preferences']">
<mat-icon>settings_applications</mat-icon> <mat-icon>settings_applications</mat-icon>
<span>Template preferences</span> <span>Template preferences</span>
</button> </button>
<button mat-menu-item (click)="goToImageManager()"> <button mat-menu-item
[disabled]="!controllerId"
[routerLink]="['controller', controllerId, 'image-manager']">
<mat-icon>collections</mat-icon> <mat-icon>collections</mat-icon>
<span>Image manager</span> <span>Image manager</span>
</button> </button>

View File

@ -36,7 +36,7 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
private controllerManagement: ControllerManagementService, private controllerManagement: ControllerManagementService,
private toasterService: ToasterService, private toasterService: ToasterService,
private progressService: ProgressService, private progressService: ProgressService,
private router: Router, public router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private controllerService: ControllerService private controllerService: ControllerService
) { ) {
@ -50,8 +50,6 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.checkIfUserIsLoginPage(); this.checkIfUserIsLoginPage();
this.controller = this.route.snapshot.data['server'];
this.routeSubscription = this.router.events.subscribe((val) => { this.routeSubscription = this.router.events.subscribe((val) => {
if (val instanceof NavigationEnd) this.checkIfUserIsLoginPage(); if (val instanceof NavigationEnd) this.checkIfUserIsLoginPage();
}); });
@ -85,7 +83,7 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
} }
checkIfUserIsLoginPage() { checkIfUserIsLoginPage() {
if (this.router.url.includes('login')) { if (this.router.url.includes("login")) {
this.isLoginPage = true; this.isLoginPage = true;
} else { } else {
this.isLoginPage = false; this.isLoginPage = false;
@ -111,26 +109,6 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
.catch((error) => this.toasterService.error('Cannot navigate to the last opened project')); .catch((error) => this.toasterService.error('Cannot navigate to the last opened project'));
} }
goToPreferences() {
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
this.router
.navigate(['/server', controllerId, 'preferences'])
.catch((error) => this.toasterService.error('Cannot navigate to the preferences'));
}
goToSystemStatus() {
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
this.router
.navigate(['/server', controllerId, 'systemstatus'])
.catch((error) => this.toasterService.error('Cannot navigate to the system status'));
}
goToImageManager() {
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
this.router
.navigate(['/server', controllerId, 'image-manager'])
.catch((error) => this.toasterService.error('Cannot navigate to the system status'));
}
@HostListener('window:beforeunload', ['$event']) @HostListener('window:beforeunload', ['$event'])
async onBeforeUnload($event) { async onBeforeUnload($event) {
if (!this.shouldStopControllersOnClosing) { if (!this.shouldStopControllersOnClosing) {