Fix for 'back to project' error

This commit is contained in:
piotrpekala7 2020-03-16 13:00:02 +01:00
parent b33eb4ce24
commit ac3335a33d
2 changed files with 9 additions and 2 deletions

View File

@ -4,7 +4,7 @@
<button mat-button routerLink="/servers">Servers</button>
<button *ngIf="recentlyOpenedProjectId && recentlyOpenedServerId" mat-button routerLink="/server/{{recentlyOpenedServerId}}/project/{{recentlyOpenedProjectId}}">Back to project</button>
<button *ngIf="recentlyOpenedProjectId && recentlyOpenedServerId" mat-button (click)="backToProject()">Back to project</button>
<span class="fill-space"></span>

View File

@ -6,6 +6,7 @@ import { Subscription } from 'rxjs';
import { ToasterService } from '../../services/toaster.service';
import { ProgressService } from '../../common/progress/progress.service';
import { version } from './../../version';
import { Router } from '@angular/router';
@Component({
@ -29,7 +30,8 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
private recentlyOpenedProjectService: RecentlyOpenedProjectService,
private serverManagement: ServerManagementService,
private toasterService: ToasterService,
private progressService: ProgressService
private progressService: ProgressService,
private router: Router
) {}
ngOnInit() {
@ -54,6 +56,11 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
this.shouldStopServersOnClosing = this.electronService.isElectronApp;
}
backToProject() {
this.router.navigate(['/server', this.recentlyOpenedServerId, 'project', this.recentlyOpenedProjectId])
.catch(error => this.toasterService.error('Cannot navigate to the last opened project'));
}
@HostListener('window:beforeunload', ['$event'])
async onBeforeUnload($event) {
if(!this.shouldStopServersOnClosing) {