You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by hs...@apache.org on 2022/09/29 09:52:07 UTC

[incubator-datalab] branch circular-dependency-hot-fix created (now db6467d25)

This is an automated email from the ASF dual-hosted git repository.

hshpak pushed a change to branch circular-dependency-hot-fix
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


      at db6467d25 fixed circular dependency

This branch includes the following new commits:

     new db6467d25 fixed circular dependency

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 01/01: fixed circular dependency

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hshpak pushed a commit to branch circular-dependency-hot-fix
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit db6467d259dc9304c9ca465edddb28b9da9e50f2
Author: Hennadii_Shpak <bo...@gmail.com>
AuthorDate: Thu Sep 29 12:51:34 2022 +0300

    fixed circular dependency
---
 .../share-dialog/share-dialog.component.ts         |  8 +---
 .../share-dialog/share-dialog.service.ts           | 16 ++++---
 .../src/app/resources/images/images.component.ts   | 14 ++++++-
 .../src/app/resources/images/images.service.ts     | 49 ++++++++++------------
 4 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.component.ts
index 433690308..b1a9c7a21 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.component.ts
@@ -21,7 +21,6 @@ import { Component, ElementRef, Inject, OnDestroy, OnInit, ViewChild } from '@an
 import { SharePlaceholder } from '../image-action.config';
 import { ShareDialogData, UserData } from '../image-action.model';
 import { FormControl } from '@angular/forms';
-import { ImagesService } from '../../../images/images.service';
 import { MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
 import {
   ImageActionModalData,
@@ -59,7 +58,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
 
   constructor(
     public toastr: ToastrService,
-    private imagesService: ImagesService,
     @Inject(MAT_DIALOG_DATA) public data: ImageActionModalData,
     private dialog: MatDialog,
     private shareDialogService: ShareDialogService
@@ -117,22 +115,20 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
       userData,
       title: ModalTitle.unShare
     };
-    const filteredList = this.shareDialogService.filterSharingList(userData);
-    const imageInfo = this.imagesService.createImageRequestInfo(this.data.image, filteredList);
 
     this.getUserListDataSubscription$ = this.dialog.open(UnShareWarningComponent, {
       data,
       panelClass: 'modal-sm'
     }).afterClosed()
       .pipe(
-        switchMap((isShare) => this.shareDialogService.sendShareRequest(isShare, imageInfo)),
+        switchMap((isShare) => this.shareDialogService.sendShareRequest(isShare, this.data.image, userData)),
         switchMap(() =>  this.shareDialogService.getImageShareInfo()),
         tap(() => this.toastr.success(Toaster_Message.successUnShare, Toaster_Message.successTitle))
       );
   }
 
   private getImageParams(): void {
-    this.shareDialogService.imageInfo = this.imagesService.createImageRequestInfo(this.data.image);
+    this.shareDialogService.getImageParams(this.data.image);
   }
 
   private initUserData(): void {
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.service.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.service.ts
index d2b2ebb47..05f75ae96 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/image-action-dialog/share-dialog/share-dialog.service.ts
@@ -25,9 +25,8 @@ import isEqual from 'lodash.isequal';
 
 import { ImagesService } from '../../../images/images.service';
 import { ImageActionDialogModule } from '../image-action-dialog.module';
-import { ImageParams, ProjectImagesInfo } from '../../../images';
+import { ImageModel, ImageParams, ProjectImagesInfo } from '../../../images';
 import { ShareDialogData, UserData } from '../image-action.model';
-import { UserImagesPageService } from '../../../../core/services';
 
 @Injectable({
   providedIn: ImageActionDialogModule
@@ -45,17 +44,18 @@ export class ShareDialogService {
 
   constructor(
     private imagesService: ImagesService,
-    private userImagesPageService: UserImagesPageService
   ) { }
 
   getUserDataForShareDropdown(userData: string = ''): Observable<UserData[]> {
-    return this.userImagesPageService.getUserDataForShareDropdown(this.imageInfo, userData)
+    return this.imagesService.getUserDataForShareDropdown(userData, this.imageInfo)
       .pipe(
         tap(response => this.filterSearchDropdown(response))
       );
   }
 
-  sendShareRequest(flag: boolean, imageInfo: ImageParams): Observable<ProjectImagesInfo> {
+  sendShareRequest(flag: boolean, image: ImageModel, userData: UserData): Observable<ProjectImagesInfo> {
+    const filteredList = this.filterSharingList(userData);
+    const imageInfo = this.imagesService.createImageRequestInfo(image, filteredList);
     if (!flag) {
       return EMPTY;
     }
@@ -63,7 +63,7 @@ export class ShareDialogService {
   }
 
   getImageShareInfo(): Observable<ShareDialogData> {
-    return this.userImagesPageService.getImageShareInfo(this.imageInfo).pipe(
+    return this.imagesService.getImageShareInfo(this.imageInfo).pipe(
       tap(({canBeSharedWith, sharedWith}) => {
         this.cashedUserDataDropdownList = canBeSharedWith;
         this.searchUserDataDropdownList$$.next(canBeSharedWith);
@@ -107,4 +107,8 @@ export class ShareDialogService {
    );
     this.searchUserDataDropdownList$$.next(filteredDropdownList);
   }
+
+  getImageParams(image: ImageModel): void {
+    this.imageInfo = this.imagesService.createImageRequestInfo(image);
+  }
 }
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/images/images.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/images/images.component.ts
index 2954922bb..6487cd088 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/images/images.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/images/images.component.ts
@@ -22,7 +22,7 @@ import { MatDialog } from '@angular/material/dialog';
 import { EMPTY, Observable, of } from 'rxjs';
 import { catchError, map, switchMap, tap } from 'rxjs/operators';
 
-import { ToastrService } from 'ngx-toastr';
+import { ComponentType, ToastrService } from 'ngx-toastr';
 
 import { GeneralEnvironmentStatus } from '../../administration/management/management.model';
 import { ApplicationSecurityService, HealthStatusService } from '../../core/services';
@@ -54,6 +54,8 @@ import { ImagesService } from './images.service';
 import { ProgressBarService } from '../../core/services/progress-bar.service';
 import { ImageDetailDialogComponent } from '../exploratory/image-detail-dialog/image-detail-dialog.component';
 import { ActivatedRoute } from '@angular/router';
+import { ShareDialogComponent } from '../exploratory/image-action-dialog/share-dialog/share-dialog.component';
+import { TerminateDialogComponent } from '../exploratory/image-action-dialog/terminate-dialog/terminate-dialog.component';
 
 @Component({
   selector: 'datalab-images',
@@ -164,7 +166,7 @@ export class ImagesComponent implements OnInit, OnDestroy {
     let imageInfo: ImageParams;
     const data = this.imagesService.createActionDialogConfig(image, actionType);
     const requestCallback = this.imagesService.getRequestByAction(actionType).bind(this.imagesService);
-    const component = this.imagesService.getComponentByAction(actionType);
+    const component = this.getComponentByAction(actionType);
 
     this.dialog.open(component, {
       data,
@@ -229,6 +231,14 @@ export class ImagesComponent implements OnInit, OnDestroy {
     this.imagesService.closeFilter();
   }
 
+  private getComponentByAction(actionType): ComponentType<unknown> {
+    const componentList = {
+      share: ShareDialogComponent,
+      terminate: TerminateDialogComponent
+    };
+    return componentList[actionType];
+  }
+
   private callActionHelpers(actionType: ImageActionType, callback?: (actionType: string) => void): void {
     const toasterInvoke = callback.bind(this);
     toasterInvoke(actionType);
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/images/images.service.ts b/services/self-service/src/main/resources/webapp/src/app/resources/images/images.service.ts
index 0a2c08fe8..b5d74f5fb 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/images/images.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/images/images.service.ts
@@ -16,10 +16,7 @@ import {
 } from './images.model';
 import { ApplicationServiceFacade, UserImagesPageService } from '../../core/services';
 import { ChangedColumnStartValue, FilterFormInitialValue, ModalTitle, SharingStatus } from './images.config';
-import { ShareDialogComponent } from '../exploratory/image-action-dialog/share-dialog/share-dialog.component';
-import { TerminateDialogComponent } from '../exploratory/image-action-dialog/terminate-dialog/terminate-dialog.component';
-import { ComponentType } from 'ngx-toastr';
-import { UserData } from '../exploratory/image-action-dialog/image-action.model';
+import { ShareDialogData, UserData } from '../exploratory/image-action-dialog/image-action.model';
 
 @Injectable({
   providedIn: 'root'
@@ -177,20 +174,6 @@ export class ImagesService {
     this.isImageListFiltered$$.next(isImageListFiltered);
   }
 
-  createImageRequestInfo(image: ImageModel, userDataList?: UserData[]): ImageParams {
-    const { name, project, endpoint } = image;
-    const imageParams = {
-      imageName: name,
-      projectName: project,
-      endpoint: endpoint,
-    };
-
-    if (userDataList) {
-      imageParams['sharedWith'] = userDataList;
-    }
-    return imageParams;
-  }
-
   createActionDialogConfig(image: ImageModel, actionType: ImageActionType): ImageActionModalData {
     const modalTitle = {
       share: ModalTitle.share,
@@ -212,14 +195,6 @@ export class ImagesService {
     return callbackList[actionType];
   }
 
-  getComponentByAction(actionType): ComponentType<unknown> {
-    const componentList = {
-      share: ShareDialogComponent,
-      terminate: TerminateDialogComponent
-    };
-    return componentList[actionType];
-  }
-
   initImagePageInfo(imagePageInfo: ProjectImagesInfo): void {
     this.getImagePageData(imagePageInfo.projectImagesInfos);
     this.getDropdownDataList(imagePageInfo.filterData);
@@ -228,6 +203,28 @@ export class ImagesService {
     this.checkIsPageFiltered();
   }
 
+  createImageRequestInfo(image: ImageModel, userDataList?: UserData[]): ImageParams {
+    const { name, project, endpoint } = image;
+    const imageParams = {
+      imageName: name,
+      projectName: project,
+      endpoint: endpoint,
+    };
+
+    if (userDataList) {
+      imageParams['sharedWith'] = userDataList;
+    }
+    return imageParams;
+  }
+
+  getImageShareInfo(imageInfo: ImageParams): Observable<ShareDialogData> {
+    return this.userImagesPageService.getImageShareInfo(imageInfo);
+  }
+
+  getUserDataForShareDropdown(userData: string, imageInfo: ImageParams): Observable<UserData[]> {
+    return this.userImagesPageService.getUserDataForShareDropdown(imageInfo, userData);
+}
+
   private isImageShared(image: ImageModel): boolean {
     return image.sharingStatus !== SharingStatus.private;
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org