adjuster.component.ts 2.2 KB

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