adjuster-advanced-panel.component.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {Component, ViewRef} from '@angular/core';
  2. import {HsLayoutService, HsPanelBaseComponent} from 'hslayers-ng';
  3. import {AdjusterPresetsService} from '../adjuster-presets.service';
  4. import {AdjusterService} from '../adjuster.service';
  5. @Component({
  6. selector: 'pra-adjuster-advanced',
  7. templateUrl: './adjuster-advanced-panel.component.html',
  8. styleUrls: ['./adjuster-advanced-panel.component.scss'],
  9. })
  10. export class AdjusterAdvancedPanelComponent extends HsPanelBaseComponent {
  11. name = 'adjuster-advanced';
  12. data: any;
  13. errorMsg: string;
  14. //method: string;
  15. showAdvancedOptions = false;
  16. viewRef: ViewRef;
  17. constructor(
  18. public adjusterService: AdjusterService,
  19. public adjusterPresetsService: AdjusterPresetsService,
  20. public hsLayoutService: HsLayoutService
  21. ) {
  22. super(hsLayoutService);
  23. //this.descriptionVisible = false;
  24. //this.method = this.adjusterService.method;
  25. /*this.adjusterEventService.loaded.subscribe(({success, err}) => {
  26. if (!success) {
  27. this.errorMsg = err.message;
  28. }
  29. });*/
  30. }
  31. hasDatasets(factor): boolean {
  32. return factor.datasets.length > 0;
  33. }
  34. getLabelInCurrentLang(labels) {
  35. return this.adjusterPresetsService.getLabelInCurrentLang(labels);
  36. }
  37. isVisible(): boolean {
  38. return this.hsLayoutService.panelVisible('adjuster-advanced');
  39. }
  40. noDataSelected(): boolean {
  41. if (this.adjusterService.factors.length === 0) {
  42. return true;
  43. }
  44. let datasetsEffectivelyTurnedOn = [];
  45. for (const factor of this.adjusterService.factors) {
  46. if (factor.weight === 0) {
  47. continue;
  48. }
  49. datasetsEffectivelyTurnedOn = [
  50. ...datasetsEffectivelyTurnedOn,
  51. ...factor.datasets.filter((ds) => ds.included),
  52. ];
  53. }
  54. return datasetsEffectivelyTurnedOn.length === 0;
  55. }
  56. noOperationSelected(): boolean {
  57. return (
  58. !this.adjusterService.allowIndex && !this.adjusterService.allowClusters
  59. );
  60. }
  61. /*selectMethod(): void {
  62. this.adjusterService.method = this.method;
  63. this.adjusterEventService.methodChanged.next(this.method);
  64. }*/
  65. }