Bookmark Refactor (#893)

* Fixed a bug which didn't take sort direction when not changing sort field

* Added foundation for Bookmark refactor

* Code broken, need to take a break. Issue is Getting bookmark image needs authentication but UI doesn't send.

* Implemented the ability to send bookmarked files to the web. Implemented ability to clear bookmarks on disk on a re-occuring basis.

* Updated the bookmark design to have it's own card that is self contained. View bookmarks modal has been updated to better lay out the cards.

* Refactored download bookmark codes to select files from bookmark directory directly rather than open underlying files.

* Wrote the basic logic to kick start the bookmark migration.

Added Installed Version into the DB to allow us to know more accurately when to run migrations

* Implemented the ability to change the bookmarks directory

* Updated all references to BookmarkDirectory to use setting from the DB.

Updated Server Settings page to use 2 col for some rows.

* Refactored some code to DirectoryService (hasWriteAccess) and fixed up some unit tests from a previous PR.

* Treat folders that start with ._ as blacklisted.

* Implemented Reset User preferences. Some extra code to prep for the migration.

* Implemented a migration for existing bookmarks to using new filesystem based bookmarks
This commit is contained in:
Joseph Milazzo 2022-01-05 09:56:49 -08:00 committed by GitHub
parent 04ffd1ef6f
commit a1a6333f09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 2006 additions and 103 deletions

View file

@ -36,6 +36,7 @@
<i class="fa fa-arrow-left mr-2" aria-hidden="true"></i>
Back
</button>
<button type="button" class="btn btn-primary float-right" [disabled]="routeStack.peek() === undefined" (click)="shareFolder('', $event)">Share</button>
</div>
</ul>
@ -50,6 +51,6 @@
</ul>
</div>
<div class="modal-footer">
<a class="btn btn-info" href="https://wiki.kavitareader.com/en/guides/adding-a-library" target="_blank">Help</a>
<a class="btn btn-info" *ngIf="helpUrl.length > 0" href="{{helpUrl}}" target="_blank">Help</a>
<button type="button" class="btn btn-secondary" (click)="close()">Cancel</button>
</div>

View file

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Stack } from 'src/app/shared/data-structures/stack';
import { LibraryService } from '../../../_services/library.service';
@ -17,6 +17,12 @@ export interface DirectoryPickerResult {
})
export class DirectoryPickerComponent implements OnInit {
@Input() startingFolder: string = '';
/**
* Url to give more information about selecting directories. Passing nothing will suppress.
*/
@Input() helpUrl: string = 'https://wiki.kavitareader.com/en/guides/adding-a-library';
currentRoot = '';
folders: string[] = [];
routeStack: Stack<string> = new Stack<string>();
@ -27,7 +33,22 @@ export class DirectoryPickerComponent implements OnInit {
}
ngOnInit(): void {
this.loadChildren(this.currentRoot);
if (this.startingFolder && this.startingFolder.length > 0) {
let folders = this.startingFolder.split('/');
let folders2 = this.startingFolder.split('\\');
if (folders.length === 1 && folders2.length > 1) {
folders = folders2;
}
if (!folders[0].endsWith('/')) {
folders[0] = folders[0] + '/';
}
folders.forEach(folder => this.routeStack.push(folder));
const fullPath = this.routeStack.items.join('/');
this.loadChildren(fullPath);
} else {
this.loadChildren(this.currentRoot);
}
}
filterFolder = (folder: string) => {
@ -38,7 +59,7 @@ export class DirectoryPickerComponent implements OnInit {
this.currentRoot = folderName;
this.routeStack.push(folderName);
const fullPath = this.routeStack.items.join('/');
this.loadChildren(fullPath);
this.loadChildren(fullPath);
}
goBack() {
@ -86,7 +107,7 @@ export class DirectoryPickerComponent implements OnInit {
if (lastPath && lastPath != path) {
let replaced = path.replace(lastPath, '');
if (replaced.startsWith('/') || replaced.startsWith('\\')) {
replaced = replaced.substr(1, replaced.length);
replaced = replaced.substring(1, replaced.length);
}
return replaced;
}
@ -95,14 +116,11 @@ export class DirectoryPickerComponent implements OnInit {
}
navigateTo(index: number) {
const numberOfPops = this.routeStack.items.length - index;
if (this.routeStack.items.length - numberOfPops > this.routeStack.items.length) {
this.routeStack.items = [];
}
for (let i = 0; i < numberOfPops; i++) {
while(this.routeStack.items.length - 1 > index) {
this.routeStack.pop();
}
this.loadChildren(this.routeStack.peek() || '');
const fullPath = this.routeStack.items.join('/');
this.loadChildren(fullPath);
}
}