Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital committed May 18, 2024
1 parent 90ebf39 commit 72c2789
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 109 deletions.
6 changes: 3 additions & 3 deletions webui/src/app/pipes/human-time.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HumanTimePipe } from './human-time.pipe';
import { HumanTimePipe } from "./human-time.pipe";

describe('HumanTimePipe', () => {
it('create an instance', () => {
describe("HumanTimePipe", () => {
it("create an instance", () => {
const pipe = new HumanTimePipe();
expect(pipe).toBeTruthy();
});
Expand Down
30 changes: 15 additions & 15 deletions webui/src/app/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,15 @@
matInput
placeholder="Search"
[formControl]="queryString"
(blur)="
search.setQueryString(queryString.value ?? '');
"
(keyup.enter)="
search.setQueryString(queryString.value ?? '');
"
(blur)="search.setQueryString(queryString.value ?? '')"
(keyup.enter)="search.setQueryString(queryString.value ?? '')"
/>
@if (queryString.value) {
<button
matSuffix
mat-icon-button
aria-label="Clear"
(click)="
queryString.reset();
search.setQueryString('');
"
(click)="queryString.reset(); search.setQueryString('')"
>
<mat-icon>close</mat-icon>
</button>
Expand All @@ -123,10 +116,13 @@
[value]="search.orderBySubject.getValue().field"
(valueChange)="search.selectOrderBy($event)"
>
@for (option of search.orderByOptions | keyvalue: originalOrder; track option.key) {
@for (
option of search.orderByOptions | keyvalue: originalOrder;
track option.key
) {
@if (option.key != "Relevance" || queryString.value) {
<mat-option [value]="option.key">
{{option.value?.label}}
{{ option.value?.label }}
</mat-option>
}
}
Expand All @@ -138,7 +134,11 @@
matTooltip="Toggle direction"
(click)="search.toggleOrderByDirection()"
>
<mat-icon>{{search.orderBySubject.getValue().descending ? "arrow_downward" : "arrow_upward"}}</mat-icon>
<mat-icon>{{
search.orderBySubject.getValue().descending
? "arrow_downward"
: "arrow_upward"
}}</mat-icon>
</button>
</div>
<div class="button-refresh">
Expand Down Expand Up @@ -386,7 +386,7 @@
<th mat-header-cell *matHeaderCellDef>Published</th>
<td class="td-published-at" mat-cell *matCellDef="let i">
<abbr
matTooltip="{{item(i).publishedAt}}"
matTooltip="{{ item(i).publishedAt }}"
matTooltipClass="tooltip-published-at"
>
{{ item(i).publishedAt | humanTime }}
Expand Down Expand Up @@ -430,7 +430,7 @@
<app-torrent-content
[torrentContent]="i"
(updated)="search.loadResult(false)"
/>
/>
</div>
</td>
</ng-container>
Expand Down
3 changes: 2 additions & 1 deletion webui/src/app/search/search.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
.field-search-order-by {
width: 160px;
}
.button-toggle-direction, .button-refresh {
.button-toggle-direction,
.button-refresh {
display: inline-block;
width: 50px;
vertical-align: top;
Expand Down
107 changes: 33 additions & 74 deletions webui/src/app/torrent/torrent-content.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

@if (
getAttribute("poster_path", "tmdb");
as posterPath
) {
@if (getAttribute("poster_path", "tmdb"); as posterPath) {
<img
[ngSrc]="'https://image.tmdb.org/t/p/w300/' + posterPath"
alt="Poster"
Expand All @@ -18,16 +14,12 @@ <h2>{{ torrentContent.torrent.name }}</h2>
class="info-hash"
matTooltip="Copy to clipboard"
[cdkCopyToClipboard]="torrentContent.infoHash"
>{{ torrentContent.infoHash }}</span
>{{ torrentContent.infoHash }}</span
>
</p>
<p>
<strong>Source:</strong>&nbsp;
@for (
s of torrentContent.torrent.sources;
let j = $index;
track s.key
) {
@for (s of torrentContent.torrent.sources; let j = $index; track s.key) {
<span>{{ (j > 0 ? ", " : "") + s.name }}</span>
}
</p>
Expand All @@ -40,10 +32,10 @@ <h2>{{ torrentContent.torrent.name }}</h2>
@for (l of torrentContent.languages; let j = $index; track l.id) {
{{
(j > 0 ? ", " : "") +
l.name +
(l.id === torrentContent.content?.originalLanguage?.id
? " (original)"
: "")
l.name +
(l.id === torrentContent.content?.originalLanguage?.id
? " (original)"
: "")
}}
}
</p>
Expand Down Expand Up @@ -71,27 +63,20 @@ <h2>{{ torrentContent.torrent.name }}</h2>
}
@if (torrentContent.content?.voteAverage != null) {
<p>
<strong>Rating:</strong> {{ torrentContent.content?.voteAverage }} /
10
<strong>Rating:</strong> {{ torrentContent.content?.voteAverage }} / 10
@if (torrentContent.content?.voteCount != null) {
<ng-container
>({{ torrentContent.content?.voteCount }} votes)</ng-container
>({{ torrentContent.content?.voteCount }} votes)</ng-container
>
}
</p>
}
@if (torrentContent.content?.externalLinks; as externalLinks) {
<p>
<strong>External links:</strong>&nbsp;
@for (
l of externalLinks;
let j = $index;
track l.metadataSource.key
) {
@for (l of externalLinks; let j = $index; track l.metadataSource.key) {
{{ j > 0 ? ", " : ""
}}<a [href]="l.url" target="_blank">{{
l.metadataSource.name
}}</a>
}}<a [href]="l.url" target="_blank">{{ l.metadataSource.name }}</a>
}
</p>
}
Expand All @@ -101,9 +86,7 @@ <h2>{{ torrentContent.torrent.name }}</h2>
<mat-tab-group
animationDuration="0"
[selectedIndex]="selectedTabIndex"
(focusChange)="
selectTab($event.index == 4 ? 0 : $event.index)
"
(focusChange)="selectTab($event.index == 4 ? 0 : $event.index)"
[mat-stretch-tabs]="false"
>
<mat-tab [aria-labelledby]="'hidden'"></mat-tab>
Expand All @@ -113,7 +96,7 @@ <h2>{{ torrentContent.torrent.name }}</h2>
<mat-icon>file_present</mat-icon>
Files
@if (filesCount(); as filesCount) {
<span class="files-count">({{filesCount | number}})</span>
<span class="files-count">({{ filesCount | number }})</span>
}
</ng-template>

Expand All @@ -128,19 +111,16 @@ <h2>{{ torrentContent.torrent.name }}</h2>
}}<br />
@if (torrentContent.torrent.fileType; as ft) {
<span
><strong>File type: </strong>
{{ ft!.charAt(0).toUpperCase() + ft!.slice(1)
}}<br
/></span>
><strong>File type: </strong>
{{ ft!.charAt(0).toUpperCase() + ft!.slice(1) }}<br
/></span>
}
<strong>File size:</strong>
{{ torrentContent.torrent.size | filesize }}
</p>
}
@if (torrentContent.torrent.filesStatus === "multi") {
<p>
{{ torrentContent.torrent.files?.length | number }} files.
</p>
<p>{{ torrentContent.torrent.files?.length | number }} files.</p>
}
@if (torrentContent.torrent.filesStatus === "over_threshold") {
<p>
Expand All @@ -157,11 +137,11 @@ <h2>{{ torrentContent.torrent.name }}</h2>
@if (torrentContent.torrent.files?.length) {
<table>
<thead>
<tr>
<th>Path</th>
<th>Type</th>
<th>Size</th>
</tr>
<tr>
<th>Path</th>
<th>Type</th>
<th>Size</th>
</tr>
</thead>
<tbody>
@for (f of torrentContent.torrent.files; track f.path) {
Expand All @@ -173,7 +153,7 @@ <h2>{{ torrentContent.torrent.name }}</h2>
{{
f.fileType
? f.fileType.charAt(0).toUpperCase() +
f.fileType.slice(1)
f.fileType.slice(1)
: "Unknown"
}}
</td>
Expand All @@ -199,23 +179,18 @@ <h2>{{ torrentContent.torrent.name }}</h2>
<mat-form-field class="form-edit-tags">
<mat-chip-grid #chipGrid aria-label="Enter tags">
@for (
tagName of torrentContent.torrent.tagNames;
tagName of torrentContent.torrent.tagNames;
let j = $index;
track tagName
) {
) {
<mat-chip-row
[editable]="true"
(edited)="
renameTag(tagName, $event.value)
"
(edited)="renameTag(tagName, $event.value)"
(removed)="deleteTag(tagName)"
[aria-description]="'press enter to edit'"
>
{{ tagName }}
<button
matChipRemove
[attr.aria-label]="'remove ' + tagName"
>
<button matChipRemove [attr.aria-label]="'remove ' + tagName">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
Expand All @@ -227,24 +202,15 @@ <h2>{{ torrentContent.torrent.name }}</h2>
[matAutocomplete]="auto"
[matChipInputFor]="chipGrid"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
(matChipInputTokenEnd)="
$event.value && addTag($event.value)
"
(matChipInputTokenEnd)="$event.value && addTag($event.value)"
[value]="newTagCtrl.value"
/>
<mat-autocomplete
#auto="matAutocomplete"
(optionSelected)="
addTag($event.option.viewValue)
"
(optionSelected)="addTag($event.option.viewValue)"
>
@for (
tagName of suggestedTags;
track tagName
) {
<mat-option [value]="tagName">{{
tagName
}}</mat-option>
@for (tagName of suggestedTags; track tagName) {
<mat-option [value]="tagName">{{ tagName }}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
Expand All @@ -262,19 +228,12 @@ <h2>{{ torrentContent.torrent.name }}</h2>
<mat-card>
<mat-card-content style="margin-top: 10px">
<p>
<strong
>Are you sure you want to delete this
torrent?</strong
>
<strong>Are you sure you want to delete this torrent?</strong>
<br />This action cannot be undone.
</p>
</mat-card-content>
<mat-card-actions class="button-row">
<button
mat-stroked-button
color="warn"
(click)="delete()"
>
<button mat-stroked-button color="warn" (click)="delete()">
<mat-icon>delete_forever</mat-icon>Delete
</button>
</mat-card-actions>
Expand Down
15 changes: 7 additions & 8 deletions webui/src/app/torrent/torrent-content.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from "@angular/core/testing";

import { TorrentContentComponent } from './torrent-content.component';
import { TorrentContentComponent } from "./torrent-content.component";

describe('TorrentContentComponent', () => {
describe("TorrentContentComponent", () => {
let component: TorrentContentComponent;
let fixture: ComponentFixture<TorrentContentComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TorrentContentComponent]
})
.compileComponents();

imports: [TorrentContentComponent],
}).compileComponents();

fixture = TestBed.createComponent(TorrentContentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
it("should create", () => {
expect(component).toBeTruthy();
});
});
12 changes: 4 additions & 8 deletions webui/src/app/torrent/torrent.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';


import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";

@NgModule({
declarations: [],
imports: [
CommonModule
]
imports: [CommonModule],
})
export class TorrentModule { }
export class TorrentModule {}

0 comments on commit 72c2789

Please sign in to comment.