Compare commits

...

6 Commits

Author SHA1 Message Date
azivner
867d794e17 release 0.10.1-beta 2018-04-06 00:15:04 -04:00
azivner
fdd8458336 fix sync branch route 2018-04-05 23:45:39 -04:00
azivner
a0bec22e96 fix non-200 logging 2018-04-05 23:35:49 -04:00
azivner
5aeb5cd214 jquery upgrade to 3.3.1 2018-04-05 23:18:15 -04:00
azivner
e827ddffb9 electron fixes 2018-04-05 23:17:19 -04:00
azivner
98f80998b9 fix electron build 2018-04-05 19:29:27 -04:00
11 changed files with 47 additions and 43 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "trilium", "name": "trilium",
"description": "Trilium Notes", "description": "Trilium Notes",
"version": "0.10.0-beta", "version": "0.10.1-beta",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"main": "electron.js", "main": "electron.js",
"repository": { "repository": {

View File

@@ -1,20 +1,19 @@
import server from './services/server.js'; import server from './services/server.js';
$(document).ready(() => { $(document).ready(async () => {
server.get('migration').then(result => { const {appDbVersion, dbVersion} = await server.get('migration');
const appDbVersion = result.app_dbVersion;
const dbVersion = result.dbVersion;
if (appDbVersion === dbVersion) { console.log("HI", {appDbVersion, dbVersion});
$("#up-to-date").show();
}
else {
$("#need-to-migrate").show();
$("#app-db-version").html(appDbVersion); if (appDbVersion === dbVersion) {
$("#db-version").html(dbVersion); $("#up-to-date").show();
} }
}); else {
$("#need-to-migrate").show();
$("#app-db-version").html(appDbVersion);
$("#db-version").html(dbVersion);
}
}); });
$("#run-migration").click(async () => { $("#run-migration").click(async () => {
@@ -37,4 +36,11 @@ $("#run-migration").click(async () => {
$("#migration-table").append(row); $("#migration-table").append(row);
} }
});
// copy of this shortcut to be able to debug migration problems
$(document).bind('keydown', 'ctrl+shift+i', () => {
require('electron').remote.getCurrentWindow().toggleDevTools();
return false;
}); });

View File

@@ -100,7 +100,7 @@ setTimeout(() => {
lastSyncId: lastSyncId lastSyncId: lastSyncId
})); }));
}, 1000); }, 1000);
}, 1000); }, 0);
export default { export default {
logError, logError,

View File

@@ -85,19 +85,17 @@ async function ajax(url, method, data) {
}); });
} }
setTimeout(() => { if (utils.isElectron()) {
if (utils.isElectron()) { const ipc = require('electron').ipcRenderer;
const ipc = require('electron').ipcRenderer;
ipc.on('server-response', (event, arg) => { ipc.on('server-response', (event, arg) => {
console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode); console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
reqResolves[arg.requestId](arg.body); reqResolves[arg.requestId](arg.body);
delete reqResolves[arg.requestId]; delete reqResolves[arg.requestId];
}); });
} }
}, 100);
export default { export default {
get, get,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@ const appInfo = require('../../services/app_info');
async function getMigrationInfo() { async function getMigrationInfo() {
return { return {
dbVersion: parseInt(await optionService.getOption('dbVersion')), dbVersion: parseInt(await optionService.getOption('dbVersion')),
app_dbVersion: appInfo.dbVersion appDbVersion: appInfo.dbVersion
}; };
} }

View File

@@ -19,6 +19,7 @@ function init(app) {
res.status = function(statusCode) { res.status = function(statusCode) {
res.statusCode = statusCode; res.statusCode = statusCode;
return res;
}; };
res.send = function(obj) { res.send = function(obj) {

View File

@@ -40,22 +40,22 @@ const cls = require('../services/cls');
const sql = require('../services/sql'); const sql = require('../services/sql');
const protectedSessionService = require('../services/protected_session'); const protectedSessionService = require('../services/protected_session');
function apiResultHandler(res, result) { function apiResultHandler(req, res, result) {
// if it's an array and first element is integer then we consider this to be [statusCode, response] format // if it's an array and first element is integer then we consider this to be [statusCode, response] format
if (Array.isArray(result) && result.length > 0 && Number.isInteger(result[0])) { if (Array.isArray(result) && result.length > 0 && Number.isInteger(result[0])) {
const [statusCode, response] = result; const [statusCode, response] = result;
res.status(statusCode).send(response); res.status(statusCode).send(response);
if (statusCode !== 200) { if (statusCode !== 200 && statusCode !== 201 && statusCode !== 204) {
log.info(`${method} ${path} returned ${statusCode} with response ${JSON.stringify(response)}`); log.info(`${req.method} ${req.originalUrl} returned ${statusCode} with response ${JSON.stringify(response)}`);
} }
} }
else if (result === undefined) { else if (result === undefined) {
res.status(204).send(); res.status(204).send();
} }
else { else {
res.status(200).send(result); res.send(result);
} }
} }
@@ -76,7 +76,7 @@ function route(method, path, middleware, routeHandler, resultHandler) {
}); });
if (resultHandler) { if (resultHandler) {
resultHandler(res, result); resultHandler(req, res, result);
} }
} }
catch (e) { catch (e) {
@@ -158,6 +158,7 @@ function register(app) {
apiRoute(GET, '/api/sync/labels/:labelId', syncApiRoute.getLabel); apiRoute(GET, '/api/sync/labels/:labelId', syncApiRoute.getLabel);
apiRoute(GET, '/api/sync/api_tokens/:apiTokenId', syncApiRoute.getApiToken); apiRoute(GET, '/api/sync/api_tokens/:apiTokenId', syncApiRoute.getApiToken);
apiRoute(PUT, '/api/sync/notes', syncApiRoute.updateNote); apiRoute(PUT, '/api/sync/notes', syncApiRoute.updateNote);
apiRoute(PUT, '/api/sync/branches', syncApiRoute.updateBranch);
apiRoute(PUT, '/api/sync/note_revisions', syncApiRoute.updateNoteRevision); apiRoute(PUT, '/api/sync/note_revisions', syncApiRoute.updateNoteRevision);
apiRoute(PUT, '/api/sync/note_reordering', syncApiRoute.updateNoteReordering); apiRoute(PUT, '/api/sync/note_reordering', syncApiRoute.updateNoteReordering);
apiRoute(PUT, '/api/sync/options', syncApiRoute.updateOption); apiRoute(PUT, '/api/sync/options', syncApiRoute.updateOption);

View File

@@ -1,6 +1,7 @@
const scriptService = require('./script'); const scriptService = require('./script');
const repository = require('./repository'); const repository = require('./repository');
const cls = require('./cls'); const cls = require('./cls');
const sqlInit = require('./sql_init');
async function runNotesWithLabel(runAttrValue) { async function runNotesWithLabel(runAttrValue) {
const notes = await repository.getEntities(` const notes = await repository.getEntities(`
@@ -19,8 +20,10 @@ async function runNotesWithLabel(runAttrValue) {
} }
} }
setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000); sqlInit.dbReady.then(() => {
setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000);
setInterval(cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000); setInterval(cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000);
setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000); setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000);
});

View File

@@ -18,8 +18,6 @@ const log = require('./services/log');
const appInfo = require('./services/app_info'); const appInfo = require('./services/app_info');
const messagingService = require('./services/messaging'); const messagingService = require('./services/messaging');
const utils = require('./services/utils'); const utils = require('./services/utils');
const sql = require('./services/sql');
const sqlInit = require('./services/sql_init');
const port = normalizePort(config['Network']['port'] || '3000'); const port = normalizePort(config['Network']['port'] || '3000');
app.set('port', port); app.set('port', port);
@@ -56,7 +54,7 @@ httpServer.listen(port);
httpServer.on('error', onError); httpServer.on('error', onError);
httpServer.on('listening', onListening); httpServer.on('listening', onListening);
sqlInit.dbReady.then(() => messagingService.init(httpServer, sessionParser)); messagingService.init(httpServer, sessionParser);
if (utils.isElectron()) { if (utils.isElectron()) {
const electronRouting = require('./routes/electron'); const electronRouting = require('./routes/electron');