-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c95ec6
commit a32e163
Showing
9 changed files
with
210 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<h1 mat-dialog-title>SauceNAO Lookup</h1> | ||
<div mat-dialog-content> | ||
<div *ngIf="saucenaoResults$ | async as saucenaoResults; else loading"> | ||
<mat-card *ngFor="let result of saucenaoResults" class="saucenao-card"> | ||
<mat-card-header> | ||
<img mat-card-avatar class="saucenao-thumbnail" [src]="result.thumbnail"> | ||
<mat-card-title>{{result.site}}{{result.authorName ? ' - ' + result.authorName : ''}}</mat-card-title> | ||
<mat-card-subtitle>{{result.similarity}}%</mat-card-subtitle> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<mat-list class="saucenao-url-list"> | ||
<mat-list-item *ngFor="let url of result.urls"> | ||
<div mat-line>{{url.site}}</div> | ||
<div mat-line>{{url.url}}</div> | ||
<a mat-icon-button rel="noopener noreferrer" target="_blank" href="{{url.url}}" title="Open URL in new tab"> | ||
<mat-icon>open_in_new</mat-icon> | ||
</a> | ||
<button mat-icon-button (click)="send(url.url)" title="Send to Hydrus"> | ||
<mat-icon>send</mat-icon> | ||
</button> | ||
</mat-list-item> | ||
</mat-list> | ||
</mat-card-content> | ||
</mat-card> | ||
<mat-card *ngIf="saucenaoResults.length === 0" class="saucenao-card"> | ||
<mat-card-header> | ||
<mat-icon mat-card-avatar>error</mat-icon> | ||
<mat-card-title>No results found</mat-card-title> | ||
</mat-card-header> | ||
</mat-card> | ||
</div> | ||
<ng-template #loading> | ||
<mat-spinner class="saucenao-spinner"></mat-spinner> | ||
</ng-template> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.saucenao-thumbnail { | ||
border-radius: 4px !important; | ||
} | ||
|
||
.metadata-line span:not(:last-of-type) { | ||
margin-right: 20px; | ||
} | ||
|
||
.saucenao-card, .url-info-card { | ||
margin-top: 16px; | ||
} | ||
|
||
.saucenao-results { | ||
margin-top: 16px; | ||
} | ||
.saucenao-spinner { | ||
margin: 32px auto 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SaucenaoDialogComponent } from './saucenao-dialog.component'; | ||
|
||
describe('SaucenaoDialogComponent', () => { | ||
let component: SaucenaoDialogComponent; | ||
let fixture: ComponentFixture<SaucenaoDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ SaucenaoDialogComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SaucenaoDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Component, Inject, OnInit } from '@angular/core'; | ||
import { MatDialog, MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { MatSnackBar } from '@angular/material/snack-bar'; | ||
import { catchError, Observable } from 'rxjs'; | ||
import { AddUrlOptions, HydrusAddService } from '../hydrus-add.service'; | ||
import { SaucenaoService, SaucenaoResults, SaucenaoUrlorFile } from '../saucenao.service'; | ||
|
||
interface SaucenaoDialogData { | ||
urlOrFile: SaucenaoUrlorFile; | ||
addUrlOptions?: AddUrlOptions; | ||
}; | ||
|
||
@Component({ | ||
selector: 'app-saucenao-dialog', | ||
templateUrl: './saucenao-dialog.component.html', | ||
styleUrls: ['./saucenao-dialog.component.scss'] | ||
}) | ||
export class SaucenaoDialogComponent implements OnInit { | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<SaucenaoDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: SaucenaoDialogData, | ||
public saucenaoService: SaucenaoService, | ||
private addService: HydrusAddService, | ||
private snackbar: MatSnackBar | ||
) { } | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
saucenaoResults$: Observable<SaucenaoResults[]> = this.saucenaoService.search(this.data.urlOrFile).pipe( | ||
catchError((err, caught) => { | ||
this.snackbar.open('Error: ' + err.message, undefined, { | ||
duration: 5000 | ||
}); | ||
throw err; | ||
}) | ||
) | ||
|
||
send(url: string) { | ||
this.addService.addUrl(url, this.data.addUrlOptions).subscribe(res => { | ||
this.snackbar.open(res.human_result_text, undefined, { | ||
duration: 5000 | ||
}); | ||
}, error => { | ||
console.log(error); | ||
this.snackbar.open(`Error: ${error.message}`, undefined, { | ||
duration: 10000 | ||
}); | ||
}); | ||
} | ||
|
||
static open(dialog: MatDialog, data?: SaucenaoDialogData, config?: MatDialogConfig<SaucenaoDialogData>) { | ||
return dialog.open<SaucenaoDialogComponent, SaucenaoDialogData, undefined>( | ||
SaucenaoDialogComponent, | ||
{ | ||
width: '80vw', | ||
data, | ||
...config | ||
} | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters