]>
git.proxmox.com Git - pmg-gui.git/blob - js/RegexTester.js
1 Ext
.define('PMG.RegexTester', {
2 extend
: 'Ext.form.FieldContainer',
3 alias
: 'widget.pmgRegexTester',
5 // the field reference which holds the regex value
6 // has to be a sibling of the RegexTester component
7 regexFieldReference
: undefined,
9 // if true, wraps the regex with ^ and $
28 handler: function(btn
) {
30 let regexField
= view
.up().child(`field[reference=${view.regexFieldReference}]`);
32 let regex
= regexField
.getValue();
33 if (view
.wholeMatch
) {
37 Proxmox
.Utils
.API2Request({
38 url
: '/api2/extjs/config/regextest',
39 waitMsgTarget
: view
.up('window'),
42 text
: view
.down('textfield[name=teststring]').getValue(),
45 success: function(response
) {
46 let elapsed
= response
.result
.data
;
48 title
: gettext('Success'),
49 message
: gettext('OK') + ` (elapsed time: ${elapsed}ms)`,
51 icon
: Ext
.MessageBox
.INFO
,
54 failure: function(response
, opts
) {
55 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
62 initComponent: function() {
65 if (!me
.regexFieldReference
) {
66 throw "No regex field reference given";