parent
f281c40247
commit
85bc6e8c41
|
@ -7,24 +7,23 @@
|
|||
|
||||
<data-table ref="datatable" id="station_streamer_broadcasts" :show-toolbar="false"
|
||||
:fields="fields" :api-url="listUrl">
|
||||
<template #cell(recording_links_download)="row">
|
||||
<template v-if="row.item.recording_links_download">
|
||||
<template #cell(recording.links.download)="row">
|
||||
<template v-if="row.item.recording.links.download">
|
||||
<play-button class="file-icon" icon-class="outlined"
|
||||
:url="row.item.recording_links_download"></play-button>
|
||||
:url="row.item.recording.links.download"></play-button>
|
||||
|
||||
<a class="name" :href="row.item.recording_links_download" target="_blank" :title="langDownload">
|
||||
<a class="name" :href="row.item.recording.links.download" target="_blank" :title="langDownload">
|
||||
<icon icon="cloud_download"></icon>
|
||||
</a>
|
||||
</template>
|
||||
<template v-else> </template>
|
||||
</template>
|
||||
<template #cell(actions)="row">
|
||||
<b-button-group size="sm" v-if="row.item.recording_links_download">
|
||||
<b-button size="sm" variant="danger" @click.prevent="doDelete(row.item.recording_links_delete)">
|
||||
<b-button-group size="sm">
|
||||
<b-button size="sm" variant="danger" @click.prevent="doDelete(row.item.links.delete)">
|
||||
<translate key="lang_btn_delete">Delete</translate>
|
||||
</b-button>
|
||||
</b-button-group>
|
||||
<template v-else> </template>
|
||||
</template>
|
||||
</data-table>
|
||||
</template>
|
||||
|
@ -52,9 +51,10 @@ export default {
|
|||
listUrl: null,
|
||||
fields: [
|
||||
{
|
||||
key: 'recording_links_download',
|
||||
key: 'recording.links.download',
|
||||
label: ' ',
|
||||
sortable: false
|
||||
sortable: false,
|
||||
class: 'shrink pr-3'
|
||||
},
|
||||
{
|
||||
key: 'timestampStart',
|
||||
|
@ -64,7 +64,8 @@ export default {
|
|||
return DateTime.fromSeconds(value).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
);
|
||||
}
|
||||
},
|
||||
class: 'pl-3'
|
||||
},
|
||||
{
|
||||
key: 'timestampEnd',
|
||||
|
@ -80,7 +81,7 @@ export default {
|
|||
}
|
||||
},
|
||||
{
|
||||
key: 'recording_size',
|
||||
key: 'recording.size',
|
||||
label: this.$gettext('Size'),
|
||||
sortable: false,
|
||||
formatter: (value, key, item) => {
|
||||
|
@ -94,7 +95,8 @@ export default {
|
|||
{
|
||||
key: 'actions',
|
||||
label: this.$gettext('Actions'),
|
||||
sortable: false
|
||||
sortable: false,
|
||||
class: 'shrink'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -60,11 +60,11 @@ final class BroadcastsController extends AbstractApiCrudController
|
|||
$paginator = Paginator::fromQuery($query, $request);
|
||||
|
||||
$router = $request->getRouter();
|
||||
|
||||
$isInternal = ('true' === $request->getParam('internal', 'false'));
|
||||
$fsRecordings = (new StationFilesystems($station))->getRecordingsFilesystem();
|
||||
|
||||
$paginator->setPostprocessor(
|
||||
function ($row) use ($id, $router, $fsRecordings) {
|
||||
function ($row) use ($id, $router, $isInternal, $fsRecordings) {
|
||||
$return = $this->toArray($row);
|
||||
|
||||
unset($return['recordingPath']);
|
||||
|
@ -79,29 +79,22 @@ final class BroadcastsController extends AbstractApiCrudController
|
|||
];
|
||||
}
|
||||
|
||||
if (!empty($recordingPath) && $fsRecordings->fileExists($recordingPath)) {
|
||||
$routeParams = [
|
||||
'broadcast_id' => $row->getId(),
|
||||
];
|
||||
if (null === $id) {
|
||||
$routeParams['id'] = $row->getStreamer()->getId();
|
||||
}
|
||||
$routeParams = [
|
||||
'broadcast_id' => $row->getId(),
|
||||
];
|
||||
if (null === $id) {
|
||||
$routeParams['id'] = $row->getStreamer()->getId();
|
||||
}
|
||||
|
||||
if (!empty($recordingPath) && $fsRecordings->fileExists($recordingPath)) {
|
||||
$return['recording'] = [
|
||||
'path' => $recordingPath,
|
||||
'size' => $fsRecordings->fileSize($recordingPath),
|
||||
'links' => [
|
||||
'download' => $router->fromHere(
|
||||
'api:stations:streamer:broadcast:download',
|
||||
$routeParams,
|
||||
[],
|
||||
true
|
||||
),
|
||||
'delete' => $router->fromHere(
|
||||
'api:stations:streamer:broadcast:delete',
|
||||
$routeParams,
|
||||
[],
|
||||
true
|
||||
routeName: 'api:stations:streamer:broadcast:download',
|
||||
routeParams: $routeParams,
|
||||
absolute: !$isInternal
|
||||
),
|
||||
],
|
||||
];
|
||||
|
@ -109,6 +102,14 @@ final class BroadcastsController extends AbstractApiCrudController
|
|||
$return['recording'] = [];
|
||||
}
|
||||
|
||||
$return['links'] = [
|
||||
'delete' => $router->fromHere(
|
||||
routeName: 'api:stations:streamer:broadcast:delete',
|
||||
routeParams: $routeParams,
|
||||
absolute: !$isInternal
|
||||
),
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
);
|
||||
|
@ -168,14 +169,12 @@ final class BroadcastsController extends AbstractApiCrudController
|
|||
|
||||
if (!empty($recordingPath)) {
|
||||
$fsRecordings = (new StationFilesystems($station))->getRecordingsFilesystem();
|
||||
|
||||
$fsRecordings->delete($recordingPath);
|
||||
|
||||
$broadcast->clearRecordingPath();
|
||||
$this->em->persist($broadcast);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
$this->em->remove($broadcast);
|
||||
$this->em->flush();
|
||||
|
||||
return $response->withJson(Entity\Api\Status::deleted());
|
||||
}
|
||||
|
||||
|
|
|
@ -91,9 +91,4 @@ class StationStreamerBroadcast implements IdentifiableEntityInterface
|
|||
{
|
||||
$this->recordingPath = $recordingPath;
|
||||
}
|
||||
|
||||
public function clearRecordingPath(): void
|
||||
{
|
||||
$this->recordingPath = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue