Skip to content

Commit

Permalink
Added button to tag panel to quickly add new tags
Browse files Browse the repository at this point in the history
Also moved download link to be the path to the file
  • Loading branch information
SimplyBoo6 committed Dec 1, 2023
1 parent 9295b42 commit 33f2127
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .env

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ test*.sh
test_data*
dump/*
version
data/
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="card tag-panel margin-bottom">
<div class="card-header card-small tag-header">
Tags
<a *ngIf="media" [href]="'/api/images/' + media.hash + '/file?download=true'">Download</a>
<button class="btn btn-primary ms-auto" (click)="createTag()"><fa-icon [icon]="faPlus"></fa-icon></button>
</div>
<div *ngIf="tagsModel && media && columnIndexes && columnTags; else loading" class="card-body card-small tag-list">
<div class="tag-list-column" *ngFor="let i of columnIndexes">
Expand Down
4 changes: 4 additions & 0 deletions client/src/app/components/tag-panel/tag-panel.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
.tag-header {
height: 2rem;
min-width: 10rem;

& > button {
width: 1.5rem;
}
}

.tag-label {
Expand Down
33 changes: 32 additions & 1 deletion client/src/app/components/tag-panel/tag-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { MediaService } from 'services/media.service';
import { PlaylistService } from 'services/playlist.service';
import { TagService } from 'services/tag.service';
import { ActorService } from 'services/actor.service';
import { Subscription } from 'rxjs';
import { PromptService } from 'services/prompt.service';
import { Subscription, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { ListItem, toListItems } from 'app/shared/types';
import { faPlus } from '@fortawesome/free-solid-svg-icons';

const DEFAULT_COLUMN_COUNT = 1;

Expand All @@ -22,6 +25,7 @@ interface MetadataModel {
styleUrls: ['./tag-panel.component.scss'],
})
export class TagPanelComponent implements OnInit, OnDestroy, AfterViewChecked {
public readonly faPlus = faPlus;
public tagsModel?: Record<string, boolean>;
public ratingModel = 0;
public actorsModel?: string[];
Expand All @@ -44,6 +48,7 @@ export class TagPanelComponent implements OnInit, OnDestroy, AfterViewChecked {
@ViewChild('ratingElement', { static: false }) private ratingElement: any;
private configService: ConfigService;
private tagService: TagService;
private promptService: PromptService;
private subscriptions: Subscription[] = [];

public constructor(
Expand All @@ -52,12 +57,14 @@ export class TagPanelComponent implements OnInit, OnDestroy, AfterViewChecked {
tagService: TagService,
actorService: ActorService,
playlistService: PlaylistService,
promptService: PromptService,
) {
this.configService = configService;
this.mediaService = mediaService;
this.tagService = tagService;
this.actorService = actorService;
this.playlistService = playlistService;
this.promptService = promptService;
}

public ngOnInit() {
Expand Down Expand Up @@ -168,6 +175,30 @@ export class TagPanelComponent implements OnInit, OnDestroy, AfterViewChecked {
}
}

public createTag(): void {
this.subscriptions.push(
from(this.promptService.prompt('Enter Tag'))
.pipe(
map(tag => {
if (!tag || !tag.trim()) {
return;
}
console.log(tag);
this.mediaService.addTag(tag);
}),
)
.subscribe(
() => {
// Nothing to do
},
err => {
// TODO
console.error(err);
},
),
);
}

private updateColumnIndexes(): void {
const count = (this.config && this.config.user.tagColumnCount) || DEFAULT_COLUMN_COUNT;
const indexes: number[] = [];
Expand Down
8 changes: 6 additions & 2 deletions client/src/app/components/viewer/viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
<app-tag-panel></app-tag-panel>
</div>
<div class="right-panel full-height">
<div *ngIf="media && tagsOpen && config && config.user.quickTagShowPath && mediaSrc" class="text-overlay">
<a
[href]="'/api/images/' + media.hash + '/file?download=true'"
*ngIf="media && tagsOpen && config && config.user.quickTagShowPath && mediaSrc"
class="text-overlay"
>
{{ media.path }}
</div>
</a>
<div *ngIf="media && media.autoTags && tagsOpen && config && config.user.quickTagShowAutoTags" class="text-overlay bottom">
May contain: {{ media.autoTags | formatArray }}
</div>
Expand Down
8 changes: 8 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export PORT=8444
export DATABASE=mongodb
export DATABASE_URI=mongodb://root:root@localhost:27017
export DATABASE_DB=vimtur
export CACHE_PATH=$(pwd)/data/cache
export DATA_PATH=$(pwd)/data/raw

mkdir -p "${CACHE_PATH}" "${DATA_PATH}"
3 changes: 3 additions & 0 deletions start-mongodb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

docker run -v /data/db --restart unless-stopped -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root -p 27017:27017 -d mongo:4

0 comments on commit 33f2127

Please sign in to comment.