diff --git a/controllers/web/show_sync.js b/controllers/web/show_sync.js index a5f1d8080..2cfaade1d 100644 --- a/controllers/web/show_sync.js +++ b/controllers/web/show_sync.js @@ -1,5 +1,7 @@ 'use strict'; +var config = require('../../config'); + module.exports = function* showSync() { var name = this.params.name || this.params[0] || this.query.name; if (!name) { @@ -11,9 +13,11 @@ module.exports = function* showSync() { name = splits[1]; type = splits[0]; } + var syncTaskUrl = config.enableWebDataRemoteRegistry ? `${config.webDataRemoteRegistry}/${name}/sync` : null; yield this.render('sync', { type: type, name: name, title: 'Sync ' + type + ' - ' + name, + syncTaskUrl, }); }; diff --git a/view/web/sync.html b/view/web/sync.html index 436e72c26..a34025cf1 100644 --- a/view/web/sync.html +++ b/view/web/sync.html @@ -15,7 +15,11 @@

Log

if (type !== 'package') { name = type + ':' + name; } + <% if (syncTaskUrl) { %> + var resourceURL = '<%= syncTaskUrl %>'; + <% } else { %> var resourceURL = '/sync/' + name; + <% } %> $(function() { var checkLogId = location.hash.match(/logid=(\d+)/); var logid = checkLogId ? checkLogId[1] : ''; @@ -26,6 +30,7 @@

Log

url: resourceURL + '?sync_upstream=true', type: 'PUT', dataType: 'json', + crossDomain: true, success: handleSyncSucess, error: function (err) { var alert = $('
'); @@ -57,6 +62,7 @@

Log

$.ajax({ url: resourceURL + '/log/' + id, type: 'GET', + crossDomain: true, dataType: 'json', success: function (data) { if (!data.ok) { @@ -72,12 +78,13 @@

Log

} if (syncDone) { log += '\nSync ' + name + ' complete!'; + var logLink = data.logUrl ? (' ' + data.logUrl + '') : ''; if (hasFail) { log += ' But some packages sync failed, you can refresh to sync again.'; location.hash = ''; - $notify.html('
Sync failed.
'); + $notify.html('
Sync failed.' + logLink + '
'); } else { - $notify.html('
Sync success.
'); + $notify.html('
Sync success.' + logLink + '
'); } clearInterval(timer); }