Fixes #5004 -- Separate pending and historical requests.
This commit is contained in:
parent
1c59c9cf8d
commit
bebf651173
|
@ -5,10 +5,8 @@
|
|||
<h2 class="card-title" key="lang_storage_locations" v-translate>Storage Locations</h2>
|
||||
</b-card-header>
|
||||
<b-tabs pills card lazy>
|
||||
<b-tab :active="activeType === 'station_media'" @click="setType('station_media')" :title="langStationMediaTab" no-body></b-tab>
|
||||
<b-tab :active="activeType === 'station_recordings'" @click="setType('station_recordings')" :title="langStationRecordingsTab" no-body></b-tab>
|
||||
<b-tab :active="activeType === 'station_podcasts'" @click="setType('station_podcasts')" :title="langStationPodcastsTab" no-body></b-tab>
|
||||
<b-tab :active="activeType === 'backup'" @click="setType('backup')" :title="langBackupsTab" no-body></b-tab>
|
||||
<b-tab v-for="tab in tabs" :key="tab.type" :active="activeType === tab.type" @click="setType(tab.type)"
|
||||
:title="tab.title" no-body></b-tab>
|
||||
</b-tabs>
|
||||
|
||||
<b-card-body body-class="card-padding-sm">
|
||||
|
@ -79,19 +77,27 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
langStationMediaTab () {
|
||||
return this.$gettext('Station Media');
|
||||
tabs() {
|
||||
return [
|
||||
{
|
||||
type: 'station_media',
|
||||
title: this.$gettext('Station Media')
|
||||
},
|
||||
{
|
||||
type: 'station_recordings',
|
||||
title: this.$gettext('Station Recordings')
|
||||
},
|
||||
{
|
||||
type: 'station_podcasts',
|
||||
title: this.$gettext('Station Podcasts'),
|
||||
},
|
||||
{
|
||||
type: 'backup',
|
||||
title: this.$gettext('Backups')
|
||||
}
|
||||
]
|
||||
},
|
||||
langStationRecordingsTab () {
|
||||
return this.$gettext('Station Recordings');
|
||||
},
|
||||
langStationPodcastsTab () {
|
||||
return this.$gettext('Station Podcasts');
|
||||
},
|
||||
langBackupsTab () {
|
||||
return this.$gettext('Backups');
|
||||
},
|
||||
listUrlForType () {
|
||||
listUrlForType() {
|
||||
return this.listUrl + '?type=' + this.activeType;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,13 +4,19 @@
|
|||
<b-card-header header-bg-variant="primary-dark">
|
||||
<h2 class="card-title" key="lang_queue" v-translate>Song Requests</h2>
|
||||
</b-card-header>
|
||||
<div class="card-actions">
|
||||
<b-tabs pills card lazy>
|
||||
<b-tab v-for="tab in tabs" :key="tab.type" :active="activeType === tab.type" @click="setType(tab.type)"
|
||||
:title="tab.title" no-body></b-tab>
|
||||
</b-tabs>
|
||||
|
||||
<div class="card-actions" v-if="activeType === 'pending'">
|
||||
<b-button variant="outline-danger" @click="doClear()">
|
||||
<icon icon="remove"></icon>
|
||||
<translate key="lang_btn_clear_requests">Clear Pending Requests</translate>
|
||||
</b-button>
|
||||
</div>
|
||||
<data-table ref="datatable" id="station_queue" :fields="fields" :api-url="listUrl">
|
||||
|
||||
<data-table ref="datatable" id="station_queue" :fields="fields" :api-url="listUrlForType">
|
||||
<template #cell(timestamp)="row">
|
||||
{{ formatTime(row.item.timestamp) }}
|
||||
</template>
|
||||
|
@ -60,8 +66,26 @@ export default {
|
|||
clearUrl: String,
|
||||
stationTimeZone: String
|
||||
},
|
||||
computed: {
|
||||
tabs() {
|
||||
return [
|
||||
{
|
||||
type: 'pending',
|
||||
title: this.$gettext('Pending Requests')
|
||||
},
|
||||
{
|
||||
type: 'history',
|
||||
title: this.$gettext('Request History')
|
||||
}
|
||||
]
|
||||
},
|
||||
listUrlForType() {
|
||||
return this.listUrl + '?type=' + this.activeType;
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeType: 'pending',
|
||||
fields: [
|
||||
{key: 'timestamp', label: this.$gettext('Date Requested'), sortable: false},
|
||||
{key: 'played_at', label: this.$gettext('Date Played'), sortable: false},
|
||||
|
@ -72,6 +96,13 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
setType(type) {
|
||||
this.activeType = type;
|
||||
this.relist();
|
||||
},
|
||||
relist() {
|
||||
this.$refs.datatable.refresh();
|
||||
},
|
||||
formatTime(time) {
|
||||
return DateTime.fromSeconds(time).setZone(this.stationTimeZone).toLocaleString(DateTime.DATETIME_MED);
|
||||
},
|
||||
|
@ -84,7 +115,7 @@ export default {
|
|||
this.axios.delete(url)
|
||||
).then((resp) => {
|
||||
this.$notifySuccess(resp.data.message);
|
||||
this.$refs.datatable.refresh();
|
||||
this.relist();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -99,7 +130,7 @@ export default {
|
|||
this.axios.post(this.clearUrl)
|
||||
).then((resp) => {
|
||||
this.$notifySuccess(resp.data.message);
|
||||
this.$refs.datatable.refresh();
|
||||
this.relist();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Entity;
|
|||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Paginator;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -19,31 +20,40 @@ class RequestsController
|
|||
) {
|
||||
}
|
||||
|
||||
public function listAction(ServerRequest $request, Response $response): ResponseInterface
|
||||
{
|
||||
public function listAction(
|
||||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
$requests = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT sr, sm
|
||||
FROM App\Entity\StationRequest sr
|
||||
JOIN sr.track sm
|
||||
WHERE sr.station = :station
|
||||
ORDER BY sr.timestamp DESC
|
||||
DQL
|
||||
)->setParameter('station', $station)
|
||||
->getArrayResult();
|
||||
$qb = $this->em->createQueryBuilder()
|
||||
->select('sr, sm')
|
||||
->from(Entity\StationRequest::class, 'sr')
|
||||
->join('sr.track', 'sm')
|
||||
->where('sr.station = :station')
|
||||
->setParameter('station', $station)
|
||||
->orderBy('sr.timestamp', 'DESC');
|
||||
|
||||
$paginator = Paginator::fromArray($requests, $request);
|
||||
$qb = match ($request->getParam('type', 'recent')) {
|
||||
'history' => $qb->andWhere('sr.played_at != 0'),
|
||||
default => $qb->andWhere('sr.played_at = 0'),
|
||||
};
|
||||
|
||||
$query = $qb->getQuery()
|
||||
->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
|
||||
|
||||
$paginator = Paginator::fromQuery($query, $request);
|
||||
|
||||
$router = $request->getRouter();
|
||||
$postProcessor = function ($row) use ($router) {
|
||||
$row['links'] = [
|
||||
'delete' => (string)$router->fromHere(
|
||||
$row['links'] = [];
|
||||
|
||||
if (0 === $row['played_at']) {
|
||||
$row['links']['delete'] = (string)$router->fromHere(
|
||||
'api:stations:reports:requests:delete',
|
||||
['request_id' => $row['id']]
|
||||
),
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
return $row;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue