// this singleton contains miscellaneous utilities
+ // use in panels with object spread (...) operator, for example:
+ // ...PMG.Utils.onlineHelpTool('sysadmin_certificate_management'),
+ onlineHelpTool: function(blockid) {
+ let info = Proxmox.Utils.get_help_info(blockid);
+ if (info === undefined) {
+ info = Proxmox.Utils.get_help_info('pmg_documentation_index');
+ if (info === undefined) {
+ throw "get_help_info failed"; // should not happen
+ }
+ }
+
+ let docsURI = window.location.origin + info.link;
+ let title = info.title || gettext('Help');
+ if (info.subtitle) {
+ title += ' - ' + info.subtitle;
+ }
+ return {
+ tools: [
+ {
+ type: 'help',
+ tooltip: title,
+ handler: () => window.open(docsURI),
+ },
+ ],
+ };
+ },
+
senderText: gettext('Sender'),
receiverText: gettext('Receiver'),
scoreText: gettext('Score'),
slideBackAnimation: 'easeOut',
iconCls: 'fa fa-check',
shadow: true,
+ align: 'br',
});
if (Ext.isFunction(callback)) {
var me = this;
// do whatever you want here
+ Proxmox.Utils.override_task_descriptions({
+ applycustomscores: ['', gettext('Apply custom SpamAssassin scores')],
+ avupdate: ['', gettext('ClamAV update')],
+ backup: ['', gettext('Backup')],
+ clustercreate: ['', gettext('Create Cluster')],
+ clusterjoin: ['', gettext('Join Cluster')],
+ restore: ['', gettext('Restore')],
+ saupdate: ['', gettext('SpamAssassin update')],
+ });
+ },
+});
+
+Ext.define('PMG.Async', {
+ singleton: true,
+
+ // Returns a Promise which executes a quarantine action when awaited.
+ // Shows a Toast message box once completed, if batchNumber and batchTotal
+ // are set, they will be included into the title of that toast.
+ doQAction: function(action, ids, batchNumber, batchTotal) {
+ if (!Ext.isArray(ids)) {
+ ids = [ids];
+ }
+ return Proxmox.Async.api2({
+ url: '/quarantine/content/',
+ params: {
+ action: action,
+ id: ids.join(';'),
+ },
+ method: 'POST',
+ }).then(
+ response => {
+ let count = ids.length;
+ let fmt = count > 1
+ ? gettext("Action '{0}' for '{1}' items successful")
+ : gettext("Action '{0}' successful")
+ ;
+ let message = Ext.String.format(fmt, action, count);
+ let titleFmt = batchNumber !== undefined && batchTotal > 1
+ ? gettext("{0} ({1}/{2}) successful")
+ : gettext("{0} successful")
+ ;
+ let title = Ext.String.format(
+ titleFmt,
+ Ext.String.capitalize(action),
+ batchNumber,
+ batchTotal,
+ );
+
+ Ext.toast({
+ html: message,
+ title: title,
+ minWidth: 200,
+ hideDuration: 250,
+ slideBackDuration: 250,
+ slideBackAnimation: 'easeOut',
+ iconCls: 'fa fa-check',
+ shadow: true,
+ align: 'br',
+ });
+ },
+ response => Proxmox.Utils.alertResponseFailure(response),
+ );
},
});