浏览代码

fix&refactor: make the code more ng9-ish

One of the changes fixes
the AdjusterLoader component not loading custom styles
Not sure which one though...
jmacura 4 年之前
父节点
当前提交
c23beca47c
共有 6 个文件被更改,包括 27 次插入24 次删除
  1. 4 0
      src/adjuster/adjuster.component.ts
  2. 6 7
      src/adjuster/adjuster.service.ts
  3. 2 2
      src/app-js.ts
  4. 2 5
      src/app.component.ts
  5. 0 1
      src/app.module.ts
  6. 13 9
      src/app.service.ts

+ 4 - 0
src/adjuster/adjuster.component.ts

@@ -31,6 +31,10 @@ export class AdjusterComponent implements HsPanelComponent {
     });
   }
 
+  ngOnInit(): void {
+    this.adjusterService.init();
+  }
+
   isVisible(): boolean {
     return this.hsLayoutService.panelVisible('adjuster');
   }

+ 6 - 7
src/adjuster/adjuster.service.ts

@@ -94,21 +94,19 @@ export class AdjusterService {
       type: 'hierarchical',
     },
   ];
-  _clusteringInProcess: boolean;
+  private _clusteringInProcess: boolean;
 
   constructor(
-    private adjusterEventService: AdjusterEventService,
-    private hsDialogContainerService: HsDialogContainerService,
-    private hsUtilsService: HsUtilsService,
-    private httpClient: HttpClient
+    public adjusterEventService: AdjusterEventService,
+    public hsDialogContainerService: HsDialogContainerService,
+    public hsUtilsService: HsUtilsService,
+    public httpClient: HttpClient
   ) {
     this.serviceBaseUrl =
       window.location.hostname === 'localhost'
         ? 'https://jmacura.ml/ws/' // 'http://localhost:3000/'
         : 'https://publish.lesprojekt.cz/nodejs/';
     this.method = 'haclustwd2';
-    this._clusteringInProcess = true;
-    this.init();
   }
 
   /**
@@ -188,6 +186,7 @@ export class AdjusterService {
   }
 
   init(): void {
+    this._clusteringInProcess = true;
     this.httpClient
       .get(this.serviceBaseUrl + 'datasets')
       .toPromise()

+ 2 - 2
src/app-js.ts

@@ -6,9 +6,9 @@ import * as angular from 'angular';
 import {downgradeInjectable} from '@angular/upgrade/static';
 
 import './adjuster/';
+import {AppComponent} from './app.component';
 import {AppConfig} from './app.config';
 import {AppService} from './app.service';
-import {HsComponent} from './app.component';
 
 export default angular
   .module('hs', [
@@ -17,5 +17,5 @@ export default angular
     'pra.adjuster',
   ])
   .value('HsConfig', AppConfig)
-  .component('hs', HsComponent)
+  .component('hs', AppComponent)
   .service('AppService', downgradeInjectable(AppService));

+ 2 - 5
src/app.component.ts

@@ -1,14 +1,11 @@
-export const HsComponent = {
+export const AppComponent = {
   template: (HsCore) => {
     'ngInject';
     return HsCore.hslayersNgTemplate;
   },
   bindings: {},
   controllerAs: 'vm',
-  controller: class HsComponent {
-    exists;
-    panelVisible;
-    PraAdjusterService;
+  controller: class AppComponent {
     constructor(HsLayoutService, AdjusterService, AppService) {
       'ngInject';
       const vm = this;

+ 0 - 1
src/app.module.ts

@@ -22,7 +22,6 @@ import {AppService} from './app.service';
   imports: [BrowserModule, UpgradeModule, HsCoreModule, AdjusterModule],
   exports: [],
   declarations: [],
-  entryComponents: [],
   providers: [
     {
       provide: APP_BOOTSTRAP_LISTENER,

+ 13 - 9
src/app.service.ts

@@ -8,13 +8,14 @@ import {Vector as VectorSource} from 'ol/source';
 
 import {HsConfig} from 'hslayers-ng/config.service';
 import {HsLayoutService} from 'hslayers-ng/components/layout/layout.service';
-import {HsMapService} from 'hslayers-ng/components/map/map.service';
+//import {HsMapService} from 'hslayers-ng/components/map/map.service';
 import {HsPanelContainerService} from 'hslayers-ng/components/layout/panels/panel-container.service';
 import {HsSidebarService} from 'hslayers-ng/components/sidebar/sidebar.service';
 
 import {AdjusterComponent} from './adjuster/adjuster.component';
 import {AdjusterEventService} from './adjuster/adjuster-event.service';
 import {AdjusterService} from './adjuster/adjuster.service';
+import {HsEventBusService} from 'hslayers-ng/components/core/event-bus.service';
 import {nuts} from './nuts';
 
 @Injectable({providedIn: 'root'})
@@ -75,13 +76,14 @@ export class AppService {
   });
   serviceUrl: string;
   constructor(
-    private adjusterService: AdjusterService,
-    private adjusterEventService: AdjusterEventService,
-    private hsConfig: HsConfig,
-    private hsLayoutService: HsLayoutService,
-    private hsMapService: HsMapService,
-    private hsSidebarService: HsSidebarService,
-    private hsPanelContainerService: HsPanelContainerService
+    public adjusterService: AdjusterService,
+    public adjusterEventService: AdjusterEventService,
+    public hsConfig: HsConfig,
+    public hsEventBus: HsEventBusService,
+    public hsLayoutService: HsLayoutService,
+    //public hsMapService: HsMapService,
+    public hsSidebarService: HsSidebarService,
+    public hsPanelContainerService: HsPanelContainerService
   ) {
     this.serviceUrl = this.adjusterService.serviceBaseUrl + 'georeport/';
     this.nuts3Layer.set('popUp', {
@@ -132,7 +134,9 @@ export class AppService {
     /*this.hsMapService
       .loaded()
       .then((map) => this.hsMapService.repopulateLayers([]));*/
-    this.init();
+    this.hsEventBus.layerLoads.subscribe(() => {
+      this.init();
+    });
   }
 
   init(): void {