column formatting Allow optional formatting for columns Provide Data formate for host modificaiton

date format
This commit is contained in:
Adam Young 2011-02-10 16:48:17 -05:00
parent 6f6d50f37f
commit d14ef576c3
3 changed files with 49 additions and 6 deletions

View File

@ -227,21 +227,28 @@ IPA.target_section = function(spec) {
that.add_field(that.attribute_table);
/*TODO these next two functions are work arounds for missing attribute
permissions for the filter text. Remove them once that has been fixed */
that.filter_text.update = function(){
var value = that.filter_text.values && that.filter_text.values.length ?
that.filter_text.values[0] : '';
$('input[name="'+that.filter_text.name+'"]', that.filter_text.container).val(value);
$('input[name="'+that.filter_text.name+'"]',
that.filter_text.container).val(value);
var label = $('label[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
label.css('display', 'none');
input.css('display', 'inline');
label.css('display', 'none');
input.css('display', 'inline');
};
that.filter_text.save = function(){
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var value = $.trim(input.val());
return value === '' ? [] : [value];
};
var target_types = [
{

View File

@ -103,6 +103,32 @@ IPA.host_add_dialog = function (spec) {
return that;
};
/* Take an LDAP format date in UTC and format it */
IPA.utc_date_column_format = function(value){
if (!value) {
return "";
}
if (value.length != "20101119025910Z".length){
return value;
}
/* We only handle GMT */
if (value.charAt(value.length -1) !== 'Z'){
return value;
}
var date = new Date();
date.setUTCFullYear(
value.substring(0, 4),
value.substring(4, 6),
value.substring(6, 8));
date.setUTCHours(
value.substring(8, 10),
value.substring(10, 12),
value.substring(12, 14));
var formated = date.toString();
return formated;
};
IPA.host_search_facet = function (spec) {
@ -115,7 +141,9 @@ IPA.host_search_facet = function (spec) {
that.create_column({name:'fqdn'});
that.create_column({name:'description'});
//TODO use the value of this field to set enrollment status
that.create_column({name:'krblastpwdchange', label:'Enrolled?'});
that.create_column({name:'krblastpwdchange', label:'Enrolled?',
format:IPA.utc_date_column_format
});
that.create_column({name:'nshostlocation'});
that.search_facet_init();

View File

@ -1005,6 +1005,9 @@ IPA.column = function (spec) {
var that = {};
if (spec.format){
that.format = spec.format;
}
that.name = spec.name;
that.label = spec.label;
that.primary_key = spec.primary_key;
@ -1025,8 +1028,13 @@ IPA.column = function (spec) {
container.empty();
var value = record[that.name];
if (that.format && value){
value = that.format(value);
}
value = value ? value.toString() : '';
container.append(value);
}