-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from e-picsa/feat/admin-resource-upload
Feat(dashboard): resource editor
- Loading branch information
Showing
70 changed files
with
3,373 additions
and
1,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/picsa-apps/dashboard/src/app/modules/resources/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './storage-link/storage-link.component'; |
29 changes: 29 additions & 0 deletions
29
...s/dashboard/src/app/modules/resources/components/storage-link/storage-link.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@if(entry){ @switch (displayStyle) { | ||
<!-- chip style --> | ||
@case ('button') { | ||
<button | ||
class="chip-button filetype-icon" | ||
mat-button | ||
[attr.data-icon]="fileTypeIcon" | ||
(click)="handleLinkClick(entry.publicUrl)" | ||
> | ||
<mat-icon class="chip-icon filetype-icon inverted" [attr.data-icon]="fileTypeIcon">{{ fileTypeIcon }}</mat-icon> | ||
<div class="chip-text filename">{{ entry.name?.split('/')?.pop() }}</div> | ||
</button> | ||
|
||
} | ||
<!-- link style --> | ||
@case ('link') { | ||
<a [href]="entry.publicUrl" target="_blank" rel="noopener"> | ||
<div class="link-text">{{ entry.name?.split('/')?.pop() }}</div> | ||
</a> | ||
} | ||
<!-- default style --> | ||
@default { | ||
<div style="display: flex; align-items: center"> | ||
<mat-icon class="filetype-icon default-icon" [attr.data-icon]="fileTypeIcon">{{ fileTypeIcon }}</mat-icon> | ||
<div class="filename" style="margin-left: 8px">{{ entry.name?.split('/')?.pop() }}</div> | ||
</div> | ||
} } } @if(notFound) { | ||
<p class="error-message">Storage file not found</p> | ||
} |
82 changes: 82 additions & 0 deletions
82
...s/dashboard/src/app/modules/resources/components/storage-link/storage-link.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
:host { | ||
display: block; | ||
max-width: 200px; | ||
} | ||
.error-message { | ||
color: var(--color-warn); | ||
} | ||
mat-icon { | ||
overflow: visible; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
color: var(--color-primary); | ||
} | ||
|
||
button.chip-button { | ||
padding: 0; | ||
margin-bottom: 4px; | ||
border: 1px solid; | ||
height: auto; | ||
|
||
.chip-icon { | ||
color: white; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 32px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.chip-text { | ||
margin-left: 32px; | ||
padding: 8px; | ||
border-top-right-radius: 4px; | ||
border-bottom-right-radius: 4px; | ||
} | ||
} | ||
.filename { | ||
word-break: break-word; | ||
} | ||
|
||
// Colors used for different filetypes | ||
$color-file-document: hsl(230, 40%, 40%); | ||
$color-file-video: hsl(0, 70%, 60%); | ||
$color-file-image: hsl(150, 60%, 40%); | ||
$color-file-audio: hsl(300, 60%, 40%); | ||
|
||
.filetype-icon { | ||
color: var(--color-primary); | ||
&[data-icon='description'] { | ||
color: $color-file-document; | ||
} | ||
&[data-icon='smart_display'] { | ||
color: $color-file-video; | ||
} | ||
&[data-icon='image'] { | ||
color: $color-file-image; | ||
} | ||
&[data-icon='music_note'] { | ||
color: $color-file-audio; | ||
} | ||
} | ||
|
||
.filetype-icon.inverted { | ||
color: white; | ||
background: var(--color-primary); | ||
&[data-icon='description'] { | ||
background: $color-file-document; | ||
} | ||
&[data-icon='smart_display'] { | ||
background: $color-file-video; | ||
} | ||
&[data-icon='image'] { | ||
background: $color-file-image; | ||
} | ||
&[data-icon='music_note'] { | ||
background: $color-file-audio; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ashboard/src/app/modules/resources/components/storage-link/storage-link.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DashboardResourcesStorageLinkComponent } from './storage-link.component'; | ||
|
||
describe('StorageLinkComponent', () => { | ||
let component: DashboardResourcesStorageLinkComponent; | ||
let fixture: ComponentFixture<DashboardResourcesStorageLinkComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [DashboardResourcesStorageLinkComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DashboardResourcesStorageLinkComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
...pps/dashboard/src/app/modules/resources/components/storage-link/storage-link.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
|
||
import { IResourceStorageEntry, ResourcesDashboardService } from '../../resources.service'; | ||
|
||
/** | ||
* Mat icons used to represent various filetype extensions | ||
* https://fonts.google.com/icons | ||
*/ | ||
const filetypeIconMapping = { | ||
pdf: 'description', | ||
jpeg: 'image', | ||
jpg: 'image', | ||
png: 'image', | ||
svg: 'image', | ||
mp4: 'smart_display', | ||
mp3: 'music_note', | ||
}; | ||
|
||
@Component({ | ||
selector: 'dashboard-resources-storage-link', | ||
standalone: true, | ||
imports: [CommonModule, MatButtonModule, MatIconModule], | ||
templateUrl: './storage-link.component.html', | ||
styleUrls: ['./storage-link.component.scss'], | ||
}) | ||
/** | ||
* Minimal component that takes a storage file id input and returns a link | ||
* to the public url of the file, as populated from resources store cache | ||
*/ | ||
export class DashboardResourcesStorageLinkComponent implements OnInit { | ||
/** Resource storage id */ | ||
@Input() id: string; | ||
|
||
@Input() displayStyle: 'button' | 'link' | 'default' = 'default'; | ||
|
||
constructor(private service: ResourcesDashboardService) {} | ||
|
||
public entry?: IResourceStorageEntry; | ||
|
||
public notFound = false; | ||
|
||
public fileTypeIcon = 'description'; | ||
|
||
async ngOnInit() { | ||
const entry = await this.service.getStorageFileById(this.id); | ||
this.entry = entry; | ||
this.notFound = entry ? false : true; | ||
if (entry) { | ||
this.fileTypeIcon = this.getFileTypeIcon(entry); | ||
} | ||
} | ||
|
||
public handleLinkClick(url: string) { | ||
window.open(url, '_blank', 'noopener'); | ||
} | ||
|
||
private getFileTypeIcon(entry: IResourceStorageEntry) { | ||
const extension = entry.name?.split('.').pop(); | ||
if (!extension) return 'document'; | ||
return filetypeIconMapping[extension] || 'document'; | ||
} | ||
} |
Oops, something went wrong.