Skip to content

Commit

Permalink
Merge pull request #294 from royteeuwen/feature/fix-extra-actions
Browse files Browse the repository at this point in the history
Displays a message when publishing was triggered successfully
  • Loading branch information
stoerr authored Feb 15, 2023
2 parents 7b9f311 + 45f0179 commit c00cc9d
Showing 1 changed file with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,49 @@
}
if (!$(event.currentTarget).hasClass('disabled')) {
var node = this.tree.current()
core.ajaxPost('/bin/replicate.json',
{
'path' : node.path,
'cmd':'activate'
}, {}, _.bind(function (result) {
}, this), _.bind(function (result) {
core.alert('danger', 'Error', 'Error on activate', result);
}, this));
this.performReplicationCommand('activate', node.path, 'Activated');
}
},

performReplicationCommand: function(cmd, path, title) {
core.ajaxPost('/bin/replicate.json',
{
'path' : path,
'cmd': cmd
}, {}, _.bind(function (result) {
if (result.path) {
// in AEMaaCS this is a JSON response
var status = result['status.code'];
var message = result['status.message'];
} else {
// result is HTML on AEM 6.5
var $result = $($.parseHTML(result));
var status = $result.find('#Status').text();
var message = $result.find('#Message').text();
}
if (status == '200' && message) {
core.alert('success', title, message);
} else {
core.alert('danger', 'Error ' + status, message ? message : 'Unparseable response on ' + cmd);
}
}, this), _.bind(function (result) {
core.alert('danger', 'Error', 'Error on ' + cmd);
}, this));
},

deactivateNode: function (event) {
if (event) {
event.preventDefault();
}
if (!$(event.currentTarget).hasClass('disabled')) {
var node = this.tree.current()
core.ajaxPost('/bin/replicate.json',
{
'path' : node.path,
'cmd':'deactivate'
}, {}, _.bind(function (result) {
}, this), _.bind(function (result) {
core.alert('danger', 'Error', 'Error on deactivate', result);
}, this));
this.performReplicationCommand('deactivate', node.path, 'Deactivated');
}
}


});

aemBrowser.treeActions = core.getView('#browser-tree-actions', aemBrowser.TreeActions, null, true);

})(CPM.nodes.aem.browser, CPM.nodes.browser, CPM.core);
})();
})();

0 comments on commit c00cc9d

Please sign in to comment.