]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-loading.directive.ts
import ceph quincy 17.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / directives / form-loading.directive.ts
index e83614b84a5553f5e1431665e28ec4545d536f9f..bf18a51e94e9a04b0afbabd933c97cbbf355d8dc 100644 (file)
@@ -1,10 +1,4 @@
-import {
-  ComponentFactoryResolver,
-  Directive,
-  Input,
-  TemplateRef,
-  ViewContainerRef
-} from '@angular/core';
+import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
 
 import { AlertPanelComponent } from '../components/alert-panel/alert-panel.component';
 import { LoadingPanelComponent } from '../components/loading-panel/loading-panel.component';
@@ -14,31 +8,26 @@ import { LoadingStatus } from '../forms/cd-form';
   selector: '[cdFormLoading]'
 })
 export class FormLoadingDirective {
-  constructor(
-    private templateRef: TemplateRef<any>,
-    private viewContainer: ViewContainerRef,
-    private componentFactoryResolver: ComponentFactoryResolver
-  ) {}
+  constructor(private templateRef: TemplateRef<any>, private viewContainer: ViewContainerRef) {}
 
-  @Input('cdFormLoading') set cdFormLoading(condition: LoadingStatus) {
-    let factory: any;
+  @Input() set cdFormLoading(condition: LoadingStatus) {
     let content: any;
 
     this.viewContainer.clear();
 
     switch (condition) {
       case LoadingStatus.Loading:
-        factory = this.componentFactoryResolver.resolveComponentFactory(LoadingPanelComponent);
         content = this.resolveNgContent($localize`Loading form data...`);
-        this.viewContainer.createComponent(factory, null, null, content);
+        this.viewContainer.createComponent(LoadingPanelComponent, { projectableNodes: content });
         break;
       case LoadingStatus.Ready:
         this.viewContainer.createEmbeddedView(this.templateRef);
         break;
       case LoadingStatus.Error:
-        factory = this.componentFactoryResolver.resolveComponentFactory(AlertPanelComponent);
         content = this.resolveNgContent($localize`Form data could not be loaded.`);
-        const componentRef = this.viewContainer.createComponent(factory, null, null, content);
+        const componentRef = this.viewContainer.createComponent(AlertPanelComponent, {
+          projectableNodes: content
+        });
         (<AlertPanelComponent>componentRef.instance).type = 'error';
         break;
     }