-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreferences.js
112 lines (104 loc) · 3.73 KB
/
preferences.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
'use strict';
const electron = require('electron');
const app = electron.app;
const path = require('path');
const os = require('os');
const ElectronPreferences = require('electron-preferences');
const main = require('./main');
const log = require('electron-log');
let datadir = path.resolve(app.getPath('userData', 'preferences.json'));
console.log(path.resolve(app.getPath('userData'), 'preferences.json'));
var config = require('./config');
let qsodatadir = config.qsodatadir;
if(qsodatadir == "")
{
const homedir = require('os').homedir();
if(process.env.LOCALAPPDATA != undefined) // Windows?
qsodatadir = homedir + '\\.js8assistant\\qsodata'; // this is the default data directory for Windows
else
qsodatadir = homedir + '/.js8assistant/qsodata'; // and for Linux and MacOS
}
let logPath = log.transports.file.getFile().path;
const preferences = new ElectronPreferences({
'dataStore': path.resolve(app.getPath('userData'), 'preferences.json'),
'defaults': {
'settings': {
'distance_unit': 'km',
'remote_ip': '127.0.0.1',
'font_size': '14'
},
},
'browserWindowOverrides': {
'title': 'JS8Assistant Settings',
},
'sections': [
{
'id': 'settings',
'label': 'Settings',
'icon': 'settings-gear-63',
'form': {
'groups': [
{
'label': 'Settings',
'fields': [
{
'label': 'Call Sign',
'key': 'call_sign',
'type': 'text',
},
{
'label': 'Distance Unit',
'key': 'distance_unit',
'type': 'dropdown',
'options': [
{'label': 'Kilometers', 'value': 'km'},
{'label': 'Miles', 'value': 'miles'},
],
},
{
'label': 'Remote IP Address',
'key': 'remote_ip',
'type': 'text',
},
{
'label': 'Font Size (default is 14)',
'key': 'font_size',
'type': 'text',
},
]
}
]
}
},
{
'id': 'info',
'label': 'Info',
'icon': 'notes',
'form': {
'groups': [
{
'label': 'Info',
'fields': [
{
'heading': 'QSO Data Folder',
'content': qsodatadir,
'type': 'message',
},
{
'heading': 'JS8Assistant Preferences Folder',
'content': datadir,
'type': 'message',
},
{
'heading': 'Log Folder',
'content': logPath,
'type': 'message',
},
]
}
]
}
},
]
});
module.exports = preferences;