2016-11-10 05:56:23 +00:00
|
|
|
import * as db from '../common/database';
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
export const name = 'Settings';
|
2016-10-02 20:57:00 +00:00
|
|
|
export const type = 'Settings';
|
|
|
|
export const prefix = 'set';
|
2017-03-23 22:10:42 +00:00
|
|
|
export const canDuplicate = false;
|
2016-11-22 19:42:10 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export function init () {
|
2016-11-10 01:15:27 +00:00
|
|
|
return {
|
2016-11-26 08:29:16 +00:00
|
|
|
showPasswords: false,
|
2016-10-02 20:57:00 +00:00
|
|
|
useBulkHeaderEditor: false,
|
2016-10-26 17:49:49 +00:00
|
|
|
followRedirects: true,
|
2016-10-02 20:57:00 +00:00
|
|
|
editorFontSize: 12,
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize: 4,
|
2016-10-02 20:57:00 +00:00
|
|
|
editorLineWrapping: true,
|
2017-01-24 22:18:11 +00:00
|
|
|
editorKeyMap: 'default',
|
2016-10-02 20:57:00 +00:00
|
|
|
httpProxy: '',
|
|
|
|
httpsProxy: '',
|
2017-03-28 22:45:23 +00:00
|
|
|
proxyEnabled: false,
|
2016-10-02 20:57:00 +00:00
|
|
|
timeout: 0,
|
2016-10-21 17:20:36 +00:00
|
|
|
validateSSL: true,
|
2016-10-26 20:19:18 +00:00
|
|
|
forceVerticalLayout: false,
|
2017-03-03 20:09:08 +00:00
|
|
|
theme: 'default'
|
2016-11-10 01:15:27 +00:00
|
|
|
};
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
export function migrate (doc) {
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:18:39 +00:00
|
|
|
export async function all () {
|
|
|
|
const settings = await db.all(type);
|
|
|
|
if (settings.length === 0) {
|
|
|
|
return [await getOrCreate()];
|
|
|
|
} else {
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function create (patch = {}) {
|
|
|
|
return db.docCreate(type, patch);
|
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function update (settings, patch) {
|
2016-09-21 20:32:45 +00:00
|
|
|
return db.docUpdate(settings, patch);
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function getOrCreate () {
|
|
|
|
const results = await db.all(type);
|
|
|
|
if (results.length === 0) {
|
|
|
|
return await create();
|
|
|
|
} else {
|
|
|
|
return results[0];
|
|
|
|
}
|
|
|
|
}
|