]> git.proxmox.com Git - pmg-gui.git/commitdiff
implement action panel
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Mar 2017 09:33:27 +0000 (10:33 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Mar 2017 11:04:43 +0000 (12:04 +0100)
js/ActionConfiguration.js [new file with mode: 0644]
js/Makefile
js/ObjectGroupConfiguration.js
js/ObjectGroupList.js
js/Utils.js

diff --git a/js/ActionConfiguration.js b/js/ActionConfiguration.js
new file mode 100644 (file)
index 0000000..377c168
--- /dev/null
@@ -0,0 +1,162 @@
+Ext.define('pmg-action-list', {
+    extend: 'Ext.data.Model',
+    fields: [
+       'id', 'name', 'info', 'descr',
+       { name: 'otype', type: 'integer' },
+    ],
+    idProperty: 'id'
+});
+
+Ext.define('PMG.ActionConfiguration', {
+    extend: 'Ext.grid.GridPanel',
+    alias: ['widget.pmgActionConfiguration'],
+
+    title: PMG.Utils.oclass_text['action'],
+
+    baseurl: '/config/ruledb/action',
+
+    otype_list: [4005],
+
+    initComponent : function() {
+       var me = this;
+
+       me.store = new Ext.data.Store({
+           model: 'pmg-action-list',
+           proxy: {
+               type: 'proxmox',
+               url: "/api2/json" + me.baseurl + '/objects',
+           },
+           sorters: {
+               property: 'name',
+               order: 'DESC'
+           }
+       });
+
+       me.selModel = Ext.create('Ext.selection.RowModel', {});
+
+       var reload = function() {
+           me.store.load();
+       };
+
+       var run_editor = function() {
+           var rec = me.selModel.getSelection()[0];
+           if (!rec) {
+               return;
+           }
+
+           var editor = PMG.Utils.object_editors[rec.data.otype];
+           if (!editor) {
+               return;
+           }
+
+           var config = Ext.apply({ method: 'PUT' }, editor);
+       
+           config.url = me.baseurl + '/' + editor.subdir + '/' + rec.data.id;
+
+           var win = Ext.createWidget('proxmoxWindowEdit', config);
+
+           win.load();
+           win.on('destroy', reload);
+           win.show();
+       };
+
+       var remove_btn = Ext.createWidget('proxmoxButton', {
+           text: gettext('Remove'),
+           disabled: true,
+           selModel: me.selModel,
+           confirmMsg: function (rec) {
+               return Ext.String.format(
+                   gettext('Are you sure you want to remove entry {0}'),
+                   "'" + rec.data.descr + "'");
+           },
+           handler: function(btn, event, rec) {
+               Proxmox.Utils.API2Request({
+                   url: me.baseurl + '/objects/' + rec.data.id,
+                   method: 'DELETE',
+                   waitMsgTarget: me,
+                   callback: reload,
+                   failure: function (response, opts) {
+                       Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+                   }
+               });
+           }
+       });
+
+       var menu_items = [];
+
+       Ext.Array.each(me.otype_list, function(otype) {
+
+           var editor = PMG.Utils.object_editors[otype];
+
+           var config = Ext.apply({ method: 'POST' }, editor);
+
+           config.create = true,
+           menu_items.push({
+               text: config.subject,
+               handler: function() {
+                   if (me.baseurl == undefined) {
+                       return;
+                   }
+                   config.url = me.baseurl + '/' + editor.subdir;
+                   var win = Ext.createWidget('proxmoxWindowEdit', config);
+                   win.on('destroy', reload);
+                   win.show();
+               }
+           });
+       });
+
+       var tbar = [
+           {
+               text: gettext('Add'),
+               menu: new Ext.menu.Menu({
+                   items: menu_items
+               })
+           },
+            {
+               xtype: 'proxmoxButton',
+               text: gettext('Edit'),
+               disabled: true,
+               selModel: me.selModel,
+               handler: run_editor
+            },
+           remove_btn
+        ];
+
+       Proxmox.Utils.monStoreErrors(me, me.store);
+
+       Ext.apply(me, {
+           tbar: tbar,
+           columns: [
+               {
+                   header: gettext('Name'),
+                   sortable: true,
+                   width: 200,
+                   dataIndex: 'name',
+                   renderer: Ext.String.htmlEncode
+               },
+               {
+                   header: gettext('Description'),
+                   sortable: true,
+                   width: 300,
+                   dataIndex: 'descr',
+                   renderer: Ext.String.htmlEncode
+               },
+               {
+                   header: gettext('Comment'),
+                   sortable: false,
+                   flex: 1,
+                   dataIndex: 'info',
+                   renderer: Ext.String.htmlEncode
+               },
+           ],
+           listeners: {
+               itemdblclick: run_editor,
+               activate: reload
+           }
+       });
+
+       me.callParent();
+
+       reload(); // initial load
+    }
+});
index 6b8b0030d789117ab171e54bfc071b4c70527f87..98707f9f5ee53021a4b742e9fc2f4270e748592a 100644 (file)
@@ -5,6 +5,7 @@ JSSRC=                                                  \
        ObjectGroupList.js                              \
        ObjectGroup.js                                  \
        ObjectGroupConfiguration.js                     \
+       ActionConfiguration.js                          \
        RuleConfiguration.js                            \
        SystemConfiguration.js                          \
        MailProxyRelaying.js                            \
index afe6749e520e6262978e2748c72a20222cb56f4e..09022285962f684854533a8f6c1ef25ae21a766c 100644 (file)
@@ -81,11 +81,3 @@ Ext.define('PMG.WhatConfiguration', {
     otype_list: []
 });
 
-Ext.define('PMG.ActionConfiguration', {
-    extend: 'PMG.ObjectGroupConfiguration',
-    alias: 'widget.pmgActionConfiguration',
-
-    ogclass: 'action',
-    otype_list: []
-});
-
index b7e29bf90aeee4a712c52ba65f8f190b9f2dd910..f88ba361299072139df3b9b95309059965fc764f 100644 (file)
@@ -29,6 +29,7 @@ Ext.define('PMG.ObjectGroupList', {
        {
            xtype: 'textfield',
            name: 'name',
+           allowBlank: false,
            fieldLabel: gettext('Name')
        },
        {
index e478dc1ba8fc44b461a266937500112ee98c69a0..813998d0034429c7de726a47649fc1438c3cf678 100644 (file)
@@ -145,6 +145,37 @@ Ext.define('PMG.Utils', {
                    fieldLabel: gettext("End Time")
                }
            ]
+       },
+       4005: {
+           subdir: 'bcc',
+           subject: gettext('BCC'),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'name',
+                   allowBlank: false,
+                   fieldLabel: gettext('Name')
+               },
+               {
+                   xtype: 'textareafield',
+                   name: 'info',
+                   fieldLabel: gettext("Description")
+               },
+               {
+                   xtype: 'textfield',
+                   name: 'target',
+                   allowBlank: false,
+                   fieldLabel: gettext("Target")
+               },
+               {
+                   xtype: 'proxmoxcheckbox',
+                   checked: true,
+                   name: 'original',
+                   fieldLabel: gettext("send orig. Mail")
+               }
+           ]
+
        }
     },