ui: use Logo/RealmComboBox from widget-toolkit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-05-18 14:18:37 +02:00 committed by Dietmar Maurer
parent 522c0da0a0
commit 1d8ef0dcf7
5 changed files with 8 additions and 89 deletions

View File

@ -114,7 +114,8 @@ Ext.define('PBS.LoginView', {
height: 38, height: 38,
items: [ items: [
{ {
xtype: 'proxmoxlogo' xtype: 'proxmoxlogo',
prefix: '',
}, },
{ {
xtype: 'versioninfo', xtype: 'versioninfo',
@ -158,10 +159,6 @@ Ext.define('PBS.LoginView', {
}, },
items: [ items: [
{
xtype: 'pbsRealmComboBox',
name: 'realm'
},
{ {
xtype: 'textfield', xtype: 'textfield',
fieldLabel: gettext('User name'), fieldLabel: gettext('User name'),
@ -178,6 +175,10 @@ Ext.define('PBS.LoginView', {
itemId: 'passwordField', itemId: 'passwordField',
reference: 'passwordField', reference: 'passwordField',
}, },
{
xtype: 'pmxRealmComboBox',
name: 'realm'
},
{ {
xtype: 'proxmoxLanguageSelector', xtype: 'proxmoxLanguageSelector',
fieldLabel: gettext('Language'), fieldLabel: gettext('Language'),

View File

@ -1,14 +0,0 @@
Ext.define('PBS.image.Logo', {
extend: 'Ext.Img',
xtype: 'proxmoxlogo',
height: 30,
width: 172,
src: '/images/proxmox_logo.png',
alt: 'Proxmox',
autoEl: {
tag: 'a',
href: 'https://www.proxmox.com',
target: '_blank'
}
});

View File

@ -177,7 +177,8 @@ Ext.define('PBS.MainView', {
height: 38, height: 38,
items: [ items: [
{ {
xtype: 'proxmoxlogo' xtype: 'proxmoxlogo',
prefix: '',
}, },
{ {
xtype: 'versioninfo' xtype: 'versioninfo'

View File

@ -6,8 +6,6 @@ IMAGES := \
JSSRC= \ JSSRC= \
Utils.js \ Utils.js \
Logo.js \
RealmComboBox.js \
LoginView.js \ LoginView.js \
VersionInfo.js \ VersionInfo.js \
SystemConfiguration.js \ SystemConfiguration.js \

View File

@ -1,67 +0,0 @@
Ext.define('pbs-domains', {
extend: "Ext.data.Model",
fields: [ 'realm', 'comment', 'default' ],
idProperty: 'realm',
proxy: {
type: 'proxmox',
url: "/api2/json/access/domains"
}
});
Ext.define('PBS.form.RealmComboBox', {
extend: 'Ext.form.field.ComboBox',
alias: ['widget.pbsRealmComboBox'],
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: 'comment',
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: 'pbsloginrealm', // We need stable ids when using stateful, not autogenerated
stateID: 'pbsloginrealm',
store: {
model: 'pbs-domains',
autoLoad: true
}
});