flamenco/web/app/src/main.js
Sybren A. Stüvel 819767ea1a Webapp: tweak the .editorconfig and .prettierrc files + re-format
Try to get the `.editorconfig` and `.prettierrc` files as close as possible
to the formatting that was used in Flamenco. Because these files weren't
here during most of Flamenco's development so far, having them caused quite
a few changes in the webapp files.

No functional changes intended.
2023-09-11 17:22:18 +02:00

56 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 { MetaApi } from '@/manager-api';
import { newBareAPIClient } from '@/api-client';
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() {
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 = newBareAPIClient();
const metaAPI = new MetaApi(apiClient);
metaAPI
.getConfiguration()
.then((config) => {
if (config.isFirstRun) setupAssistantMode();
else normalMode();
})
.catch((error) => {
console.warn('Error getting Manager configuration:', error);
});