mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* wip * remove transcode property; use i18n * add api * use computed table headers for i18npull/769/head
14 changed files with 166 additions and 18 deletions
@ -0,0 +1,5 @@ |
|||||||
|
using ErsatzTV.Core.Api.FFmpegProfiles; |
||||||
|
|
||||||
|
namespace ErsatzTV.Application.FFmpegProfiles; |
||||||
|
|
||||||
|
public record GetAllFFmpegProfilesForApi : IRequest<List<FFmpegProfileResponseModel>>; |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
using ErsatzTV.Core.Api.FFmpegProfiles; |
||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using ErsatzTV.Infrastructure.Data; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using static ErsatzTV.Application.FFmpegProfiles.Mapper; |
||||||
|
|
||||||
|
namespace ErsatzTV.Application.FFmpegProfiles; |
||||||
|
|
||||||
|
public class |
||||||
|
GetAllFFmpegProfilesForApiHandler : IRequestHandler<GetAllFFmpegProfilesForApi, List<FFmpegProfileResponseModel>> |
||||||
|
{ |
||||||
|
private readonly IDbContextFactory<TvContext> _dbContextFactory; |
||||||
|
|
||||||
|
public GetAllFFmpegProfilesForApiHandler(IDbContextFactory<TvContext> dbContextFactory) => |
||||||
|
_dbContextFactory = dbContextFactory; |
||||||
|
|
||||||
|
public async Task<List<FFmpegProfileResponseModel>> Handle( |
||||||
|
GetAllFFmpegProfilesForApi request, |
||||||
|
CancellationToken cancellationToken) |
||||||
|
{ |
||||||
|
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); |
||||||
|
List<FFmpegProfile> ffmpegProfiles = await dbContext.FFmpegProfiles |
||||||
|
.AsNoTracking() |
||||||
|
.Include(p => p.Resolution) |
||||||
|
.ToListAsync(cancellationToken); |
||||||
|
return ffmpegProfiles.Map(ProjectToResponseModel).ToList(); |
||||||
|
} |
||||||
|
} |
||||||
@ -1,9 +1,11 @@ |
|||||||
namespace ErsatzTV.Core.Api.Channels; |
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace ErsatzTV.Core.Api.Channels; |
||||||
|
|
||||||
public record ChannelResponseModel( |
public record ChannelResponseModel( |
||||||
int Id, |
int Id, |
||||||
string Number, |
string Number, |
||||||
string Name, |
string Name, |
||||||
string FFmpegProfile, |
[property: JsonProperty("ffmpegProfile")] string FFmpegProfile, |
||||||
string Language, |
string Language, |
||||||
string StreamingMode); |
string StreamingMode); |
||||||
|
|||||||
@ -0,0 +1,8 @@ |
|||||||
|
namespace ErsatzTV.Core.Api.FFmpegProfiles; |
||||||
|
|
||||||
|
public record FFmpegProfileResponseModel( |
||||||
|
int Id, |
||||||
|
string Name, |
||||||
|
string Resolution, |
||||||
|
string Video, |
||||||
|
string Audio); |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
using ErsatzTV.Application.FFmpegProfiles; |
||||||
|
using ErsatzTV.Core.Api.FFmpegProfiles; |
||||||
|
using MediatR; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
|
||||||
|
namespace ErsatzTV.Controllers.Api; |
||||||
|
|
||||||
|
[ApiController] |
||||||
|
public class FFmpegProfileController |
||||||
|
{ |
||||||
|
private readonly IMediator _mediator; |
||||||
|
|
||||||
|
public FFmpegProfileController(IMediator mediator) => _mediator = mediator; |
||||||
|
|
||||||
|
[HttpGet("/api/ffmpeg/profiles")] |
||||||
|
public async Task<List<FFmpegProfileResponseModel>> GetAll() => |
||||||
|
await _mediator.Send(new GetAllFFmpegProfilesForApi()); |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
export interface FFmpegProfile { |
||||||
|
id: number; |
||||||
|
name: string; |
||||||
|
resolution: string; |
||||||
|
video: string; |
||||||
|
audio: string; |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
import { AbstractApiService } from './AbstractApiService'; |
||||||
|
import { FFmpegProfile } from '@/models/FFmpegProfile'; |
||||||
|
|
||||||
|
class FFmpegProfileApiService extends AbstractApiService { |
||||||
|
public constructor() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
public getAll(): Promise<FFmpegProfile[]> { |
||||||
|
return this.http |
||||||
|
.get('/api/ffmpeg/profiles') |
||||||
|
.then(this.handleResponse.bind(this)) |
||||||
|
.catch(this.handleError.bind(this)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export const ffmpegProfileApiService: FFmpegProfileApiService = |
||||||
|
new FFmpegProfileApiService(); |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<v-data-table |
||||||
|
:headers="headers" |
||||||
|
:items="ffmpegProfiles" |
||||||
|
:sort-by="['name']" |
||||||
|
class="elevation-1" |
||||||
|
> |
||||||
|
</v-data-table> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts"> |
||||||
|
import { Vue, Component } from 'vue-property-decorator'; |
||||||
|
import { FFmpegProfile } from '@/models/FFmpegProfile'; |
||||||
|
import { ffmpegProfileApiService } from '@/services/FFmpegProfileService'; |
||||||
|
|
||||||
|
@Component |
||||||
|
export default class FFmpegProfiles extends Vue { |
||||||
|
private ffmpegProfiles: FFmpegProfile[] = []; |
||||||
|
|
||||||
|
get headers() { |
||||||
|
return [ |
||||||
|
{ text: this.$t('ffmpeg-profiles.table.name'), value: 'name' }, |
||||||
|
{ |
||||||
|
text: this.$t('ffmpeg-profiles.table.resolution'), |
||||||
|
value: 'resolution' |
||||||
|
}, |
||||||
|
{ text: this.$t('ffmpeg-profiles.table.video'), value: 'video' }, |
||||||
|
{ text: this.$t('ffmpeg-profiles.table.audio'), value: 'audio' } |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
title: string = 'FFMpeg Profiles'; |
||||||
|
|
||||||
|
async mounted(): Promise<void> { |
||||||
|
this.ffmpegProfiles = await ffmpegProfileApiService.getAll(); |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
Loading…
Reference in new issue