mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-18 14:58:15 +00:00
Merge branch 'master' into Create-templates-from-appliances
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gns3-web-ui",
|
"name": "gns3-web-ui",
|
||||||
"version": "2020.2.0-beta.4",
|
"version": "2020.2.0-beta.5",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "GNS3 Technology Inc.",
|
"name": "GNS3 Technology Inc.",
|
||||||
"email": "developers@gns3.com"
|
"email": "developers@gns3.com"
|
||||||
|
@ -1,6 +1,25 @@
|
|||||||
GNS3 WebUI is web implementation of user interface for GNS3 software.
|
GNS3 WebUI is web implementation of user interface for GNS3 software.
|
||||||
|
|
||||||
Current version: GNS3 Web UI 2020.2.0-beta.4
|
Current version: 2020.2.0-beta.5
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
|
||||||
|
- Bug in symbol selection
|
||||||
|
- Same question is asked after going back to project
|
||||||
|
- Cannot read property 'forEach' of undefined
|
||||||
|
- Error when selecting existing Docker image
|
||||||
|
- Invalid property when adding VMware VM template
|
||||||
|
- Invalid type for adapters field when adding Docker template
|
||||||
|
- Prevent user to move to another step when adding template
|
||||||
|
- Web UI cannot set flag "Leave this project running in the background after closing"
|
||||||
|
|
||||||
|
What's new
|
||||||
|
- Default values in templates
|
||||||
|
- New option for Qemu VMs
|
||||||
|
- Ability to quickly change Hostname from right click
|
||||||
|
- Progress bar for node creation
|
||||||
|
|
||||||
|
GNS3 Web UI 2020.2.0-beta.4
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
- New port setting for GNS3 VM preferences
|
- New port setting for GNS3 VM preferences
|
||||||
|
@ -62,7 +62,6 @@ import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.componen
|
|||||||
import { DirectLinkComponent } from './components/direct-link/direct-link.component';
|
import { DirectLinkComponent } from './components/direct-link/direct-link.component';
|
||||||
import { SystemStatusComponent } from './components/system-status/system-status.component';
|
import { SystemStatusComponent } from './components/system-status/system-status.component';
|
||||||
import { ServerResolve } from './resolvers/server-resolve';
|
import { ServerResolve } from './resolvers/server-resolve';
|
||||||
import { ProjectMapGuard } from './guards/project-map-guard';
|
|
||||||
import { WebConsoleFullWindowComponent } from './components/web-console-full-window/web-console-full-window.component';
|
import { WebConsoleFullWindowComponent } from './components/web-console-full-window/web-console-full-window.component';
|
||||||
import { ConsoleGuard } from './guards/console-guard';
|
import { ConsoleGuard } from './guards/console-guard';
|
||||||
|
|
||||||
@ -154,13 +153,11 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'server/:server_id/project/:project_id',
|
path: 'server/:server_id/project/:project_id',
|
||||||
component: ProjectMapComponent,
|
component: ProjectMapComponent,
|
||||||
canActivate: [ProjectMapGuard],
|
|
||||||
canDeactivate: [ConsoleGuard]
|
canDeactivate: [ConsoleGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'server/:server_id/project/:project_id/nodes/:node_id',
|
path: 'server/:server_id/project/:project_id/nodes/:node_id',
|
||||||
component: WebConsoleFullWindowComponent,
|
component: WebConsoleFullWindowComponent
|
||||||
canActivate: [ProjectMapGuard]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '**',
|
path: '**',
|
||||||
|
@ -267,7 +267,6 @@ import { NgCircleProgressModule } from 'ng-circle-progress';
|
|||||||
import { OpenFileExplorerActionComponent } from './components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component';
|
import { OpenFileExplorerActionComponent } from './components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component';
|
||||||
import { NgxChildProcessModule } from 'ngx-childprocess';
|
import { NgxChildProcessModule } from 'ngx-childprocess';
|
||||||
import { ServerResolve } from './resolvers/server-resolve';
|
import { ServerResolve } from './resolvers/server-resolve';
|
||||||
import { ProjectMapGuard } from './guards/project-map-guard';
|
|
||||||
import { HttpConsoleActionComponent } from './components/project-map/context-menu/actions/http-console/http-console-action.component';
|
import { HttpConsoleActionComponent } from './components/project-map/context-menu/actions/http-console/http-console-action.component';
|
||||||
import { WebConsoleComponent } from './components/project-map/web-console/web-console.component';
|
import { WebConsoleComponent } from './components/project-map/web-console/web-console.component';
|
||||||
import { ConsoleWrapperComponent } from './components/project-map/console-wrapper/console-wrapper.component';
|
import { ConsoleWrapperComponent } from './components/project-map/console-wrapper/console-wrapper.component';
|
||||||
@ -566,7 +565,6 @@ if (environment.production) {
|
|||||||
GoogleAnalyticsService,
|
GoogleAnalyticsService,
|
||||||
NodeConsoleService,
|
NodeConsoleService,
|
||||||
ServerResolve,
|
ServerResolve,
|
||||||
ProjectMapGuard,
|
|
||||||
ConsoleGuard,
|
ConsoleGuard,
|
||||||
Title,
|
Title,
|
||||||
ApplianceService
|
ApplianceService
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<svg id="map" #svg class="map" preserveAspectRatio="none" movingCanvas zoomingCanvas>
|
<svg id="map" #svg class="map" preserveAspectRatio="none" movingCanvas zoomingCanvas>
|
||||||
<filter id="grayscale"><feColorMatrix id="feGrayscale" type="saturate" values="0" /></filter>
|
<filter id="grayscale"><feColorMatrix id="feGrayscale" type="saturate" values="0" /></filter>
|
||||||
<defs>
|
<defs>
|
||||||
<pattern id="gridDrawing" attr.width="{{project.drawing_grid_size}}" attr.height="{{project.drawing_grid_size}}" patternUnits="userSpaceOnUse">
|
<pattern attr.x="{{drawingGridX}}" attr.y="{{drawingGridY}}" id="gridDrawing" attr.width="{{project.drawing_grid_size}}" attr.height="{{project.drawing_grid_size}}" patternUnits="userSpaceOnUse">
|
||||||
<path attr.d="M {{project.drawing_grid_size}} 0 L 0 0 0 {{project.drawing_grid_size}}" fill="none" stroke="silver" attr.stroke-width="{{gridVisibility}}"/>
|
<path attr.d="M {{project.drawing_grid_size}} 0 L 0 0 0 {{project.drawing_grid_size}}" fill="none" stroke="silver" attr.stroke-width="{{gridVisibility}}"/>
|
||||||
</pattern>
|
</pattern>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
<defs>
|
<defs>
|
||||||
<pattern id="gridNode" attr.width="{{project.grid_size}}" attr.height="{{project.grid_size}}" patternUnits="userSpaceOnUse">
|
<pattern attr.x="{{nodeGridX}}" attr.y="{{nodeGridY}}" id="gridNode" attr.width="{{project.grid_size}}" attr.height="{{project.grid_size}}" patternUnits="userSpaceOnUse">
|
||||||
<path attr.d="M {{project.grid_size}} 0 L 0 0 0 {{project.grid_size}}" fill="none" stroke="DarkSlateGray" attr.stroke-width="{{gridVisibility}}"/>
|
<path attr.d="M {{project.grid_size}} 0 L 0 0 0 {{project.grid_size}}" fill="none" stroke="DarkSlateGray" attr.stroke-width="{{gridVisibility}}"/>
|
||||||
</pattern>
|
</pattern>
|
||||||
</defs>
|
</defs>
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
@ -64,6 +64,11 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
};
|
};
|
||||||
public gridVisibility: number = 0;
|
public gridVisibility: number = 0;
|
||||||
|
|
||||||
|
public nodeGridX: number = 0;
|
||||||
|
public nodeGridY: number = 0;
|
||||||
|
public drawingGridX: number = 0;
|
||||||
|
public drawingGridY: number = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private graphDataManager: GraphDataManager,
|
private graphDataManager: GraphDataManager,
|
||||||
public context: Context,
|
public context: Context,
|
||||||
@ -189,6 +194,8 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private redraw() {
|
private redraw() {
|
||||||
|
this.updateGrid();
|
||||||
|
|
||||||
this.graphDataManager.setNodes(this.nodes);
|
this.graphDataManager.setNodes(this.nodes);
|
||||||
this.graphDataManager.setLinks(this.links);
|
this.graphDataManager.setLinks(this.links);
|
||||||
this.graphDataManager.setDrawings(this.drawings);
|
this.graphDataManager.setDrawings(this.drawings);
|
||||||
@ -198,6 +205,14 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.mapSettingsService.mapRenderedEmitter.emit(true);
|
this.mapSettingsService.mapRenderedEmitter.emit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateGrid() {
|
||||||
|
this.nodeGridX = (this.project.scene_width/2 - (Math.floor(this.project.scene_width/2 / this.project.grid_size) * this.project.grid_size));
|
||||||
|
this.nodeGridY = (this.project.scene_height/2 - (Math.floor(this.project.scene_height/2 / this.project.grid_size) * this.project.grid_size));
|
||||||
|
|
||||||
|
this.drawingGridX = (this.project.scene_width/2 - (Math.floor(this.project.scene_width/2 / this.project.drawing_grid_size) * this.project.drawing_grid_size));
|
||||||
|
this.drawingGridY = (this.project.scene_height/2 - (Math.floor(this.project.scene_height/2 / this.project.drawing_grid_size) * this.project.drawing_grid_size));
|
||||||
|
}
|
||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
onResize(event) {
|
onResize(event) {
|
||||||
this.changeLayout();
|
this.changeLayout();
|
||||||
|
@ -21,29 +21,35 @@ export class DirectLinkComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
if (this.serverService.isServiceInitialized) this.getServers();
|
||||||
|
|
||||||
|
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
||||||
|
if (value) {
|
||||||
|
this.getServers();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getServers() {
|
||||||
const serverIp = this.route.snapshot.paramMap.get('server_ip');
|
const serverIp = this.route.snapshot.paramMap.get('server_ip');
|
||||||
const serverPort = +this.route.snapshot.paramMap.get('server_port');
|
const serverPort = +this.route.snapshot.paramMap.get('server_port');
|
||||||
const projectId = this.route.snapshot.paramMap.get('project_id');
|
const projectId = this.route.snapshot.paramMap.get('project_id');
|
||||||
|
|
||||||
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
const servers = await this.serverService.findAll();
|
||||||
if (value) {
|
const server = servers.filter(server => server.host === serverIp && server.port === serverPort)[0];
|
||||||
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]);
|
||||||
if (server) {
|
} else {
|
||||||
this.router.navigate(['/server', server.id, 'project', projectId]);
|
let serverToAdd: Server = new Server();
|
||||||
} else {
|
serverToAdd.host = serverIp;
|
||||||
let serverToAdd: Server = new Server();
|
serverToAdd.port = serverPort;
|
||||||
serverToAdd.host = serverIp;
|
serverToAdd.location = 'bundled';
|
||||||
serverToAdd.port = serverPort;
|
serverToAdd.name = serverIp;
|
||||||
serverToAdd.location = 'bundled';
|
|
||||||
serverToAdd.name = serverIp;
|
this.serverService.create(serverToAdd).then((addedServer: Server) => {
|
||||||
|
this.router.navigate(['/server', addedServer.id, 'project', projectId]);
|
||||||
this.serverService.create(serverToAdd).then((addedServer: Server) => {
|
});
|
||||||
this.router.navigate(['/server', addedServer.id, 'project', projectId]);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,56 +170,16 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.mapSettingsService.logConsoleSubject.subscribe(value => this.isConsoleVisible = value);
|
this.mapSettingsService.logConsoleSubject.subscribe(value => this.isConsoleVisible = value);
|
||||||
|
|
||||||
this.progressService.activate();
|
this.progressService.activate();
|
||||||
const routeSub = this.route.paramMap.subscribe((paramMap: ParamMap) => {
|
|
||||||
const server_id = parseInt(paramMap.get('server_id'), 10);
|
|
||||||
|
|
||||||
from(this.serverService.get(server_id))
|
if (this.serverService.isServiceInitialized) {
|
||||||
.pipe(
|
this.getData();
|
||||||
mergeMap((server: Server) => {
|
} else {
|
||||||
this.server = server;
|
this.projectMapSubscription.add(
|
||||||
return this.projectService.get(server, paramMap.get('project_id')).pipe(
|
this.serverService.serviceInitialized.subscribe((val) => {
|
||||||
map(project => {
|
if (val) this.getData();
|
||||||
return project;
|
})
|
||||||
})
|
);
|
||||||
);
|
}
|
||||||
}),
|
|
||||||
mergeMap((project: Project) => {
|
|
||||||
this.project = project;
|
|
||||||
this.projectService.open(this.server, this.project.project_id);
|
|
||||||
this.title.setTitle(this.project.name);
|
|
||||||
|
|
||||||
if (this.mapSettingsService.interfaceLabels.has(project.project_id)) {
|
|
||||||
this.isInterfaceLabelVisible = this.mapSettingsService.interfaceLabels.get(project.project_id);
|
|
||||||
} else {
|
|
||||||
this.isInterfaceLabelVisible = this.project.show_interface_labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.recentlyOpenedProjectService.setServerId(this.server.id.toString());
|
|
||||||
this.recentlyOpenedProjectService.setProjectId(this.project.project_id);
|
|
||||||
|
|
||||||
if (this.project.status === 'opened') {
|
|
||||||
return new Observable<Project>(observer => {
|
|
||||||
observer.next(this.project);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return this.projectService.open(this.server, this.project.project_id);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe(
|
|
||||||
(project: Project) => {
|
|
||||||
this.onProjectLoad(project);
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
this.progressService.setError(error);
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.progressService.deactivate();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.projectMapSubscription.add(routeSub);
|
|
||||||
|
|
||||||
this.projectMapSubscription.add(
|
this.projectMapSubscription.add(
|
||||||
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
||||||
@ -273,6 +233,63 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.addKeyboardListeners();
|
this.addKeyboardListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
const routeSub = this.route.paramMap.subscribe((paramMap: ParamMap) => {
|
||||||
|
const server_id = parseInt(paramMap.get('server_id'), 10);
|
||||||
|
|
||||||
|
from(this.serverService.get(server_id))
|
||||||
|
.pipe(
|
||||||
|
mergeMap((server: Server) => {
|
||||||
|
if (!server ) this.router.navigate(['/servers']);
|
||||||
|
|
||||||
|
this.server = server;
|
||||||
|
return this.projectService.get(server, paramMap.get('project_id')).pipe(
|
||||||
|
map(project => {
|
||||||
|
return project;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
mergeMap((project: Project) => {
|
||||||
|
this.project = project;
|
||||||
|
if (!project ) this.router.navigate(['/servers']);
|
||||||
|
|
||||||
|
this.projectService.open(this.server, this.project.project_id);
|
||||||
|
this.title.setTitle(this.project.name);
|
||||||
|
|
||||||
|
if (this.mapSettingsService.interfaceLabels.has(project.project_id)) {
|
||||||
|
this.isInterfaceLabelVisible = this.mapSettingsService.interfaceLabels.get(project.project_id);
|
||||||
|
} else {
|
||||||
|
this.isInterfaceLabelVisible = this.project.show_interface_labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.recentlyOpenedProjectService.setServerId(this.server.id.toString());
|
||||||
|
this.recentlyOpenedProjectService.setProjectId(this.project.project_id);
|
||||||
|
|
||||||
|
if (this.project.status === 'opened') {
|
||||||
|
return new Observable<Project>(observer => {
|
||||||
|
observer.next(this.project);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return this.projectService.open(this.server, this.project.project_id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(project: Project) => {
|
||||||
|
this.onProjectLoad(project);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.progressService.setError(error);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.progressService.deactivate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.projectMapSubscription.add(routeSub);
|
||||||
|
}
|
||||||
|
|
||||||
addKeyboardListeners() {
|
addKeyboardListeners() {
|
||||||
Mousetrap.bind('ctrl++', (event: Event) => {
|
Mousetrap.bind('ctrl++', (event: Event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -53,6 +53,8 @@ export class ProjectsComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.server = this.route.snapshot.data['server'];
|
this.server = this.route.snapshot.data['server'];
|
||||||
|
if(!this.server) this.router.navigate(['/servers']);
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.sort.sort(<MatSortable>{
|
this.sort.sort(<MatSortable>{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
|
@ -32,6 +32,8 @@ export class ServerDiscoveryComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (this.serverService.isServiceInitialized) this.discoverFirstAvailableServer();
|
||||||
|
|
||||||
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.discoverFirstAvailableServer();
|
this.discoverFirstAvailableServer();
|
||||||
|
@ -35,32 +35,39 @@ export class ServersComponent implements OnInit, OnDestroy {
|
|||||||
private childProcessService: ChildProcessService,
|
private childProcessService: ChildProcessService,
|
||||||
private bottomSheet: MatBottomSheet,
|
private bottomSheet: MatBottomSheet,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
getServers() {
|
||||||
|
const runningServersNames = this.serverManagement.getRunningServers();
|
||||||
|
|
||||||
|
this.serverService.findAll().then((servers: Server[]) => {
|
||||||
|
servers.forEach((server) => {
|
||||||
|
const serverIndex = runningServersNames.findIndex((serverName) => server.name === serverName);
|
||||||
|
if(serverIndex >= 0) {
|
||||||
|
server.status = 'running';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
servers.forEach((server) => {
|
||||||
|
this.serverService.checkServerVersion(server).subscribe(
|
||||||
|
(serverInfo) => {
|
||||||
|
if ((serverInfo.version.split('.')[1]>=2) && (serverInfo.version.split('.')[0]>=2)) {
|
||||||
|
if (!this.serverDatabase.find(server.name)) this.serverDatabase.addServer(server);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isElectronApp = this.electronService.isElectronApp;
|
this.isElectronApp = this.electronService.isElectronApp;
|
||||||
const runningServersNames = this.serverManagement.getRunningServers();
|
|
||||||
|
if (this.serverService.isServiceInitialized) this.getServers();
|
||||||
|
|
||||||
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
this.serverService.serviceInitialized.subscribe(async (value: boolean) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.serverService.findAll().then((servers: Server[]) => {
|
this.getServers();
|
||||||
servers.forEach((server) => {
|
|
||||||
const serverIndex = runningServersNames.findIndex((serverName) => server.name === serverName);
|
|
||||||
if(serverIndex >= 0) {
|
|
||||||
server.status = 'running';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
servers.forEach((server) => {
|
|
||||||
this.serverService.checkServerVersion(server).subscribe(
|
|
||||||
(serverInfo) => {
|
|
||||||
if ((serverInfo.version.split('.')[1]>=2) && (serverInfo.version.split('.')[0]>=2)) {
|
|
||||||
if (!this.serverDatabase.find(server.name)) this.serverDatabase.addServer(server);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => {}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { ServerService } from '../../services/server.service';
|
import { ServerService } from '../../services/server.service';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { NodeService } from '../../services/node.service';
|
import { NodeService } from '../../services/node.service';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -22,7 +23,7 @@ export class WebConsoleFullWindowComponent implements OnInit {
|
|||||||
private serverId: string;
|
private serverId: string;
|
||||||
private projectId: string;
|
private projectId: string;
|
||||||
private nodeId: string;
|
private nodeId: string;
|
||||||
|
private subscriptions: Subscription = new Subscription();
|
||||||
private server: Server;
|
private server: Server;
|
||||||
private node: Node;
|
private node: Node;
|
||||||
|
|
||||||
@ -40,6 +41,18 @@ export class WebConsoleFullWindowComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (this.serverService.isServiceInitialized) {
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.subscriptions.add(
|
||||||
|
this.serverService.serviceInitialized.subscribe((val) => {
|
||||||
|
if (val) this.getData();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
this.serverId = this.route.snapshot.paramMap.get("server_id");
|
this.serverId = this.route.snapshot.paramMap.get("server_id");
|
||||||
this.projectId = this.route.snapshot.paramMap.get("project_id");
|
this.projectId = this.route.snapshot.paramMap.get("project_id");
|
||||||
this.nodeId = this.route.snapshot.paramMap.get("node_id");
|
this.nodeId = this.route.snapshot.paramMap.get("node_id");
|
||||||
@ -55,7 +68,7 @@ export class WebConsoleFullWindowComponent implements OnInit {
|
|||||||
this.title.setTitle(this.node.name);
|
this.title.setTitle(this.node.name);
|
||||||
this.openTerminal();
|
this.openTerminal();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openTerminal() {
|
openTerminal() {
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
|
|
||||||
import { ProjectMapComponent } from '../components/project-map/project-map.component';
|
|
||||||
import { Observable, pipe, timer, from } from 'rxjs';
|
|
||||||
import { ProjectService } from '../services/project.service';
|
|
||||||
import { Server } from '../models/server';
|
|
||||||
import { ServerService } from '../services/server.service';
|
|
||||||
import { switchMap, map } from 'rxjs/operators';
|
|
||||||
import { ToasterService } from '../services/toaster.service';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ProjectMapGuard implements CanActivate {
|
|
||||||
constructor(
|
|
||||||
private projectService: ProjectService,
|
|
||||||
private serverService: ServerService,
|
|
||||||
private toasterService: ToasterService,
|
|
||||||
private router: Router
|
|
||||||
) {}
|
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
|
||||||
const server_id = route.paramMap.get("server_id");
|
|
||||||
const project_id = route.paramMap.get("project_id");
|
|
||||||
|
|
||||||
return from(this.serverService.get(parseInt(server_id, 10))).pipe(
|
|
||||||
switchMap(response => {
|
|
||||||
if (!response) this.router.navigate(['/servers']);
|
|
||||||
return this.projectService.list(response as Server)
|
|
||||||
}),
|
|
||||||
map(response => {
|
|
||||||
let projectToOpen = response.find(n => n.project_id === project_id);
|
|
||||||
if (projectToOpen) return true;
|
|
||||||
|
|
||||||
this.toasterService.error('Project could not be opened');
|
|
||||||
this.projectService.projectListUpdated();
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -70,7 +70,7 @@ export class NodeService {
|
|||||||
|
|
||||||
if (project.snap_to_grid) {
|
if (project.snap_to_grid) {
|
||||||
xPosition = Math.round((xPosition + node.width/2) / project.grid_size) * project.grid_size;
|
xPosition = Math.round((xPosition + node.width/2) / project.grid_size) * project.grid_size;
|
||||||
yPosition = Math.round((yPosition + node.width/2) / project.grid_size) * project.grid_size;
|
yPosition = Math.round((yPosition + node.height/2) / project.grid_size) * project.grid_size;
|
||||||
|
|
||||||
xPosition = Math.round(xPosition - node.width/2);
|
xPosition = Math.round(xPosition - node.width/2);
|
||||||
yPosition = Math.round(yPosition - node.height/2);
|
yPosition = Math.round(yPosition - node.height/2);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { Injectable, EventEmitter } from '@angular/core';
|
import { Injectable, EventEmitter } from '@angular/core';
|
||||||
import { IndexedDbService } from './indexed-db.service';
|
import { IndexedDbService } from './indexed-db.service';
|
||||||
import { Server } from '../models/server';
|
import { Server } from '../models/server';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { HttpServer } from './http-server.service';
|
import { HttpServer } from './http-server.service';
|
||||||
import { ToasterService } from './toaster.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServerService {
|
export class ServerService {
|
||||||
@ -11,24 +10,41 @@ export class ServerService {
|
|||||||
private ready: Promise<any>;
|
private ready: Promise<any>;
|
||||||
private isIncognitoMode: boolean = false;
|
private isIncognitoMode: boolean = false;
|
||||||
private serverIdsInIncognitoMode: string[] = [];
|
private serverIdsInIncognitoMode: string[] = [];
|
||||||
public serviceInitialized: EventEmitter<boolean> = new EventEmitter<boolean>();
|
public serviceInitialized: Subject<boolean> = new Subject<boolean>();
|
||||||
|
public isServiceInitialized: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private indexedDbService: IndexedDbService,
|
private indexedDbService: IndexedDbService,
|
||||||
private httpServer: HttpServer,
|
private httpServer: HttpServer
|
||||||
private toasterService: ToasterService
|
|
||||||
) {
|
) {
|
||||||
this.indexedDbService.get().openDatabase(1).then(() => {
|
this.ready = this.indexedDbService.get().openDatabase(1, evt => {
|
||||||
this.ready = indexedDbService.get().openDatabase(1, evt => {
|
evt.currentTarget.result.createObjectStore(this.tablename, { keyPath: 'id', autoIncrement: true });
|
||||||
evt.currentTarget.result.createObjectStore(this.tablename, { keyPath: 'id', autoIncrement: true });
|
}).then(() => {
|
||||||
|
this.indexedDbService.get().getAll(this.tablename)
|
||||||
|
.then(() => {})
|
||||||
|
.catch(() => {
|
||||||
|
this.isIncognitoMode = true;
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.isIncognitoMode = true;
|
this.isIncognitoMode = true;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.serviceInitialized.emit(true);
|
this.isServiceInitialized = true;
|
||||||
|
this.serviceInitialized.next(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public tryToCreateDb() {
|
||||||
|
let promise = new Promise(resolve => {
|
||||||
|
this.indexedDbService.get().openDatabase(1, evt => {
|
||||||
|
evt.currentTarget.result.createObjectStore(this.tablename, { keyPath: 'id', autoIncrement: true });
|
||||||
|
}).then(() => {
|
||||||
|
}).catch(() => {
|
||||||
|
this.isIncognitoMode = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
public get(id: number): Promise<Server> {
|
public get(id: number): Promise<Server> {
|
||||||
if (this.isIncognitoMode) {
|
if (this.isIncognitoMode) {
|
||||||
let server: Server = JSON.parse(localStorage.getItem(`server-${id}`));
|
let server: Server = JSON.parse(localStorage.getItem(`server-${id}`));
|
||||||
|
Reference in New Issue
Block a user