|
@@ -3,7 +3,7 @@ import {Injectable} from '@angular/core';
|
|
|
import {Subject} from 'rxjs';
|
|
import {Subject} from 'rxjs';
|
|
|
import {catchError} from 'rxjs/operators';
|
|
import {catchError} from 'rxjs/operators';
|
|
|
|
|
|
|
|
-import {HsConfig} from 'hslayers-ng';
|
|
|
|
|
|
|
+import {HsConfig, HsLanguageService, HsToastService} from 'hslayers-ng';
|
|
|
|
|
|
|
|
import {FieldService} from './field.service';
|
|
import {FieldService} from './field.service';
|
|
|
import {ZonesService} from './zones.service';
|
|
import {ZonesService} from './zones.service';
|
|
@@ -31,6 +31,8 @@ export class CalculatorService {
|
|
|
constructor(
|
|
constructor(
|
|
|
private fieldService: FieldService,
|
|
private fieldService: FieldService,
|
|
|
private hsConfig: HsConfig,
|
|
private hsConfig: HsConfig,
|
|
|
|
|
+ private hsLanguageService: HsLanguageService,
|
|
|
|
|
+ private hsToastService: HsToastService,
|
|
|
private httpClient: HttpClient,
|
|
private httpClient: HttpClient,
|
|
|
private zonesService: ZonesService
|
|
private zonesService: ZonesService
|
|
|
) {
|
|
) {
|
|
@@ -69,8 +71,7 @@ export class CalculatorService {
|
|
|
)
|
|
)
|
|
|
.toPromise();
|
|
.toPromise();
|
|
|
this._datesLoading = false;
|
|
this._datesLoading = false;
|
|
|
- console.log('data received!');
|
|
|
|
|
- console.log(data);
|
|
|
|
|
|
|
+ console.log('data received!', data);
|
|
|
this.availableDates = data.dates;
|
|
this.availableDates = data.dates;
|
|
|
/* Any previously selected date must be cleaned up
|
|
/* Any previously selected date must be cleaned up
|
|
|
* so it won't get sent to the API as a wrong param
|
|
* so it won't get sent to the API as a wrong param
|
|
@@ -78,6 +79,19 @@ export class CalculatorService {
|
|
|
this.selectedDate = undefined;
|
|
this.selectedDate = undefined;
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
this._datesLoading = false;
|
|
this._datesLoading = false;
|
|
|
|
|
+ this.hsToastService.createToastPopupMessage(
|
|
|
|
|
+ this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
+ 'CALCULATOR',
|
|
|
|
|
+ 'errorLoading'
|
|
|
|
|
+ ),
|
|
|
|
|
+ this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
+ 'CALCULATOR',
|
|
|
|
|
+ 'errorLoadingDates'
|
|
|
|
|
+ ),
|
|
|
|
|
+ {
|
|
|
|
|
+ toastStyleClasses: 'bg-warning text-dark',
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
console.error('Somethin fucked up!');
|
|
console.error('Somethin fucked up!');
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
}
|
|
}
|
|
@@ -118,13 +132,25 @@ export class CalculatorService {
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
.toPromise();
|
|
.toPromise();
|
|
|
- console.log('data received!');
|
|
|
|
|
- console.log(data);
|
|
|
|
|
|
|
+ console.log('data received!', data);
|
|
|
this._zonesLoading = false;
|
|
this._zonesLoading = false;
|
|
|
this.zonesService.updateZones(data, {quantileCount: this.quantileCount});
|
|
this.zonesService.updateZones(data, {quantileCount: this.quantileCount});
|
|
|
this.updateImageBackground(this.selectedDate);
|
|
this.updateImageBackground(this.selectedDate);
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
this._zonesLoading = false;
|
|
this._zonesLoading = false;
|
|
|
|
|
+ this.hsToastService.createToastPopupMessage(
|
|
|
|
|
+ this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
+ 'CALCULATOR',
|
|
|
|
|
+ 'errorLoading'
|
|
|
|
|
+ ),
|
|
|
|
|
+ this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
+ 'CALCULATOR',
|
|
|
|
|
+ 'errorLoadingZones'
|
|
|
|
|
+ ),
|
|
|
|
|
+ {
|
|
|
|
|
+ toastStyleClasses: 'bg-warning text-dark',
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
console.error('Somethin fucked up!');
|
|
console.error('Somethin fucked up!');
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
}
|
|
}
|