X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=js%2FUtils.js;h=149abd684711812bb47b3f820048544a4f8b7764;hb=HEAD;hp=b96010f6d008284f1a552aff8542cba08fd97616;hpb=74468b03a5f7e296c8a564c475e5d12bdc0a28c7;p=pmg-gui.git
diff --git a/js/Utils.js b/js/Utils.js
index b96010f..9b5f054 100644
--- a/js/Utils.js
+++ b/js/Utils.js
@@ -1,4 +1,3 @@
-/*global Proxmox */
Ext.ns('PMG');
console.log("Starting PMG Manager");
@@ -9,6 +8,33 @@ Ext.define('PMG.Utils', {
// 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'),
@@ -18,7 +44,7 @@ Ext.define('PMG.Utils', {
admin: gettext('Administrator'),
helpdesk: gettext('Help Desk'),
qmanager: gettext('Quarantine Manager'),
- audit: gettext('Auditor')
+ audit: gettext('Auditor'),
},
format_user_role: function(role) {
@@ -31,7 +57,7 @@ Ext.define('PMG.Utils', {
when: gettext('When Objects'),
action: gettext('Action Objects'),
from: gettext('From'),
- to: gettext('To')
+ to: gettext('To'),
},
oclass_icon: {
@@ -40,7 +66,7 @@ Ext.define('PMG.Utils', {
when: ' ',
action: ' ',
from: ' ',
- to: ' '
+ to: ' ',
},
mail_status_map: {
@@ -51,7 +77,7 @@ Ext.define('PMG.Utils', {
G: 'greylisted',
A: 'accepted',
B: 'blocked',
- Q: 'quarantine'
+ Q: 'quarantine',
},
icon_status_map_class: {
@@ -62,14 +88,14 @@ Ext.define('PMG.Utils', {
G: 'list',
A: 'check',
B: 'ban',
- Q: 'cube'
+ Q: 'cube',
},
icon_status_map_color: {
2: 'green',
5: 'gray',
A: 'green',
- B: 'red'
+ B: 'red',
},
format_status_icon: function(status) {
@@ -87,13 +113,13 @@ Ext.define('PMG.Utils', {
rule_direction_text: {
0: gettext('In'),
1: gettext('Out'),
- 2: gettext('In & Out')
+ 2: gettext('In & Out'),
},
rule_direction_icon: {
0: ' ',
1: ' ',
- 2: ' '
+ 2: ' ',
},
format_rule_direction: function(dir) {
@@ -103,14 +129,12 @@ Ext.define('PMG.Utils', {
},
format_otype: function(otype) {
- var editor = PMG.Utils.object_editors[otype];
- var iconCls = 'fa fa-question-circle';
+ let editor = PMG.Utils.object_editors[otype];
+ let iconCls = 'fa fa-question-circle';
if (editor) {
- var icon = ' ';
- return icon + editor.subject;
+ return ` ${editor.subject}`;
}
-
- return ' unknown';
+ return ` unknown`;
},
format_ldap_protocol: function(p) {
@@ -122,7 +146,7 @@ Ext.define('PMG.Utils', {
},
convert_field_to_per_min: function(value, record) {
- return (value/(record.data.timespan/60));
+ return value / (record.data.timespan / 60);
},
object_editors: {
@@ -137,32 +161,30 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'regex',
- labelWidth: 150,
reference: 'regex',
- fieldLabel: gettext("Regular Expression")
+ fieldLabel: gettext("Regex"),
},
{
- labelWidth: 150,
- fieldLabel: gettext('Test String'),
xtype: 'pmgRegexTester',
+ fieldLabel: gettext('Test String'),
wholeMatch: true,
- regexFieldReference: 'regex'
- }
- ]
+ regexFieldReference: 'regex',
+ },
+ ],
},
1005: {
onlineHelp: 'pmgconfig_ldap',
iconCls: 'fa fa-users',
xtype: 'pmgLDAPGroupEditor',
subdir: 'ldap',
- subject: gettext("LDAP Group")
+ subject: gettext("LDAP Group"),
},
1006: {
onlineHelp: 'pmgconfig_ldap',
iconCls: 'fa fa-user',
xtype: 'pmgLDAPUserEditor',
subdir: 'ldapuser',
- subject: gettext("LDAP User")
+ subject: gettext("LDAP User"),
},
1009: {
onlineHelp: 'pmg_mailfilter_regex',
@@ -176,10 +198,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'regex',
- labelWidth: 150,
- fieldLabel: gettext("Regular Expression")
- }
- ]
+ fieldLabel: gettext("Regex"),
+ },
+ ],
},
1001: {
onlineHelp: 'pmg_mailfilter_who',
@@ -192,9 +213,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'email',
- fieldLabel: gettext("E-Mail")
- }
- ]
+ fieldLabel: gettext("E-Mail"),
+ },
+ ],
},
1007: {
onlineHelp: 'pmg_mailfilter_who',
@@ -208,9 +229,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'email',
- fieldLabel: gettext("E-Mail")
- }
- ]
+ fieldLabel: gettext("E-Mail"),
+ },
+ ],
},
1002: {
onlineHelp: 'pmg_mailfilter_who',
@@ -223,9 +244,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'domain',
- fieldLabel: gettext("Domain")
- }
- ]
+ fieldLabel: gettext("Domain"),
+ },
+ ],
},
1008: {
onlineHelp: 'pmg_mailfilter_who',
@@ -239,9 +260,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'domain',
- fieldLabel: gettext("Domain")
- }
- ]
+ fieldLabel: gettext("Domain"),
+ },
+ ],
},
1003: {
onlineHelp: 'pmg_mailfilter_who',
@@ -254,9 +275,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'ip',
- fieldLabel: gettext("IP Address")
- }
- ]
+ fieldLabel: gettext("IP Address"),
+ },
+ ],
},
1004: {
onlineHelp: 'pmg_mailfilter_who',
@@ -269,9 +290,9 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'cidr',
- fieldLabel: gettext("IP Network")
- }
- ]
+ fieldLabel: gettext("IP Network"),
+ },
+ ],
},
2000: {
onlineHelp: 'pmg_mailfilter_when',
@@ -284,15 +305,15 @@ Ext.define('PMG.Utils', {
xtype: 'timefield',
name: 'start',
format: 'H:i',
- fieldLabel: gettext("Start Time")
+ fieldLabel: gettext("Start Time"),
},
{
xtype: 'timefield',
name: 'end',
format: 'H:i',
- fieldLabel: gettext("End Time")
- }
- ]
+ fieldLabel: gettext("End Time"),
+ },
+ ],
},
3000: {
onlineHelp: 'pmg_mailfilter_what',
@@ -306,9 +327,9 @@ Ext.define('PMG.Utils', {
name: 'spamlevel',
allowBlank: false,
minValue: 0,
- fieldLabel: gettext('Level')
- }
- ]
+ fieldLabel: gettext('Level'),
+ },
+ ],
},
3001: {
onlineHelp: 'pmg_mailfilter_what',
@@ -321,8 +342,8 @@ Ext.define('PMG.Utils', {
listeners: {
show: function(win) {
win.submit();
- }
- }
+ },
+ },
},
3002: {
onlineHelp: 'pmg_mailfilter_regex',
@@ -335,25 +356,22 @@ Ext.define('PMG.Utils', {
{
xtype: 'textfield',
name: 'field',
- labelWidth: 150,
allowBlank: false,
- fieldLabel: gettext('Field')
+ fieldLabel: gettext('Field'),
},
{
xtype: 'textfield',
- reference: 'value',
name: 'value',
- labelWidth: 150,
+ reference: 'value',
allowBlank: false,
- fieldLabel: gettext('Value')
+ fieldLabel: gettext('Value'),
},
{
- labelWidth: 150,
- fieldLabel: gettext('Test String'),
xtype: 'pmgRegexTester',
- regexFieldReference: 'value'
- }
- ]
+ fieldLabel: gettext('Test String'),
+ regexFieldReference: 'value',
+ },
+ ],
},
3003: {
onlineHelp: 'pmg_mailfilter_what',
@@ -366,7 +384,6 @@ Ext.define('PMG.Utils', {
{
xtype: 'combobox',
displayField: 'text',
- labelWidth: 150,
valueField: 'mimetype',
name: 'contenttype',
editable: true,
@@ -375,8 +392,8 @@ Ext.define('PMG.Utils', {
autoLoad: true,
proxy: {
type: 'proxmox',
- url: '/api2/json/config/mimetypes'
- }
+ url: '/api2/json/config/mimetypes',
+ },
},
fieldLabel: gettext('Content Type'),
anyMatch: true,
@@ -385,17 +402,16 @@ Ext.define('PMG.Utils', {
change: function(cb, value) {
var me = this;
me.up().down('displayfield').setValue(value);
- }
- }
+ },
+ },
},
{
xtype: 'displayfield',
fieldLabel: gettext('Value'),
- labelWidth: 150,
allowBlank: false,
- reset: Ext.emptyFn
- }
- ]
+ reset: Ext.emptyFn,
+ },
+ ],
},
3004: {
onlineHelp: 'pmg_mailfilter_regex',
@@ -410,17 +426,15 @@ Ext.define('PMG.Utils', {
name: 'filename',
reference: 'filename',
fieldLabel: gettext('Filename'),
- labelWidth: 150,
- allowBlank: false
+ allowBlank: false,
},
{
- labelWidth: 150,
+ xtype: 'pmgRegexTester',
fieldLabel: gettext('Test String'),
wholeMatch: true,
- xtype: 'pmgRegexTester',
- regexFieldReference: 'filename'
- }
- ]
+ regexFieldReference: 'filename',
+ },
+ ],
},
3005: {
onlineHelp: 'pmg_mailfilter_what',
@@ -433,7 +447,6 @@ Ext.define('PMG.Utils', {
{
xtype: 'combobox',
displayField: 'text',
- labelWidth: 150,
valueField: 'mimetype',
name: 'contenttype',
editable: true,
@@ -442,8 +455,8 @@ Ext.define('PMG.Utils', {
autoLoad: true,
proxy: {
type: 'proxmox',
- url: '/api2/json/config/mimetypes'
- }
+ url: '/api2/json/config/mimetypes',
+ },
},
fieldLabel: gettext('Content Type'),
anyMatch: true,
@@ -452,17 +465,16 @@ Ext.define('PMG.Utils', {
change: function(cb, value) {
var me = this;
me.up().down('displayfield').setValue(value);
- }
- }
+ },
+ },
},
{
xtype: 'displayfield',
fieldLabel: gettext('Value'),
- labelWidth: 150,
allowBlank: false,
- reset: Ext.emptyFn
- }
- ]
+ reset: Ext.emptyFn,
+ },
+ ],
},
3006: {
onlineHelp: 'pmg_mailfilter_regex',
@@ -477,17 +489,15 @@ Ext.define('PMG.Utils', {
name: 'filename',
reference: 'filename',
fieldLabel: gettext('Filename'),
- labelWidth: 150,
- allowBlank: false
+ allowBlank: false,
},
{
- labelWidth: 150,
+ xtype: 'pmgRegexTester',
fieldLabel: gettext('Test String'),
wholeMatch: true,
- xtype: 'pmgRegexTester',
- regexFieldReference: 'filename'
- }
- ]
+ regexFieldReference: 'filename',
+ },
+ ],
},
4002: {
onlineHelp: 'pmg_mailfilter_action',
@@ -500,26 +510,26 @@ Ext.define('PMG.Utils', {
xtype: 'textfield',
name: 'name',
allowBlank: false,
- fieldLabel: gettext('Name')
+ fieldLabel: gettext('Name'),
},
{
xtype: 'textareafield',
name: 'info',
- fieldLabel: gettext("Comment")
+ fieldLabel: gettext("Comment"),
},
{
xtype: 'textfield',
name: 'to',
allowBlank: false,
value: '__ADMIN__',
- fieldLabel: gettext('Receiver')
+ fieldLabel: gettext('Receiver'),
},
{
xtype: 'textfield',
name: 'subject',
allowBlank: false,
value: 'Notification: __SUBJECT__',
- fieldLabel: gettext('Subject')
+ fieldLabel: gettext('Subject'),
},
{
xtype: 'textarea',
@@ -528,7 +538,7 @@ Ext.define('PMG.Utils', {
grow: true,
growMax: 250,
value:
- "Proxmox Notifcation:\n\n" +
+ "Proxmox Notification:\n\n" +
"Sender: __SENDER__\n" +
"Receiver: __RECEIVERS__\n" +
"Targets: __TARGETS__\n\n" +
@@ -537,14 +547,14 @@ Ext.define('PMG.Utils', {
"__RULE_INFO__\n\n" +
"__VIRUS_INFO__\n" +
"__SPAM_INFO__\n",
- fieldLabel: gettext('Body')
+ fieldLabel: gettext('Body'),
},
{
xtype: 'proxmoxcheckbox',
name: 'attach',
- fieldLabel: gettext("Attach orig. Mail")
- }
- ]
+ fieldLabel: gettext("Attach orig. Mail"),
+ },
+ ],
},
4003: {
onlineHelp: 'pmg_mailfilter_action',
@@ -557,27 +567,27 @@ Ext.define('PMG.Utils', {
xtype: 'textfield',
name: 'name',
allowBlank: false,
- fieldLabel: gettext('Name')
+ fieldLabel: gettext('Name'),
},
{
xtype: 'textareafield',
name: 'info',
- fieldLabel: gettext("Comment")
+ fieldLabel: gettext("Comment"),
},
{
xtype: 'textfield',
name: 'field',
allowBlank: false,
- fieldLabel: gettext('Field')
+ fieldLabel: gettext('Field'),
},
{
xtype: 'textfield',
reference: 'value',
name: 'value',
allowBlank: false,
- fieldLabel: gettext('Value')
- }
- ]
+ fieldLabel: gettext('Value'),
+ },
+ ],
},
4005: {
onlineHelp: 'pmg_mailfilter_action',
@@ -590,26 +600,26 @@ Ext.define('PMG.Utils', {
xtype: 'textfield',
name: 'name',
allowBlank: false,
- fieldLabel: gettext('Name')
+ fieldLabel: gettext('Name'),
},
{
xtype: 'textareafield',
name: 'info',
- fieldLabel: gettext("Comment")
+ fieldLabel: gettext("Comment"),
},
{
xtype: 'textfield',
name: 'target',
allowBlank: false,
- fieldLabel: gettext("Target")
+ fieldLabel: gettext("Target"),
},
{
xtype: 'proxmoxcheckbox',
checked: true,
name: 'original',
- fieldLabel: gettext("send orig. Mail")
- }
- ]
+ boxLabel: gettext("Send Original Mail"),
+ },
+ ],
},
4007: {
@@ -618,41 +628,38 @@ Ext.define('PMG.Utils', {
subdir: 'removeattachments',
subject: gettext('Remove Attachments'),
width: 500,
- fieldDefaults: {
- labelWidth: 150
- },
items: [
{
xtype: 'textfield',
name: 'name',
allowBlank: false,
- fieldLabel: gettext('Name')
+ fieldLabel: gettext('Name'),
},
{
xtype: 'textareafield',
name: 'info',
- fieldLabel: gettext("Comment")
+ fieldLabel: gettext("Comment"),
},
{
xtype: 'textareafield',
name: 'text',
grow: true,
growMax: 250,
- fieldLabel: gettext("Text Replacement")
+ fieldLabel: gettext("Text Replacement"),
},
{
xtype: 'proxmoxcheckbox',
checked: true,
name: 'all',
- fieldLabel: gettext("Remove all attachments")
+ boxLabel: gettext("Remove all Attachments"),
},
{
xtype: 'proxmoxcheckbox',
checked: false,
name: 'quarantine',
- fieldLabel: gettext("Copy orignal mail to Attachment Quarantine")
- }
- ]
+ boxLabel: gettext("Copy original mail to Attachment Quarantine"),
+ },
+ ],
},
4009: {
onlineHelp: 'pmg_mailfilter_action',
@@ -665,53 +672,68 @@ Ext.define('PMG.Utils', {
xtype: 'textfield',
name: 'name',
allowBlank: false,
- fieldLabel: gettext('Name')
+ fieldLabel: gettext('Name'),
},
{
xtype: 'textareafield',
name: 'info',
- fieldLabel: gettext("Comment")
+ fieldLabel: gettext("Comment"),
},
{
xtype: 'textareafield',
name: 'disclaimer',
grow: true,
growMax: 250,
- fieldLabel: gettext("Disclaimer")
- }
- ]
- }
+ fieldLabel: gettext("Disclaimer"),
+ },
+ {
+ xtype: 'proxmoxKVComboBox',
+ name: 'position',
+ fieldLabel: gettext("Position"),
+ deleteEmpty: false,
+ value: 'end',
+ comboItems: [
+ ['end', gettext('End')],
+ ['start', gettext('Start')],
+ ],
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'add-separator',
+ fieldLabel: gettext("Add Separator"),
+ uncheckedValue: '0',
+ value: true,
+ },
+ ],
+ },
},
updateLoginData: function(data) {
Proxmox.CSRFPreventionToken = data.CSRFPreventionToken;
Proxmox.UserName = data.username;
- Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true );
+ Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true);
},
quarantineActionExtracted: false,
extractQuarantineAction: function() {
-
- if (PMG.Utils.quarantineActionExtracted) { return; }
+ if (PMG.Utils.quarantineActionExtracted) {
+ return null;
+ }
PMG.Utils.quarantineActionExtracted = true;
- var qs = Ext.Object.fromQueryString(location.search);
+ let qs = Ext.Object.fromQueryString(location.search);
- var cselect = qs.cselect;
- var action = qs.action;
- var ticket = qs.ticket;
- var dateString = qs.date;
+ let cselect = qs.cselect;
+ let action = qs.action;
+ let dateString = qs.date;
if (dateString) {
- var date = new Date(dateString).getTime()/1000;
+ let date = new Date(dateString).getTime()/1000;
// set from date for QuarantineList
- /*jslint confusion: true*/
- /*from is a string above and number here */
PMG.QuarantineList.from = date;
- /*jslint confusion: false*/
}
delete qs.cselect;
@@ -726,50 +748,55 @@ Ext.define('PMG.Utils', {
newurl += location.hash;
if (window.history) {
- window.history.pushState({ path:newurl }, '', newurl);
+ window.history.pushState({ path: newurl }, '', newurl);
}
if (action || cselect) {
- return { action: action, cselect: cselect };
+ return {
+ action: action,
+ cselect: cselect,
+ };
}
+ return null;
},
doQuarantineAction: function(action, id, callback) {
- var count = id.split(';').length;
- var successMessage = "Action '{0}'";
- if (count > 1) {
- successMessage += " for '{1}' items";
- }
- successMessage += " successful";
-
- /*jslint confusion: true*/
- /*format is string and function*/
Proxmox.Utils.API2Request({
url: '/quarantine/content/',
params: {
action: action,
- id: id
+ id: id,
},
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
- var win = Ext.create('Ext.window.MessageBox',{
- closeAction: 'destroy'
- }).show({
- title: gettext('Info'),
- message: Ext.String.format(successMessage, action, count),
- buttons: Ext.Msg.OK,
- icon: Ext.MessageBox.INFO
+ let count = id.split(';').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 title = Ext.String.format("{0} successful", Ext.String.capitalize(action));
+
+ Ext.toast({
+ html: message,
+ title: title,
+ minWidth: 200,
+ hideDuration: 250,
+ slideBackDuration: 250,
+ slideBackAnimation: 'easeOut',
+ iconCls: 'fa fa-check',
+ shadow: true,
+ align: 'br',
});
if (Ext.isFunction(callback)) {
callback();
}
- }
+ },
});
- /*jslint confusion: false*/
},
render_filetype: function(value) {
@@ -781,7 +808,7 @@ Ext.define('PMG.Utils', {
}
text = value.toString().toLowerCase();
- let type = text.split('/')[0];
+ const type = text.split('/')[0];
switch (type) {
case 'audio':
@@ -790,13 +817,13 @@ Ext.define('PMG.Utils', {
case 'text':
iconCls = `fa-file-${type}-o`;
break;
- case 'application':
- let subtypes = ['excel', 'pdf', 'word', 'powerpoint'];
+ case 'application': {
+ const subtypes = ['excel', 'pdf', 'word', 'powerpoint'];
let found = subtypes.find(st => text.includes(st));
if (found !== undefined) {
iconCls = `fa-file-${found}-o`;
}
- break;
+ } break;
default:
break;
}
@@ -804,23 +831,97 @@ Ext.define('PMG.Utils', {
return ` ${text}`;
},
- sender_renderer: function(value, metaData, rec) {
- var subject = Ext.htmlEncode(value);
- var from = Ext.htmlEncode(rec.data.from);
- var sender = Ext.htmlEncode(rec.data.sender);
- if (sender) {
- /*jslint confusion: true*/
- /*format is a string above*/
- from = Ext.String.format(gettext("{0} on behalf of {1}"),
- sender, from);
- /*jslint confusion: false*/
+ render_envelope: function(value, { data }, render_receiver) {
+ let subject = Ext.htmlEncode(value);
+ let from = Ext.htmlEncode(data.from);
+ if (data.sender) {
+ let sender = Ext.htmlEncode(data.sender);
+ from = Ext.String.format(gettext("{0} on behalf of {1}"), sender, from);
+ }
+ if (render_receiver) {
+ let receiver = Ext.htmlEncode(data.receiver);
+ return `${from}
To: ${receiver}
${subject}`;
}
- return '' + from + '
' + subject;
+ return `${from}
${subject}`;
},
+ render_sender: (value, _meta, rec) => PMG.Utils.render_envelope(value, rec, false),
+ render_sender_receiver: (value, _meta, rec) => PMG.Utils.render_envelope(value, rec, true),
+
constructor: function() {
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),
+ );
+ },
+});
+
+// custom Vtypes
+Ext.apply(Ext.form.field.VTypes, {
+ // matches the pmg-email-address in pmg-api
+ PMGMail: function(v) {
+ return (/^[^\s\\@]+@[^\s/\\@]+$/).test(v);
+ },
+ PMGMailText: gettext('Example') + ": user@example.com",
});