From 4de4471d736caa7f302f6d97a5c36a4c5a26fcbc Mon Sep 17 00:00:00 2001
From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com>
Date: Tue, 11 Feb 2020 17:16:47 +0100
Subject: [PATCH 01/11] On push strategy for project map components
---
.../project-map/nodes-menu/nodes-menu.component.ts | 5 +++--
.../project-map-menu/project-map-menu.component.ts | 6 +++---
.../topology-summary/topology-summary.component.ts | 5 +++--
src/main.ts | 14 ++++++++++----
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts
index 93ae7f11..0c9a1d2c 100644
--- a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts
+++ b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input } from "@angular/core";
+import { Component, Input, ChangeDetectionStrategy } from "@angular/core";
import { Project } from '../../../models/project';
import { Server } from '../../../models/server';
import { NodeService } from '../../../services/node.service';
@@ -11,7 +11,8 @@ import { ServerService } from '../../../services/server.service';
@Component({
selector: 'app-nodes-menu',
templateUrl: './nodes-menu.component.html',
- styleUrls: ['./nodes-menu.component.scss']
+ styleUrls: ['./nodes-menu.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush
})
export class NodesMenuComponent {
@Input('project') project: Project;
diff --git a/src/app/components/project-map/project-map-menu/project-map-menu.component.ts b/src/app/components/project-map/project-map-menu/project-map-menu.component.ts
index 86fcb6fb..388501fd 100644
--- a/src/app/components/project-map/project-map-menu/project-map-menu.component.ts
+++ b/src/app/components/project-map/project-map-menu/project-map-menu.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, OnDestroy, Input } from '@angular/core';
+import { Component, OnInit, OnDestroy, Input, ChangeDetectionStrategy } from '@angular/core';
import { Project } from '../../../models/project';
import { Server } from '../../../models/server';
import { ToolsService } from '../../../services/tools.service';
@@ -14,11 +14,11 @@ import { ScreenshotDialogComponent, Screenshot } from '../screenshot-dialog/scre
import { saveAsPng, saveAsJpeg } from 'save-html-as-image';
import { ThemeService } from '../../../services/theme.service';
-
@Component({
selector: 'app-project-map-menu',
templateUrl: './project-map-menu.component.html',
- styleUrls: ['./project-map-menu.component.scss']
+ styleUrls: ['./project-map-menu.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProjectMapMenuComponent implements OnInit, OnDestroy {
@Input() project: Project;
diff --git a/src/app/components/topology-summary/topology-summary.component.ts b/src/app/components/topology-summary/topology-summary.component.ts
index d69ca2e6..0afbbe9c 100644
--- a/src/app/components/topology-summary/topology-summary.component.ts
+++ b/src/app/components/topology-summary/topology-summary.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, OnDestroy, Input, AfterViewInit, Output, EventEmitter } from '@angular/core';
+import { Component, OnInit, OnDestroy, Input, AfterViewInit, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Project } from '../../models/project';
import { Server } from '../../models/server';
import { NodesDataSource } from '../../cartography/datasources/nodes-datasource';
@@ -16,7 +16,8 @@ import { ThemeService } from '../../services/theme.service';
@Component({
selector: 'app-topology-summary',
templateUrl: './topology-summary.component.html',
- styleUrls: ['./topology-summary.component.scss']
+ styleUrls: ['./topology-summary.component.scss'],
+ changeDetection: ChangeDetectionStrategy.Default
})
export class TopologySummaryComponent implements OnInit, OnDestroy {
@Input() server: Server;
diff --git a/src/main.ts b/src/main.ts
index 08e893ab..d5268bc1 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,14 +1,20 @@
import 'hammerjs';
-import { enableProdMode } from '@angular/core';
+import { enableProdMode, ApplicationRef } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
+import { enableDebugTools } from '@angular/platform-browser';
if (environment.production) {
enableProdMode();
}
-platformBrowserDynamic()
- .bootstrapModule(AppModule)
- .catch(err => console.error(err));
+platformBrowserDynamic().bootstrapModule(AppModule)
+ .then(moduleRef => {
+ const applicationRef = moduleRef.injector.get(ApplicationRef);
+ const componentRef = applicationRef.components[0];
+ // allows to run `ng.profiler.timeChangeDetection();`
+ enableDebugTools(componentRef);
+ })
+ .catch(err => console.log(err));
From b28f224fdd88b74b85d932e03cafbab598446bf7 Mon Sep 17 00:00:00 2001
From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com>
Date: Thu, 13 Feb 2020 11:26:27 +0100
Subject: [PATCH 02/11] Getters in code instead of extended ngClass in HTML
files
---
.../project-map-menu.component.html | 6 +++---
.../project-map-menu.component.ts | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/app/components/project-map/project-map-menu/project-map-menu.component.html b/src/app/components/project-map/project-map-menu/project-map-menu.component.html
index c86e770d..3834d991 100644
--- a/src/app/components/project-map/project-map-menu/project-map-menu.component.html
+++ b/src/app/components/project-map/project-map-menu/project-map-menu.component.html
@@ -3,7 +3,7 @@
mat-icon-button
class="menu-button"
(click)="addDrawing('text')">
- create
+ create
- crop_3_2
+ crop_3_2