Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update job viewer formatter to handle N/A case for byte data. #1208

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions html/gui/js/modules/job_viewer/JobViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ XDMoD.Module.JobViewer = Ext.extend(XDMoD.PortalModule, {
* @returns {*}
*/
formatData: function (val, units) {
var formatBytes = function (value, unitname, precision) {
if (value < 0) {
return 'NA';
}
return XDMoD.utils.format.convertToBinaryPrefix(value, unitname, precision);
};

switch (units) {
case "TODO":
case "":
Expand All @@ -412,13 +419,13 @@ XDMoD.Module.JobViewer = Ext.extend(XDMoD.PortalModule, {
case 'bytes':
case 'B':
case 'B/s':
return XDMoD.utils.format.convertToBinaryPrefix(val, units, 4);
return formatBytes(val, units, 4);
break;
case 'kilobyte':
return XDMoD.utils.format.convertToBinaryPrefix(val * 1024.0, 'byte', 4);
return formatBytes(val * 1024.0, 'byte', 4);
break;
case 'megabyte':
return XDMoD.utils.format.convertToBinaryPrefix(val * 1024.0 * 1024.0, 'byte', 4);
return formatBytes(val * 1024.0 * 1024.0, 'byte', 4);
break;
case 'joules':
return Ext.util.Format.number(val / 3.6e6, '0,000.000') + ' kWh';
Expand Down Expand Up @@ -654,7 +661,9 @@ XDMoD.Module.JobViewer = Ext.extend(XDMoD.PortalModule, {
id: valueColumnId,
renderer: function (value, metadata, record) {
var fmt = String(self.formatData(value, record.get('units')));
if (fmt.indexOf(value) !== 0) {
if (fmt === 'NA') {
metadata.attr = 'ext:qtip="This information is not available"';
} else if (fmt.indexOf(value) !== 0) {
metadata.attr = 'ext:qtip="' + value + ' ' + record.get('units') + '"';
}
return fmt;
Expand Down