flamenco/web/app/src/main.js
Sybren A. Stüvel 37477fc6bd Web: remove console.log calls
Remove a whole lot of `console.log()` calls. They were useful during
development, but not really suitable for production environments. Because
they also include (potentially large) objects, they can even slow down
the webapp itself.
2022-08-01 17:11:45 +02:00

55 lines
1.7 KiB
JavaScript

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { DateTime } from 'luxon';
import App from '@/App.vue'
import SetupAssistant from '@/SetupAssistant.vue'
import autoreload from '@/autoreloader'
import router from '@/router/index'
import setupAssistantRouter from '@/router/setup-assistant'
import { ApiClient, MetaApi } from "@/manager-api";
import * as urls from '@/urls'
// Ensure Tabulator can find `luxon`, which it needs for sorting by
// date/time/datetime.
window.DateTime = DateTime;
// plain removes any Vue reactivity.
window.plain = (x) => JSON.parse(JSON.stringify(x));
// objectEmpty returns whether the object is empty or not.
window.objectEmpty = (o) => !o || Object.entries(o).length == 0;
// Automatically reload the window after a period of inactivity from the user.
autoreload();
const pinia = createPinia()
function normalMode() {
console.log("Flamenco is starting in normal operation mode");
const app = createApp(App)
app.use(pinia)
app.use(router)
app.mount('#app')
}
function setupAssistantMode() {
console.log("Flamenco Setup Assistant is starting");
const app = createApp(SetupAssistant)
app.use(pinia)
app.use(setupAssistantRouter)
app.mount('#app')
}
/* This cannot use the client from '@/stores/api-query-count', as that would
* require Pinia, which is unavailable until the app is actually started. And to
* know which app to start, this API call needs to return data. */
const apiClient = new ApiClient(urls.api());;
const metaAPI = new MetaApi(apiClient);
metaAPI.getConfiguration()
.then((config) => {
if (config.isFirstRun) setupAssistantMode();
else normalMode();
})
.catch((error) => {
console.warn("Error getting Manager configuration:", error);
})