瀏覽代碼

Use clusters instead of scores

jmacura 5 年之前
父節點
當前提交
398f4bf2ec
共有 1 個文件被更改,包括 19 次插入14 次删除
  1. 19 14
      src/adjuster/adjuster.service.js

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

@@ -1,25 +1,29 @@
 // import attractivity from '../Attractivity.json';
-import nuts from '../nuts.js';
+// import nuts from '../nuts.js';
 import {factors} from './factors.js';
 
 export class AdjusterService {
-  constructor(HsCore, HsUtilsService, $rootScope, $http) {
+  constructor(HsCore, HsUtilsService, $rootScope, $http, $location) {
     'ngInject';
     this.HsCore = HsCore;
     this.HsUtilsService = HsUtilsService;
     this.$rootScope = $rootScope;
     this.$http = $http;
+    this.serviceBaseUrl =
+      $location.host() === 'localhost'
+        ? 'https://jmacura.ml/ws/'
+        : 'https://publish.lesprojekt.cz/nodejs/';
     this.factors = factors;
     this.nutsCodeRecordRelations = {};
-    this.init();
+    this.apply();
   }
 
   apply() {
     const f = () => {
       this.$http({
-        method: 'post',
-        url: 'https://publish.lesprojekt.cz/nodejs/scores',
-        data: {
+        method: 'get',
+        url: this.serviceBaseUrl + 'clusters',
+        /*data: {
           factors: this.factors.map((f) => {
             return {
               factor: f.factor,
@@ -29,11 +33,12 @@ export class AdjusterService {
                 .map((ds) => ds.name),
             };
           }),
-        },
+        },*/
       }).then((response) => {
-        this.attractivity = response.data;
-        let max = 0;
-        this.attractivity.forEach((a) => {
+        this.clusters = response.data.response;
+        console.log(this.clusters);
+        /*let max = 0;
+        this.clusters.forEach((a) => {
           if (a.aggregate > max) {
             max = a.aggregate;
           }
@@ -67,15 +72,15 @@ export class AdjusterService {
               ).toFixed(2)
             );
           });
-        });
+        });*/
       });
     };
     this.HsUtilsService.debounce(f, 300)();
   }
 
-  init() {
+  /*init() {
     this.$http({
-      url: 'https://publish.lesprojekt.cz/nodejs/datasets',
+      url: this.serviceBaseUrl + 'datasets',
     }).then((response) => {
       this.factors = response.data.map((dataset) => {
         return {factor: dataset.Factor, weight: 1, datasets: []};
@@ -96,5 +101,5 @@ export class AdjusterService {
       });
       this.apply();
     });
-  }
+  }*/
 }