Vue.component('VoiceCallActive', {
//language=Vue
template: `
Ringing
Outgoing
Ingoing
{{ !isNaN(new Date(row.answer_time)) ? window.moment(row.answer_time, 'YYYY-MM-DD HH:mm:ss Z').format('DD.MM.YYYY HH:mm:ss') : 'Call is not running' }}
{{ row.status }}
`,
data() {
return {
window: window,
VoiceCallActiveTableConfig: {
customRowClass: function (row) {
if (row.status.toLowerCase() === 'ringing') {
return 'voice-yellow';
}
if (!row.dst_device_extension) {
return 'voice-red';
}
if (row.status.toLowerCase() === 'answered') {
return 'voice-green';
}
},
headers: [
{text: 'Call ID', key: 'id', filter: false, sortable: false},
{text: 'Status', key: 'status', filter: false, sortable: false},
{text: 'Answer Time', key: 'answer_time', filter: false, sortable: false},
{text: 'Duration', key: 'duration', filter: false, sortable: false},
{text: 'Source', key: 'src', filter: false, sortable: false},
{text: 'Device Type', key: 'device_type', filter: false, sortable: false},
{text: 'Destination', key: 'localized_dst', filter: false, sortable: false},
{text: 'Destination User', key: 'dst_user', filter: false, sortable: false},
{text: 'Destination Device Extension', key: 'dst_device_extension', filter: false, sortable: false},
],
tableHeader: 'Active Voice Calls',
key: 'VoiceCallActive',
},
refreshLoading: false,
autoRefresh: null,
}
},
mounted() {
//TODO: create vue tooltip component
$('[data-toggle="tooltip"]').tooltip();
const _this = this;
$('#autoRefresh').change(function () {
console.log(this.checked);
if (this.checked) {
_this.autoRefresh = setInterval(function () {
_this.refresh();
}, 5000);
} else {
clearInterval(_this.autoRefresh);
}
})
},
methods: {
async refresh() {
this.refreshLoading = true;
this.$refs.table.loading = true;
await this.$refs.table.fetchData();
$('.tooltip').tooltip('hide');
this.$refs.table.loading = false;
this.refreshLoading = false;
},
}
})