feat: add dialog about playlist details

This commit is contained in:
4gray committed 2021-02-17 19:04:16 +01:00
1 parent 97a9f91c46
commit 9f951fa017
8 files changed
+110 -1

No files matched your search

+3 -1
View File
@@ -7,14 +7,16 @@ import { UrlUploadComponent } from './url-upload/url-upload.component';
import { RecentPlaylistsComponent } from './recent-playlists/recent-playlists.component'; import { RecentPlaylistsComponent } from './recent-playlists/recent-playlists.component';
import { HomeRoutingModule } from './home.routing'; import { HomeRoutingModule } from './home.routing';
import { NgxUploaderModule } from 'ngx-uploader'; import { NgxUploaderModule } from 'ngx-uploader';
import { PlaylistInfoComponent } from './recent-playlists/playlist-info/playlist-info.component';
@NgModule({ @NgModule({
imports: [CommonModule, HomeRoutingModule, NgxUploaderModule, SharedModule], imports: [CommonModule, HomeRoutingModule, NgxUploaderModule, SharedModule],
declarations: [ declarations: [
HomeComponent, HomeComponent,
FileUploadComponent, FileUploadComponent,
UrlUploadComponent, PlaylistInfoComponent,
RecentPlaylistsComponent, RecentPlaylistsComponent,
UrlUploadComponent,
], ],
}) })
export class HomeModule {} export class HomeModule {}
@@ -0,0 +1,24 @@
<h2 mat-dialog-title>Playlist details</h2>
<mat-dialog-content class="mat-typography">
<mat-form-field class="full-width">
<mat-label>Title</mat-label>
<input matInput [value]="playlist.title" disabled="true" />
</mat-form-field>
<mat-form-field class="full-width" *ngIf="playlist.url">
<mat-label>Added from the URL</mat-label>
<input matInput [value]="playlist.url" disabled="true" />
</mat-form-field>
<mat-form-field class="full-width">
<mat-label>Import date</mat-label>
<input matInput [value]="playlist.importDate | date" disabled="true" />
</mat-form-field>
<mat-form-field class="full-width">
<mat-label>Number of channels</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="primary">
CLOSE
</button>
</mat-dialog-actions>
Whitespace-only changes.
@@ -0,0 +1,34 @@
import { MockModule } from 'ng-mocks';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { PlaylistInfoComponent } from './playlist-info.component';
describe('PlaylistInfoComponent', () => {
let component: PlaylistInfoComponent;
let fixture: ComponentFixture<PlaylistInfoComponent>;
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
MockModule(MatDialogModule),
MockModule(MatFormFieldModule),
],
declarations: [PlaylistInfoComponent],
providers: [{ provide: MAT_DIALOG_DATA, useValue: {} }],
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(PlaylistInfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,21 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Playlist } from '../../playlist.interface';
@Component({
selector: 'app-playlist-info',
templateUrl: './playlist-info.component.html',
styleUrls: ['./playlist-info.component.scss'],
})
export class PlaylistInfoComponent {
/** Playlist object */
playlist: Playlist;
/**
* Creates an instance of the component and injects the selected playlist from the parent component
* @param data playlist object to show
*/
constructor(@Inject(MAT_DIALOG_DATA) playlist: Playlist) {
this.playlist = playlist;
}
}
@@ -30,6 +30,14 @@
| Added: {{ item.importDate | date }} | Added: {{ item.importDate | date }}
</ng-container> </ng-container>
</div> </div>
<button
mat-icon-button
color="primary"
(click)="$event.stopPropagation(); openInfoDialog(item)"
matTooltip="Show playlist details"
>
<mat-icon>info</mat-icon>
</button>
<button <button
mat-icon-button mat-icon-button
color="primary" color="primary"
@@ -1,5 +1,7 @@
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Playlist } from '../playlist.interface'; import { Playlist } from '../playlist.interface';
import { MatDialog } from '@angular/material/dialog';
import { PlaylistInfoComponent } from './playlist-info/playlist-info.component';
@Component({ @Component({
selector: 'app-recent-playlists', selector: 'app-recent-playlists',
@@ -18,4 +20,20 @@ export class RecentPlaylistsComponent {
/** Emits on playlist rename click */ /** Emits on playlist rename click */
@Output() renameClicked: EventEmitter<Playlist> = new EventEmitter(); @Output() renameClicked: EventEmitter<Playlist> = new EventEmitter();
/**
* Creates an instance of the component
* @param dialog angular material dialog reference
*/
constructor(public dialog: MatDialog) {}
/**
* Opens the details dialog with the information about the provided playlist
* @param data selected playlist
*/
openInfoDialog(data: Playlist): void {
this.dialog.open(PlaylistInfoComponent, {
data,
});
}
} }
+2
View File
@@ -14,11 +14,13 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
import { ScrollingModule } from '@angular/cdk/scrolling'; import { ScrollingModule } from '@angular/cdk/scrolling';
import { MatGridListModule } from '@angular/material/grid-list'; import { MatGridListModule } from '@angular/material/grid-list';
import { MatTooltipModule } from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip';
import { MatDialogModule } from '@angular/material/dialog';
@NgModule({ @NgModule({
exports: [ exports: [
MatButtonModule, MatButtonModule,
MatCardModule, MatCardModule,
MatDialogModule,
MatExpansionModule, MatExpansionModule,
MatIconModule, MatIconModule,
MatInputModule, MatInputModule,