diff --git a/.eslintignore b/.eslintignore index d8b0d0a..4147c4b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ test/unit/coverage/** test/unit/*.js test/e2e/*.js +src/** diff --git a/src/main/index.js b/src/main/index.js index 3aed3f7..99fc2c9 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,8 +1,9 @@ 'use strict' -import { app, BrowserWindow, Tray, ipcMain, Notification } from 'electron' +import { app, BrowserWindow, Tray, ipcMain, Notification, dialog } from 'electron' import path from 'path' import ps from 'portscanner' +import fs from 'fs' /** * Set `__static` path to static files in production * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html @@ -132,6 +133,44 @@ ipcMain.on('serviceStatusChange', (event, service, status) => { } }) +ipcMain.on('allFolderConfigurations', (event) => { + let userConfiguration = readConfigurationFile() + event.sender.send('allFolderConfigurationsz', userConfiguration) +}) + +ipcMain.on('updateFolderConfigurations', (event, userConfiguration) => { + createUpdateConfigurationFile(userConfiguration) +}) + +ipcMain.on('openDirectory', (event) => { + // if (false) { + // dialog.showOpenDialog(mainWindow, { + + // properties: ['openDirectory'] + + // }) + // } + +}) + +ipcMain.on('selectFcsDirectory', (event) => { + event.sender.send('fcsDirectory', dialog.showOpenDialog(mainWindow, { + properties: ['openDirectory'] + })) +}) + +ipcMain.on('selectFcsWebDirectory', (event) => { + event.sender.send('fcsWebDirectory', dialog.showOpenDialog(mainWindow, { + properties: ['openDirectory'] + })) +}) + +ipcMain.on('selectFcsUiDirectory', (event) => { + event.sender.send('fcsUiDirectory', dialog.showOpenDialog(mainWindow, { + properties: ['openDirectory'] + })) +}) + setInterval(() => { // console.log('Interval has been passed!!') let portsForServices = [ @@ -158,6 +197,57 @@ setInterval(() => { checkIfPortsOpenAndEmit(portsForExternals, externalsEvent) }, 300) +// function parseDataFile (filePath, defaults) { +// try { +// return JSON.parse(fs.readFileSync(filepPath)) +// } catch (error) { +// return { +// default: true +// } +// } +// } + +function readConfigurationFile () { + let pathToFile = app.getPath('appData') + '/FCSToolbar/configuration.json' + try { + let userConfiguration = fs.readFileSync(pathToFile) + return JSON.parse(userConfiguration) + } catch (err) { + createUpdateConfigurationFile() + let userConfiguration = fs.readFileSync(pathToFile) + return JSON.parse(userConfiguration) + } +} + +function createUpdateConfigurationFile (userConfiguration = {name: '', fcsLocation: '', fcsWebLocation: '', fcsUiLocation: ''}) { + let pathToStorage = app.getPath('appData') + '/FCSToolbar' + let pathToFile = pathToStorage + '/configuration.json' + console.log(app.getAppPath()) + console.log(app.getPath('appData')) + + if (!fs.existsSync(pathToStorage)) { + fs.mkdirSync(pathToStorage) + } + + // if (!fs.existsSync(pathToFile)) { + // fs.writeFile(pathToFile, 'utf8', function (err) { + // if (err) throw err + // }) + // } + + let configuration = { name: '', fcsLocation: '', fcsWebLocation: '', fcsUiLocation: '' } + configuration.fcsLocation = userConfiguration.fcsLocation + configuration.fcsWebLocation = userConfiguration.fcsWebLocation + configuration.fcsUiLocation = userConfiguration.fcsUiLocation + + let configurationString = JSON.stringify(configuration) + try { + fs.writeFileSync(pathToFile, configurationString, 'utf8') + } catch (err) { + throw err + } +} + function checkIfPortsOpenAndEmit (portsArray, servicesEvent) { let activePortMapping = {} let promiseArray = [] diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 2997c6a..73eddd7 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -1,15 +1,95 @@ diff --git a/src/renderer/components/LandingPage.vue b/src/renderer/components/LandingPage.vue index 62a2e4a..c8cb23d 100644 --- a/src/renderer/components/LandingPage.vue +++ b/src/renderer/components/LandingPage.vue @@ -1,14 +1,4 @@ \ No newline at end of file diff --git a/src/renderer/components/toolbar-apps/FCSCommands.vue b/src/renderer/components/toolbar-apps/FCSCommands.vue index ff4ebc9..c90eed0 100644 --- a/src/renderer/components/toolbar-apps/FCSCommands.vue +++ b/src/renderer/components/toolbar-apps/FCSCommands.vue @@ -1,71 +1,80 @@ + + \ No newline at end of file diff --git a/src/renderer/components/toolbar-apps/FCSLinks.vue b/src/renderer/components/toolbar-apps/FCSLinks.vue index 4067de2..59044cb 100644 --- a/src/renderer/components/toolbar-apps/FCSLinks.vue +++ b/src/renderer/components/toolbar-apps/FCSLinks.vue @@ -1,71 +1,80 @@ + + \ No newline at end of file diff --git a/src/renderer/components/toolbar-apps/TrafficLight.vue b/src/renderer/components/toolbar-apps/TrafficLight.vue index 0431732..0bacc72 100644 --- a/src/renderer/components/toolbar-apps/TrafficLight.vue +++ b/src/renderer/components/toolbar-apps/TrafficLight.vue @@ -1,71 +1,80 @@ + + \ No newline at end of file diff --git a/src/renderer/components/toolbar-apps/WeightedList/Home.vue b/src/renderer/components/toolbar-apps/WeightedList/Home.vue index 54fd1f4..7ab9da8 100644 --- a/src/renderer/components/toolbar-apps/WeightedList/Home.vue +++ b/src/renderer/components/toolbar-apps/WeightedList/Home.vue @@ -1,88 +1,89 @@ - \ No newline at end of file diff --git a/src/renderer/components/toolbar-apps/WeightedList/WeightedList.vue b/src/renderer/components/toolbar-apps/WeightedList/WeightedList.vue index 33018e3..a4e531b 100644 --- a/src/renderer/components/toolbar-apps/WeightedList/WeightedList.vue +++ b/src/renderer/components/toolbar-apps/WeightedList/WeightedList.vue @@ -1,56 +1,57 @@ \ No newline at end of file diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js index a09d5d8..9fb2e4e 100644 --- a/src/renderer/router/index.js +++ b/src/renderer/router/index.js @@ -13,22 +13,39 @@ export default new Router({ { path: '/fc', name: 'fc', - component: require('@/components/toolbar-apps/FCSCommands').default + component: require('@/components/toolbar-apps/FCSCommands').default, + props: { + showHeaderAndFooter: false + } }, { path: '/wl', name: 'wl', - component: require('@/components/toolbar-apps/WeightedList/WeightedList').default + component: require('@/components/toolbar-apps/WeightedList/Home').default, + props: { + showHeaderAndFooter: false + } }, { path: '/tl', name: 'tl', - component: require('@/components/toolbar-apps/TrafficLight').default + component: require('@/components/toolbar-apps/TrafficLight').default, + props: { + showHeaderAndFooter: false + } }, { path: '/ul', name: 'ul', - component: require('@/components/toolbar-apps/FCSLinks').default + component: require('@/components/toolbar-apps/FCSLinks').default, + props: { + showHeaderAndFooter: false + } + }, + { + path: '/settings', + name: 'settings', + component: require('@/components/Settings').default }, { path: '*', diff --git a/static/index.css b/static/index.css index a3edbc5..3296208 100644 --- a/static/index.css +++ b/static/index.css @@ -73,7 +73,7 @@ width: 100%; margin: auto; text-align: center; - margin-top: 16px; + margin-top: 5px; font-size: var(--font-size); font-weight: 300; color: var(--text-color);