mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-18 14:58:15 +00:00
DrawingsDataSource
This commit is contained in:
@ -59,6 +59,7 @@ import {NodesDataSource} from "./cartography/shared/datasources/nodes-datasource
|
|||||||
import { SymbolsDataSource } from "./cartography/shared/datasources/symbols-datasource";
|
import { SymbolsDataSource } from "./cartography/shared/datasources/symbols-datasource";
|
||||||
import { SelectionManager } from "./cartography/shared/managers/selection-manager";
|
import { SelectionManager } from "./cartography/shared/managers/selection-manager";
|
||||||
import { InRectangleHelper } from "./cartography/map/helpers/in-rectangle-helper";
|
import { InRectangleHelper } from "./cartography/map/helpers/in-rectangle-helper";
|
||||||
|
import { DrawingsDataSource } from "./cartography/shared/datasources/drawings-datasource";
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -120,7 +121,8 @@ import {InRectangleHelper} from "./cartography/map/helpers/in-rectangle-helper";
|
|||||||
NodesDataSource,
|
NodesDataSource,
|
||||||
SymbolsDataSource,
|
SymbolsDataSource,
|
||||||
SelectionManager,
|
SelectionManager,
|
||||||
InRectangleHelper
|
InRectangleHelper,
|
||||||
|
DrawingsDataSource
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -12,7 +12,6 @@ class TestDataSource extends DataSource<Item> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('TestDataSource', () => {
|
describe('TestDataSource', () => {
|
||||||
let dataSource: TestDataSource;
|
let dataSource: TestDataSource;
|
||||||
let data: Item[];
|
let data: Item[];
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
import { DrawingsDataSource } from "./drawings-datasource";
|
||||||
|
import { Drawing } from "../models/drawing";
|
||||||
|
|
||||||
|
|
||||||
|
describe('DrawingsDataSource', () => {
|
||||||
|
let dataSource: DrawingsDataSource;
|
||||||
|
let data: Drawing[];
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dataSource = new DrawingsDataSource();
|
||||||
|
dataSource.connect().subscribe((drawings: Drawing[]) => {
|
||||||
|
data = drawings;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Drawing can be updated', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const drawing = new Drawing();
|
||||||
|
drawing.drawing_id = "1";
|
||||||
|
drawing.project_id = "project1";
|
||||||
|
dataSource.add(drawing);
|
||||||
|
|
||||||
|
drawing.project_id = "project2";
|
||||||
|
dataSource.update(drawing);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('project_id should change', () => {
|
||||||
|
expect(data[0].drawing_id).toEqual("1");
|
||||||
|
expect(data[0].project_id).toEqual("project2");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,12 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
import { Drawing } from "../models/drawing";
|
||||||
|
import { DataSource } from "./datasource";
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DrawingsDataSource extends DataSource<Drawing> {
|
||||||
|
protected findIndex(drawing: Drawing) {
|
||||||
|
return this.data.findIndex((d: Drawing) => d.drawing_id === drawing.drawing_id);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
import { Node } from "../models/node";
|
import { Node } from "../models/node";
|
||||||
import { DataSource } from "./datasource";
|
import { DataSource } from "./datasource";
|
||||||
import {Injectable} from "@angular/core";
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {Node} from "../models/node";
|
|
||||||
import {DataSource} from "./datasource";
|
|
||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
import { DataSource } from "./datasource";
|
||||||
import { Symbol } from "../models/symbol";
|
import { Symbol } from "../models/symbol";
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ export class LinksWidget implements Widget {
|
|||||||
const link = view
|
const link = view
|
||||||
.selectAll<SVGGElement, Link>("g.link")
|
.selectAll<SVGGElement, Link>("g.link")
|
||||||
.data((layer: Layer) => {
|
.data((layer: Layer) => {
|
||||||
console.log(layer.links);
|
|
||||||
if (layer.links) {
|
if (layer.links) {
|
||||||
const layer_links = layer.links.filter((l: Link) => {
|
const layer_links = layer.links.filter((l: Link) => {
|
||||||
return l.target && l.source;
|
return l.target && l.source;
|
||||||
|
@ -36,9 +36,9 @@ import { ToasterService } from '../shared/services/toaster.service';
|
|||||||
import { NodesDataSource } from "../cartography/shared/datasources/nodes-datasource";
|
import { NodesDataSource } from "../cartography/shared/datasources/nodes-datasource";
|
||||||
import { LinksDataSource } from "../cartography/shared/datasources/links-datasource";
|
import { LinksDataSource } from "../cartography/shared/datasources/links-datasource";
|
||||||
import { ProjectWebServiceHandler } from "../shared/handlers/project-web-service-handler";
|
import { ProjectWebServiceHandler } from "../shared/handlers/project-web-service-handler";
|
||||||
import { Rectangle } from "../cartography/shared/models/rectangle";
|
|
||||||
import { SelectionManager } from "../cartography/shared/managers/selection-manager";
|
import { SelectionManager } from "../cartography/shared/managers/selection-manager";
|
||||||
import { InRectangleHelper } from "../cartography/map/helpers/in-rectangle-helper";
|
import { InRectangleHelper } from "../cartography/map/helpers/in-rectangle-helper";
|
||||||
|
import { DrawingsDataSource } from "../cartography/shared/datasources/drawings-datasource";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -81,6 +81,7 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
private projectWebServiceHandler: ProjectWebServiceHandler,
|
private projectWebServiceHandler: ProjectWebServiceHandler,
|
||||||
protected nodesDataSource: NodesDataSource,
|
protected nodesDataSource: NodesDataSource,
|
||||||
protected linksDataSource: LinksDataSource,
|
protected linksDataSource: LinksDataSource,
|
||||||
|
protected drawingsDataSource: DrawingsDataSource
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +115,13 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
this.symbols = symbols;
|
this.symbols = symbols;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.drawingsDataSource.connect().subscribe((drawings: Drawing[]) => {
|
||||||
|
this.drawings = drawings;
|
||||||
|
if (this.mapChild) {
|
||||||
|
this.mapChild.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.nodesDataSource.connect().subscribe((nodes: Node[]) => {
|
this.nodesDataSource.connect().subscribe((nodes: Node[]) => {
|
||||||
this.nodes = nodes;
|
this.nodes = nodes;
|
||||||
if (this.mapChild) {
|
if (this.mapChild) {
|
||||||
@ -136,7 +144,7 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
return this.projectService.drawings(this.server, project.project_id);
|
return this.projectService.drawings(this.server, project.project_id);
|
||||||
})
|
})
|
||||||
.flatMap((drawings: Drawing[]) => {
|
.flatMap((drawings: Drawing[]) => {
|
||||||
this.drawings = drawings;
|
this.drawingsDataSource.set(drawings);
|
||||||
return this.projectService.links(this.server, project.project_id);
|
return this.projectService.links(this.server, project.project_id);
|
||||||
})
|
})
|
||||||
.flatMap((links: Link[]) => {
|
.flatMap((links: Link[]) => {
|
||||||
|
Reference in New Issue
Block a user