2018-06-01 18:05:51 +05:30
|
|
|
<template>
|
2020-01-28 13:50:42 +05:30
|
|
|
<div
|
|
|
|
id="app"
|
|
|
|
class="h-screen flex flex-col font-sans overflow-hidden antialiased"
|
|
|
|
>
|
2021-11-24 14:38:13 +05:30
|
|
|
<WindowsTitleBar v-if="platform === 'Windows'" />
|
|
|
|
<Desk
|
|
|
|
class="flex-1"
|
|
|
|
v-if="activeScreen === 'Desk'"
|
|
|
|
@change-db-file="changeDbFile"
|
2019-12-16 17:04:22 +05:30
|
|
|
/>
|
2020-01-01 13:41:57 +05:30
|
|
|
<DatabaseSelector
|
|
|
|
v-if="activeScreen === 'DatabaseSelector'"
|
2020-02-03 23:12:34 +05:30
|
|
|
@database-connect="showSetupWizardOrDesk(true)"
|
2020-01-01 13:41:57 +05:30
|
|
|
/>
|
|
|
|
<SetupWizard
|
|
|
|
v-if="activeScreen === 'SetupWizard'"
|
2022-02-02 13:53:04 +05:30
|
|
|
@setup-complete="setupComplete"
|
2021-12-20 15:22:31 +05:30
|
|
|
@setup-canceled="setupCanceled"
|
2020-01-01 13:41:57 +05:30
|
|
|
/>
|
2022-02-16 16:07:09 +05:30
|
|
|
<div
|
|
|
|
id="toast-container"
|
|
|
|
class="absolute bottom-0 flex flex-col items-end mb-3 pr-6"
|
|
|
|
style="width: 100%"
|
|
|
|
>
|
|
|
|
<div id="toast-target" />
|
|
|
|
</div>
|
2022-03-11 15:15:43 +05:30
|
|
|
<TelemetryModal />
|
2018-06-01 18:05:51 +05:30
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-20 12:08:47 +05:30
|
|
|
import { ipcRenderer } from 'electron';
|
|
|
|
import fs from 'fs/promises';
|
|
|
|
import frappe from 'fyo';
|
|
|
|
import WindowsTitleBar from 'src/components/WindowsTitleBar';
|
|
|
|
import config from 'src/config';
|
2022-02-02 13:53:04 +05:30
|
|
|
import {
|
2022-04-19 11:29:36 +05:30
|
|
|
connectToLocalDatabase,
|
|
|
|
postSetup,
|
|
|
|
purgeCache
|
2022-04-20 12:08:47 +05:30
|
|
|
} from 'src/initialization';
|
2022-04-19 11:29:36 +05:30
|
|
|
import { IPC_ACTIONS, IPC_MESSAGES } from 'utils/messages';
|
2022-03-11 15:15:43 +05:30
|
|
|
import TelemetryModal from './components/once/TelemetryModal.vue';
|
2022-01-19 13:09:39 +05:30
|
|
|
import { showErrorDialog } from './errorHandling';
|
2022-03-11 15:15:43 +05:30
|
|
|
import DatabaseSelector from './pages/DatabaseSelector';
|
|
|
|
import Desk from './pages/Desk';
|
|
|
|
import SetupWizard from './pages/SetupWizard/SetupWizard';
|
|
|
|
import './styles/index.css';
|
2022-03-15 17:27:37 +05:30
|
|
|
import telemetry from './telemetry/telemetry';
|
2022-03-11 15:15:43 +05:30
|
|
|
import { checkForUpdates, routeTo } from './utils';
|
2018-06-01 18:05:51 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'App',
|
2018-06-11 15:16:25 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2021-11-04 15:03:51 +05:30
|
|
|
activeScreen: null,
|
2019-08-20 14:27:27 +05:30
|
|
|
};
|
2018-06-11 15:16:25 +05:30
|
|
|
},
|
2019-10-13 17:33:01 +05:30
|
|
|
watch: {
|
2021-11-04 15:03:51 +05:30
|
|
|
async activeScreen(value) {
|
2020-01-01 13:41:57 +05:30
|
|
|
if (!value) return;
|
2021-11-06 01:11:39 +05:30
|
|
|
const { width, height } = await ipcRenderer.invoke(
|
2021-11-04 15:03:51 +05:30
|
|
|
IPC_ACTIONS.GET_PRIMARY_DISPLAY_SIZE
|
|
|
|
);
|
2021-11-24 14:38:13 +05:30
|
|
|
|
2020-01-01 13:41:57 +05:30
|
|
|
let size = {
|
2020-01-23 18:28:51 +05:30
|
|
|
Desk: [width, height],
|
2020-01-01 13:41:57 +05:30
|
|
|
DatabaseSelector: [600, 600],
|
|
|
|
SetupWizard: [600, 600],
|
|
|
|
}[value];
|
|
|
|
let resizable = value === 'Desk';
|
|
|
|
|
2021-11-24 14:38:13 +05:30
|
|
|
if (size.length) {
|
2021-11-04 15:03:51 +05:30
|
|
|
ipcRenderer.send(IPC_MESSAGES.RESIZE_MAIN_WINDOW, size, resizable);
|
2019-10-13 17:33:01 +05:30
|
|
|
}
|
2021-11-04 15:03:51 +05:30
|
|
|
},
|
2019-10-13 17:33:01 +05:30
|
|
|
},
|
2018-06-01 18:05:51 +05:30
|
|
|
components: {
|
2018-10-23 18:12:36 +05:30
|
|
|
Desk,
|
2018-10-22 23:40:22 +05:30
|
|
|
SetupWizard,
|
2019-10-19 19:56:13 +05:30
|
|
|
DatabaseSelector,
|
2021-11-04 15:03:51 +05:30
|
|
|
WindowsTitleBar,
|
2022-03-11 15:15:43 +05:30
|
|
|
TelemetryModal,
|
2018-06-11 15:16:25 +05:30
|
|
|
},
|
2020-01-01 13:41:57 +05:30
|
|
|
async mounted() {
|
2022-03-18 15:39:17 +05:30
|
|
|
telemetry.platform = this.platform;
|
2021-11-06 01:11:39 +05:30
|
|
|
const lastSelectedFilePath = config.get('lastSelectedFilePath', null);
|
2021-12-10 13:36:38 +05:30
|
|
|
const { connectionSuccess, reason } = await connectToLocalDatabase(
|
2021-11-06 01:11:39 +05:30
|
|
|
lastSelectedFilePath
|
|
|
|
);
|
|
|
|
|
|
|
|
if (connectionSuccess) {
|
2022-02-02 13:53:04 +05:30
|
|
|
this.showSetupWizardOrDesk(false);
|
2021-12-10 13:36:38 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastSelectedFilePath) {
|
2022-01-24 14:34:37 +05:30
|
|
|
const title = this.t`DB Connection Error`;
|
|
|
|
const content = `reason: ${reason}, filePath: ${lastSelectedFilePath}`;
|
|
|
|
|
|
|
|
await showErrorDialog(title, content);
|
2018-10-23 18:12:36 +05:30
|
|
|
}
|
2021-12-10 13:36:38 +05:30
|
|
|
|
|
|
|
this.activeScreen = 'DatabaseSelector';
|
2020-01-01 13:41:57 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2022-02-02 13:53:04 +05:30
|
|
|
async setupComplete() {
|
|
|
|
await postSetup();
|
|
|
|
await this.showSetupWizardOrDesk(true);
|
|
|
|
},
|
2021-12-02 18:50:51 +05:30
|
|
|
async showSetupWizardOrDesk(resetRoute = false) {
|
2020-01-01 13:41:57 +05:30
|
|
|
const { setupComplete } = frappe.AccountingSettings;
|
|
|
|
if (!setupComplete) {
|
|
|
|
this.activeScreen = 'SetupWizard';
|
2019-10-24 16:09:57 +05:30
|
|
|
} else {
|
2020-01-01 13:41:57 +05:30
|
|
|
this.activeScreen = 'Desk';
|
2022-02-16 17:03:39 +05:30
|
|
|
await checkForUpdates(false);
|
2019-10-24 16:09:57 +05:30
|
|
|
}
|
2021-12-02 18:50:51 +05:30
|
|
|
|
|
|
|
if (!resetRoute) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { onboardingComplete } = await frappe.getSingle('GetStarted');
|
|
|
|
const { hideGetStarted } = await frappe.getSingle('SystemSettings');
|
|
|
|
|
|
|
|
if (hideGetStarted || onboardingComplete) {
|
2021-11-24 14:38:13 +05:30
|
|
|
routeTo('/');
|
2021-12-02 18:50:51 +05:30
|
|
|
} else {
|
|
|
|
routeTo('/get-started');
|
2019-12-16 17:04:22 +05:30
|
|
|
}
|
2019-12-27 12:07:39 +05:30
|
|
|
},
|
2022-03-17 17:16:49 +05:30
|
|
|
async changeDbFile() {
|
2021-11-24 14:38:13 +05:30
|
|
|
config.set('lastSelectedFilePath', null);
|
2022-03-18 15:39:17 +05:30
|
|
|
telemetry.stop();
|
2022-03-17 17:16:49 +05:30
|
|
|
await purgeCache(true);
|
2021-11-24 14:38:13 +05:30
|
|
|
this.activeScreen = 'DatabaseSelector';
|
|
|
|
},
|
2021-12-20 15:22:31 +05:30
|
|
|
async setupCanceled() {
|
2021-12-21 18:03:30 +05:30
|
|
|
const filePath = config.get('lastSelectedFilePath');
|
|
|
|
await fs.unlink(filePath);
|
|
|
|
this.changeDbFile();
|
2021-12-20 15:22:31 +05:30
|
|
|
},
|
2021-11-04 15:03:51 +05:30
|
|
|
},
|
2019-08-20 14:27:27 +05:30
|
|
|
};
|
2018-06-01 18:05:51 +05:30
|
|
|
</script>
|