From 77d288d9051e737d03b60b4726e8b9219c098946 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 18 Feb 2022 18:41:16 +0100 Subject: [PATCH] Add about dialog Signed-off-by: trivernis --- .../app/components/core/core.component.html | 2 +- .../src/app/components/core/core.module.ts | 2 ++ .../about-dialog/about-dialog.component.html | 24 ++++++++++++++ .../about-dialog/about-dialog.component.scss | 20 ++++++++++++ .../about-dialog.component.spec.ts | 25 +++++++++++++++ .../about-dialog/about-dialog.component.ts | 31 +++++++++++++++++++ .../repository-overview.component.html | 9 ++++-- .../repository-overview.component.scss | 19 ++++++++++++ .../repository-overview.component.ts | 8 +++++ .../shared/app-common/app-common.module.ts | 3 ++ .../external-url/external-url.component.html | 3 ++ .../external-url/external-url.component.scss | 15 +++++++++ .../external-url.component.spec.ts | 25 +++++++++++++++ .../external-url/external-url.component.ts | 31 +++++++++++++++++++ .../metadata-entry.component.html | 4 ++- .../metadata-entry.component.scss | 24 +++++++++++++- .../metadata-entry.component.ts | 7 +++-- 17 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.html create mode 100644 mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.scss create mode 100644 mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.spec.ts create mode 100644 mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.ts create mode 100644 mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.html create mode 100644 mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.scss create mode 100644 mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.spec.ts create mode 100644 mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.ts diff --git a/mediarepo-ui/src/app/components/core/core.component.html b/mediarepo-ui/src/app/components/core/core.component.html index def7489..94f56f3 100644 --- a/mediarepo-ui/src/app/components/core/core.component.html +++ b/mediarepo-ui/src/app/components/core/core.component.html @@ -1,7 +1,7 @@
- + diff --git a/mediarepo-ui/src/app/components/core/core.module.ts b/mediarepo-ui/src/app/components/core/core.module.ts index 067bb3a..feb3733 100644 --- a/mediarepo-ui/src/app/components/core/core.module.ts +++ b/mediarepo-ui/src/app/components/core/core.module.ts @@ -41,6 +41,7 @@ import { } from "./repositories-tab/repository-details-view/repository-details-view.component"; import { EmptyTabComponent } from './empty-tab/empty-tab.component'; import { RepositoryOverviewComponent } from './repositories-tab/repository-overview/repository-overview.component'; +import { AboutDialogComponent } from './repositories-tab/repository-overview/about-dialog/about-dialog.component'; @NgModule({ @@ -56,6 +57,7 @@ import { RepositoryOverviewComponent } from './repositories-tab/repository-overv RepositoryDetailsViewComponent, EmptyTabComponent, RepositoryOverviewComponent, + AboutDialogComponent, ], exports: [ CoreComponent, diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.html b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.html new file mode 100644 index 0000000..9b57198 --- /dev/null +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.html @@ -0,0 +1,24 @@ +

+ About mediarepo +

+
+ + {{version | async}} + + + {{tauriVersion | async}} + +
+ +

Built with

+
+ + {{lib[0]}} + +
+
+
+ +
diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.scss b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.scss new file mode 100644 index 0000000..607eefd --- /dev/null +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.scss @@ -0,0 +1,20 @@ +.title { + text-align: center; +} + +.actions { + display: block; + + button { + float: right; + } +} + +.content { + text-align: center; +} + +.lib-list { + display: flex; + flex-direction: column; +} diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.spec.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.spec.ts new file mode 100644 index 0000000..e95648e --- /dev/null +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import {ComponentFixture, TestBed} from "@angular/core/testing"; + +import {AboutDialogComponent} from "./about-dialog.component"; + +describe("AboutDialogComponent", () => { + let component: AboutDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [AboutDialogComponent] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AboutDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.ts new file mode 100644 index 0000000..e4c49ed --- /dev/null +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/about-dialog/about-dialog.component.ts @@ -0,0 +1,31 @@ +import {ChangeDetectionStrategy, Component, OnInit} from "@angular/core"; +import {MatDialogRef} from "@angular/material/dialog"; +import {app} from "@tauri-apps/api"; +import {Subject} from "rxjs"; + +@Component({ + selector: "app-about-dialog", + templateUrl: "./about-dialog.component.html", + styleUrls: ["./about-dialog.component.scss"], + changeDetection: ChangeDetectionStrategy.Default +}) +export class AboutDialogComponent implements OnInit { + + public version = new Subject(); + public tauriVersion = new Subject(); + public usedLibs = [ + ["Tauri", "https://tauri.studio"], + ["Angular", "https://angular.io/"], + ["SeaORM", "https://www.sea-ql.org"], + ["Tokio", "https://tokio.rs/"], + ["bromine", "https://github.com/Trivernis/bromine"] + ]; + + constructor(public dialogRef: MatDialogRef) { + } + + public async ngOnInit() { + this.version.next(await app.getVersion()); + this.tauriVersion.next(await app.getTauriVersion()); + } +} diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/repository-overview.component.html b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/repository-overview.component.html index 6b9d51f..8220df4 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/repository-overview.component.html +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-overview/repository-overview.component.html @@ -1,7 +1,10 @@ + +

All Repositories

+ + +
-
- -
, dialog: MatDialogRef }; @@ -94,6 +95,13 @@ export class RepositoryOverviewComponent implements OnInit, AfterViewInit { } } + public openAboutDialog(): void { + this.dialog.open(AboutDialogComponent, { + minWidth: "30%", + minHeight: "50%", + }); + } + private async forceCloseRepository() { try { await this.repoService.closeSelectedRepository(); diff --git a/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts b/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts index a556c14..0a25e48 100644 --- a/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts +++ b/mediarepo-ui/src/app/components/shared/app-common/app-common.module.ts @@ -25,6 +25,7 @@ import {MatRippleModule} from "@angular/material/core"; import {FlapButtonComponent} from "./flap-button/flap-button.component"; import {MiddleCenteredComponent} from "./middle-centered/middle-centered.component"; import {FormatBytesPipe} from "./pipes/format-bytes.pipe"; +import {ExternalUrlComponent} from "./external-url/external-url.component"; @NgModule({ @@ -44,6 +45,7 @@ import {FormatBytesPipe} from "./pipes/format-bytes.pipe"; FlapButtonComponent, MiddleCenteredComponent, FormatBytesPipe, + ExternalUrlComponent, ], exports: [ ConfirmDialogComponent, @@ -60,6 +62,7 @@ import {FormatBytesPipe} from "./pipes/format-bytes.pipe"; FlapButtonComponent, MiddleCenteredComponent, FormatBytesPipe, + ExternalUrlComponent, ], imports: [ CommonModule, diff --git a/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.html b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.html new file mode 100644 index 0000000..7148987 --- /dev/null +++ b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.html @@ -0,0 +1,3 @@ + + + diff --git a/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.scss b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.scss new file mode 100644 index 0000000..3fccf25 --- /dev/null +++ b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.scss @@ -0,0 +1,15 @@ +@import "src/colors"; + +.highlight { + cursor: pointer; + color: $primary-lighter-20; + text-decoration: underline; + + &:hover { + color: $primary-lighter-30; + } + + &:active { + color: $accent; + } +} diff --git a/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.spec.ts b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.spec.ts new file mode 100644 index 0000000..77018c4 --- /dev/null +++ b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.spec.ts @@ -0,0 +1,25 @@ +import {ComponentFixture, TestBed} from "@angular/core/testing"; + +import {ExternalUrlComponent} from "./external-url.component"; + +describe("ExternalUrlComponent", () => { + let component: ExternalUrlComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ExternalUrlComponent] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ExternalUrlComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.ts b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.ts new file mode 100644 index 0000000..7d3c10b --- /dev/null +++ b/mediarepo-ui/src/app/components/shared/app-common/external-url/external-url.component.ts @@ -0,0 +1,31 @@ +import {ChangeDetectionStrategy, Component, Input} from "@angular/core"; +import {shell} from "@tauri-apps/api"; + +@Component({ + selector: "app-external-url", + templateUrl: "./external-url.component.html", + styleUrls: ["./external-url.component.scss"], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class ExternalUrlComponent { + + @Input() href!: string; + private opening = false; + + constructor() { + } + + public async openUrl() { + if (this.opening) { + return; + } + this.opening = true; + try { + await shell.open(this.href); + } catch (err) { + console.error(err); + } finally { + this.opening = false; + } + } +} diff --git a/mediarepo-ui/src/app/components/shared/app-common/metadata-entry/metadata-entry.component.html b/mediarepo-ui/src/app/components/shared/app-common/metadata-entry/metadata-entry.component.html index 9edc4cb..22dfb2f 100644 --- a/mediarepo-ui/src/app/components/shared/app-common/metadata-entry/metadata-entry.component.html +++ b/mediarepo-ui/src/app/components/shared/app-common/metadata-entry/metadata-entry.component.html @@ -1,4 +1,6 @@ -