ui: datastore content: allow to create new namespace
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
		@ -62,6 +62,7 @@ JSSRC=							\
 | 
				
			|||||||
	window/BackupGroupChangeOwner.js		\
 | 
						window/BackupGroupChangeOwner.js		\
 | 
				
			||||||
	window/CreateDirectory.js			\
 | 
						window/CreateDirectory.js			\
 | 
				
			||||||
	window/DataStoreEdit.js				\
 | 
						window/DataStoreEdit.js				\
 | 
				
			||||||
 | 
						window/NamespaceEdit.js				\
 | 
				
			||||||
	window/MaintenanceOptions.js			\
 | 
						window/MaintenanceOptions.js			\
 | 
				
			||||||
	window/NotesEdit.js				\
 | 
						window/NotesEdit.js				\
 | 
				
			||||||
	window/RemoteEdit.js				\
 | 
						window/RemoteEdit.js				\
 | 
				
			||||||
 | 
				
			|||||||
@ -388,6 +388,21 @@ Ext.define('PBS.DataStoreContent', {
 | 
				
			|||||||
	    });
 | 
						    });
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						addNS: function() {
 | 
				
			||||||
 | 
						    let me = this;
 | 
				
			||||||
 | 
						    let view = me.getView();
 | 
				
			||||||
 | 
						    if (!view.datastore) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    Ext.create('PBS.window.NamespaceEdit', {
 | 
				
			||||||
 | 
							autoShow: true,
 | 
				
			||||||
 | 
							datastore: view.datastore,
 | 
				
			||||||
 | 
							listeners: {
 | 
				
			||||||
 | 
							    destroy: () => view.down('pbsNamespaceSelector').store?.load(),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						    });
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	onVerify: function(view, rI, cI, item, e, rec) {
 | 
						onVerify: function(view, rI, cI, item, e, rec) {
 | 
				
			||||||
	    let me = this;
 | 
						    let me = this;
 | 
				
			||||||
	    view = me.getView();
 | 
						    view = me.getView();
 | 
				
			||||||
@ -1036,10 +1051,17 @@ Ext.define('PBS.DataStoreContent', {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	    xtype: 'pbsNamespaceSelector',
 | 
						    xtype: 'pbsNamespaceSelector',
 | 
				
			||||||
 | 
						    width: 200,
 | 
				
			||||||
	    cbind: {
 | 
						    cbind: {
 | 
				
			||||||
		datastore: '{datastore}',
 | 
							datastore: '{datastore}',
 | 
				
			||||||
	    },
 | 
						    },
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						    xtype: 'proxmoxButton',
 | 
				
			||||||
 | 
						    text: gettext('Add NS'),
 | 
				
			||||||
 | 
						    iconCls: 'fa fa-plus-square',
 | 
				
			||||||
 | 
						    handler: 'addNS',
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	'-',
 | 
						'-',
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	    xtype: 'tbtext',
 | 
						    xtype: 'tbtext',
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										52
									
								
								www/window/NamespaceEdit.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								www/window/NamespaceEdit.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					Ext.define('PBS.window.NamespaceEdit', {
 | 
				
			||||||
 | 
					    extend: 'Proxmox.window.Edit',
 | 
				
			||||||
 | 
					    xtype: 'pbsNamespaceEdit', // for now rather "NamespaceAdd"
 | 
				
			||||||
 | 
					    mixins: ['Proxmox.Mixin.CBind'],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //onlineHelp: 'namespaces', // TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    isCreate: true,
 | 
				
			||||||
 | 
					    subject: gettext('Namespace'),
 | 
				
			||||||
 | 
					    // avoid that the trigger of the combogrid fields open on window show
 | 
				
			||||||
 | 
					    defaultFocus: 'proxmoxHelpButton',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cbind: {
 | 
				
			||||||
 | 
						url: '/api2/extjs/admin/datastore/{datastore}/namespace',
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    method: 'POST',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    width: 450,
 | 
				
			||||||
 | 
					    fieldDefaults: {
 | 
				
			||||||
 | 
						labelWidth: 120,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    items: {
 | 
				
			||||||
 | 
						xtype: 'inputpanel',
 | 
				
			||||||
 | 
						onGetValues: function(values) {
 | 
				
			||||||
 | 
						    if (values.parent === '') {
 | 
				
			||||||
 | 
							delete values.parent;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    return values;
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						items: [
 | 
				
			||||||
 | 
						    {
 | 
				
			||||||
 | 
							xtype: 'pbsNamespaceSelector',
 | 
				
			||||||
 | 
							name: 'parent',
 | 
				
			||||||
 | 
							fieldLabel: gettext('Parent Namespace'),
 | 
				
			||||||
 | 
							cbind: {
 | 
				
			||||||
 | 
							    datastore: '{datastore}',
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						    },
 | 
				
			||||||
 | 
						    {
 | 
				
			||||||
 | 
							xtype: 'proxmoxtextfield',
 | 
				
			||||||
 | 
							name: 'name',
 | 
				
			||||||
 | 
							fieldLabel: gettext('Namespace Name'),
 | 
				
			||||||
 | 
							value: '',
 | 
				
			||||||
 | 
							allowBlank: false,
 | 
				
			||||||
 | 
							maxLength: 31,
 | 
				
			||||||
 | 
							regex: PBS.Utils.SAFE_ID_RE,
 | 
				
			||||||
 | 
							regexText: gettext("Only alpha numerical, '_' and '-' (if not at start) allowed"),
 | 
				
			||||||
 | 
						    },
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Reference in New Issue
	
	Block a user