mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge branch 'master' into fix/empty_field
This commit is contained in:
commit
8041769aa5
4 changed files with 36 additions and 7 deletions
|
@ -36,20 +36,31 @@ define(function (require) {
|
|||
{ id: false, name: '- none -' },
|
||||
{ id: 'lower', name: 'Lower Case' },
|
||||
{ id: 'upper', name: 'Upper Case' },
|
||||
{ id: 'short', name: 'Short Dots' }
|
||||
{ id: 'short', name: 'Short Dots' },
|
||||
{ id: 'base64', name: 'Base64 Decode'}
|
||||
];
|
||||
|
||||
_String.sampleInputs = [
|
||||
'A Quick Brown Fox.',
|
||||
'com.organizations.project.ClassName',
|
||||
'hostname.net'
|
||||
'hostname.net',
|
||||
'SGVsbG8gd29ybGQ='
|
||||
];
|
||||
|
||||
_String.prototype._base64Decode = function (val) {
|
||||
try {
|
||||
return window.atob(val);
|
||||
} catch (e) {
|
||||
return _.asPrettyString(val);
|
||||
}
|
||||
};
|
||||
|
||||
_String.prototype._convert = function (val) {
|
||||
switch (this.param('transform')) {
|
||||
case 'lower': return String(val).toLowerCase();
|
||||
case 'upper': return String(val).toUpperCase();
|
||||
case 'short': return _.shortenDottedString(val);
|
||||
case 'base64': return this._base64Decode(val);
|
||||
default: return _.asPrettyString(val);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,7 +22,8 @@ define(function (require) {
|
|||
// track request so we can abort it if needed
|
||||
var request = {};
|
||||
|
||||
var errorElem = $('<i class="fa fa-ban input-error"></i>').hide();
|
||||
var errorElem = $('<i tooltip={{tooltipMsg}} class="fa fa-ban input-error"></i>').hide();
|
||||
$compile(errorElem)($scope);
|
||||
|
||||
var init = function () {
|
||||
elem.after(errorElem);
|
||||
|
@ -84,10 +85,7 @@ define(function (require) {
|
|||
msg = resp.body.error;
|
||||
}
|
||||
|
||||
errorElem.attr('tooltip', msg);
|
||||
|
||||
// Compile is needed for the tooltip
|
||||
$compile(errorElem)($scope);
|
||||
$scope.tooltipMsg = msg;
|
||||
errorElem.show();
|
||||
|
||||
return undefined;
|
||||
|
|
19
test/unit/specs/components/stringify/_string.js
Normal file
19
test/unit/specs/components/stringify/_string.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
define(function (require) {
|
||||
return ['String Format', function () {
|
||||
var fieldFormats;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
beforeEach(inject(function (Private) {
|
||||
fieldFormats = Private(require('registry/field_formats'));
|
||||
}));
|
||||
|
||||
it('decode a base64 string', function () {
|
||||
var StringFormat = fieldFormats.getType('string');
|
||||
var string = new StringFormat({
|
||||
transform: 'base64'
|
||||
});
|
||||
expect(string.convert('Zm9vYmFy')).to.be('foobar');
|
||||
});
|
||||
|
||||
}];
|
||||
});
|
|
@ -3,6 +3,7 @@ define(function (require) {
|
|||
describe(require('specs/components/stringify/_conformance'));
|
||||
describe(require('specs/components/stringify/_ip'));
|
||||
describe(require('specs/components/stringify/_source'));
|
||||
describe(require('specs/components/stringify/_string'));
|
||||
describe(require('specs/components/stringify/_url'));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue