mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-10 00:11:29 +03:00
Completed notification functionality
Minor code cleanup
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Notification } from 'api-types';
|
||||
import { NotificationAction } from 'api-types/models/NotificationAction';
|
||||
import { NotificationType } from 'api-types/models/NotificationType';
|
||||
|
||||
@Component({
|
||||
selector: 'app-notifications-list',
|
||||
templateUrl: './notifications-list.component.html',
|
||||
styleUrls: ['./notifications-list.component.scss']
|
||||
})
|
||||
export class NotificationsListComponent {
|
||||
@Input() notifications = null;
|
||||
@Output() deleteNotification = new EventEmitter<string>();
|
||||
@Output() notificationAction = new EventEmitter<{notification: Notification, action: NotificationAction}>();
|
||||
|
||||
NOTIFICATION_PREFIX: { [key in NotificationType]: string } = {
|
||||
download_complete: $localize`Finished downloading:`,
|
||||
download_error: $localize`Download failed:`
|
||||
}
|
||||
|
||||
// Attaches string to the end of the notification text
|
||||
NOTIFICATION_SUFFIX_KEY: { [key in NotificationType]: string } = {
|
||||
download_complete: 'file_title',
|
||||
download_error: 'file_url'
|
||||
}
|
||||
|
||||
NOTIFICATION_ACTION_TO_STRING: { [key in NotificationAction]: string } = {
|
||||
play: $localize`Play`,
|
||||
retry_download: $localize`Retry download`,
|
||||
view_download_error: $localize`View error`
|
||||
}
|
||||
|
||||
NOTIFICATION_COLOR: { [key in NotificationAction]: string } = {
|
||||
play: 'primary',
|
||||
retry_download: 'primary',
|
||||
view_download_error: 'warn'
|
||||
}
|
||||
|
||||
NOTIFICATION_ICON: { [key in NotificationAction]: string } = {
|
||||
play: 'smart_display',
|
||||
retry_download: 'restart_alt',
|
||||
view_download_error: 'warning'
|
||||
}
|
||||
|
||||
emitNotificationAction(notification: Notification, action: NotificationAction): void {
|
||||
this.notificationAction.emit({notification: notification, action: action});
|
||||
}
|
||||
|
||||
emitDeleteNotification(uid: string): void {
|
||||
this.deleteNotification.emit(uid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user