Files
thetool/public/js/pages/raspberryDisplay.js
Luca Haid 742a2c1495 - fixed RaspberryDisplay definition
- added axios library to plugins
- added vue library to plugins
- added tt-frontend-framework for vue with basic documentation
- added git_merge_ts to additionalCSS
- added git_merge_ts to additionalJS
- added property JSGlobals
- refactored RaspberryDisplay Module
2024-02-14 11:05:52 +01:00

63 lines
2.0 KiB
JavaScript

// noinspection JSJQueryEfficiency
Vue.filter('cleanupURL', function (value) {
value = value.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0];
return value;
})
new Vue({
el: '#app',
mounted() {
this.fetchDisplays()
},
methods: {
async rebootRaspberry(displayID) {
this.loading = true;
await axios.get(`${window['TT_CONFIG']["BASE_URL"]}/api?do=reboot`, {
params: {
displayID: displayID
}
});
this.loading = false;
},
async fetchDisplays() {
this.loading = true;
const response = await axios.get(`${window['TT_CONFIG']["BASE_URL"]}/api?do=getDisplays`);
this.displays = response.data.result;
this.loading = false;
Vue.nextTick(() => {
$('[data-toggle="tooltip"]').tooltip('dispose');
$('[data-toggle="tooltip"]').tooltip();
});
},
enableDisplayURLEditMode(displayID) {
this.displaysURLEditMode = displayID;
const _this = this;
// wait for the DOM to update
Vue.nextTick(() => {
_this.$refs['displayURLEditInput'][0].focus();
});
},
disableDisplayURLEditMode(displayID, displayURL) {
this.displaysURLEditMode = null;
this.submitChanges(displayID, 'display_url', displayURL);
},
async submitChanges(displayID, field, value) {
this.loading = true;
await axios.get(`${window['TT_CONFIG']["BASE_URL"]}/api?do=change`, {
params: {
displayID: displayID,
field: field,
value: value,
}
});
await this.fetchDisplays();
this.loading = false;
}
},
data: {
loading: false,
displaysURLEditMode: null,
displays: null,
}
});