From 6dda34f54510c31ff36d58ed47c8e5193466b3f2 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Sat, 17 Sep 2022 11:30:47 -0500 Subject: [PATCH] Add hyshare integration to file info sheet --- src/app/app.module.ts | 4 +- .../file-info-sheet.component.html | 104 +++++++++++------- .../file-info-sheet.component.scss | 8 ++ .../file-info-sheet.component.ts | 9 +- src/app/settings.service.ts | 12 +- src/app/settings.ts | 4 +- src/app/settings/settings.component.html | 5 + 7 files changed, 97 insertions(+), 49 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 77300c1..645b359 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -40,6 +40,7 @@ import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {PortalModule} from '@angular/cdk/portal'; import {ScrollingModule} from '@angular/cdk/scrolling'; +import {ClipboardModule} from '@angular/cdk/clipboard'; import { ReactiveFormsModule } from '@angular/forms'; @@ -125,7 +126,8 @@ const MAT_MODULES = [ LayoutModule, ReactiveFormsModule, VirtualScrollerModule, - NgPipesModule + NgPipesModule, + ClipboardModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/file-info-sheet/file-info-sheet.component.html b/src/app/file-info-sheet/file-info-sheet.component.html index 60cd606..84817a0 100644 --- a/src/app/file-info-sheet/file-info-sheet.component.html +++ b/src/app/file-info-sheet/file-info-sheet.component.html @@ -1,54 +1,74 @@ -

File Info

- - - {{fileIcon}} -
{{data.file.file_id}}
- -
- - {{data.file.is_inbox ? "inbox" : data.file.is_trashed ? "delete" : "archive"}} -
{{data.file.is_inbox ? "In Inbox" : data.file.is_trashed ? "In Trash" : "Archived"}}
- - open_in_new - +
+

File Info

+
- - - - - Known URLs ({{data.file.known_urls.length}}) - - - - - {{ url }} - + + + open_in_new + Open file in new tab + + + + +
+
+
+ + + {{fileIcon}} +
{{data.file.file_id}}
+
- - -
- -
-

Tags

- - + + {{data.file.is_inbox ? "inbox" : data.file.is_trashed ? "delete" : "archive"}} +
{{data.file.is_inbox ? "In Inbox" : data.file.is_trashed ? "In Trash" : "Archived"}}
+
+ + - {{service.serviceName}} ({{service.statuses[0].length}}) + Known URLs ({{data.file.known_urls.length}}) - - - - {{tag}} - - - + + + + {{ url }} + + + -
+
+ +
+

Tags

+ + + + {{service.serviceName}} ({{service.statuses[0].length}}) + + + + + {{tag}} + + + + + +
diff --git a/src/app/file-info-sheet/file-info-sheet.component.scss b/src/app/file-info-sheet/file-info-sheet.component.scss index ebb07fe..0d01d36 100644 --- a/src/app/file-info-sheet/file-info-sheet.component.scss +++ b/src/app/file-info-sheet/file-info-sheet.component.scss @@ -7,3 +7,11 @@ .mat-list { padding-top: 0; } + +.sheet-title { + margin-top: 0; +} + +.title-row { + margin-top: 8px; +} diff --git a/src/app/file-info-sheet/file-info-sheet.component.ts b/src/app/file-info-sheet/file-info-sheet.component.ts index 4b6a51f..4ac8ef5 100644 --- a/src/app/file-info-sheet/file-info-sheet.component.ts +++ b/src/app/file-info-sheet/file-info-sheet.component.ts @@ -5,6 +5,7 @@ import { HydrusFilesService } from '../hydrus-files.service'; import { saveAs } from 'file-saver'; import { MatSnackBar } from '@angular/material/snack-bar'; import { tagsObjectFromFile } from '../utils/tag-utils'; +import { SettingsService } from '../settings.service'; interface ShareData { title?: string; @@ -32,7 +33,8 @@ export class FileInfoSheetComponent { constructor( @Inject(MAT_BOTTOM_SHEET_DATA) public data: {file: HydrusFile}, private filesService: HydrusFilesService, - private snackbar: MatSnackBar + private snackbar: MatSnackBar, + public settings: SettingsService, ) { } tags = Object.entries(tagsObjectFromFile(this.data.file)) @@ -56,6 +58,11 @@ export class FileInfoSheetComponent { navigatorShare = navigator.share; navigatorCanShare = navigator.canShare; + hyshareUrl = + this.settings.appSettings.hyshareUrl && !this.settings.appSettings.hyshareUrl.endsWith('/') + ? `${this.settings.appSettings.hyshareUrl}/` + : this.settings.appSettings.hyshareUrl; + shareUrl(url: string) { if (navigator.share) { navigator.share({ diff --git a/src/app/settings.service.ts b/src/app/settings.service.ts index c885f64..1c3ba34 100644 --- a/src/app/settings.service.ts +++ b/src/app/settings.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { LocalStorageService } from 'ngx-localstorage'; import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs'; -import { AppSettings, defaultAppSettings } from './settings'; +import { AppSettings, AppSettingsStorage, defaultAppSettings } from './settings'; @Injectable({ providedIn: 'root' @@ -17,8 +17,8 @@ export class SettingsService { public appSettings$: Observable; constructor(private ls: LocalStorageService) { - const appSettingsFromStorage = ls.get(this.appSettingsKey) as AppSettings | null; - this._appSettings = {...defaultAppSettings, ...appSettingsFromStorage}; + const {version, ...settings} = ls.get(this.appSettingsKey) as AppSettingsStorage | null || {}; + this._appSettings = {...defaultAppSettings, ...settings}; this._appSettings$ = new BehaviorSubject(this._appSettings); this.appSettings$ = this._appSettings$.asObservable(); console.log(this.appSettings); @@ -29,10 +29,14 @@ export class SettingsService { return this._appSettings; } + private async storeAppSettings(settings: AppSettingsStorage) { + return this.ls.asPromisable().set(this.appSettingsKey, settings); + } + public async setAppSettings(newSettings: Partial) { this._appSettings = {...defaultAppSettings, ...newSettings}; this._appSettings$.next(this._appSettings); - return this.ls.asPromisable().set(this.appSettingsKey, this._appSettings); + this.storeAppSettings({version : 1, ...this._appSettings}) } diff --git a/src/app/settings.ts b/src/app/settings.ts index 915b4ba..d72d97e 100644 --- a/src/app/settings.ts +++ b/src/app/settings.ts @@ -6,6 +6,7 @@ export interface AppSettingsV1 { browseSearchOnLoad: boolean; browseSearchWhenEmpty: boolean; browseDefaultSearchTags: HydrusSearchTags; + hyshareUrl: string; } export type AppSettingsStorage = AppSettingsV1; @@ -14,5 +15,6 @@ export type AppSettings = Omit; export const defaultAppSettings: AppSettings = { browseSearchOnLoad: true, browseSearchWhenEmpty: true, - browseDefaultSearchTags: [] + browseDefaultSearchTags: [], + hyshareUrl: '' } diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 7925997..3a056a3 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -23,6 +23,11 @@ Search immediately on the browse page Search with no tags entered + + + hyshare base URL + +