-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set custom user agent for a playlist
This commit closes the feature request from #26
- Loading branch information
Showing
8 changed files
with
176 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
// EPG related commands | ||
export const EPG_FETCH = 'EPG:FETCH'; | ||
export const EPG_FETCH_DONE = 'EPG:FETCH_DONE'; | ||
export const EPG_ERROR = 'EPG:ERROR'; | ||
export const EPG_GET_PROGRAM = 'EPG:GET_PROGRAM'; | ||
export const EPG_GET_PROGRAM_DONE = 'EPG:GET_PROGRAM_DONE'; | ||
|
||
// Playlist related commands | ||
export const PLAYLIST_SAVE_DETAILS = 'PLAYLIST:SAVE_DETAILS'; |
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 |
---|---|---|
|
@@ -14,4 +14,5 @@ export interface Playlist { | |
favorites: string[]; | ||
count: number; | ||
url?: string; | ||
userAgent?: string; | ||
} |
94 changes: 60 additions & 34 deletions
94
src/app/home/recent-playlists/playlist-info/playlist-info.component.html
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 |
---|---|---|
@@ -1,34 +1,60 @@ | ||
<h2 mat-dialog-title> | ||
{{ 'HOME.PLAYLISTS.INFO_DIALOG.PLAYLIST_DETAILS' | translate }} | ||
</h2> | ||
<mat-dialog-content class="mat-typography"> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.TITLE' | translate | ||
}}</mat-label> | ||
<input matInput [value]="playlist.title" disabled="true" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width" *ngIf="playlist.url"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.FROM_URL' | translate | ||
}}</mat-label> | ||
<input matInput [value]="playlist.url" disabled="true" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.IMPORT_DATE' | translate | ||
}}</mat-label> | ||
<input matInput [value]="playlist.importDate | date" disabled="true" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.CHANNELS' | translate | ||
}}</mat-label> | ||
<input matInput [value]="playlist.count" disabled="true" /> | ||
</mat-form-field> | ||
</mat-dialog-content> | ||
<mat-dialog-actions align="end"> | ||
<button mat-button mat-dialog-close cdkFocusInitial color="accent"> | ||
{{ 'HOME.PLAYLISTS.INFO_DIALOG.CLOSE' | translate }} | ||
</button> | ||
</mat-dialog-actions> | ||
<form | ||
[formGroup]="playlistDetails" | ||
(ngSubmit)="saveChanges(playlistDetails.value)" | ||
> | ||
<h2 mat-dialog-title> | ||
{{ 'HOME.PLAYLISTS.INFO_DIALOG.PLAYLIST_DETAILS' | translate }} | ||
</h2> | ||
<mat-dialog-content class="mat-typography"> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.TITLE' | translate | ||
}}</mat-label> | ||
<input formControlName="title" matInput /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width" *ngIf="playlist.url"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.FROM_URL' | translate | ||
}}</mat-label> | ||
<input matInput formControlName="url" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.ORIGINAL_FILENAME' | translate | ||
}}</mat-label> | ||
<input matInput formControlName="filename" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.IMPORT_DATE' | translate | ||
}}</mat-label> | ||
<input matInput formControlName="importDate" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.CHANNELS' | translate | ||
}}</mat-label> | ||
<input matInput formControlName="count" /> | ||
</mat-form-field> | ||
<mat-form-field class="full-width"> | ||
<mat-label>{{ | ||
'HOME.PLAYLISTS.INFO_DIALOG.USER_AGENT' | translate | ||
}}</mat-label> | ||
<input formControlName="userAgent" matInput /> | ||
</mat-form-field> | ||
</mat-dialog-content> | ||
<mat-dialog-actions align="end"> | ||
<button | ||
mat-flat-button | ||
mat-dialog-close | ||
color="accent" | ||
type="submit" | ||
[disabled]="!playlistDetails.valid || playlistDetails.pristine" | ||
> | ||
{{ 'HOME.PLAYLISTS.INFO_DIALOG.SAVE' | translate }} | ||
</button> | ||
<button mat-button mat-dialog-close cdkFocusInitial color="accent"> | ||
{{ 'HOME.PLAYLISTS.INFO_DIALOG.CLOSE' | translate }} | ||
</button> | ||
</mat-dialog-actions> | ||
</form> |
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
45 changes: 43 additions & 2 deletions
45
src/app/home/recent-playlists/playlist-info/playlist-info.component.ts
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 |
---|---|---|
@@ -1,21 +1,62 @@ | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
import { DatePipe } from '@angular/common'; | ||
import { Component, Inject } from '@angular/core'; | ||
import { | ||
FormBuilder, | ||
FormControl, | ||
FormGroup, | ||
Validators, | ||
} from '@angular/forms'; | ||
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { PLAYLIST_SAVE_DETAILS } from '../../../../../ipc-commands'; | ||
import { ElectronService } from '../../../services/electron.service'; | ||
import { Playlist } from '../../playlist.interface'; | ||
|
||
@Component({ | ||
selector: 'app-playlist-info', | ||
templateUrl: './playlist-info.component.html', | ||
styleUrls: ['./playlist-info.component.scss'], | ||
providers: [DatePipe], | ||
}) | ||
export class PlaylistInfoComponent { | ||
/** Playlist object */ | ||
playlist: Playlist; | ||
|
||
playlistDetails: FormGroup; | ||
|
||
/** | ||
* Creates an instance of the component and injects the selected playlist from the parent component | ||
* @param data playlist object to show | ||
* @param playlist playlist object to show | ||
*/ | ||
constructor(@Inject(MAT_DIALOG_DATA) playlist: Playlist) { | ||
constructor( | ||
@Inject(MAT_DIALOG_DATA) playlist: Playlist, | ||
datePipe: DatePipe, | ||
formBuilder: FormBuilder, | ||
private electronService: ElectronService | ||
) { | ||
this.playlist = playlist; | ||
this.playlistDetails = formBuilder.group({ | ||
_id: playlist._id, | ||
title: new FormControl(playlist.title, Validators.required), | ||
userAgent: playlist.userAgent || '', | ||
filename: new FormControl({ | ||
value: playlist.filename || '', | ||
disabled: true, | ||
}), | ||
count: new FormControl({ value: playlist.count, disabled: true }), | ||
importDate: new FormControl({ | ||
value: datePipe.transform(playlist.importDate), | ||
disabled: true, | ||
}), | ||
url: new FormControl({ value: playlist.url, disabled: true }), | ||
}); | ||
} | ||
|
||
/** | ||
* Saves updated playlist information | ||
* @param data updated form data | ||
*/ | ||
saveChanges(data: Pick<Playlist, '_id' | 'title' | 'userAgent'>): void { | ||
this.electronService.ipcRenderer.send(PLAYLIST_SAVE_DETAILS, data); | ||
} | ||
} |
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