Bladeren bron

Disable clustering button when already in process

jmacura 5 jaren geleden
bovenliggende
commit
7b7a1a0998
2 gewijzigde bestanden met toevoegingen van 15 en 1 verwijderingen
  1. 1 1
      src/adjuster/adjuster.directive.html
  2. 14 0
      src/adjuster/adjuster.service.js

+ 1 - 1
src/adjuster/adjuster.directive.html

@@ -11,7 +11,7 @@
     }
   </style>
   <div class="card-body">
-    <button type="button" class="btn btn-primary" ng-click="PraAdjusterService.apply()">Calculate clusters</button>
+    <button type="button" class="btn btn-primary" ng-click="PraAdjusterService.apply()" ng-disabled="PraAdjusterService.isClusteringInProcess()">Calculate clusters</button>
     <div class="card-body">
       <div ng-repeat="factor in PraAdjusterService.factors">
         <div class="d-flex flex-row">

+ 14 - 0
src/adjuster/adjuster.service.js

@@ -15,11 +15,17 @@ export class AdjusterService {
         : 'https://publish.lesprojekt.cz/nodejs/';
     this.factors = factors;
     this.clusters = [];
+    this._clusteringInProcess = true;
     this.init();
   }
 
+  /**
+   * Sends a request to polirural-attractiveness-service
+   * and applies the returned values
+   */
   apply() {
     const f = () => {
+      this._clusteringInProcess = true;
       this.$http({
         method: 'get',
         url: this.serviceBaseUrl + 'clusters',
@@ -67,6 +73,7 @@ export class AdjusterService {
           }
         }
         this.clusters = clusters;
+        this._clusteringInProcess = false;
         this.$rootScope.$broadcast('clusters_loaded');
       });
     };
@@ -94,4 +101,11 @@ export class AdjusterService {
       this.apply();
     });
   }
+
+  /**
+   * @returns {boolean} true if clustering is in process, false otherwise
+   */
+  isClusteringInProcess() {
+    return this._clusteringInProcess;
+  }
 }