This is an automated email from the ASF dual-hosted git repository.
hshpak pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/develop by this push:
new cfb13db8c refactored code
cfb13db8c is described below
commit cfb13db8ca33eaa4b0015f775a03a68503a31699
Author: Hennadii_Shpak <[email protected]>
AuthorDate: Wed Jun 29 12:18:47 2022 +0300
refactored code
---
.../app/core/services/user-images-page.service.ts | 2 +-
.../src/app/resources/images/images.component.ts | 22 +++++++++++++---
.../src/app/resources/images/images.service.ts | 11 --------
.../share-image/share-image.component.html | 2 +-
.../share-image/share-image.component.ts | 29 ++--------------------
5 files changed, 22 insertions(+), 44 deletions(-)
diff --git
a/services/self-service/src/main/resources/webapp/src/app/core/services/user-images-page.service.ts
b/services/self-service/src/main/resources/webapp/src/app/core/services/user-images-page.service.ts
index aca404052..8a4472883 100644
---
a/services/self-service/src/main/resources/webapp/src/app/core/services/user-images-page.service.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/core/services/user-images-page.service.ts
@@ -37,7 +37,7 @@ export class UserImagesPageService {
);
}
- shareImageAllUsers(params: ShareImageAllUsersParams) {
+ shareImageAllUsers(params: ShareImageAllUsersParams):
Observable<ProjectModel[]> {
return this.applicationServiceFacade.buildShareImageAllUsers(params)
.pipe(
catchError(ErrorUtils.handleServiceError)
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 b5dcc7826..02a0551eb 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
@@ -23,11 +23,12 @@ import { ToastrService } from 'ngx-toastr';
import { GeneralEnvironmentStatus } from
'../../administration/management/management.model';
import { HealthStatusService, UserImagesPageService } from
'../../core/services';
-import { ImageModel, ProjectModel } from './images.model';
+import { ImageModel, ProjectModel, ShareImageAllUsersParams } from
'./images.model';
import { Image_Table_Column_Headers, Image_Table_Titles, Localstorage_Key,
Shared_Status } from './images.config';
import { MatDialog } from '@angular/material/dialog';
import { ShareImageComponent } from
'../../shared/modal-dialog/share-image/share-image.component';
-import { ImagesService } from './images.service';
+import { switchMap, tap } from 'rxjs/operators';
+import { Observable } from 'rxjs';
@Component({
selector: 'datalab-images',
@@ -60,7 +61,6 @@ export class ImagesComponent implements OnInit {
public toastr: ToastrService,
private userImagesPageService: UserImagesPageService,
private dialog: MatDialog,
- private imagesService: ImagesService
) { }
ngOnInit(): void {
@@ -108,7 +108,11 @@ export class ImagesComponent implements OnInit {
image
},
panelClass: 'modal-sm'
- }).afterClosed().subscribe(() =>
this.initImageTable(this.imagesService.projectList));
+ }).afterClosed()
+ .pipe(
+ switchMap(() => this.shareImageAllUsers(image)),
+ tap((imageListData: ProjectModel[]) =>
this.initImageTable(imageListData))
+ ).subscribe();
}
private getImageList(): ImageModel[] {
@@ -150,6 +154,16 @@ export class ImagesComponent implements OnInit {
this.userName = localStorage.getItem(Localstorage_Key.userName);
}
+ private shareImageAllUsers(image: ImageModel): Observable<ProjectModel[]> {
+ const shareParams: ShareImageAllUsersParams = {
+ imageName: image.name,
+ projectName: image.project,
+ endpoint: image.endpoint
+ };
+
+ return this.userImagesPageService.shareImageAllUsers(shareParams);
+ }
+
get isProjectsMoreThanOne(): boolean {
return this.projectList.length > 1;
}
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
deleted file mode 100644
index 36a9e5963..000000000
---
a/services/self-service/src/main/resources/webapp/src/app/resources/images/images.service.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { Injectable } from '@angular/core';
-import { ProjectModel } from './images.model';
-
-@Injectable({
- providedIn: 'root'
-})
-export class ImagesService {
- projectList!: ProjectModel[];
-
- constructor() { }
-}
diff --git
a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.html
b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.html
index dff6919bf..db83d0eaa 100644
---
a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.html
+++
b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.html
@@ -32,7 +32,7 @@
<div class="text-center m-top-30 m-bott-10">
<button type="button" class="butt mat-raised-button"
(click)="dialogRef.close()">No</button>
<button type="button" class="butt butt-success mat-raised-button"
- (click)="onYesClick()">Yes
+ (click)="dialogRef.close(true)">Yes
</button>
</div>
</section>
diff --git
a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.ts
b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.ts
index e034b10ec..ce60e32a1 100644
---
a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/share-image/share-image.component.ts
@@ -17,44 +17,19 @@
* under the License.
*/
-import { Component, Inject, OnInit } from '@angular/core';
+import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { UserImagesPageService } from '../../../core/services';
-import { ShareImageAllUsersParams } from '../../../resources/images';
-import { ImagesService } from '../../../resources/images/images.service';
@Component({
selector: 'datalab-share-image',
templateUrl: './share-image.component.html',
styleUrls: ['./share-image.component.scss']
})
-export class ShareImageComponent implements OnInit {
+export class ShareImageComponent {
imageName!: string;
constructor(
public dialogRef: MatDialogRef<ShareImageComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
- private userImagesPageService: UserImagesPageService,
- private imagesService: ImagesService
) { }
-
- ngOnInit(): void {
- this.getImageName();
- }
-
- getImageName(): void {
- this.imageName = this.data.image.name;
- }
-
- onYesClick(): void {
- const shareParams: ShareImageAllUsersParams = {
- imageName: this.data.image.name,
- projectName: this.data.image.project,
- endpoint: this.data.image.endpoint
- };
-
- this.userImagesPageService.shareImageAllUsers(shareParams)
- .subscribe(projectList => this.imagesService.projectList = projectList);
- this.dialogRef.close();
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]