From 70022a74937b6f1d24d9451b4f4b8e3d73c2cdbc Mon Sep 17 00:00:00 2001
From: kbeyro <121854496+kbeyro@users.noreply.github.com>
Date: Tue, 22 Aug 2023 15:37:18 +0200
Subject: [PATCH] Rename type, add small upgrade to bulk deploy

---
 .../appchoose/appdeployment.component.html    |  2 +-
 .../bulkDeployment/appdeployment.service.ts   |  4 +-
 .../bulk-app-list/bulk-app-list.component.ts  |  2 +-
 .../bulk-domain-list.component.ts             |  2 +-
 .../bulk-list/bulk-list.component.ts          |  2 +-
 .../bulk-view/bulk-view.component.html        | 40 +++++++++----------
 .../bulk-view/bulk-view.component.ts          | 10 ++---
 .../domainupload/domainupload.component.ts    | 16 +++++---
 src/app/model/bulk-deployment.ts              |  4 +-
 .../{bulk-replay.ts => bulk-response.ts}      |  2 +-
 10 files changed, 45 insertions(+), 39 deletions(-)
 rename src/app/model/{bulk-replay.ts => bulk-response.ts} (91%)

diff --git a/src/app/appmarket/bulkDeployment/appDeployment/appchoose/appdeployment.component.html b/src/app/appmarket/bulkDeployment/appDeployment/appchoose/appdeployment.component.html
index fa13ea74..511559b5 100644
--- a/src/app/appmarket/bulkDeployment/appDeployment/appchoose/appdeployment.component.html
+++ b/src/app/appmarket/bulkDeployment/appDeployment/appchoose/appdeployment.component.html
@@ -7,7 +7,7 @@
         <h4>{{'BULK.APP.INFO' | translate}}</h4>
     </div>
     <div style="margin-top: 3rem;">
-        <p-dropdown [options]="apps" optionLabel="name" [(ngModel)]="selectedApp"></p-dropdown>
+        <p-dropdown [options]="apps" optionLabel="name" [(ngModel)]="selectedApp" [filter]="true"></p-dropdown>
     </div>
     <div class="row .navbar-right" style="margin-top: 3rem; display: flex; justify-content: right">
         <button  class="btn btn-primary" (click)="selectApp()"> {{'BULK.LIST.CONTINUE' | translate}}</button>
diff --git a/src/app/appmarket/bulkDeployment/appdeployment.service.ts b/src/app/appmarket/bulkDeployment/appdeployment.service.ts
index 22094e03..b4d31abc 100644
--- a/src/app/appmarket/bulkDeployment/appdeployment.service.ts
+++ b/src/app/appmarket/bulkDeployment/appdeployment.service.ts
@@ -2,7 +2,7 @@ import {Injectable} from '@angular/core';
 import {ApplicationBase} from '../../model/application-base';
 import {HttpClient} from '@angular/common/http';
 import {AppConfigService} from '../../service';
-import {BulkReplay} from '../../model/bulk-replay';
+import {BulkResponse} from '../../model/bulk-response';
 import {Observable} from 'rxjs';
 import {BulkDeployment} from '../../model/bulk-deployment';
 
@@ -17,7 +17,7 @@ export class AppdeploymentService {
     private selectedApp: string = undefined;
     private selectedAppId: string = undefined;
 
-    public result: BulkReplay[] = [];
+    public result: BulkResponse[] = [];
 
     public bulk: BulkDeployment;
 
diff --git a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts
index c321c9ca..6b16e157 100644
--- a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts
+++ b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts
@@ -1,7 +1,7 @@
 import {Component, OnInit, ViewChild} from '@angular/core';
 import {BulkDeployment} from '../../../model/bulk-deployment';
 import {AppdeploymentService} from '../appdeployment.service';
-import {BulkType} from '../../../model/bulk-replay';
+import {BulkType} from '../../../model/bulk-response';
 import {ModalComponent} from '../../../shared';
 
 @Component({
diff --git a/src/app/appmarket/bulkDeployment/bulk-domain-list/bulk-domain-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-domain-list/bulk-domain-list.component.ts
index 96c31b8c..2a7b3213 100644
--- a/src/app/appmarket/bulkDeployment/bulk-domain-list/bulk-domain-list.component.ts
+++ b/src/app/appmarket/bulkDeployment/bulk-domain-list/bulk-domain-list.component.ts
@@ -1,7 +1,7 @@
 import {Component, OnInit} from '@angular/core';
 import {AppdeploymentService} from '../appdeployment.service';
 import {BulkDeployment} from '../../../model/bulk-deployment';
-import {BulkType} from '../../../model/bulk-replay';
+import {BulkType} from '../../../model/bulk-response';
 
 @Component({
     selector: 'app-bulk-domain-list',
diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts
index cd5e3d5f..9f16ab03 100644
--- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts
+++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts
@@ -1,6 +1,6 @@
 import {Component, Input, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
 import {BulkDeployment} from '../../../model/bulk-deployment';
-import {BulkType} from '../../../model/bulk-replay';
+import {BulkType} from '../../../model/bulk-response';
 import {SortableHeaderDirective} from '../../../service/sort-domain.directive';
 import {ModalComponent} from '../../../shared';
 
diff --git a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.html b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.html
index c836480e..fccc7db7 100644
--- a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.html
+++ b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.html
@@ -53,11 +53,11 @@
                         <th>{{'BULK.LIST.DETAILS' | translate}}</th>
                         <th style="width: 5%" scope="col"></th>
                     </tr>
-                    <ng-template ngFor let-replay [ngForOf]="bulk.entries" let-i="index">
-                        <tr *ngIf="replay.type === 'DOMAIN'" class="table-row">
-                            <td>{{'BULK.STATE.' + replay.state | translate}}</td>
-                            <td>{{replay.created}}</td>
-                            <td>{{getDetails(replay)}}</td>
+                    <ng-template ngFor let-response [ngForOf]="bulk.entries" let-i="index">
+                        <tr *ngIf="response.type === 'DOMAIN'" class="table-row">
+                            <td>{{'BULK.STATE.' + response.state | translate}}</td>
+                            <td>{{response.created}}</td>
+                            <td>{{getDetails(response)}}</td>
                             <td style="width: 5%" class="text-right">
                     <span class="dropdown">
             <a style="display: inline-block" class="dropdown-toggle " aria-expanded="false" aria-haspopup="true"
@@ -65,11 +65,11 @@
               <em class="fas fa-cog icon-black icon-bigger"></em>
             </a>
             <ul class="dropdown-menu pull-right-drop">
-              <li *ngIf="replay.type === 'DOMAIN'">
-                <a [routerLink]="['/admin/domains/view/', replay?.details['domainId']]">{{ 'BULK.LIST.MOVE_DOMAIN' | translate }}</a>
+              <li *ngIf="response.type === 'DOMAIN'">
+                <a [routerLink]="['/admin/domains/view/', response?.details['domainId']]">{{ 'BULK.LIST.MOVE_DOMAIN' | translate }}</a>
               </li>
-                 <li *ngIf="replay.type === 'USER'">
-                <a [routerLink]="['/admin/users/view', replay?.details['userId']]">{{ 'BULK.LIST.MOVE_USER' | translate }}</a>
+                 <li *ngIf="response.type === 'USER'">
+                <a [routerLink]="['/admin/users/view', response?.details['userId']]">{{ 'BULK.LIST.MOVE_USER' | translate }}</a>
               </li>
             </ul>
           </span>
@@ -201,16 +201,16 @@
                         <th>{{'BULK.APP.DOMAIN' | translate}}</th>
                         <th style="width: 5%" scope="col"></th>
                     </tr>
-                    <ng-template ngFor let-replay [ngForOf]="bulk.entries" let-i="index">
-                        <tr *ngIf="replay.type === 'APPLICATION'" class="table-row">
-                            <td >{{'BULK.STATE.' + replay.state | translate}}  <i *ngIf="replay.state == 'PROCESSING'"
+                    <ng-template ngFor let-response [ngForOf]="bulk.entries" let-i="index">
+                        <tr *ngIf="response.type === 'APPLICATION'" class="table-row">
+                            <td >{{'BULK.STATE.' + response.state | translate}}  <i *ngIf="response.state == 'PROCESSING'"
                                                                                  class="pi pi-spin pi-spinner ml-1"
                                                                                  style="font-size: 1.4rem"></i>
-                                <i *ngIf="replay.state == 'FAILED'" class="pi pi-info-circle" style="font-size: 1.4rem"
-                                   pTooltip="{{replay?.details['errorMessage']}}" tooltipStyleClass="p-tooltip-width " [fitContent]="false"></i></td>
-                            <td>{{getAppInstanceId(replay)}}</td>
-                            <td>{{getAppInstanceName(replay)}}</td>
-                            <td>{{getDomainCodeName(replay)}}</td>
+                                <i *ngIf="response.state == 'FAILED'" class="pi pi-info-circle" style="font-size: 1.4rem"
+                                   pTooltip="{{response?.details['errorMessage']}}" tooltipStyleClass="p-tooltip-width " [fitContent]="false"></i></td>
+                            <td>{{getAppInstanceId(response)}}</td>
+                            <td>{{getAppInstanceName(response)}}</td>
+                            <td>{{getDomainCodeName(response)}}</td>
                             <td style="width: 5%" class="text-right">
                     <span class="dropdown">
             <a style="display: inline-block" class="dropdown-toggle " aria-expanded="false" aria-haspopup="true"
@@ -218,10 +218,10 @@
               <em class="fas fa-cog icon-black icon-bigger"></em>
             </a>
             <ul class="dropdown-menu pull-right-drop">
-                 <li *ngIf="replay.type === 'APPLICATION' && replay?.details['appInstanceId'] !== undefined">
-                <a [routerLink]="['/instances/', replay?.details['appInstanceId']]">{{ 'BULK.LIST.MOVE_APP' | translate }}</a>
+                 <li *ngIf="response.type === 'APPLICATION' && response?.details['appInstanceId'] !== undefined">
+                <a [routerLink]="['/instances/', response?.details['appInstanceId']]">{{ 'BULK.LIST.MOVE_APP' | translate }}</a>
               </li>
-                  <li *ngIf="replay.type === 'APPLICATION' && replay.state !== 'COMPLETED'">
+                  <li *ngIf="response.type === 'APPLICATION' && response.state !== 'COMPLETED'">
                     <a>{{ 'BULK.APP.CHECK_STATE' | translate }}</a>
                 </li>
             </ul>
diff --git a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts
index 0d3025bb..8511fb0d 100644
--- a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts
+++ b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts
@@ -2,7 +2,7 @@ import {Component, OnDestroy, OnInit} from '@angular/core';
 import {BulkDeployment} from '../../../model/bulk-deployment';
 import {AppdeploymentService} from '../appdeployment.service';
 import {ActivatedRoute, Router} from '@angular/router';
-import {BulkReplay, BulkType} from '../../../model/bulk-replay';
+import {BulkResponse, BulkType} from '../../../model/bulk-response';
 import {timer} from 'rxjs';
 import {map} from 'rxjs/operators';
 import {AppImagesService} from '../../../service';
@@ -51,7 +51,7 @@ export class BulkViewComponent implements OnInit, OnDestroy {
         });
     }
 
-    public getDetails(entry: BulkReplay) {
+    public getDetails(entry: BulkResponse) {
         if (entry.type === 'USER') {
             return `Username: ${entry.details['userName']} email: ${entry.details['email']} userId: ${entry.details['userId']}`
         } else if (entry.type === 'DOMAIN') {
@@ -61,15 +61,15 @@ export class BulkViewComponent implements OnInit, OnDestroy {
         }
     }
 
-    public getAppInstanceId(entry: BulkReplay) {
+    public getAppInstanceId(entry: BulkResponse) {
         return entry?.details['appInstanceId']
     }
 
-    public getAppInstanceName(entry: BulkReplay) {
+    public getAppInstanceName(entry: BulkResponse) {
         return entry?.details['appInstanceName']
     }
 
-    public getDomainCodeName(entry: BulkReplay) {
+    public getDomainCodeName(entry: BulkResponse) {
         return entry?.details['domainCodename'] || entry?.details['domainName']
     }
 
diff --git a/src/app/appmarket/bulkDeployment/domainDeployment/domainupload/domainupload.component.ts b/src/app/appmarket/bulkDeployment/domainDeployment/domainupload/domainupload.component.ts
index c3290605..0e7d6737 100644
--- a/src/app/appmarket/bulkDeployment/domainDeployment/domainupload/domainupload.component.ts
+++ b/src/app/appmarket/bulkDeployment/domainDeployment/domainupload/domainupload.component.ts
@@ -1,7 +1,8 @@
 import {Component, OnInit} from '@angular/core';
 import {AppdeploymentService} from '../../appdeployment.service';
 import {Router} from '@angular/router';
-import {BulkType} from '../../../../model/bulk-replay';
+import {BulkType} from '../../../../model/bulk-response';
+import {DomainService} from '../../../../service';
 
 @Component({
   selector: 'app-domainupload',
@@ -12,12 +13,15 @@ export class DomainuploadComponent implements OnInit {
 
   public showProgressBar = false;
 
-  public csvText = '';
+  public csvText = '"domain","username","networks","domainGroups","email"\n' +
+      '"ExampleDomain","TestUser","","Lab1","email@domain.com"\n' +
+      '"ExampleDomain2","TestUser2","","Lab1","email2@domain.com"\n';
 
   public errorMessage = '';
 
   constructor(private readonly deployService: AppdeploymentService,
-              private router: Router) { }
+              private router: Router,
+              private domainService: DomainService) { }
 
   ngOnInit(): void {
   }
@@ -29,7 +33,8 @@ export class DomainuploadComponent implements OnInit {
     this.deployService.uploadUserDomainFile(event.files[0]).subscribe( val => {
       console.warn("done")
       this.deployService.bulk = val;
-      if (val.type === BulkType.DOMAIN) {
+      this.domainService.setUpdateRequiredFlag(true);
+          if (val.type === BulkType.DOMAIN) {
         this.router.navigate(['admin/domains/bulks/', val.id])
       } else {
         this.router.navigate(['admin/domains/deploy/summary'])
@@ -49,7 +54,8 @@ export class DomainuploadComponent implements OnInit {
     this.deployService.uploadUserDomainFile(file).subscribe( val => {
       console.warn("done")
       this.deployService.bulk = val;
-      if (val.type === BulkType.DOMAIN) {
+      this.domainService.setUpdateRequiredFlag(true);
+          if (val.type === BulkType.DOMAIN) {
         this.router.navigate(['admin/domains/bulks/', val.id])
       } else {
         this.router.navigate(['admin/domains/deploy/summary'])
diff --git a/src/app/model/bulk-deployment.ts b/src/app/model/bulk-deployment.ts
index c062ad02..718e0c2b 100644
--- a/src/app/model/bulk-deployment.ts
+++ b/src/app/model/bulk-deployment.ts
@@ -1,11 +1,11 @@
 import {User} from './user';
-import {BulkReplay, BulkType} from './bulk-replay';
+import {BulkResponse, BulkType} from './bulk-response';
 
 export class BulkDeployment {
     public id: number;
     public creationDate: Date;
     public creator: User;
-    public entries: BulkReplay[] = [];
+    public entries: BulkResponse[] = [];
     public state: BulkDeploymentState;
     public type: BulkType;
     public details: Map<string, string>;
diff --git a/src/app/model/bulk-replay.ts b/src/app/model/bulk-response.ts
similarity index 91%
rename from src/app/model/bulk-replay.ts
rename to src/app/model/bulk-response.ts
index eb4ce117..d55a0c0e 100644
--- a/src/app/model/bulk-replay.ts
+++ b/src/app/model/bulk-response.ts
@@ -1,6 +1,6 @@
 import {BulkDeploymentState} from './bulk-deployment';
 
-export class BulkReplay {
+export class BulkResponse {
     public state: BulkDeploymentState;
     public created: boolean;
     public details: Map<string, string>;
-- 
GitLab