Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
webui status tab: change the implementation back to static columns
  • Loading branch information
perexg committed Aug 1, 2014
1 parent 247848f commit b5f39d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 66 deletions.
8 changes: 8 additions & 0 deletions src/webui/static/app/extensions.js
Expand Up @@ -347,6 +347,7 @@ Ext.reg("multiselect", Ext.ux.Multiselect);

/**
* 22/07/2014: ceiling support backported from version 1.2, by Kai Sommerfeld
* 01/08/2014: tvh_renderer fcn added by Jaroslav Kysela
*/
Ext.namespace('Ext.ux.grid');

Expand Down Expand Up @@ -402,7 +403,14 @@ Ext.extend(Ext.ux.grid.ProgressColumn, Ext.util.Observable, {
this.grid.startEditing(rowIndex, colIndex);
}
},
tvh_renderer: function (v, p, record) {
return v;
},
renderer: function(v, p, record) {
v = this.tvh_renderer(v, p, record);
if (typeof v === "string")
return v; // custom string

var style = '';
var textClass = (v < (this.ceiling / 1.818)) ? 'x-progress-text-back' : 'x-progress-text-front' + (Ext.isIE6 ? '-ie6' : '');

Expand Down
101 changes: 35 additions & 66 deletions src/webui/static/app/status.js
Expand Up @@ -269,10 +269,41 @@ tvheadend.status_streams = function() {
dataIndex: 'cc'
}]);

var has_signal_rel = false;
var has_signal_dbm = false;
var has_snr_rel = false;
var has_snr_db = false;
cm.config.push(new Ext.ux.grid.ProgressColumn({
header: "SNR",
dataIndex: 'snr',
width: 85,
colored: true,
ceiling: 65535,
tvh_renderer: function(v, p, record) {
var scale = record.get('snr_scale');
if (scale == 1)
return v;
if (scale == 2 && v > 0) {
var snr = v * 0.0001;
return snr.toFixed(1) + " dB";
}
return '<span class="tvh-grid-unset">Unknown</span>';
}
}));

cm.config.push(new Ext.ux.grid.ProgressColumn({
header: "Signal Strength",
dataIndex: 'signal',
width: 85,
colored: true,
ceiling: 65535,
tvh_renderer: function(v, p, record) {
var scale = record.get('snr_scale');
if (scale == 1)
return v;
if (scale == 2 && v > 0) {
var snr = v * 0.0001;
return snr.toFixed(1) + " dBm";
}
return '<span class="tvh-grid-unset">Unknown</span>';
}
}));

tvheadend.comet.on('input_status', function(m) {
if (m.reload != null)
Expand All @@ -296,68 +327,6 @@ tvheadend.status_streams = function() {
r.data.ec_block = m.ec_block;
r.data.tc_block = m.tc_block;

if (r.data.snr_scale == 1 /* scale_relative */) {
if (!has_snr_rel) {
cm.config.push(new Ext.ux.grid.ProgressColumn({
header: "SNR (%)",
dataIndex: 'snr',
width: 85,
colored: true,
ceiling: 65535
}));
has_snr_rel = true;
}
}
else if (r.data.snr_scale == 2 /* scale_decibel */) {
if (!has_snr_db) {
cm.config.push(new Ext.grid.Column({
width: 50,
header: "SNR (dB)",
dataIndex: 'snr',
renderer: function(value) {
if (value > 0) {
var snr = value * 0.0001;
return snr.toFixed(1) + " dB";
} else {
return '<span class="tvh-grid-unset">Unknown</span>';
}
}
}));
has_snr_db = true;
}
}

if (r.data.signal_scale == 1 /* scale_relative */) {
if (!has_signal_rel) {
cm.config.push(new Ext.ux.grid.ProgressColumn({
header: "Signal Strength (%)",
dataIndex: 'signal',
width: 85,
colored: true,
ceiling: 65535
}));
has_signal_rel = true;
}
}
else if (r.data.signal_scale == 2 /* scale_decibel */) {
if (!has_signal_dbm) {
cm.config.push(new Ext.grid.Column({
width: 50,
header: "Signal Strength (dBm)",
dataIndex: 'signal',
renderer: function(value) {
if (value > 0) {
var snr = value * 0.0001;
return snr.toFixed(1) + " dBm";
} else {
return '<span class="tvh-grid-unset">Unknown</span>';
}
}
}));
has_signal_dbm = true;
}
}

tvheadend.streamStatusStore.afterEdit(r);
tvheadend.streamStatusStore.fireEvent('updated',
tvheadend.streamStatusStore,
Expand Down

3 comments on commit b5f39d5

@ksooo
Copy link
Contributor

@ksooo ksooo commented on b5f39d5 Aug 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might lead in percentages and dBm values both displayed in the same column as different adapters might report snr/signal in different metrics. Is this your intention? I consider my approach more straight.

@perexg
Copy link
Contributor Author

@perexg perexg commented on b5f39d5 Aug 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are suffixes ('%' and 'dB' or 'dBm') so users can quite easy read the values. Also, percentage shows as a bar. Unfortunately, my firefox renders the dynamically added columns incorrectly (they are in the invisible area on the right side by default) and basically I don't like to have 4 columns for more complex hardware configurations rather then 2.

I'm not against any other solution, if it works...

@ksooo
Copy link
Contributor

@ksooo ksooo commented on b5f39d5 Aug 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. I'm fine with your solution.

Please sign in to comment.