From ff8f595cd46de5be20959cae7acb988ae55266eb Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 11 Dec 2018 14:26:44 +0100 Subject: [PATCH 1/7] Rename appliances to templates in order to support 2.2 API, Fixes #227 --- src/app/app.module.ts | 14 ++--- .../appliance/appliance.component.html | 3 -- .../appliance/appliance.component.ts | 36 ------------- .../project-map/project-map.component.html | 4 +- .../project-map/project-map.component.ts | 6 +-- .../template-list-dialog.component.html} | 2 +- .../template-list-dialog.component.scss} | 0 .../template-list-dialog.component.spec.ts} | 12 ++--- .../template-list-dialog.component.ts} | 52 +++++++++---------- .../template/template.component.html | 3 ++ .../template.component.scss} | 0 .../template.component.spec.ts} | 12 ++--- .../components/template/template.component.ts | 36 +++++++++++++ src/app/models/{appliance.ts => template.ts} | 4 +- src/app/services/node.service.spec.ts | 12 ++--- src/app/services/node.service.ts | 8 +-- ...rvice.spec.ts => template.service.spec.ts} | 12 ++--- ...pliance.service.ts => template.service.ts} | 8 +-- 18 files changed, 112 insertions(+), 112 deletions(-) delete mode 100644 src/app/components/appliance/appliance.component.html delete mode 100644 src/app/components/appliance/appliance.component.ts rename src/app/components/{appliance/appliance-list-dialog/appliance-list-dialog.component.html => template/template-list-dialog/template-list-dialog.component.html} (92%) rename src/app/components/{appliance/appliance-list-dialog/appliance-list-dialog.component.scss => template/template-list-dialog/template-list-dialog.component.scss} (100%) rename src/app/components/{appliance/appliance-list-dialog/appliance-list-dialog.component.spec.ts => template/template-list-dialog/template-list-dialog.component.spec.ts} (50%) rename src/app/components/{appliance/appliance-list-dialog/appliance-list-dialog.component.ts => template/template-list-dialog/template-list-dialog.component.ts} (52%) create mode 100644 src/app/components/template/template.component.html rename src/app/components/{appliance/appliance.component.scss => template/template.component.scss} (100%) rename src/app/components/{appliance/appliance.component.spec.ts => template/template.component.spec.ts} (55%) create mode 100644 src/app/components/template/template.component.ts rename src/app/models/{appliance.ts => template.ts} (75%) rename src/app/services/{appliance.service.spec.ts => template.service.spec.ts} (79%) rename src/app/services/{appliance.service.ts => template.service.ts} (58%) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 83e5d9db..86aa99ab 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,7 +23,7 @@ import { HttpServer, ServerErrorHandler } from "./services/http-server.service"; import { SnapshotService } from "./services/snapshot.service"; import { ProgressDialogService } from "./common/progress-dialog/progress-dialog.service"; import { NodeService } from "./services/node.service"; -import { ApplianceService } from "./services/appliance.service"; +import { TemplateService } from "./services/template.service"; import { LinkService } from "./services/link.service"; import { ProjectsComponent } from './components/projects/projects.component'; @@ -39,8 +39,8 @@ import { ServersComponent, AddServerDialogComponent } from './components/servers import { NodeContextMenuComponent } from './components/project-map/node-context-menu/node-context-menu.component'; import { StartNodeActionComponent } from './components/project-map/node-context-menu/actions/start-node-action/start-node-action.component'; import { StopNodeActionComponent } from './components/project-map/node-context-menu/actions/stop-node-action/stop-node-action.component'; -import { ApplianceComponent } from './components/appliance/appliance.component'; -import { ApplianceListDialogComponent } from './components/appliance/appliance-list-dialog/appliance-list-dialog.component'; +import { TemplateComponent } from './components/template/template.component'; +import { TemplateListDialogComponent } from './components/template/template-list-dialog/template-list-dialog.component'; import { CartographyModule } from './cartography/cartography.module'; import { ToasterService } from './services/toaster.service'; import { ProjectWebServiceHandler } from "./handlers/project-web-service-handler"; @@ -105,8 +105,8 @@ if (environment.production) { NodeContextMenuComponent, StartNodeActionComponent, StopNodeActionComponent, - ApplianceComponent, - ApplianceListDialogComponent, + TemplateComponent, + TemplateListDialogComponent, MoveLayerDownActionComponent, MoveLayerUpActionComponent, ProjectMapShortcutsComponent, @@ -140,7 +140,7 @@ if (environment.production) { ProjectService, SymbolService, ServerService, - ApplianceService, + TemplateService, NodeService, LinkService, DrawingService, @@ -165,7 +165,7 @@ if (environment.production) { AddServerDialogComponent, CreateSnapshotDialogComponent, ProgressDialogComponent, - ApplianceListDialogComponent, + TemplateListDialogComponent, AddBlankProjectDialogComponent, ImportProjectDialogComponent, ConfirmationDialogComponent diff --git a/src/app/components/appliance/appliance.component.html b/src/app/components/appliance/appliance.component.html deleted file mode 100644 index baef47be..00000000 --- a/src/app/components/appliance/appliance.component.html +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/src/app/components/appliance/appliance.component.ts b/src/app/components/appliance/appliance.component.ts deleted file mode 100644 index aaed1faa..00000000 --- a/src/app/components/appliance/appliance.component.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {MatDialog} from "@angular/material"; -import {ApplianceListDialogComponent} from "./appliance-list-dialog/appliance-list-dialog.component"; - -import {Server} from "../../models/server"; -import {Appliance} from "../../models/appliance"; - -@Component({ - selector: 'app-appliance', - templateUrl: './appliance.component.html', - styleUrls: ['./appliance.component.scss'] -}) -export class ApplianceComponent implements OnInit { - @Input() server: Server; - @Output() onNodeCreation = new EventEmitter(); - - constructor(private dialog: MatDialog) { } - - ngOnInit() {} - - listAppliancesModal() { - const dialogRef = this.dialog.open(ApplianceListDialogComponent, { - width: '600px', - height: '560px', - data: { - 'server': this.server - } - }); - - dialogRef.afterClosed().subscribe((appliance: Appliance) => { - if (appliance !== null) { - this.onNodeCreation.emit(appliance); - } - }); - } -} diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html index 9be28e62..39405f6d 100644 --- a/src/app/components/project-map/project-map.component.html +++ b/src/app/components/project-map/project-map.component.html @@ -85,10 +85,10 @@ - + > diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 9d34c0b5..ced0364d 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -13,7 +13,7 @@ import { ProjectService } from '../../services/project.service'; import { Server } from "../../models/server"; import { Drawing } from "../../cartography/models/drawing"; import { NodeContextMenuComponent } from "./node-context-menu/node-context-menu.component"; -import { Appliance } from "../../models/appliance"; +import { Template } from "../../models/template"; import { NodeService } from "../../services/node.service"; import { Symbol } from "../../models/symbol"; import { LinkService } from "../../services/link.service"; @@ -227,9 +227,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.mapChangeDetectorRef.detectChanges(); } - onNodeCreation(appliance: Appliance) { + onNodeCreation(template: Template) { this.nodeService - .createFromAppliance(this.server, this.project, appliance, 0, 0, 'local') + .createFromTemplate(this.server, this.project, template, 0, 0, 'local') .subscribe((createdNode: Node) => { this.projectService .nodes(this.server, this.project.project_id) diff --git a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.html b/src/app/components/template/template-list-dialog/template-list-dialog.component.html similarity index 92% rename from src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.html rename to src/app/components/template/template-list-dialog/template-list-dialog.component.html index 2be8b639..6358698c 100644 --- a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.html +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.scss b/src/app/components/template/template-list-dialog/template-list-dialog.component.scss similarity index 100% rename from src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.scss rename to src/app/components/template/template-list-dialog/template-list-dialog.component.scss diff --git a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.spec.ts b/src/app/components/template/template-list-dialog/template-list-dialog.component.spec.ts similarity index 50% rename from src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.spec.ts rename to src/app/components/template/template-list-dialog/template-list-dialog.component.spec.ts index 0fa7a189..335c8371 100644 --- a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.spec.ts +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ApplianceListDialogComponent } from './appliance-list-dialog.component'; +import { TemplateListDialogComponent } from './template-list-dialog.component'; -describe('ApplianceListDialogComponent', () => { - let component: ApplianceListDialogComponent; - let fixture: ComponentFixture; +describe('TemplateListDialogComponent', () => { + let component: TemplateListDialogComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ApplianceListDialogComponent ] + declarations: [ TemplateListDialogComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(ApplianceListDialogComponent); + fixture = TestBed.createComponent(TemplateListDialogComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.ts b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts similarity index 52% rename from src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.ts rename to src/app/components/template/template-list-dialog/template-list-dialog.component.ts index e25c312e..565bf35d 100644 --- a/src/app/components/appliance/appliance-list-dialog/appliance-list-dialog.component.ts +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts @@ -6,33 +6,33 @@ import { Observable, BehaviorSubject, fromEvent, merge } from "rxjs"; import { debounceTime, distinctUntilChanged, map } from "rxjs/operators"; import { Server } from "../../../models/server"; -import { ApplianceService } from "../../../services/appliance.service"; -import { Appliance } from "../../../models/appliance"; +import { TemplateService } from "../../../services/template.service"; +import { Template } from "../../../models/template"; @Component({ - selector: 'app-appliance-list-dialog', - templateUrl: './appliance-list-dialog.component.html', - styleUrls: ['./appliance-list-dialog.component.scss'] + selector: 'app-template-list-dialog', + templateUrl: './template-list-dialog.component.html', + styleUrls: ['./template-list-dialog.component.scss'] }) -export class ApplianceListDialogComponent implements OnInit { +export class TemplateListDialogComponent implements OnInit { server: Server; - applianceDatabase: ApplianceDatabase; - dataSource: ApplianceDataSource; + templateDatabase: TemplateDatabase; + dataSource: TemplateDataSource; displayedColumns = ['name']; @ViewChild('filter') filter: ElementRef; constructor( - public dialogRef: MatDialogRef, - private applianceService: ApplianceService, + public dialogRef: MatDialogRef, + private templateService: TemplateService, @Inject(MAT_DIALOG_DATA) public data: any) { this.server = data['server']; } ngOnInit() { - this.applianceDatabase = new ApplianceDatabase(this.server, this.applianceService); - this.dataSource = new ApplianceDataSource(this.applianceDatabase); + this.templateDatabase = new TemplateDatabase(this.server, this.templateService); + this.dataSource = new TemplateDataSource(this.templateDatabase); fromEvent(this.filter.nativeElement, 'keyup').pipe( debounceTime(150), @@ -49,48 +49,48 @@ export class ApplianceListDialogComponent implements OnInit { this.dialogRef.close(); } - addNode(appliance: Appliance): void { - this.dialogRef.close(appliance); + addNode(template: Template): void { + this.dialogRef.close(template); } } -export class ApplianceDatabase { - dataChange: BehaviorSubject = new BehaviorSubject([]); +export class TemplateDatabase { + dataChange: BehaviorSubject = new BehaviorSubject([]); - get data(): Appliance[] { + get data(): Template[] { return this.dataChange.value; } - constructor(private server: Server, private applianceService: ApplianceService) { - this.applianceService + constructor(private server: Server, private templateService: TemplateService) { + this.templateService .list(this.server) - .subscribe((appliances) => { - this.dataChange.next(appliances); + .subscribe((templates) => { + this.dataChange.next(templates); }); } }; -export class ApplianceDataSource extends DataSource { +export class TemplateDataSource extends DataSource