]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/Snapshot.js
ui: restore overrides: switch from column to hbox+panel layout
[pve-manager.git] / www / manager6 / window / Snapshot.js
index e4355106d6ea5ac89ef175bdb4424d6e70d85d0a..426be7cc8efafaf6504a9fd82a369c188843f623 100644 (file)
@@ -1,6 +1,19 @@
 Ext.define('PVE.window.Snapshot', {
     extend: 'Proxmox.window.Edit',
 
+    viewModel: {
+       data: {
+           type: undefined,
+           isCreate: undefined,
+           running: false,
+           guestAgentEnabled: false,
+       },
+       formulas: {
+           runningWithoutGuestAgent: (get) => get('type') === 'qemu' && get('running') && !get('guestAgentEnabled'),
+           shouldWarnAboutFS: (get) => get('isCreate') && get('runningWithoutGuestAgent') && get('!vmstate.checked'),
+       },
+    },
+
     onGetValues: function(values) {
        let me = this;
 
@@ -11,8 +24,9 @@ Ext.define('PVE.window.Snapshot', {
        return values;
     },
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
+       var vm = me.getViewModel();
 
        if (!me.nodename) {
            throw "no node name specified";
@@ -26,6 +40,23 @@ Ext.define('PVE.window.Snapshot', {
            throw "no type specified";
        }
 
+       vm.set('type', me.type);
+       vm.set('running', me.running);
+       vm.set('isCreate', me.isCreate);
+
+       if (me.type === 'qemu' && me.isCreate) {
+           Proxmox.Utils.API2Request({
+               url: `/nodes/${me.nodename}/${me.type}/${me.vmid}/config`,
+               params: { 'current': '1' },
+               method: 'GET',
+               success: function(response, options) {
+                   let res = response.result.data;
+                   let enabled = PVE.Parser.parsePropertyString(res.agent, 'enabled');
+                   vm.set('guestAgentEnabled', !!PVE.Parser.parseBoolean(enabled.enabled));
+               },
+           });
+       }
+
        me.items = [
            {
                xtype: me.isCreate ? 'textfield' : 'displayfield',
@@ -33,7 +64,7 @@ Ext.define('PVE.window.Snapshot', {
                value: me.snapname,
                fieldLabel: gettext('Name'),
                vtype: 'ConfigId',
-               allowBlank: false
+               allowBlank: false,
            },
            {
                xtype: 'displayfield',
@@ -41,24 +72,35 @@ Ext.define('PVE.window.Snapshot', {
                disabled: me.isCreate,
                name: 'snaptime',
                renderer: PVE.Utils.render_timestamp_human_readable,
-               fieldLabel: gettext('Timestamp')
+               fieldLabel: gettext('Timestamp'),
            },
            {
                xtype: 'proxmoxcheckbox',
-               hidden: me.type !== 'qemu' || !me.isCreate,
-               disabled: me.type !== 'qemu' || !me.isCreate,
+               hidden: me.type !== 'qemu' || !me.isCreate || !me.running,
+               disabled: me.type !== 'qemu' || !me.isCreate || !me.running,
                name: 'vmstate',
+               reference: 'vmstate',
                uncheckedValue: 0,
                defaultValue: 0,
                checked: 1,
-               fieldLabel: gettext('Include RAM')
+               fieldLabel: gettext('Include RAM'),
            },
            {
                xtype: 'textareafield',
                grow: true,
                editable: !me.viewonly,
                name: 'description',
-               fieldLabel: gettext('Description')
+               fieldLabel: gettext('Description'),
+           },
+           {
+               xtype: 'displayfield',
+               userCls: 'pmx-hint',
+               name: 'fswarning',
+               hidden: true,
+               value: gettext('It is recommended to either include the RAM or use the QEMU Guest Agent when taking a snapshot of a running VM to avoid inconsistencies.'),
+               bind: {
+                   hidden: '{!shouldWarnAboutFS}',
+               },
            },
            {
                title: gettext('Settings'),
@@ -71,10 +113,10 @@ Ext.define('PVE.window.Snapshot', {
                    model: 'KeyValue',
                    sorters: [
                        {
-                           property : 'key',
-                           direction: 'ASC'
-                       }
-                   ]
+                           property: 'key',
+                           direction: 'ASC',
+                       },
+                   ],
                },
                columns: [
                    {
@@ -86,9 +128,9 @@ Ext.define('PVE.window.Snapshot', {
                        header: gettext('Value'),
                        flex: 1,
                        dataIndex: 'value',
-                   }
-               ]
-           }
+                   },
+               ],
+           },
        ];
 
        me.url = `/nodes/${me.nodename}/${me.type}/${me.vmid}/snapshot`;
@@ -97,7 +139,7 @@ Ext.define('PVE.window.Snapshot', {
        if (me.isCreate) {
            subject = (me.type === 'qemu' ? 'VM' : 'CT') + me.vmid + ' ' + gettext('Snapshot');
            me.method = 'POST';
-           me.showProgress = true;
+           me.showTaskViewer = true;
        } else {
            subject = `${gettext('Snapshot')} ${me.snapname}`;
            me.url += `/${me.snapname}/config`;
@@ -133,7 +175,7 @@ Ext.define('PVE.window.Snapshot', {
                summarystore.fireEvent('refresh', summarystore);
 
                me.setValues(response.result.data);
-           }
+           },
        });
-    }
+    },
 });