frontend, api: add ability to clear comments

This commit is contained in:
Adhityaa Chandrasekar
2019-04-13 21:02:40 -04:00
parent 65ea597c08
commit 9607c15c2b
6 changed files with 151 additions and 34 deletions

View File

@@ -20,6 +20,18 @@
}
// Clears all comments in a domain.
global.domainClearHandler = function() {
var data = global.dashboard.$data;
global.domainClear(data.domains[data.cd].domain, function(success) {
if (success) {
document.location = global.origin + "/dashboard";
}
});
}
// Freezes a domain.
global.domainFreezeHandler = function() {
var data = global.dashboard.$data;

View File

@@ -149,4 +149,24 @@
});
}
// Clears the comments in a domain.
global.domainClear = function(domain, callback) {
var json = {
"ownerToken": global.cookieGet("commentoOwnerToken"),
"domain": domain,
};
global.post(global.origin + "/api/domain/clear", json, function(resp) {
if (!resp.success) {
global.globalErrorShow(resp.message);
return;
}
if (callback !== undefined) {
callback(resp.success);
}
});
}
} (window.commento, document));