adjuster.component.ts 2.1 KB

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