mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-21 10:01:44 +00:00
server reolver for projects page
This commit is contained in:
parent
e11281ddf6
commit
f5ee039510
@ -61,6 +61,7 @@ import { PageNotFoundComponent } from './components/page-not-found/page-not-foun
|
||||
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
|
||||
import { DirectLinkComponent } from './components/direct-link/direct-link.component';
|
||||
import { SystemStatusComponent } from './components/system-status/system-status.component';
|
||||
import { ServerResolve } from './resolvers/server-resolve';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@ -70,7 +71,11 @@ const routes: Routes = [
|
||||
{ path: '', redirectTo: 'servers', pathMatch: 'full' },
|
||||
{ path: 'servers', component: ServersComponent },
|
||||
{ path: 'bundled', component: BundledServerFinderComponent },
|
||||
{ path: 'server/:server_id/projects', component: ProjectsComponent },
|
||||
{
|
||||
path: 'server/:server_id/projects',
|
||||
component: ProjectsComponent,
|
||||
resolve: { server : ServerResolve }
|
||||
},
|
||||
{ path: 'help', component: HelpComponent },
|
||||
{ path: 'settings', component: SettingsComponent },
|
||||
{ path: 'settings/console', component: ConsoleComponent },
|
||||
|
@ -266,6 +266,7 @@ import { StatusChartComponent } from './components/system-status/status-chart/st
|
||||
import { NgCircleProgressModule } from 'ng-circle-progress';
|
||||
import { OpenFileExplorerActionComponent } from './components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component';
|
||||
import { NgxChildProcessModule } from 'ngx-childprocess';
|
||||
import { ServerResolve } from './resolvers/server-resolve';
|
||||
|
||||
if (environment.production) {
|
||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||
@ -538,7 +539,8 @@ if (environment.production) {
|
||||
NotificationService,
|
||||
Gns3vmService,
|
||||
ThemeService,
|
||||
GoogleAnalyticsService
|
||||
GoogleAnalyticsService,
|
||||
ServerResolve
|
||||
],
|
||||
entryComponents: [
|
||||
AddServerDialogComponent,
|
||||
|
@ -41,7 +41,6 @@ export class ProjectsComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private serverService: ServerService,
|
||||
private projectService: ProjectService,
|
||||
private settingsService: SettingsService,
|
||||
private progressService: ProgressService,
|
||||
@ -53,24 +52,13 @@ export class ProjectsComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.server = this.route.snapshot.data['server'];
|
||||
this.refresh();
|
||||
this.sort.sort(<MatSortable>{
|
||||
id: 'name',
|
||||
start: 'asc'
|
||||
});
|
||||
this.dataSource = new ProjectDataSource(this.projectDatabase, this.sort);
|
||||
|
||||
this.route.paramMap
|
||||
.pipe(
|
||||
switchMap((params: ParamMap) => {
|
||||
const server_id = params.get('server_id');
|
||||
return this.serverService.get(parseInt(server_id, 10));
|
||||
})
|
||||
)
|
||||
.subscribe((server: Server) => {
|
||||
this.server = server;
|
||||
this.refresh();
|
||||
});
|
||||
|
||||
this.settings = this.settingsService.getAll();
|
||||
|
||||
let gns3vmConfig = localStorage.getItem('gns3vmConfig');
|
||||
|
15
src/app/resolvers/server-resolve.ts
Normal file
15
src/app/resolvers/server-resolve.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { ServerService } from '../services/server.service';
|
||||
import { Server } from '../models/server';
|
||||
|
||||
@Injectable()
|
||||
export class ServerResolve implements Resolve<Server> {
|
||||
constructor(
|
||||
private serverService: ServerService
|
||||
) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot) {
|
||||
return this.serverService.get(parseInt(route.params['server_id']));
|
||||
}
|
||||
}
|
@ -18,8 +18,8 @@ export class ServerService {
|
||||
});
|
||||
}
|
||||
|
||||
public get(id: number) {
|
||||
return this.onReady(() => this.indexedDbService.get().getByKey(this.tablename, id));
|
||||
public get(id: number): Promise<Server> {
|
||||
return this.onReady(() => this.indexedDbService.get().getByKey(this.tablename, id)) as Promise<Server>;
|
||||
}
|
||||
|
||||
public create(server: Server) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user