Extend Xapp deploy workflow
[portal/ric-dashboard.git] / dashboard / webapp-frontend / src / app / catalog / catalog.component.ts
index ac8e6ec..df43995 100644 (file)
  * limitations under the License.
  * ========================LICENSE_END===================================
  */
-import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
 import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
 import { MatSort } from '@angular/material/sort';
 import { Subscription } from 'rxjs';
-import { finalize } from 'rxjs/operators';
-import { RicInstance } from '../interfaces/dashboard.types';
 import { XMXapp } from '../interfaces/app-mgr.types';
+import { RicInstance } from '../interfaces/dashboard.types';
 import { AppMgrService } from '../services/app-mgr/app-mgr.service';
 import { InstanceSelectorService } from '../services/instance-selector/instance-selector.service';
+import { ConfirmDialogService } from '../services/ui/confirm-dialog.service';
 import { LoadingDialogService } from '../services/ui/loading-dialog.service';
+import { NotificationService } from '../services/ui/notification.service';
 import { UiService } from '../services/ui/ui.service';
+import { DeployDialogComponent } from '../ui/deploy-dialog/deploy-dialog.component';
 import { AppConfigurationComponent } from './../app-configuration/app-configuration.component';
-import { ConfirmDialogService } from '../services/ui/confirm-dialog.service';
 import { OnboardComponent } from './../onboard/onboard.component';
-import { NotificationService } from '../services/ui/notification.service';
 import { CatalogDataSource } from './catalog.datasource';
 
 @Component({
@@ -100,30 +99,24 @@ export class CatalogComponent implements OnInit, OnDestroy {
   }
 
   onDeployApp(app: XMXapp): void {
-    this.confirmDialogService.openConfirmDialog('Deploy application ' + app.name + '?')
-      .afterClosed().subscribe((res: boolean) => {
-        if (res) {
-          this.loadingDialogService.startLoading('Deploying ' + app.name);
-          this.appMgrService.deployXapp(this.instanceKey, app.name)
-            .pipe(
-              finalize(() => this.loadingDialogService.stopLoading())
-            )
-            .subscribe(
-              (response: HttpResponse<Object>) => {
-                this.notificationService.success('App deploy succeeded!');
-              },
-              ((her: HttpErrorResponse) => {
-                // the error field should have an ErrorTransport object
-                let msg = her.message;
-                if (her.error && her.error.message) {
-                  msg = her.error.message;
-                }
-                this.notificationService.warn('App deploy failed: ' + msg);
-              })
-            );
-        }
+    if (this.darkMode) {
+      this.panelClass = 'dark-theme';
+    } else {
+      this.panelClass = '';
+    }
+    const dialogRef = this.dialog.open(DeployDialogComponent, {
+      panelClass: this.panelClass,
+      width: '400px',
+      maxHeight: '1000px',
+      position: {
+        top: '10%'
+      },
+      data: {
+        xappName: app.name,
+        instanceKey: this.instanceKey
       }
-      );
+
+    });
   }
 
   onboard(): void {