Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(archive): new archive representation view (DEV-1084) #785

Merged
merged 7 commits into from Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,18 +1,49 @@
<div *ngIf="src && src.fileValue.fileUrl">
<!-- in case of an error -->
<app-status [status]="404" [url]="src.fileValue.fileUrl" [representation]="'archive'" *ngIf="failedToLoad"></app-status>
<app-status [status]="404" [url]="src.fileValue.fileUrl" [representation]="'archive'" *ngIf="failedToLoad">
</app-status>

<button class="download" mat-button (click)="downloadArchive(src.fileValue.fileUrl)" [disabled]="failedToLoad">
<div class="file-representation">
<div class="container">
<div class="contents">
<div class="icon">
<mat-icon>
description
</mat-icon>
</div>
<div class="file">
<p>{{originalFilename}}</p>
</div>
</div>
</div>
<div class="toolbar">
<!-- toolbar -->
<div class="action horizontal bottom">
<!-- vertical more button with menu to downlaod and replace file -->
Copy link
Collaborator

@Vijeinath Vijeinath Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the word "vertical" does not make sense for me in this sentence. In the outer div there is "horizontal" written

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It refers to the three dots menu which has three vertical dots but I can see how it can be confusing with the "horizontal" class name right above it. I'll clarify the comment.

<button mat-icon-button [matMenuTriggerFor]="more">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #more="matMenu">
<button mat-menu-item (click)="downloadArchive(src.fileValue.fileUrl)">
Download file
</button>
<button mat-menu-item (click)="openReplaceFileDialog()">
Replace file
</button>
</mat-menu>
</div>
</div>
</div>
<!-- <button class="download" mat-button (click)="downloadArchive(src.fileValue.fileUrl)" [disabled]="failedToLoad">
<mat-icon>
file_download
</mat-icon>
Click to download
</button>
<button mat-button matTooltip="Replace archive file" (click)="openReplaceFileDialog()">
<mat-icon>cloud_upload</mat-icon>
</button>
</button> -->
</div>
<div *ngIf="!src || !src.fileValue.fileUrl">
No valid file url found for this resource.
</div>

</div>
@@ -0,0 +1,28 @@
@import "../../../../../assets/style/responsive";
@import "../../../../../assets/style/config";

.file-representation {
width: 100%;

.container {
background: #292929;
border-radius: 8px 8px 0px 0px;
display: flex;
justify-content: center;
align-items: center;
padding: 15.5% 0%;

.contents {
color: #FFFFFF;

.icon {
mat-icon {
height: 90px;
width: 90px;
font-size: 90px;
line-height: 90px;
}
}
}
}
}
Expand Up @@ -4,8 +4,8 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { Component, OnInit, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { MatDialogModule } from '@angular/material/dialog';
import { MatMenuModule } from '@angular/material/menu';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { AppInitService } from 'src/app/app-init.service';
import { DspApiConfigToken, DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
Expand All @@ -14,6 +14,7 @@ import { FileRepresentation } from '../file-representation';

import { ArchiveComponent } from './archive.component';


const archiveFileValue = {
'arkUrl': 'http://0.0.0.0:3336/ark:/72163/1/0123/6c=f69h6Ss6GXPME565EqAS/dDHcFHlwQ9K46255QfUGrQ8',
'attachedToUser': 'http://rdfh.ch/users/root',
Expand Down Expand Up @@ -64,7 +65,8 @@ describe('ArchiveComponent', () => {
imports: [
HttpClientTestingModule,
MatDialogModule,
MatSnackBarModule
MatSnackBarModule,
MatMenuModule
],
providers: [
AppInitService,
Expand Down Expand Up @@ -92,19 +94,4 @@ describe('ArchiveComponent', () => {
it('should have a file url', () => {
expect(testHostComponent.archiveFileRepresentation.fileValue.fileUrl).toEqual('http://0.0.0.0:1024/0123/Eu71soNXOAL-DVweVgODkFh.zip/file');
});

it('should show a download button if the file url is provided', async () => {
const downloadButtonElement = await loader.getHarness(MatButtonHarness.with({ selector: '.download' }));

expect(downloadButtonElement).toBeTruthy();
});

it('should NOT show a download button if the file url is NOT provided', async () => {
testHostComponent.archiveFileRepresentation = undefined;
testHostFixture.detectChanges();

const downloadButtonElement = await loader.getAllHarnesses(MatButtonHarness.with({ selector: '.download' }));

expect(downloadButtonElement.length).toEqual(0);
});
});
Expand Up @@ -73,6 +73,7 @@
.action {
position: inherit;
height: 40px;
flex-wrap: nowrap;

.mat-icon-button[disabled][disabled] {
color: rgba(255, 255, 255, 0.26);
Expand Down Expand Up @@ -120,6 +121,7 @@

.action {
margin: 24px 0 0;
flex-wrap: nowrap;
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/assets/style/_elements.scss
Expand Up @@ -296,6 +296,7 @@ a,
display: block;
position: relative;
padding: 0;
margin-bottom: 10px;

&.video,
&.audio,
Expand All @@ -311,6 +312,14 @@ a,
max-width: 50%;
}

.toolbar {
color: $primary_50;
background-color: $dark;
height: 64px;
border-radius: 0px 0px 8px 8px;
box-shadow: 0px 4px 4px 0px #888888;
}

.action,
.navigation {
.mat-button-disabled {
Expand All @@ -324,6 +333,8 @@ a,
display: flex;
flex-wrap: wrap;
color: $primary_50;
height: 40px;
padding: 8px 0;

a {
color: $primary_50 !important;
Expand Down Expand Up @@ -809,4 +820,4 @@ $gc-small: $form-width - $gc-large - 4;
.mat-slider-thumb {
background-color: $primary_400;
}
}
}