Ver código fonte

♻️ prepare for simple-panel

jmacura 3 anos atrás
pai
commit
d22a843bf3

+ 6 - 4
src/adjuster/adjuster.component.ts → src/adjuster/adjuster-advanced-panel.component.ts

@@ -9,12 +9,14 @@ import {AdjusterPresetsService} from './adjuster-presets.service';
 import {AdjusterService} from './adjuster.service';
 
 @Component({
-  selector: 'pra-adjuster',
+  selector: 'pra-adjuster-advanced',
   templateUrl: './adjuster.component.html',
   styleUrls: ['./adjuster.component.scss'],
 })
-export class AdjusterComponent implements HsPanelComponent, OnInit {
-  name = 'adjuster';
+export class AdjusterAdvancedPanelComponent
+  implements HsPanelComponent, OnInit
+{
+  name = 'adjuster-advanced';
   data: any;
   errorMsg: string;
   //method: string;
@@ -49,7 +51,7 @@ export class AdjusterComponent implements HsPanelComponent, OnInit {
   }
 
   isVisible(): boolean {
-    return this.hsLayoutService.panelVisible('adjuster');
+    return this.hsLayoutService.panelVisible('adjuster-advanced');
   }
 
   noDataSelected(): boolean {

+ 29 - 0
src/adjuster/adjuster-simple-panel.component.ts

@@ -0,0 +1,29 @@
+import {Component, ViewRef} from '@angular/core';
+
+import {HsLayoutService} from 'hslayers-ng';
+import {HsPanelComponent} from 'hslayers-ng';
+
+import {AdjusterUIService} from './adjuster-ui.service';
+
+@Component({
+  selector: 'pra-adjuster-simple',
+  templateUrl: './adjuster.component.html',
+  styleUrls: ['./adjuster.component.scss'],
+})
+export class AdjusterSimplePanelComponent implements HsPanelComponent {
+  name = 'adjuster-simple';
+  data: any;
+  errorMsg: string;
+  //method: string;
+  showAdvancedOptions = false;
+  viewRef: ViewRef;
+
+  constructor(
+    public adjUIService: AdjusterUIService,
+    public hsLayoutService: HsLayoutService
+  ) {}
+
+  isVisible(): boolean {
+    return this.hsLayoutService.panelVisible('adjuster-simple');
+  }
+}

+ 63 - 0
src/adjuster/adjuster-ui.service.ts

@@ -0,0 +1,63 @@
+import {Injectable} from '@angular/core';
+
+import {
+  HsDialogContainerService,
+  HsLayoutService,
+  HsPanelComponent,
+} from 'hslayers-ng';
+
+import {AdjusterLoaderComponent} from './adjuster-loader.component';
+import {AdjusterPresetsService} from './adjuster-presets.service';
+import {AdjusterService} from './adjuster.service';
+
+@Injectable({providedIn: 'root'})
+export class AdjusterUIService {
+  constructor(
+    public adjusterService: AdjusterService,
+    public adjusterPresetsService: AdjusterPresetsService,
+    public hsDialogContainerService: HsDialogContainerService,
+    public hsLayoutService: HsLayoutService
+  ) {
+    this.hsDialogContainerService.create(AdjusterLoaderComponent, {});
+  }
+
+  hasDatasets(factor): boolean {
+    return factor.datasets.length > 0;
+  }
+
+  getLabelInCurrentLang(labels) {
+    return this.adjusterPresetsService.getLabelInCurrentLang(labels);
+  }
+
+  isVisible(): boolean {
+    return this.hsLayoutService.panelVisible('adjuster-advanced');
+  }
+
+  noDataSelected(): boolean {
+    if (this.adjusterService.factors.length === 0) {
+      return true;
+    }
+    let datasetsEffectivelyTurnedOn = [];
+    for (const factor of this.adjusterService.factors) {
+      if (factor.weight === 0) {
+        continue;
+      }
+      datasetsEffectivelyTurnedOn = [
+        ...datasetsEffectivelyTurnedOn,
+        ...factor.datasets.filter((ds) => ds.included),
+      ];
+    }
+    return datasetsEffectivelyTurnedOn.length === 0;
+  }
+
+  noOperationSelected(): boolean {
+    return (
+      !this.adjusterService.allowIndex && !this.adjusterService.allowClusters
+    );
+  }
+
+  /*selectMethod(): void {
+    this.adjusterService.method = this.method;
+    this.adjusterEventService.methodChanged.next(this.method);
+  }*/
+}

+ 3 - 3
src/adjuster/adjuster.module.ts

@@ -6,7 +6,7 @@ import {TranslateModule} from '@ngx-translate/core';
 
 import {HsPanelHelpersModule} from 'hslayers-ng';
 
-import {AdjusterComponent} from './adjuster.component';
+import {AdjusterAdvancedPanelComponent} from './adjuster-advanced-panel.component';
 import {AdjusterEventService} from './adjuster-event.service';
 import {AdjusterLegendService} from './adjuster-legend.service';
 import {AdjusterLoaderComponent} from './adjuster-loader.component';
@@ -25,9 +25,9 @@ import {MetadataDialogComponent} from './metadata-dialog/metadata-dialog.compone
     NgbModule,
     TranslateModule,
   ],
-  exports: [AdjusterComponent],
+  exports: [AdjusterAdvancedPanelComponent],
   declarations: [
-    AdjusterComponent,
+    AdjusterAdvancedPanelComponent,
     AdjusterLoaderComponent,
     DatasetListComponent,
     MetadataDialogComponent,

+ 0 - 4
src/adjuster/index.ts

@@ -1,4 +0,0 @@
-export {AdjusterComponent} from './adjuster.component';
-export {AdjusterService} from './adjuster.service';
-
-export {AdjusterModule} from './adjuster.module';

+ 2 - 2
src/app.service.ts

@@ -19,7 +19,7 @@ import {
   HsToastService,
 } from 'hslayers-ng';
 
-import {AdjusterComponent} from './adjuster/adjuster.component';
+import {AdjusterAdvancedPanelComponent} from './adjuster/adjuster-advanced-panel.component';
 import {AdjusterEventService} from './adjuster/adjuster-event.service';
 import {AdjusterLegendService} from './adjuster/adjuster-legend.service';
 import {AdjusterService} from './adjuster/adjuster.service';
@@ -72,7 +72,7 @@ export class AppService {
       description: 'Adjust factors for computation',
       icon: 'icon-analytics-piechart',
     });
-    this.hsPanelContainerService.create(AdjusterComponent, {});
+    this.hsPanelContainerService.create(AdjusterAdvancedPanelComponent, {});
     this.prepareLayers();
     this.adjusterEventService.loaded.subscribe(({success}) => {
       if (success) {