mirror of
https://github.com/zadam/trilium.git
synced 2025-01-09 16:49:11 +08:00
#98, test sync impl
This commit is contained in:
parent
e7460ca3a9
commit
a06618d851
6 changed files with 43 additions and 2 deletions
|
@ -192,6 +192,7 @@ addTabHandler((function() {
|
|||
const $syncServerHost = $("#sync-server-host");
|
||||
const $syncServerTimeout = $("#sync-server-timeout");
|
||||
const $syncProxy = $("#sync-proxy");
|
||||
const $testSyncButton = $("#test-sync-button");
|
||||
|
||||
function optionsLoaded(options) {
|
||||
$syncServerHost.val(options['syncServerHost']);
|
||||
|
@ -209,6 +210,17 @@ addTabHandler((function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
$testSyncButton.click(async () => {
|
||||
const result = await server.post('sync/test');
|
||||
|
||||
if (result.connection === "Success") {
|
||||
infoService.showMessage("Sync server handshake has been successful");
|
||||
}
|
||||
else {
|
||||
infoService.showError("Sync server handshake failed, error: " + result.error);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
optionsLoaded
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ async function setupSyncFromServer(req) {
|
|||
auth: username + ':' + password
|
||||
};
|
||||
|
||||
log.info("Getting document from: " + serverAddress + JSON.stringify(options));
|
||||
log.info("Getting document from: " + serverAddress);
|
||||
|
||||
http.request(options, function(response) {
|
||||
response.pipe(file);
|
||||
|
|
|
@ -9,6 +9,20 @@ const contentHashService = require('../../services/content_hash');
|
|||
const log = require('../../services/log');
|
||||
const DOCUMENT_PATH = require('../../services/data_dir').DOCUMENT_PATH;
|
||||
|
||||
async function testSync() {
|
||||
try {
|
||||
await syncService.login();
|
||||
|
||||
return { connection: "Success" };
|
||||
}
|
||||
catch (e) {
|
||||
return {
|
||||
connection: "Failure",
|
||||
error: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function checkSync() {
|
||||
return {
|
||||
hashes: await contentHashService.getHashes(),
|
||||
|
@ -80,6 +94,7 @@ async function getDocument(req, resp) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
testSync,
|
||||
checkSync,
|
||||
syncNow,
|
||||
fillSyncRows,
|
||||
|
|
|
@ -148,6 +148,7 @@ function register(app) {
|
|||
|
||||
apiRoute(POST, '/api/password/change', passwordApiRoute.changePassword);
|
||||
|
||||
apiRoute(POST, '/api/sync/test', syncApiRoute.testSync);
|
||||
apiRoute(GET, '/api/sync/check', syncApiRoute.checkSync);
|
||||
apiRoute(POST, '/api/sync/now', syncApiRoute.syncNow);
|
||||
apiRoute(POST, '/api/sync/fill-sync-rows', syncApiRoute.fillSyncRows);
|
||||
|
|
|
@ -289,5 +289,6 @@ sqlInit.dbReady.then(async () => {
|
|||
|
||||
module.exports = {
|
||||
sync,
|
||||
login,
|
||||
getSyncRecords
|
||||
};
|
|
@ -406,7 +406,7 @@
|
|||
</form>
|
||||
</div>
|
||||
<div id="sync-setup">
|
||||
<h4 style="margin-top: 0px;">Sync</h4>
|
||||
<h4 style="margin-top: 0px;">Sync configuration</h4>
|
||||
|
||||
<form id="sync-setup-form">
|
||||
<div class="form-group">
|
||||
|
@ -426,6 +426,18 @@
|
|||
|
||||
<button class="btn btn-sm">Save</button>
|
||||
</form>
|
||||
|
||||
<h4>Sync test</h4>
|
||||
|
||||
<p>This will test connection and handshake to the sync server.</p>
|
||||
|
||||
<button id="test-sync-button" class="btn btn-sm">Test sync</button>
|
||||
|
||||
<h4>Copy document to the server instance</h4>
|
||||
|
||||
<p>This is used when you're setting up server instance of Trilium. After the installation the databa</p>
|
||||
|
||||
<button id="test-sync-button" class="btn btn-sm">Copy document to the sync server</button>
|
||||
</div>
|
||||
<div id="advanced">
|
||||
<h4 style="margin-top: 0px;">Sync</h4>
|
||||
|
|
Loading…
Reference in a new issue