This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push:
new d7cbb91 [DLAB-1744] Conveyed notebook links of other users to
administrator (#764)
d7cbb91 is described below
commit d7cbb916a1c9293aa362e3bc61deceea706af9dc
Author: Dmytro Gnatyshyn <[email protected]>
AuthorDate: Tue May 26 14:34:05 2020 +0300
[DLAB-1744] Conveyed notebook links of other users to administrator (#764)
* [DLAB-1744] Conveyed notebook links of other users to administrator
---
.../backendapi/resources/dto/UserResourceInfo.java | 70 ++++------------------
.../service/impl/EnvironmentServiceImpl.java | 29 +++++----
.../management-grid/management-grid.component.html | 5 +-
.../management-grid/management-grid.component.scss | 4 ++
.../management-grid/management-grid.component.ts | 28 ++++++---
.../administration/management/management.model.ts | 6 +-
.../detail-dialog/detail-dialog.component.html | 23 +++++--
.../detail-dialog/detail-dialog.component.ts | 3 +-
8 files changed, 79 insertions(+), 89 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
index ea1198e..5958411 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
@@ -18,88 +18,38 @@
*/
package com.epam.dlab.backendapi.resources.dto;
+import com.epam.dlab.dto.ResourceURL;
import com.epam.dlab.dto.computational.UserComputationalResource;
import com.epam.dlab.model.ResourceEnum;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Builder;
import lombok.Data;
-import java.util.Collections;
import java.util.List;
@Data
+@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserResourceInfo {
-
+ @JsonProperty
+ private String user;
+ @JsonProperty
+ private String project;
@JsonProperty("resource_type")
private ResourceEnum resourceType;
-
@JsonProperty("resource_name")
private String resourceName;
-
@JsonProperty("shape")
private String resourceShape;
-
@JsonProperty("status")
private String resourceStatus;
-
@JsonProperty("computational_resources")
- private List<UserComputationalResource> computationalResources =
Collections.emptyList();
-
- @JsonProperty
- private String user;
- @JsonProperty
- private String project;
-
+ private List<UserComputationalResource> computationalResources;
@JsonProperty("public_ip")
private String ip;
-
@JsonProperty("cloud_provider")
private String cloudProvider;
-
-
- public UserResourceInfo withResourceType(ResourceEnum resourceType) {
- setResourceType(resourceType);
- return this;
- }
-
- public UserResourceInfo withResourceName(String resourceName) {
- setResourceName(resourceName);
- return this;
- }
-
- public UserResourceInfo withResourceShape(String resourceShape) {
- setResourceShape(resourceShape);
- return this;
- }
-
- public UserResourceInfo withResourceStatus(String resourceStatus) {
- setResourceStatus(resourceStatus);
- return this;
- }
-
- public UserResourceInfo
withCompResources(List<UserComputationalResource> compResources) {
- setComputationalResources(compResources);
- return this;
- }
-
- public UserResourceInfo withUser(String user) {
- setUser(user);
- return this;
- }
-
- public UserResourceInfo withIp(String ip) {
- setIp(ip);
- return this;
- }
-
- public UserResourceInfo withProject(String project) {
- setProject(project);
- return this;
- }
-
- public UserResourceInfo withCloudProvider(String cloudProvider) {
- setCloudProvider(cloudProvider);
- return this;
- }
+ @JsonProperty("exploratory_urls")
+ private List<ResourceURL> exploratoryUrls;
}
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
index 8b2806b..6815f9d 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
@@ -194,10 +194,12 @@ public class EnvironmentServiceImpl implements
EnvironmentService {
if (projectDTO.getEndpoints() != null) {
final Stream<UserResourceInfo> edges =
projectDTO.getEndpoints()
.stream()
- .map(e -> new
UserResourceInfo().withResourceType(ResourceEnum.EDGE_NODE)
-
.withResourceStatus(e.getStatus().toString())
-
.withProject(projectDTO.getName())
- .withIp(e.getEdgeInfo()
!= null ? e.getEdgeInfo().getPublicIp() : null));
+ .map(e -> UserResourceInfo.builder()
+
.resourceType(ResourceEnum.EDGE_NODE)
+
.resourceStatus(e.getStatus().toString())
+
.project(projectDTO.getName())
+ .ip(e.getEdgeInfo() !=
null ? e.getEdgeInfo().getPublicIp() : null)
+ .build());
return Stream.concat(edges,
userResources).collect(toList());
} else {
return userResources.collect(toList());
@@ -205,14 +207,17 @@ public class EnvironmentServiceImpl implements
EnvironmentService {
}
private UserResourceInfo toUserResourceInfo(UserInstanceDTO
userInstance) {
- return new
UserResourceInfo().withResourceType(ResourceEnum.NOTEBOOK)
-
.withResourceName(userInstance.getExploratoryName())
- .withResourceShape(userInstance.getShape())
- .withResourceStatus(userInstance.getStatus())
- .withCompResources(userInstance.getResources())
- .withUser(userInstance.getUser())
- .withProject(userInstance.getProject())
-
.withCloudProvider(userInstance.getCloudProvider());
+ return UserResourceInfo.builder()
+ .resourceType(ResourceEnum.NOTEBOOK)
+ .resourceName(userInstance.getExploratoryName())
+ .resourceShape(userInstance.getShape())
+ .resourceStatus(userInstance.getStatus())
+
.computationalResources(userInstance.getResources())
+ .user(userInstance.getUser())
+ .project(userInstance.getProject())
+ .cloudProvider(userInstance.getCloudProvider())
+ .exploratoryUrls(userInstance.getResourceUrl())
+ .build();
}
private void checkProjectResourceConditions(String project, String
action) {
diff --git
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html
index b4f726c..8b7e459 100644
---
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html
+++
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html
@@ -60,7 +60,10 @@
<span [hidden]="filtering && filterForm.type.length > 0 &&
!collapsedFilterRow">more_vert</span>
</i>
</button> </th>
- <td type mat-cell *matCellDef="let element">{{ element.name ||
element.type }}</td>
+ <td type mat-cell *matCellDef="let element">
+ <span *ngIf="element.name" class="computation"
(click)="openNotebookDetails(element)">{{element.name}}</span>
+ <span *ngIf="!element.name">{{element.type}}</span>
+ </td>
</ng-container>
<ng-container matColumnDef="shape">
diff --git
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
index 30c082d..37f127d 100644
---
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
+++
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
@@ -119,3 +119,7 @@ table.management {
background: inherit;
}
}
+
+.computation{
+ cursor: pointer;
+}
diff --git
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts
index d0ab9dc..8153f26 100644
---
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts
@@ -28,6 +28,7 @@ import { ConfirmationDialogComponent } from
'../../../shared/modal-dialog/confir
import { EnvironmentsDataService } from '../management-data.service';
import { EnvironmentModel, ManagementConfigModel } from '../management.model';
import {ProgressBarService} from '../../../core/services/progress-bar.service';
+import {DetailDialogComponent} from
'../../../resources/exploratory/detail-dialog';
export interface ManageAction {
action: string;
@@ -112,7 +113,9 @@ export class ManagementGridComponent implements OnInit {
let filteredData = this.getEnvironmentDataCopy();
const containsStatus = (list, selectedItems) => {
- return list.filter((item: any) => { if
(selectedItems.indexOf(item.status) !== -1) return item; });
+ if (list){
+ return list.filter((item: any) => { if
(selectedItems.indexOf(item.status) !== -1) return item; });
+ }
};
if (filteredData.length) this.filtering = true;
@@ -131,8 +134,8 @@ export class ManagementGridComponent implements OnInit {
if (config.resources.length > 0 && modifiedResources.length > 0) {
item.resources = modifiedResources; }
- if (config.resources.length === 0 && config.type === 'active' ||
- modifiedResources.length >= 0 && config.resources.length > 0 &&
config.type === 'active') {
+ if (config.resources && config.resources.length === 0 && config.type
=== 'active' ||
+ modifiedResources && modifiedResources.length >= 0 &&
config.resources.length > 0 && config.type === 'active') {
item.resources = modifiedResources;
isResources = true;
}
@@ -216,15 +219,24 @@ export class ManagementGridComponent implements OnInit {
if (item.status && statuses.indexOf(item.status.toLowerCase()) === -1)
statuses.push(item.status.toLowerCase());
if (item.project && projects.indexOf(item.project) === -1)
projects.push(item.project);
if (item.shape && shapes.indexOf(item.shape) === -1)
shapes.push(item.shape);
-
- item.computational_resources.map((resource: any) => {
- if (resources.indexOf(resource.status) === -1)
resources.push(resource.status);
- resources.sort(SortUtils.statusSort);
- });
+ if (item.computational_resources) {
+ item.computational_resources.map((resource: any) => {
+ if (resources.indexOf(resource.status) === -1)
resources.push(resource.status);
+ resources.sort(SortUtils.statusSort);
+ });
+ }
});
this.filterConfiguration = new ManagementConfigModel(users, '', projects,
shapes, statuses, resources);
}
+
+ openNotebookDetails(data) {
+ this.dialog.open(DetailDialogComponent, { data:
+ {notebook: data, bucketStatus: {view: true, upload: true, download:
true, delete: true}, buckets: [], type: 'environment'},
+ panelClass: 'modal-lg'
+ })
+ .afterClosed().subscribe(() => {});
+ }
}
diff --git
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
index 2b2fdf3..6b0f600 100644
---
a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
@@ -27,7 +27,8 @@ export class EnvironmentModel {
public ip: string,
public type?: string,
public project?: string,
- public cloud_provider?: string
+ public cloud_provider?: string,
+ public exploratory_urls?: Array<any>
) { }
public static loadEnvironments(data: Array<any>) {
@@ -41,7 +42,8 @@ export class EnvironmentModel {
value.public_ip,
value.resource_type,
value.project,
- value.cloud_provider
+ value.cloud_provider,
+ value.exploratory_urls
));
}
}
diff --git
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
index 75712d4..6b67c40 100644
---
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
+++
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
@@ -22,10 +22,10 @@
<button type="button" class="close"
(click)="dialogRef.close()">×</button>
</header>
<div class="dialog-content">
- <div *ngIf="data">
+ <div *ngIf="data ">
<table class="detail-header">
<tr>
- <td>{{notebook.template_name}}</td>
+ <td>{{notebook.template_name || notebook.name}}</td>
<td>
<span class="status" ngClass="{{notebook.status || ''}}">
{{notebook.status}}
@@ -34,12 +34,24 @@
<td>{{notebook.shape}}</td>
</tr>
</table>
+
<div class="content-box">
<div class="detail-info" *ngIf="notebook.error_message">
<p class="failed">{{ notebook.error_message }}</p>
</div>
-
- <div class="scroll-box" id="scrolling">
+ <div *ngIf="data.type === 'environment'" class="detail-info">
+ <p>Open following URL(s) in your browser to access this box:</p>
+ <div class="links_block">
+ <p *ngFor="let item of notebook.exploratory_urls">
+ <span class="description">{{item.description}}: </span>
+ <a class="ellipsis" matTooltip="{{item.url}}"
matTooltipPosition="above" href="{{item.url}}"
+ target="_blank">
+ {{item.url}}
+ </a>
+ </p>
+ </div>
+ </div>
+ <div class="scroll-box" id="scrolling" *ngIf="data.type ===
'resource'">
<div class="detail-info" *ngIf="!notebook.error_message">
<p>Edge Node IP Address {{notebook.node_ip}}</p>
<p *ngIf="notebook.status === 'running'">Up time {{upTimeInHours}}
hour(s) since
@@ -59,7 +71,7 @@
<p class="flex" *ngIf="notebook.password">Password: <span
class="strong">{{ notebook.password }}</span></p>
- <p class="m-top-30">{{ DICTIONARY[PROVIDER].personal_storage }}:
</p>
+ <p class="m-top-30">{{ 'Project bucket' }}: </p>
<!-- (click)="bucketBrowser(notebook.bucket_name,
notebook.endpoint, this.bucketStatus.view)"-->
<div class="links_block" (mouseleave)="hideCopyIcon()">
<p *ngIf="PROVIDER === 'azure' && notebook.account_name">
@@ -203,5 +215,6 @@
</div>
</div>
</div>
+
</div>
</div>
diff --git
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
index c6748e2..9468157 100644
---
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
@@ -37,7 +37,7 @@ import {CopyPathUtils} from
'../../../core/util/copyPathUtils';
export class DetailDialogComponent implements OnInit {
readonly DICTIONARY = DICTIONARY;
- readonly PROVIDER = this.data.notebook.cloud_provider;
+ readonly PROVIDER = this.data.notebook.cloud_provider.toLowerCase();
private isCopied: boolean = true;
notebook: any;
upTimeInHours: number;
@@ -65,6 +65,7 @@ export class DetailDialogComponent implements OnInit {
}
ngOnInit() {
+ console.log(this.data.notebook);
this.bucketStatus = this.data.bucketStatus;
this.notebook = this.data.notebook;
if (this.notebook) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]