mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 14:28:13 +00:00
Merge pull request #653 from GNS3/Direct-links-to-servers-and-projects
Direct links to servers and projects
This commit is contained in:
@ -59,6 +59,7 @@ import { AddTracengTemplateComponent } from './components/preferences/traceng/ad
|
|||||||
import { TracengTemplateDetailsComponent } from './components/preferences/traceng/traceng-template-details/traceng-template-details.component';
|
import { TracengTemplateDetailsComponent } from './components/preferences/traceng/traceng-template-details/traceng-template-details.component';
|
||||||
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component';
|
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component';
|
||||||
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
|
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
|
||||||
|
import { DirectLinkComponent } from './components/direct-link/direct-link.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -73,6 +74,8 @@ const routes: Routes = [
|
|||||||
{ path: 'settings', component: SettingsComponent },
|
{ path: 'settings', component: SettingsComponent },
|
||||||
{ path: 'settings/console', component: ConsoleComponent },
|
{ path: 'settings/console', component: ConsoleComponent },
|
||||||
{ path: 'installed-software', component: InstalledSoftwareComponent },
|
{ path: 'installed-software', component: InstalledSoftwareComponent },
|
||||||
|
|
||||||
|
{ path: 'server/:server_ip/:server_port/project/:project_id', component: DirectLinkComponent},
|
||||||
{ path: 'server/:server_id/project/:project_id/snapshots', component: ListOfSnapshotsComponent },
|
{ path: 'server/:server_id/project/:project_id/snapshots', component: ListOfSnapshotsComponent },
|
||||||
{ path: 'server/:server_id/preferences', component: PreferencesComponent },
|
{ path: 'server/:server_id/preferences', component: PreferencesComponent },
|
||||||
{ path: 'server/:server_id/preferences/gns3vm', component: Gns3vmComponent },
|
{ path: 'server/:server_id/preferences/gns3vm', component: Gns3vmComponent },
|
||||||
|
@ -259,6 +259,7 @@ import { ThemeService } from './services/theme.service';
|
|||||||
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
|
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
|
||||||
import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
|
import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
|
||||||
import { GoogleAnalyticsService } from './services/google-analytics.service';
|
import { GoogleAnalyticsService } from './services/google-analytics.service';
|
||||||
|
import { DirectLinkComponent } from './components/direct-link/direct-link.component';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -435,7 +436,8 @@ if (environment.production) {
|
|||||||
ConfigDialogComponent,
|
ConfigDialogComponent,
|
||||||
Gns3vmComponent,
|
Gns3vmComponent,
|
||||||
ConfigureGns3VMDialogComponent,
|
ConfigureGns3VMDialogComponent,
|
||||||
ImportApplianceComponent
|
ImportApplianceComponent,
|
||||||
|
DirectLinkComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
45
src/app/components/direct-link/direct-link.component.ts
Normal file
45
src/app/components/direct-link/direct-link.component.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { Component, OnInit, ElementRef, ViewChild, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { ServerService } from '../../services/server.service';
|
||||||
|
import { ServerDatabase } from '../../services/server.database';
|
||||||
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
import { Server } from '../../models/server';
|
||||||
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-direct-link',
|
||||||
|
templateUrl: './direct-link.component.html',
|
||||||
|
styleUrls: ['./direct-link.component.scss'],
|
||||||
|
encapsulation: ViewEncapsulation.None
|
||||||
|
})
|
||||||
|
export class DirectLinkComponent implements OnInit {
|
||||||
|
constructor(
|
||||||
|
private serverService: ServerService,
|
||||||
|
private serverDatabase: ServerDatabase,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private toasterService: ToasterService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
const serverIp = this.route.snapshot.paramMap.get('server_ip');
|
||||||
|
const serverPort = +this.route.snapshot.paramMap.get('server_port');
|
||||||
|
const projectId = this.route.snapshot.paramMap.get('project_id');
|
||||||
|
|
||||||
|
const servers = await this.serverService.findAll();
|
||||||
|
const server = servers.filter(server => server.host === serverIp && server.port === serverPort)[0];
|
||||||
|
|
||||||
|
if (server) {
|
||||||
|
this.router.navigate(['/server', server.id, 'project', projectId]);
|
||||||
|
} else {
|
||||||
|
let serverToAdd: Server = new Server();
|
||||||
|
serverToAdd.host = serverIp;
|
||||||
|
serverToAdd.port = serverPort;
|
||||||
|
serverToAdd.location = 'bundled';
|
||||||
|
serverToAdd.name = serverIp;
|
||||||
|
|
||||||
|
this.serverService.create(serverToAdd).then((addedServer: Server) => {
|
||||||
|
this.router.navigate(['/server', addedServer.id, 'project', projectId]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user