Skip to content

Commit c047c86

Browse files
authored
Merge pull request #190 from Vafilor/feat/onepanelio.core.595-expande.node.details
feat: increase node info size and support multiple artifact file browsers
2 parents 8d44bd5 + e369e5e commit c047c86

26 files changed

+299
-228
lines changed

.github/workflows/push_tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Notify Slack Channels
2626
uses: rtCamp/[email protected]
2727
env:
28-
SLACK_CHANNEL: dev
28+
SLACK_CHANNEL: org
2929
SLACK_ICON: https://avatars1.githubusercontent.com/u/30390575?s=48&v=4
3030
SLACK_TITLE: New Core-UI Version
3131
SLACK_USERNAME: opBot

src/app/app.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<app-navbar
22
*ngIf="!loggingIn && showNavigationBar"
33
[activeUrl]="activeUrl"
4-
[servicesVisible]="servicesVisible"
54
(logout)="logout()"
65
(namespaceClick)="onFormFieldClick()">
76
</app-navbar>

src/app/app.component.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class AppComponent implements OnInit {
3030
version = '1.0.0';
3131
showNamespaceManager = false;
3232
showNavigationBar = true;
33-
servicesVisible?: boolean = undefined;
3433

3534
constructor(public namespaceTracker: NamespaceTracker,
3635
private appRouter: AppRouter,
@@ -39,16 +38,14 @@ export class AppComponent implements OnInit {
3938
private activatedRoute: ActivatedRoute,
4039
private router: Router,
4140
private dialog: MatDialog,
42-
private snackbar: MatSnackBar,
43-
private servicesService: ServiceServiceService) {
41+
private snackbar: MatSnackBar) {
4442
this.version = environment.version;
4543

4644
this.namespaceTracker.namespacesChanged.subscribe(() => {
4745
const namespace = this.activatedRoute.snapshot.firstChild.paramMap.get('namespace');
4846

4947
if (namespace) {
5048
this.namespaceTracker.activeNamespace = namespace;
51-
this.getServicesVisible(namespace);
5249
}
5350
});
5451

@@ -117,37 +114,4 @@ export class AppComponent implements OnInit {
117114
onRouterOutletActivate(data) {
118115
this.showNavigationBar = !data.hideNavigationBar;
119116
}
120-
121-
/**
122-
* Sets the servicesVisible variable to the input value.
123-
* Further stores it in local storage.
124-
*/
125-
private setServicesVisible(visible: boolean) {
126-
this.servicesVisible = visible;
127-
localStorage.setItem('services-visible', JSON.stringify(visible));
128-
}
129-
130-
/**
131-
* Sets the servicesVisible variable.
132-
*
133-
* If it is already set, use that.
134-
* If we have it stored in local storage, use that.
135-
* Otherwise, make a network request to check.
136-
*
137-
*/
138-
private getServicesVisible(namespace: string) {
139-
if (this.servicesVisible !== undefined) {
140-
return;
141-
}
142-
143-
const localStorageValue = localStorage.getItem('services-visible');
144-
if (localStorageValue !== null) {
145-
this.servicesVisible = JSON.parse(localStorageValue);
146-
return;
147-
}
148-
149-
this.servicesService.listServices(namespace).subscribe(res => {
150-
this.setServicesVisible(res.count !== undefined);
151-
});
152-
}
153117
}

src/app/auth/auth.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@angular/core';
22
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
3-
import { AuthService } from "./auth.service";
3+
import { AuthService } from './auth.service';
44

55
@Injectable({
66
providedIn: 'root'
@@ -11,7 +11,7 @@ export class AuthGuard implements CanActivate {
1111
canActivate(
1212
next: ActivatedRouteSnapshot,
1313
state: RouterStateSnapshot): boolean {
14-
let url: string = state.url;
14+
const url: string = state.url;
1515

1616
return this.checkLogin(url);
1717
}

src/app/files/file-browser/file-browser.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div class="op-border hide-overflow">
2-
<div class="bg-light-gray toolbar font-roboto font-size-regular">
3-
<span class="font-weight-bold">Location: </span>
4-
<span (click)="goToRoot()" class="pointer-hover">
2+
<div class="bg-light-gray toolbar d-flex flex-wrap align-items-baseline font-roboto font-size-small">
3+
<div class="font-weight-bold lh-36">Location: </div>
4+
<div (click)="goToRoot()" class="pointer-hover ml-1">
55
<span [class.active-link]="pathParts.length != 0">{{rootName}}</span>
66
<span *ngIf="pathParts.length > 0" class="path-separator">/</span>
7-
</span>
7+
</div>
88
<app-breadcrumbs [parts]="pathParts" (breadcrumbClick)="onBreadcrumbClicked($event)"></app-breadcrumbs>
99
<mat-spinner *ngIf="loading"
1010
color="primary"
@@ -24,7 +24,7 @@
2424
<span class="font-weight-bold ml-1">{{fileNavigator.file.value.name}}</span>
2525
<span class="ml-2">{{fileNavigator.file.value.size | fileSize}}</span>
2626
</div>
27-
<div class="pointer-hover" (click)="onFileDownload(fileNavigator.file.value)">
27+
<div *ngIf="canDownload(fileNavigator.file.value)" class="pointer-hover" (click)="onFileDownload(fileNavigator.file.value)">
2828
<i class="fas fa-download"></i> Download
2929
</div>
3030
</div>

src/app/files/file-browser/file-browser.component.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
.toolbar {
44
padding: 5px 20px;
55
min-height: 36px;
6+
}
7+
8+
.lh-36 {
69
line-height: 36px;
710
}
811

src/app/files/file-browser/file-browser.component.ts

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
2-
import { FileNavigator, LongRunningTaskState, SlowValueUpdate } from "../fileNavigator";
3-
import { BreadcrumbEvent } from "../../breadcrumbs/breadcrumbs.component";
4-
import { FileActionEvent } from "../file-navigator/file-navigator.component";
5-
import { ModelFile, WorkflowServiceService } from "../../../api";
2+
import { FileNavigator, LongRunningTaskState, SlowValueUpdate } from '../fileNavigator';
3+
import { BreadcrumbEvent } from '../../breadcrumbs/breadcrumbs.component';
4+
import { FileActionEvent } from '../file-navigator/file-navigator.component';
5+
import { ModelFile, WorkflowServiceService } from '../../../api';
6+
import { GenericFileViewComponent } from '../file-viewer/generic-file-view/generic-file-view.component';
67

78
@Component({
89
selector: 'app-file-browser',
@@ -12,47 +13,49 @@ import { ModelFile, WorkflowServiceService } from "../../../api";
1213
export class FileBrowserComponent implements OnInit, OnDestroy {
1314
private filePathChangedSubscriber;
1415
private fileChangedSubscriber;
16+
17+
// tslint:disable-next-line:variable-name
1518
private _fileNavigator: FileNavigator;
1619

1720
@Input() displayedColumns = [];
1821

1922
showingFile = false;
2023

21-
loading: boolean = false;
24+
loading = false;
2225

23-
@Input() rootName: string = '';
26+
@Input() rootName = '';
2427
@Input() set fileNavigator(value: FileNavigator) {
2528
this._fileNavigator = value;
2629

27-
if(this.filePathChangedSubscriber) {
30+
if (this.filePathChangedSubscriber) {
2831
this.filePathChangedSubscriber.unsubscribe();
2932
}
3033

3134
this.filePathChangedSubscriber = value.path.valueChanged.subscribe((change: SlowValueUpdate<string>) => {
32-
if(change.state === LongRunningTaskState.Succeeded) {
35+
if (change.state === LongRunningTaskState.Succeeded) {
3336
this.updatePathParts(change.value);
3437
}
3538
});
3639

37-
if(this.fileChangedSubscriber) {
40+
if (this.fileChangedSubscriber) {
3841
this.fileChangedSubscriber.unsubscribe();
3942
}
4043

4144
this.fileChangedSubscriber = value.file.valueChanged.subscribe((change: SlowValueUpdate<ModelFile>) => {
42-
if(!this.showingFile && change.state === LongRunningTaskState.Started) {
45+
if (!this.showingFile && change.state === LongRunningTaskState.Started) {
4346
this.loading = true;
4447
}
4548

46-
if(change.state === LongRunningTaskState.Succeeded) {
49+
if (change.state === LongRunningTaskState.Succeeded) {
4750
this.updateFile(change.value);
4851

49-
if(!this.showingFile) {
52+
if (!this.showingFile) {
5053
this.loading = false;
5154
}
5255
}
5356

54-
if(change.state === LongRunningTaskState.Failed) {
55-
if(!this.showingFile) {
57+
if (change.state === LongRunningTaskState.Failed) {
58+
if (!this.showingFile) {
5659
this.loading = false;
5760
}
5861
}
@@ -81,7 +84,7 @@ export class FileBrowserComponent implements OnInit, OnDestroy {
8184
}
8285

8386
updateFile(newFile: ModelFile) {
84-
if(newFile.directory) {
87+
if (newFile.directory) {
8588
this.showingFile = false;
8689
return;
8790
}
@@ -90,7 +93,7 @@ export class FileBrowserComponent implements OnInit, OnDestroy {
9093
}
9194

9295
ngOnDestroy(): void {
93-
if(this.filePathChangedSubscriber) {
96+
if (this.filePathChangedSubscriber) {
9497
this.filePathChangedSubscriber.unsubscribe();
9598
this.filePathChangedSubscriber = null;
9699
}
@@ -109,29 +112,29 @@ export class FileBrowserComponent implements OnInit, OnDestroy {
109112
const path = this.fileNavigator.path.value;
110113
const subPath = path.substring(this.fileNavigator.rootPath.length);
111114

112-
let parts = subPath.split('/').filter(value => value.length != 0);
115+
const parts = subPath.split('/').filter(value => value.length != 0);
113116

114117
const partUntil = parts.slice(0, index + 1).join('/');
115118

116119
return this.fileNavigator.rootPath + '/' + partUntil;
117120
}
118121

119122
onFileEvent(e: FileActionEvent) {
120-
if(e.action === 'download') {
123+
if (e.action === 'download') {
121124
this.onFileDownload(e.file);
122125
}
123126
}
124127

125128
onFileDownload(file: ModelFile) {
126-
if(file.directory) {
127-
throw 'Unable to download a directory';
129+
if (file.directory) {
130+
throw new Error('Unable to download a directory');
128131
}
129132

130133
this.workflowService.getArtifact(this.namespace, this.name, file.path)
131134
.subscribe((res: any) => {
132-
const link = <HTMLAnchorElement>document.createElement('a');
135+
const link = document.createElement('a') as HTMLAnchorElement;
133136
let downloadName = `${this.namespace}-${this.name}-${file.name}`;
134-
if(file.extension) {
137+
if (file.extension) {
135138
downloadName += `.${file.extension}`;
136139
}
137140

@@ -142,14 +145,20 @@ export class FileBrowserComponent implements OnInit, OnDestroy {
142145
document.body.appendChild(link);
143146
link.click();
144147
document.body.removeChild(link);
145-
})
148+
});
146149
}
147150

148151
onFileLoadingChange(value: boolean) {
149-
if(this.showingFile) {
152+
if (this.showingFile) {
150153
setTimeout(() => {
151154
this.loading = value;
152155
});
153156
}
154157
}
158+
159+
canDownload(file: ModelFile) {
160+
return !file.directory &&
161+
parseInt(file.size, 10) < GenericFileViewComponent.MAX_DOWNLOAD_SIZE
162+
;
163+
}
155164
}

src/app/files/file-navigator/file-navigator.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<ng-container cdkColumnDef="actions">
3232
<cdk-header-cell *cdkHeaderCellDef></cdk-header-cell>
3333
<cdk-cell *cdkCellDef="let file" class="color-primary">
34-
<div *ngIf="!file.directory" (click)="onFileDownload(file)" class="pointer-hover"><i class="fas fa-download"></i></div>
34+
<div (click)="onFileDownload(file)" [class.hidden]="!canDownload(file)" class="pointer-hover"><i class="fas fa-download"></i></div>
3535
</cdk-cell>
3636
</ng-container>
3737

src/app/files/file-navigator/file-navigator.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
22
import { FileNavigator } from "../fileNavigator";
33
import { ModelFile } from "../../../api";
4+
import { GenericFileViewComponent } from '../file-viewer/generic-file-view/generic-file-view.component';
45

56
export type FileAction = 'download';
67

@@ -17,24 +18,23 @@ export interface FileActionEvent {
1718
export class FileNavigatorComponent implements OnInit {
1819
@Input() displayedColumns = ['icon', 'name', 'last-modified', 'size', 'actions'];
1920

21+
// tslint:disable-next-line:variable-name
2022
private _fileNavigator: FileNavigator;
2123

2224

2325
@Input() set fileNavigator(fileNavigator: FileNavigator) {
24-
if(!fileNavigator) {
26+
if (!fileNavigator) {
2527
return;
2628
}
2729

2830
this._fileNavigator = fileNavigator;
2931
this._fileNavigator.loadFiles();
3032
}
31-
32-
@Output() fileAction = new EventEmitter<FileActionEvent>();
33-
3433
get fileNavigator(): FileNavigator {
3534
return this._fileNavigator;
3635
}
3736

37+
@Output() fileAction = new EventEmitter<FileActionEvent>();
3838
constructor() { }
3939

4040
ngOnInit() {
@@ -47,7 +47,13 @@ export class FileNavigatorComponent implements OnInit {
4747
onFileDownload(file: ModelFile) {
4848
this.fileAction.emit({
4949
action: 'download',
50-
file: file,
51-
})
50+
file,
51+
});
52+
}
53+
54+
canDownload(file: ModelFile) {
55+
return !file.directory &&
56+
parseInt(file.size, 10) < GenericFileViewComponent.MAX_DOWNLOAD_SIZE
57+
;
5258
}
5359
}

src/app/files/file-viewer/big-file-view/big-file-view.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="big-file-view bg-lighter-white font-roboto">
2-
<div class="text-center color-darker-gray" (click)="onFileDownload()">
2+
<div *ngIf="displayDownload" class="text-center color-darker-gray" (click)="onFileDownload()">
33
<i class="fa fa-download font-size-XL pointer-hover"></i>
44
<div class="font-size-regular mt-1 pointer-hover">Download <span *ngIf="file.size">({{file.size | fileSize }})</span></div>
55
</div>

0 commit comments

Comments
 (0)