mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-08 13:51:28 +03:00
Added ability to generate RSS feed URLs from the UI
Moved property sorting into its own component
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<div>
|
||||
<div style="display: inline-block;">
|
||||
<mat-form-field appearance="outline" style="width: 165px;">
|
||||
<mat-select [(ngModel)]="this.sortProperty" (selectionChange)="emitSortOptionChanged()">
|
||||
<mat-option *ngFor="let sortOption of sortProperties | keyvalue" [value]="sortOption.key">
|
||||
{{sortOption['value']['label']}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="sort-dir-div">
|
||||
<button (click)="toggleModeChange()" mat-icon-button><mat-icon>{{descendingMode ? 'arrow_downward' : 'arrow_upward'}}</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
.sort-dir-div {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SortPropertyComponent } from './sort-property.component';
|
||||
|
||||
describe('SortPropertyComponent', () => {
|
||||
let component: SortPropertyComponent;
|
||||
let fixture: ComponentFixture<SortPropertyComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SortPropertyComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SortPropertyComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
54
src/app/components/sort-property/sort-property.component.ts
Normal file
54
src/app/components/sort-property/sort-property.component.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Component, Input, EventEmitter, Output } from '@angular/core';
|
||||
import { Sort } from 'api-types';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sort-property',
|
||||
templateUrl: './sort-property.component.html',
|
||||
styleUrls: ['./sort-property.component.scss']
|
||||
})
|
||||
export class SortPropertyComponent {
|
||||
sortProperties = {
|
||||
'registered': {
|
||||
'key': 'registered',
|
||||
'label': $localize`Download Date`
|
||||
},
|
||||
'upload_date': {
|
||||
'key': 'upload_date',
|
||||
'label': $localize`Upload Date`
|
||||
},
|
||||
'title': {
|
||||
'key': 'title',
|
||||
'label': $localize`Name`
|
||||
},
|
||||
'size': {
|
||||
'key': 'size',
|
||||
'label': $localize`File Size`
|
||||
},
|
||||
'duration': {
|
||||
'key': 'duration',
|
||||
'label': $localize`Duration`
|
||||
}
|
||||
};
|
||||
|
||||
@Input() sortProperty = 'registered';
|
||||
@Input() descendingMode = true;
|
||||
|
||||
@Output() sortPropertyChange = new EventEmitter<unknown>();
|
||||
@Output() descendingModeChange = new EventEmitter<number>();
|
||||
@Output() sortOptionChanged = new EventEmitter<Sort>();
|
||||
|
||||
toggleModeChange(): void {
|
||||
this.descendingMode = !this.descendingMode;
|
||||
this.emitSortOptionChanged();
|
||||
}
|
||||
|
||||
emitSortOptionChanged(): void {
|
||||
if (!this.sortProperty || !this.sortProperties[this.sortProperty]) {
|
||||
return;
|
||||
}
|
||||
this.sortOptionChanged.emit({
|
||||
by: this.sortProperty,
|
||||
order: this.descendingMode ? -1 : 1
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user