Modify code that depends on SweetAlert2 to use new result structure.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-10-07 03:21:03 -05:00
parent daf6e09bb9
commit e6b7309a1d
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
7 changed files with 506 additions and 506 deletions

View File

@ -34,8 +34,8 @@ $(function () {
e.preventDefault();
const linkUrl = $(this).attr('href');
confirmDangerousAction(e.target).then((value) => {
if (value) {
confirmDangerousAction(e.target).then((result) => {
if (result.value) {
window.location.href = linkUrl;
}
});

View File

@ -115,161 +115,161 @@
</template>
<script>
import DataTable from './components/DataTable';
import Schedule from './components/ScheduleView';
import EditModal from './station_playlists/PlaylistEditModal';
import ReorderModal from './station_playlists/PlaylistReorderModal';
import ImportModal from './station_playlists/PlaylistImportModal';
import axios from 'axios';
import DataTable from './components/DataTable';
import Schedule from './components/ScheduleView';
import EditModal from './station_playlists/PlaylistEditModal';
import ReorderModal from './station_playlists/PlaylistReorderModal';
import ImportModal from './station_playlists/PlaylistImportModal';
import axios from 'axios';
export default {
name: 'StationPlaylists',
components: { ImportModal, ReorderModal, EditModal, Schedule, DataTable },
props: {
listUrl: String,
scheduleUrl: String,
locale: String,
filesUrl: String,
stationTimeZone: String,
enableAdvancedFeatures: Boolean
export default {
name: 'StationPlaylists',
components: { ImportModal, ReorderModal, EditModal, Schedule, DataTable },
props: {
listUrl: String,
scheduleUrl: String,
locale: String,
filesUrl: String,
stationTimeZone: String,
enableAdvancedFeatures: Boolean
},
data () {
return {
fields: [
{ key: 'actions', label: this.$gettext('Actions'), sortable: false },
{ key: 'name', label: this.$gettext('Playlist'), sortable: false },
{ key: 'scheduling', label: this.$gettext('Scheduling'), sortable: false },
{ key: 'num_songs', label: this.$gettext('# Songs'), sortable: false }
]
};
},
computed: {
langAllPlaylistsTab () {
return this.$gettext('All Playlists');
},
data () {
return {
fields: [
{ key: 'actions', label: this.$gettext('Actions'), sortable: false },
{ key: 'name', label: this.$gettext('Playlist'), sortable: false },
{ key: 'scheduling', label: this.$gettext('Scheduling'), sortable: false },
{ key: 'num_songs', label: this.$gettext('# Songs'), sortable: false }
]
};
langScheduleViewTab () {
return this.$gettext('Schedule View');
},
computed: {
langAllPlaylistsTab () {
return this.$gettext('All Playlists');
},
langScheduleViewTab () {
return this.$gettext('Schedule View');
},
langMore () {
return this.$gettext('More');
},
langReorderButton () {
return this.$gettext('Reorder');
},
langReshuffleButton () {
return this.$gettext('Reshuffle');
},
langImportButton () {
return this.$gettext('Import from PLS/M3U');
langMore () {
return this.$gettext('More');
},
langReorderButton () {
return this.$gettext('Reorder');
},
langReshuffleButton () {
return this.$gettext('Reshuffle');
},
langImportButton () {
return this.$gettext('Import from PLS/M3U');
}
},
mounted () {
moment.relativeTimeThreshold('ss', 1);
moment.relativeTimeRounding(function (value) {
return Math.round(value * 10) / 10;
});
},
methods: {
langToggleButton (record) {
return (record.is_enabled)
? this.$gettext('Disable')
: this.$gettext('Enable');
},
formatTime (time) {
return moment(time).tz(this.stationTimeZone).format('LT');
},
formatLength (length) {
return moment.duration(length, 'seconds').humanize();
},
formatType (record) {
if (!record.is_enabled) {
return this.$gettext('Disabled');
}
switch (record.type) {
case 'default':
return this.$gettext('General Rotation') + '<br>' + this.$gettext('Weight') + ': ' + record.weight;
case 'once_per_x_songs':
let oncePerSongs = this.$gettext('Once per %{songs} Songs');
return this.$gettextInterpolate(oncePerSongs, { songs: record.play_per_songs });
case 'once_per_x_minutes':
let oncePerMinutes = this.$gettext('Once per %{minutes} Minutes');
return this.$gettextInterpolate(oncePerMinutes, { minutes: record.play_per_minutes });
case 'once_per_hour':
let oncePerHour = this.$gettext('Once per Hour (at %{minute})');
return this.$gettextInterpolate(oncePerHour, { minute: record.play_per_hour_minute });
default:
return this.$gettext('Custom');
}
},
mounted () {
moment.relativeTimeThreshold('ss', 1);
moment.relativeTimeRounding(function (value) {
return Math.round(value * 10) / 10;
relist () {
if (this.$refs.datatable) {
this.$refs.datatable.refresh();
}
if (this.$refs.schedule) {
this.$refs.schedule.refresh();
}
},
doCreate () {
this.$refs.editModal.create();
},
doCalendarClick (event) {
this.doEdit(event.extendedProps.edit_url);
},
doEdit (url) {
this.$refs.editModal.edit(url);
},
doReorder (url) {
this.$refs.reorderModal.open(url);
},
doImport (url) {
this.$refs.importModal.open(url);
},
doModify (url) {
notify('<b>' + this.$gettext('Applying changes...') + '</b>', 'warning', {
delay: 3000
});
axios.put(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
},
methods: {
langToggleButton (record) {
return (record.is_enabled)
? this.$gettext('Disable')
: this.$gettext('Enable');
},
formatTime (time) {
return moment(time).tz(this.stationTimeZone).format('LT');
},
formatLength (length) {
return moment.duration(length, 'seconds').humanize();
},
formatType (record) {
if (!record.is_enabled) {
return this.$gettext('Disabled');
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete playlist?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((result) => {
if (result.value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
}
switch (record.type) {
case 'default':
return this.$gettext('General Rotation') + '<br>' + this.$gettext('Weight') + ': ' + record.weight;
case 'once_per_x_songs':
let oncePerSongs = this.$gettext('Once per %{songs} Songs');
return this.$gettextInterpolate(oncePerSongs, { songs: record.play_per_songs });
case 'once_per_x_minutes':
let oncePerMinutes = this.$gettext('Once per %{minutes} Minutes');
return this.$gettextInterpolate(oncePerMinutes, { minutes: record.play_per_minutes });
case 'once_per_hour':
let oncePerHour = this.$gettext('Once per Hour (at %{minute})');
return this.$gettextInterpolate(oncePerHour, { minute: record.play_per_hour_minute });
default:
return this.$gettext('Custom');
}
},
relist () {
if (this.$refs.datatable) {
this.$refs.datatable.refresh();
}
if (this.$refs.schedule) {
this.$refs.schedule.refresh();
}
},
doCreate () {
this.$refs.editModal.create();
},
doCalendarClick (event) {
this.doEdit(event.extendedProps.edit_url);
},
doEdit (url) {
this.$refs.editModal.edit(url);
},
doReorder (url) {
this.$refs.reorderModal.open(url);
},
doImport (url) {
this.$refs.importModal.open(url);
},
doModify (url) {
notify('<b>' + this.$gettext('Applying changes...') + '</b>', 'warning', {
delay: 3000
});
axios.put(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete playlist?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((value) => {
if (value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
}
});
}
});
}
};
}
};
</script>

View File

@ -59,87 +59,87 @@
</template>
<script>
import DataTable from './components/DataTable';
import axios from 'axios';
import EditModal from './station_streamers/StreamerEditModal';
import BroadcastsModal from './station_streamers/StreamerBroadcastsModal';
import Schedule from './components/ScheduleView';
import DataTable from './components/DataTable';
import axios from 'axios';
import EditModal from './station_streamers/StreamerEditModal';
import BroadcastsModal from './station_streamers/StreamerBroadcastsModal';
import Schedule from './components/ScheduleView';
export default {
name: 'StationStreamers',
components: { EditModal, BroadcastsModal, DataTable, Schedule },
props: {
listUrl: String,
scheduleUrl: String,
filesUrl: String,
locale: String,
stationTimeZone: String
export default {
name: 'StationStreamers',
components: { EditModal, BroadcastsModal, DataTable, Schedule },
props: {
listUrl: String,
scheduleUrl: String,
filesUrl: String,
locale: String,
stationTimeZone: String
},
data () {
return {
fields: [
{ key: 'actions', label: this.$gettext('Actions'), sortable: false },
{ key: 'streamer_username', label: this.$gettext('Username'), sortable: false },
{ key: 'display_name', label: this.$gettext('Display Name'), sortable: false },
{ key: 'comments', label: this.$gettext('Notes'), sortable: false }
]
};
},
computed: {
langAccountListTab () {
return this.$gettext('Account List');
},
data () {
return {
fields: [
{ key: 'actions', label: this.$gettext('Actions'), sortable: false },
{ key: 'streamer_username', label: this.$gettext('Username'), sortable: false },
{ key: 'display_name', label: this.$gettext('Display Name'), sortable: false },
{ key: 'comments', label: this.$gettext('Notes'), sortable: false }
]
};
},
computed: {
langAccountListTab () {
return this.$gettext('Account List');
},
langScheduleViewTab () {
return this.$gettext('Schedule View');
}
},
mounted () {
moment.relativeTimeThreshold('ss', 1);
moment.relativeTimeRounding(function (value) {
return Math.round(value * 10) / 10;
});
},
methods: {
relist () {
this.$refs.datatable.refresh();
},
doCreate () {
this.$refs.editModal.create();
},
doCalendarClick (event) {
this.doEdit(event.extendedProps.edit_url);
},
doEdit (url) {
this.$refs.editModal.edit(url);
},
doShowBroadcasts (url) {
this.$refs.broadcastsModal.open(url);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete streamer?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((value) => {
if (value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
}
});
}
langScheduleViewTab () {
return this.$gettext('Schedule View');
}
};
},
mounted () {
moment.relativeTimeThreshold('ss', 1);
moment.relativeTimeRounding(function (value) {
return Math.round(value * 10) / 10;
});
},
methods: {
relist () {
this.$refs.datatable.refresh();
},
doCreate () {
this.$refs.editModal.create();
},
doCalendarClick (event) {
this.doEdit(event.extendedProps.edit_url);
},
doEdit (url) {
this.$refs.editModal.edit(url);
},
doShowBroadcasts (url) {
this.$refs.broadcastsModal.open(url);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete streamer?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((result) => {
if (result.value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.relist();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
}
});
}
}
};
</script>

View File

@ -63,149 +63,149 @@
</div>
</template>
<script>
import axios from 'axios';
import axios from 'axios';
export default {
name: 'station-media-toolbar',
props: {
currentDirectory: String,
selectedFiles: Array,
initialPlaylists: Array,
batchUrl: String
},
data () {
return {
playlists: this.initialPlaylists,
checkedPlaylists: [],
newPlaylist: ''
};
},
watch: {
newPlaylist (text) {
if (text !== '') {
if (!this.checkedPlaylists.includes('new')) {
this.checkedPlaylists.push('new');
}
}
}
},
computed: {
langPlaylistDropdown () {
return this.$gettext('Set or clear playlists from the selected media');
},
langNewPlaylist () {
return this.$gettext('New Playlist');
},
langQueue () {
return this.$gettext('Queue the selected media to play next');
},
langErrors () {
return this.$gettext('The request could not be processed.');
},
newPlaylistIsChecked () {
return this.newPlaylist !== '';
}
},
methods: {
doQueue (e) {
this.doBatch('queue', this.$gettext('Files queued for playback:'));
},
doDelete (e) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete %{ num } media file(s)?');
Swal.fire({
title: this.$gettextInterpolate(buttonConfirmText, { num: this.selectedFiles.length }),
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((value) => {
if (value) {
this.doBatch('delete', this.$gettext('Files removed:'));
}
});
},
doBatch (action, notifyMessage) {
if (this.selectedFiles.length) {
this.notifyPending();
axios.put(this.batchUrl, {
'do': action,
'files': this.selectedFiles,
'file': this.currentDirectory
}).then((resp) => {
if (resp.data.success) {
notify('<b>' + notifyMessage + '</b><br>' + this.selectedFiles.join('<br>'), 'success', false);
} else {
notify('<b>' + this.langErrors + '</b><br>' + resp.data.errors.join('<br>'), 'danger');
}
this.$emit('relist');
}).catch((err) => {
this.handleError(err);
});
} else {
this.notifyNoFiles();
}
},
clearPlaylists () {
this.checkedPlaylists = [];
this.newPlaylist = '';
this.setPlaylists();
},
setPlaylists () {
this.$refs.setPlaylistsDropdown.hide();
if (this.selectedFiles.length) {
this.notifyPending();
axios.put(this.batchUrl, {
'do': 'playlist',
'playlists': this.checkedPlaylists,
'new_playlist_name': this.newPlaylist,
'files': this.selectedFiles,
'file': this.currentDirectory
}).then((resp) => {
if (resp.data.success) {
if (resp.data.record) {
this.playlists.push(resp.data.record);
}
let notifyMessage = (this.checkedPlaylists.length > 0)
? this.$gettext('Playlists updated for selected files:')
: this.$gettext('Playlists cleared for selected files:');
notify('<b>' + notifyMessage + '</b><br>' + this.selectedFiles.join('<br>'), 'success');
this.checkedPlaylists = [];
this.newPlaylist = '';
} else {
notify(resp.data.errors.join('<br>'), 'danger');
}
this.$emit('relist');
}).catch((err) => {
this.handleError(err);
});
} else {
this.notifyNoFiles();
}
},
notifyPending () {
notify('<b>' + this.$gettext('Applying changes...') + '</b>', 'warning', {
delay: 3000
});
},
notifyNoFiles () {
notify('<b>' + this.$gettext('No files selected.') + '</b>', 'danger');
},
handleError (err) {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
export default {
name: 'station-media-toolbar',
props: {
currentDirectory: String,
selectedFiles: Array,
initialPlaylists: Array,
batchUrl: String
},
data () {
return {
playlists: this.initialPlaylists,
checkedPlaylists: [],
newPlaylist: ''
};
},
watch: {
newPlaylist (text) {
if (text !== '') {
if (!this.checkedPlaylists.includes('new')) {
this.checkedPlaylists.push('new');
}
}
}
};
},
computed: {
langPlaylistDropdown () {
return this.$gettext('Set or clear playlists from the selected media');
},
langNewPlaylist () {
return this.$gettext('New Playlist');
},
langQueue () {
return this.$gettext('Queue the selected media to play next');
},
langErrors () {
return this.$gettext('The request could not be processed.');
},
newPlaylistIsChecked () {
return this.newPlaylist !== '';
}
},
methods: {
doQueue (e) {
this.doBatch('queue', this.$gettext('Files queued for playback:'));
},
doDelete (e) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete %{ num } media file(s)?');
Swal.fire({
title: this.$gettextInterpolate(buttonConfirmText, { num: this.selectedFiles.length }),
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((result) => {
if (result.value) {
this.doBatch('delete', this.$gettext('Files removed:'));
}
});
},
doBatch (action, notifyMessage) {
if (this.selectedFiles.length) {
this.notifyPending();
axios.put(this.batchUrl, {
'do': action,
'files': this.selectedFiles,
'file': this.currentDirectory
}).then((resp) => {
if (resp.data.success) {
notify('<b>' + notifyMessage + '</b><br>' + this.selectedFiles.join('<br>'), 'success', false);
} else {
notify('<b>' + this.langErrors + '</b><br>' + resp.data.errors.join('<br>'), 'danger');
}
this.$emit('relist');
}).catch((err) => {
this.handleError(err);
});
} else {
this.notifyNoFiles();
}
},
clearPlaylists () {
this.checkedPlaylists = [];
this.newPlaylist = '';
this.setPlaylists();
},
setPlaylists () {
this.$refs.setPlaylistsDropdown.hide();
if (this.selectedFiles.length) {
this.notifyPending();
axios.put(this.batchUrl, {
'do': 'playlist',
'playlists': this.checkedPlaylists,
'new_playlist_name': this.newPlaylist,
'files': this.selectedFiles,
'file': this.currentDirectory
}).then((resp) => {
if (resp.data.success) {
if (resp.data.record) {
this.playlists.push(resp.data.record);
}
let notifyMessage = (this.checkedPlaylists.length > 0)
? this.$gettext('Playlists updated for selected files:')
: this.$gettext('Playlists cleared for selected files:');
notify('<b>' + notifyMessage + '</b><br>' + this.selectedFiles.join('<br>'), 'success');
this.checkedPlaylists = [];
this.newPlaylist = '';
} else {
notify(resp.data.errors.join('<br>'), 'danger');
}
this.$emit('relist');
}).catch((err) => {
this.handleError(err);
});
} else {
this.notifyNoFiles();
}
},
notifyPending () {
notify('<b>' + this.$gettext('Applying changes...') + '</b>', 'warning', {
delay: 3000
});
},
notifyNoFiles () {
notify('<b>' + this.$gettext('No files selected.') + '</b>', 'danger');
},
handleError (err) {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
}
}
};
</script>

View File

@ -39,128 +39,128 @@
</b-modal>
</template>
<script>
import DataTable from '../components/DataTable.vue';
import axios from 'axios';
import { formatFileSize } from '../inc/format_file_size';
import InlinePlayer from '../InlinePlayer';
import DataTable from '../components/DataTable.vue';
import axios from 'axios';
import { formatFileSize } from '../inc/format_file_size';
import InlinePlayer from '../InlinePlayer';
export default {
name: 'StreamerBroadcastsModal',
components: { InlinePlayer, DataTable },
data () {
return {
now_playing_url: null,
listUrl: null,
fields: [
{
key: 'recording_links_download',
label: ' ',
sortable: false
},
{
key: 'timestampStart',
label: this.$gettext('Start Time'),
sortable: false,
formatter: (value, key, item) => {
return moment.unix(value).format('lll');
}
},
{
key: 'timestampEnd',
label: this.$gettext('End Time'),
sortable: false,
formatter: (value, key, item) => {
if (value === 0) {
return this.$gettext('Live');
}
return moment.unix(value).format('lll');
}
},
{
key: 'recording_size',
label: this.$gettext('Size'),
sortable: false,
formatter: (value, key, item) => {
if (!value) {
return '';
}
return formatFileSize(value);
}
},
{
key: 'actions',
label: this.$gettext('Actions'),
sortable: false
export default {
name: 'StreamerBroadcastsModal',
components: { InlinePlayer, DataTable },
data () {
return {
now_playing_url: null,
listUrl: null,
fields: [
{
key: 'recording_links_download',
label: ' ',
sortable: false
},
{
key: 'timestampStart',
label: this.$gettext('Start Time'),
sortable: false,
formatter: (value, key, item) => {
return moment.unix(value).format('lll');
}
]
};
},
{
key: 'timestampEnd',
label: this.$gettext('End Time'),
sortable: false,
formatter: (value, key, item) => {
if (value === 0) {
return this.$gettext('Live');
}
return moment.unix(value).format('lll');
}
},
{
key: 'recording_size',
label: this.$gettext('Size'),
sortable: false,
formatter: (value, key, item) => {
if (!value) {
return '';
}
return formatFileSize(value);
}
},
{
key: 'actions',
label: this.$gettext('Actions'),
sortable: false
}
]
};
},
computed: {
langHeader () {
return this.$gettext('Streamer Broadcasts');
},
computed: {
langHeader () {
return this.$gettext('Streamer Broadcasts');
},
langPlayPause () {
return this.$gettext('Play/Pause');
},
langDownload () {
return this.$gettext('Download');
langPlayPause () {
return this.$gettext('Play/Pause');
},
langDownload () {
return this.$gettext('Download');
}
},
mounted () {
this.$eventHub.$on('player_stopped', () => {
this.now_playing_url = null;
});
this.$eventHub.$on('player_playing', (url) => {
this.now_playing_url = url;
});
},
methods: {
playAudio (url) {
if (this.now_playing_url === url) {
this.$refs.player.stop();
} else {
this.$refs.player.play(url);
}
},
mounted () {
this.$eventHub.$on('player_stopped', () => {
this.now_playing_url = null;
});
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete broadcast?');
this.$eventHub.$on('player_playing', (url) => {
this.now_playing_url = url;
});
},
methods: {
playAudio (url) {
if (this.now_playing_url === url) {
this.$refs.player.stop();
} else {
this.$refs.player.play(url);
}
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete broadcast?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((value) => {
if (value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.$refs.datatable.refresh();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
}).then((result) => {
if (result.value) {
axios.delete(url).then((resp) => {
notify('<b>' + resp.data.message + '</b>', 'success');
this.$refs.datatable.refresh();
}
});
},
open (listUrl) {
this.listUrl = listUrl;
this.$refs.modal.show();
},
close () {
this.$refs.player.stop();
}).catch((err) => {
console.error(err);
if (err.response.message) {
notify('<b>' + err.response.message + '</b>', 'danger');
}
});
this.listUrl = null;
this.$refs.modal.hide();
}
this.$refs.datatable.refresh();
}
});
},
open (listUrl) {
this.listUrl = listUrl;
this.$refs.modal.show();
},
close () {
this.$refs.player.stop();
this.listUrl = null;
this.$refs.modal.hide();
}
};
}
};
</script>

View File

@ -1,10 +1,10 @@
const api_url = "<?=$router->fromHere('api:stations:queue') ?>";
$(function() {
var grid = $(".data-table").bootgrid({
$(function () {
var grid = $('.data-table').bootgrid({
ajax: true,
ajaxSettings: {
method: "GET",
method: 'GET',
cache: false
},
sorting: false,
@ -12,43 +12,43 @@ $(function() {
rowCount: [10, 25, 50],
url: api_url,
formatters: {
"datetime": function(column, row) {
'datetime': function (column, row) {
return formatTimestamp(row.cued_at);
},
"song_title": function(column, row) {
'song_title': function (column, row) {
if (row.autodj_custom_uri) {
return row.autodj_custom_uri;
} else if (row.song_title) {
return '<b>'+row.song_title+'</b><br>'+row.song_artist;
return '<b>' + row.song_title + '</b><br>' + row.song_artist;
} else {
return row.song_text;
}
},
"source": function(column, row) {
'source': function (column, row) {
if (row.is_request) {
return <?=$this->escapeJs(__('Listener Request')) ?>;
} else if (row.playlist) {
return <?=$this->escapeJs(__('Playlist:')) ?>+" "+row.playlist;
return <?=$this->escapeJs(__('Playlist:')) ?> + ' ' + row.playlist;
}
},
"commands": function(column, row) {
'commands': function (column, row) {
if (row.links_self) {
return '<a class="btn btn-sm btn-danger" data-confirm-title="<?=$this->e(__('Delete queue item?')) ?>" href="' + row.links_self + '"><?=__('Delete') ?></a>';
}
}
}
}).on("loaded.rs.jquery.bootgrid", function() {
}).on('loaded.rs.jquery.bootgrid', function () {
/* Executes after data is loaded and rendered */
grid.find(".btn-danger").on("click", function(e) {
grid.find('.btn-danger').on('click', function (e) {
e.preventDefault();
const linkUrl = $(this).attr('href');
confirmDangerousAction(e.target).then(function(value) {
if (value) {
confirmDangerousAction(e.target).then(function (result) {
if (result.value) {
$.ajax(linkUrl, {
method: "DELETE",
dataType: "json",
success: function(data) {
method: 'DELETE',
dataType: 'json',
success: function (data) {
notify(data.message, 'success', false);
grid.bootgrid('reload');
}
@ -60,7 +60,7 @@ $(function() {
});
});
function formatTimestamp(unix_timestamp) {
function formatTimestamp (unix_timestamp) {
return moment.unix(unix_timestamp).format('lll');
}
});

View File

@ -17,13 +17,13 @@ $(function () {
var btn_original_text = btn.html();
var trigger_reload = !btn.hasClass('no-reload');
confirmDangerousAction(e.target).then(function (value) {
if (value) {
confirmDangerousAction(e.target).then(function (result) {
if (result.value) {
btn.text(<?=$this->escapeJs(__('Please wait...')) ?>);
btn.addClass('disabled');
$.ajax({
type: "POST",
type: 'POST',
url: btn.attr('href'),
success: function (data) {
// Only restart if the user isn't on a form page
@ -42,7 +42,7 @@ $(function () {
btn.removeClass('disabled').html(btn_original_text);
},
dataType: "json"
dataType: 'json'
});
}
});