diff --git a/ui/src/app/metadata/domain/effect/entity.effect.ts b/ui/src/app/metadata/domain/effect/entity.effect.ts index 2bf1825aa..ec722591f 100644 --- a/ui/src/app/metadata/domain/effect/entity.effect.ts +++ b/ui/src/app/metadata/domain/effect/entity.effect.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { Effect, Actions, ofType } from '@ngrx/effects'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { map, tap } from 'rxjs/operators'; @@ -12,6 +13,10 @@ import { MetadataTypes } from '../domain.type'; import { EntityIdService } from '../service/entity-id.service'; import * as entityActions from '../action/entity.action'; +import * as fromRoot from '../../../app.reducer'; + +import { AddNotification } from '../../../notification/action/notification.action'; +import { Notification, NotificationType } from '../../../notification/model/notification'; @Injectable() export class EntityEffects { @@ -27,20 +32,30 @@ export class EntityEffects { private actions$: Actions, private modalService: NgbModal, private providerService: ResolverService, - private entityService: EntityIdService + private entityService: EntityIdService, + private store: Store ) { } openModal(prev: { id: string, entity: MetadataEntity }): void { let { id, entity } = prev, request: Observable = entity.kind === MetadataTypes.FILTER ? this.entityService.preview(id) : this.providerService.preview(id); - request.subscribe(xml => { - let modal = this.modalService.open(PreviewDialogComponent, { - size: 'lg', - windowClass: 'modal-xl' - }); - modal.componentInstance.entity = entity; - modal.componentInstance.xml = xml; - }); + request.subscribe( + xml => { + let modal = this.modalService.open(PreviewDialogComponent, { + size: 'lg', + windowClass: 'modal-xl' + }); + modal.componentInstance.entity = entity; + modal.componentInstance.xml = xml; + }, + err => { + this.store.dispatch(new AddNotification(new Notification( + NotificationType.Danger, + `Unable to preview entity.`, + 8000 + ))); + } + ); } } /* istanbul ignore next */ diff --git a/ui/src/app/schema-form/widget/button/icon-button.component.html b/ui/src/app/schema-form/widget/button/icon-button.component.html index 107a8eb7c..cb830c4df 100644 --- a/ui/src/app/schema-form/widget/button/icon-button.component.html +++ b/ui/src/app/schema-form/widget/button/icon-button.component.html @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/ui/src/app/schema-form/widget/button/icon-button.component.ts b/ui/src/app/schema-form/widget/button/icon-button.component.ts index 2dcca890f..652490804 100644 --- a/ui/src/app/schema-form/widget/button/icon-button.component.ts +++ b/ui/src/app/schema-form/widget/button/icon-button.component.ts @@ -1,8 +1,9 @@ import { - Component, AfterViewInit, + Component, AfterViewInit, ChangeDetectorRef } from '@angular/core'; import { ButtonWidget } from 'ngx-schema-form'; import { ɵb as ActionRegistry } from 'ngx-schema-form'; +import { interval } from 'rxjs'; @Component({ selector: 'icon-button', @@ -10,9 +11,14 @@ import { ɵb as ActionRegistry } from 'ngx-schema-form'; }) export class IconButtonComponent extends ButtonWidget implements AfterViewInit { - action = ($event) => {}; + visible = false; - constructor(private actionRegistry: ActionRegistry) { + action = (e) => {}; + + constructor( + private actionRegistry: ActionRegistry, + private changeDetector: ChangeDetectorRef + ) { super(); } @@ -24,5 +30,8 @@ export class IconButtonComponent extends ButtonWidget implements AfterViewInit { } e.preventDefault(); }; + + this.visible = !!this.actionRegistry.get(this.button.id); + this.changeDetector.detectChanges(); } } diff --git a/ui/src/app/schema-form/widget/filter-target/filter-target.component.html b/ui/src/app/schema-form/widget/filter-target/filter-target.component.html index c234bc490..37bc19ca4 100644 --- a/ui/src/app/schema-form/widget/filter-target/filter-target.component.html +++ b/ui/src/app/schema-form/widget/filter-target/filter-target.component.html @@ -98,7 +98,11 @@
  • {{ id }} - + +