Bladeren bron

✨ allow calculate only one of index/clusters

jmacura 4 jaren geleden
bovenliggende
commit
767b096fb9

+ 7 - 2
src/adjuster/adjuster.component.ts

@@ -14,7 +14,7 @@ import {AdjusterService} from './adjuster.service';
 })
 export class AdjusterComponent implements HsPanelComponent {
   data: any;
-  descriptionVisible: boolean;
+  //descriptionVisible: boolean;
   errorMsg: string;
   //method: string;
   viewRef: ViewRef;
@@ -24,7 +24,7 @@ export class AdjusterComponent implements HsPanelComponent {
     public hsDialogContainerService: HsDialogContainerService,
     public hsLayoutService: HsLayoutService
   ) {
-    this.descriptionVisible = false;
+    //this.descriptionVisible = false;
     //this.method = this.adjusterService.method;
     /*this.adjusterEventService.clustersLoaded.subscribe(({success, err}) => {
       if (!success) {
@@ -59,6 +59,11 @@ export class AdjusterComponent implements HsPanelComponent {
     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);

+ 19 - 3
src/adjuster/adjuster.directive.html

@@ -2,12 +2,28 @@
   <hs-panel-header name="adjuster" [title]="'ADJUSTER.adjustFactors' | translate"></hs-panel-header>
   <div class="card-body">
     <div class="p-2 center-block">
-      <button type="button" class="btn btn-primary" (click)="adjusterService.apply()"
-        [disabled]="adjusterService.isInProcess() || noDataSelected()">{{'ADJUSTER.calculate' | translate}}</button>
+      <div class="d-flex flex-row">
+        <div>
+          <button type="button" class="btn btn-primary btn-lg" (click)="adjusterService.apply()"
+            [disabled]="adjusterService.isInProcess() || noDataSelected() || noOperationSelected() ">{{'ADJUSTER.calculate' | translate}}</button>
+        </div>
+        <div>
+          <button type="button" class="btn btn-sm btn-light hs-lm-item-visibility"
+            [ngClass]="adjusterService.allowIndex ? 'hs-checkmark' : 'hs-uncheckmark'"
+            (click)="adjusterService.allowIndex = !adjusterService.allowIndex; $event.stopPropagation()"></button>
+          <label class="pl-2 text-secondary">{{'ADJUSTER.index' | translate}}</label>
+        </div>
+        <div>
+          <button type="button" class="btn btn-sm btn-light hs-lm-item-visibility"
+            [ngClass]="adjusterService.allowClusters ? 'hs-checkmark' : 'hs-uncheckmark'"
+            (click)="adjusterService.allowClusters = !adjusterService.allowClusters; $event.stopPropagation()"></button>
+            <label class="pl-2 text-secondary">{{'ADJUSTER.clusters' | translate}}</label>
+        </div>
+      </div>
       <div class="text-warning pt-2" [hidden]="!noDataSelected() || errorMsg">{{'ADJUSTER.noDataSelectedMsg' | translate}}</div>
       <div class="text-danger pt-2" [hidden]="!errorMsg">{{'ADJUSTER.serverError' | translate}}: {{errorMsg}}</div>
     </div>
-    <div class="p-2 center-block">
+    <div class="p-2 center-block" [hidden]="!allowClusters">
       <div class="pt-2 text-secondary">{{'ADJUSTER.numberOfClusters' | translate}}: {{adjusterService.numberOfClusters}}</div>
       <input type="range" class="custom-range" [(ngModel)]="adjusterService.numberOfClusters" min="5" max="15" step="1">
     </div>

+ 11 - 3
src/adjuster/adjuster.service.ts

@@ -20,8 +20,12 @@ export class AdjusterService {
   initialWeights;
   /** To be read from a config file */
   serviceBaseUrl: string;
+  /** Used in the UI as a selector */
+  allowClusters = true;
+  /** Used in the UI as a selector */
+  allowIndex = true;
   factors = [];
-  numberOfClusters;
+  numberOfClusters: number;
   //method: string;
   methods: Array<{
     codename: string;
@@ -62,8 +66,12 @@ export class AdjusterService {
    * and applies the returned values
    */
   apply(): void {
-    this.calculateIndex();
-    this.calculateClusters();
+    if (this.allowIndex) {
+      this.calculateIndex();
+    }
+    if (this.allowClusters) {
+      this.calculateClusters();
+    }
   }
 
   calculateIndex(): void {

+ 4 - 0
src/translations.json

@@ -5,6 +5,8 @@
       "calculate": "Vypočítat",
       "calcAttractivity": "Počítám atraktivitu",
       "calcClusters": "Počítám shluky",
+      "clusters": "Shluky",
+      "index": "Index",
       "layerManagerLink1": "Vrstvy můžete prozkoumat",
       "layerManagerLink2": "ve",
       "layerManagerLinkLMName": "Správci vrstev",
@@ -22,6 +24,8 @@
       "calculate": "Calculate",
       "calcAttractivity": "Calculating attractivity",
       "calcClusters": "Calculating clusters",
+      "clusters": "Clusters",
+      "index": "Index",
       "layerManagerLink1": "You can investigate the layers",
       "layerManagerLink2": "in the",
       "layerManagerLinkLMName": "Layer Manager",