From 1a1c020896b66f8b00a5a41b48221ef83eaf03ff Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Aug 2011 09:27:42 +0200 Subject: [PATCH] implement datacenter http_proxy editor --- www/manager/Utils.js | 9 +++++++-- www/manager/dc/OptionView.js | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/www/manager/Utils.js b/www/manager/Utils.js index c6ad79ecc..4934c8cc9 100644 --- a/www/manager/Utils.js +++ b/www/manager/Utils.js @@ -25,7 +25,7 @@ Ext.Ajax.on('beforerequest', function(conn, options) { } }); -// custom Vtype for vtype:'IPAddress' +// custom Vtypes Ext.apply(Ext.form.field.VTypes, { IPAddress: function(v) { return (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/).test(v); @@ -57,7 +57,12 @@ Ext.apply(Ext.form.field.VTypes, { StorageId: function(v) { return (/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i).test(v); }, - StorageIdText: "ID contains illegal characters (allowed characters: 'a-z', '0-9', '-', '_' and '.')" + StorageIdText: "ID contains illegal characters (allowed characters: 'a-z', '0-9', '-', '_' and '.')", + + HttpProxy: function(v) { + return (/^http:\/\/.*$/).test(v); + }, + HttpProxyText: "Must confirm to schema 'http://.*' (example: 'http://username:password\@host:port/')" }); // we dont want that a displayfield set the form dirty flag! diff --git a/www/manager/dc/OptionView.js b/www/manager/dc/OptionView.js index 404da5a9d..e4792fc6a 100644 --- a/www/manager/dc/OptionView.js +++ b/www/manager/dc/OptionView.js @@ -1,3 +1,28 @@ +Ext.define('PVE.dc.HttpProxyEdit', { + extend: 'PVE.window.Edit', + + initComponent : function() { + var me = this; + + Ext.applyIf(me, { + title: "Edit HTTP proxy settings", + items: { + xtype: 'pvetextfield', + name: 'http_proxy', + vtype: 'HttpProxy', + emptyText: 'Do not use any proxy', + deleteEmpty: true, + value: '', + fieldLabel: 'HTTP proxy' + } + }); + + me.callParent(); + + me.load(); + } +}); + Ext.define('PVE.dc.LanguageEdit', { extend: 'PVE.window.Edit', @@ -67,8 +92,15 @@ Ext.define('PVE.dc.OptionView', { required: true }, http_proxy: { - header: 'HTTP proxy', - required: true + header: 'HTTP proxy', + editor: 'PVE.dc.HttpProxyEdit', + required: true, + renderer: function(value) { + if (!value) { + return "Do not use any proxy"; + } + return value; + } } };