streamer as separate application; working streamer monitor interface

This commit is contained in:
bkfox
2019-09-21 17:14:40 +02:00
parent 4e61ec1520
commit d3f39c5ade
39 changed files with 1347 additions and 148 deletions

View File

@ -1,17 +1,53 @@
import Vue from 'vue';
export var app = null;
export default app;
export const appBaseConfig = {
el: '#app',
delimiters: ['[[', ']]'],
}
function loadApp() {
app = new Vue({
el: '#app',
delimiters: [ '[[', ']]' ],
/**
* Application config for the main application instance
*/
var appConfig = {};
export function setAppConfig(config) {
for(var member in appConfig) delete appConfig[member];
return Object.assign(appConfig, config)
}
export function getAppConfig(config) {
if(config instanceof Function)
config = config()
config = config == null ? appConfig : config;
return {...appBaseConfig, ...config}
}
/**
* Create Vue application at window 'load' event and return a Promise
* resolving to the created app.
*
* config: defaults to appConfig (checked when window is loaded)
*/
export function loadApp(config=null) {
return new Promise(function(resolve, reject) {
window.addEventListener('load', function() {
try {
config = getAppConfig(config)
const el = document.querySelector(config.el)
if(!el) {
reject(`Error: missing element ${config.el}`);
return;
}
resolve(new Vue(config))
}
catch(error) { reject(error) }
})
})
}
window.addEventListener('load', loadApp);