adjuster.component.ts 2.0 KB

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