[pve-devel] [PATCH manager 2/2] ui: remove Realm model and RealmComboBox

Dominik Csapak d.csapak at proxmox.com
Fri May 15 10:19:28 CEST 2020


and use it from widget-toolkit

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile              |  2 -
 www/manager6/data/model/Realm.js   | 30 --------------
 www/manager6/form/RealmComboBox.js | 65 ------------------------------
 www/manager6/window/LoginWindow.js |  2 +-
 4 files changed, 1 insertion(+), 98 deletions(-)
 delete mode 100644 www/manager6/data/model/Realm.js
 delete mode 100644 www/manager6/form/RealmComboBox.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 08861cca..a29e280d 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -17,7 +17,6 @@ JSSRC= 				                 	\
 	VNCConsole.js					\
 	data/PermPathStore.js				\
 	data/ResourceStore.js				\
-	data/model/Realm.js				\
 	data/model/RRDModels.js				\
 	form/VLanField.js				\
 	form/Boolean.js					\
@@ -36,7 +35,6 @@ JSSRC= 				                 	\
 	form/BusTypeSelector.js				\
 	form/ControllerSelector.js			\
 	form/EmailNotificationSelector.js		\
-	form/RealmComboBox.js				\
 	form/ViewSelector.js				\
 	form/NodeSelector.js				\
 	form/FileSelector.js				\
diff --git a/www/manager6/data/model/Realm.js b/www/manager6/data/model/Realm.js
deleted file mode 100644
index 01f36351..00000000
--- a/www/manager6/data/model/Realm.js
+++ /dev/null
@@ -1,30 +0,0 @@
-Ext.define('pve-domains', {
-    extend: "Ext.data.Model",
-    fields: [
-	'realm', 'type', 'comment', 'default', 'tfa',
-	{
-	    name: 'descr',
-	    // Note: We use this in the RealmComboBox.js (see Bug #125)
-	    convert: function(value, record) {
-		if (value) {
-		    return value;
-		}
-
-		var info = record.data;
-		// return realm if there is no comment
-		var text = info.comment || info.realm;
-
-		if (info.tfa) {
-		    text += " (+ " + info.tfa + ")";
-		}
-
-		return Ext.String.htmlEncode(text);
-	    }
-	}
-    ],
-    idProperty: 'realm',
-    proxy: {
-	type: 'proxmox',
-	url: "/api2/json/access/domains"
-    }
-});
diff --git a/www/manager6/form/RealmComboBox.js b/www/manager6/form/RealmComboBox.js
deleted file mode 100644
index c85fe7d2..00000000
--- a/www/manager6/form/RealmComboBox.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*global Proxmox*/
-Ext.define('PVE.form.RealmComboBox', {
-    extend: 'Ext.form.field.ComboBox',
-    alias: ['widget.pveRealmComboBox'],
-
-    controller: {
-	xclass: 'Ext.app.ViewController',
-
-	init: function(view) {
-	    view.store.on('load', this.onLoad, view);
-	},
-
-	onLoad: function(store, records, success) {
-	    if (!success) {
-		return;
-	    }
-	    var me = this;
-	    var val = me.getValue();
-	    if (!val || !me.store.findRecord('realm', val)) {
-		var def = 'pam';
-		Ext.each(records, function(rec) {
-		    if (rec.data && rec.data['default']) {
-			def = rec.data.realm;
-		    }
-		});
-		me.setValue(def);
-	    }
-	}
-    },
-
-    fieldLabel: gettext('Realm'),
-    name: 'realm',
-    queryMode: 'local',
-    allowBlank: false,
-    editable: false,
-    forceSelection: true,
-    autoSelect: false,
-    triggerAction: 'all',
-    valueField: 'realm',
-    displayField: 'descr',
-    getState: function() {
-	return { value: this.getValue() };
-    },
-    applyState : function(state) {
-	if (state && state.value) {
-	    this.setValue(state.value);
-	}
-    },
-    stateEvents: [ 'select' ],
-    stateful: true, // last chosen auth realm is saved between page reloads
-    id: 'pveloginrealm', // We need stable ids when using stateful, not autogenerated
-    stateID: 'pveloginrealm',
-
-    needOTP: function(realm) {
-	var me = this;
-	// use exact match
-	var rec = me.store.findRecord('realm', realm, 0, false, false, true);
-	return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
-    },
-
-    store: {
-	model: 'pve-domains',
-	autoLoad: true
-    }
-});
diff --git a/www/manager6/window/LoginWindow.js b/www/manager6/window/LoginWindow.js
index e29b7352..6123c655 100644
--- a/www/manager6/window/LoginWindow.js
+++ b/www/manager6/window/LoginWindow.js
@@ -227,7 +227,7 @@ Ext.define('PVE.window.LoginWindow', {
 		reference: 'passwordField'
 	    },
 	    {
-		xtype: 'pveRealmComboBox',
+		xtype: 'pmxRealmComboBox',
 		name: 'realm'
 	    },
 	    {
-- 
2.20.1





More information about the pve-devel mailing list