Skip to content

Commit 75f3c01

Browse files
committedJul 5, 2015
Removed HTMLSCFormatter, caused sorting/greying to persist across hiding and the refresh button.
1 parent ecb6011 commit 75f3c01

File tree

2 files changed

+22
-74
lines changed

2 files changed

+22
-74
lines changed
 

‎esp/esp/program/modules/handlers/schedulingcheckmodule.py

-62
Original file line numberDiff line numberDiff line change
@@ -47,68 +47,6 @@ def format_table(self, l, options={}, help_text=""):
4747
def format_list(self, l, options={}, help_text=""):
4848
return l
4949

50-
class HTMLSCFormatter: # This might be dead, but idk maybe someone still wants it
51-
#requires: d, a two level dictionary where the the first set of
52-
# keys are the headings expected on the side of the table, and
53-
# the second set are the headings expected on the top of the table
54-
def format_table(self, d, options={}, help_text=""):
55-
if isinstance(d, list):
56-
return self._format_list_table(d, options['headings'], help_text=help_text)
57-
else:
58-
return self._format_dict_table(d, options['headings'], help_text=help_text)
59-
60-
def format_list(self, l, help_text=""):
61-
output = self._table_start(help_text)
62-
for row in l:
63-
output += self._table_row([row])
64-
output += "</table>"
65-
return output
66-
67-
def _table_start(self, help_text=""):
68-
output = ''
69-
if help_text:
70-
output += '<div class="help-text">%s</div>' % help_text
71-
output += '<table cellpadding=10>'
72-
return output
73-
74-
def _table_headings(self, headings):
75-
#column headings
76-
next_row = ""
77-
for h in headings:
78-
next_row = next_row + "<th><div style=\"cursor: pointer;\">" + str(h) + "</div></th>"
79-
next_row = next_row + "</tr></thread>"
80-
return next_row
81-
82-
def _table_row(self, row):
83-
next_row = ""
84-
for r in row:
85-
#displaying lists is sometimes borked. This makes it not borked
86-
if isinstance(r, list):
87-
r = [str(i) for i in r]
88-
next_row += "<td>" + str(r) + "</td>"
89-
next_row += "</tr>"
90-
return next_row
91-
92-
def _format_list_table(self, d, headings, help_text=""):
93-
output = self._table_start(help_text)
94-
output = output + self._table_headings(headings)
95-
for row in d:
96-
ordered_row = [row[h] for h in headings]
97-
output = output + self._table_row(ordered_row)
98-
output = output + "</table>"
99-
return output
100-
101-
def _format_dict_table(self, d, headings, help_text=""):
102-
headings = [""] + headings[:]
103-
output = self._table_start(help_text)
104-
output = output + self._table_headings(headings)
105-
106-
for key, row in sorted(d.iteritems()):
107-
ordered_row = [row[h] for h in headings if h]
108-
output = output + self._table_row([key] + ordered_row)
109-
output += "</table>"
110-
return output
111-
11250
# Builds JSON output for an object with attributes help_text, headings, and body.
11351
class JSONFormatter:
11452
#requires: d, a two level dictionary where the the first set of

‎esp/public/media/scripts/program/modules/scheduling_checks.jsx

+22-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ var SchedulingCheckList = React.createClass({
1616
*
1717
* This might or might not be loaded yet; clicking the heading will load the
1818
* data from the server and expand it.
19+
*
20+
* There is supposedly a functionality in which clicking on a table row will cause it
21+
* to be greyed out, however whether this actually happens depends on your
22+
* scheduling_checks.css (clicking could possibly do nothing, or possibly
23+
* do other things).
24+
*
25+
* Likewise, clicking on a table header will sort by that column. You can also
26+
* add formatting in scheduling_checks.css so that the selected header will
27+
* look different, e.g. be colored differently.
1928
*/
2029
var SchedulingCheck = React.createClass({
2130
propTypes: {
@@ -28,6 +37,10 @@ var SchedulingCheck = React.createClass({
2837
open: false,
2938
failed: false,
3039
timestamp: "never",
40+
tableState: {
41+
greyed: {},
42+
sort: -1
43+
}
3144
};
3245
},
3346

@@ -86,7 +99,7 @@ var SchedulingCheck = React.createClass({
8699
var settings = {
87100
header: false
88101
};
89-
table = <SelectTable rows = {data.body} settings = {settings} />;
102+
table = <SelectTable rows = {data.body} settings = {settings} saveState = {this.state.tableState} />;
90103
} else {
91104
var columns = [];
92105
for (i = 0; i < data.headings.length; i++) {
@@ -96,7 +109,10 @@ var SchedulingCheck = React.createClass({
96109
columns[i] = {key: String(i), label: " "};
97110
}
98111
}
99-
table = <SelectTable rows = {data.body} columns = {columns} />;
112+
var settings = {
113+
header: true
114+
};
115+
table = <SelectTable rows = {data.body} columns = {columns} settings = {settings} saveState = {this.state.tableState} />;
100116
}
101117
body = <div>
102118
<div className="placeholder">
@@ -135,19 +151,11 @@ var RefreshButton = React.createClass({
135151

136152

137153
// Modified from react-json-table example code.
154+
// Required props: rows, saveState (with sort and greyed attributes), settings (with header attribute)
138155
var SelectTable = React.createClass({
139156
getInitialState: function(){
140157
// We will store the sorted column and whether each row is greyed out
141-
var temp = new Array();
142-
for (i = 0; i < this.props.rows.length; i++) {
143-
temp[this.props.rows[i]] = false;
144-
}
145-
if (this.props.settings == undefined) {
146-
this.props.settings = {
147-
header: true
148-
};
149-
}
150-
return {sort: -1, greyed : temp};
158+
return {sort: this.props.saveState.sort, greyed : this.props.saveState.greyed};
151159
},
152160
render: function(){
153161
var me = this,
@@ -198,11 +206,13 @@ var SelectTable = React.createClass({
198206
},
199207

200208
onClickHeader: function( e, column ){
209+
this.props.saveState.sort = column;
201210
this.setState( {sort: column} );
202211
},
203212

204213
onClickRow: function( e, item ){
205214
this.state.greyed[item] = !this.state.greyed[item];
215+
this.props.saveState.greyed[item] = this.state.greyed[item];
206216
this.setState(); // so that it actually updates
207217
}
208218
});

0 commit comments

Comments
 (0)
Please sign in to comment.