Big improvement to web config history speed
Nice dashed table seprators
This commit is contained in:
parent
1889db3263
commit
c8bc535f22
@ -94,8 +94,13 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.data_table_cell {
|
.data_table_cell {
|
||||||
padding-bottom: 10px;
|
padding-top: 5px;
|
||||||
|
padding-bottom: 5px;
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
|
border-bottom: #444 dotted 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no_overflow {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
@ -146,6 +151,7 @@ function switch_tab(new_tab) {
|
|||||||
/* Hide some things */
|
/* Hide some things */
|
||||||
$('#colorpicker_term256').hide()
|
$('#colorpicker_term256').hide()
|
||||||
$('#data_table').hide()
|
$('#data_table').hide()
|
||||||
|
$('#data_table').empty()
|
||||||
|
|
||||||
/* Load something new */
|
/* Load something new */
|
||||||
if (new_tab == 'tab_colors') {
|
if (new_tab == 'tab_colors') {
|
||||||
@ -169,7 +175,10 @@ function switch_tab(new_tab) {
|
|||||||
})
|
})
|
||||||
$('#data_table').show()
|
$('#data_table').show()
|
||||||
} else if (new_tab == 'tab_history') {
|
} else if (new_tab == 'tab_history') {
|
||||||
|
run_get_request('/history/', function(contents){
|
||||||
|
create_data_table_element([contents])
|
||||||
|
})
|
||||||
|
$('#data_table').show()
|
||||||
} else {
|
} else {
|
||||||
alert("Unknown tab");
|
alert("Unknown tab");
|
||||||
}
|
}
|
||||||
@ -225,23 +234,39 @@ function create_master_element(contents) {
|
|||||||
).appendTo('#master')
|
).appendTo('#master')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Toggle the no_overflow class */
|
||||||
|
function toggle_overflow(who) {
|
||||||
|
$(who).toggleClass('no_overflow')
|
||||||
|
}
|
||||||
|
|
||||||
/* Creates a new row in the data table */
|
/* Creates a new row in the data table */
|
||||||
function create_data_table_element(contents_list) {
|
function create_data_table_element(contents_list) {
|
||||||
var row = $('<tr>', {
|
var row = $('<tr>', {
|
||||||
class: 'data_table_row'
|
class: 'data_table_row'
|
||||||
})
|
})
|
||||||
for (idx = 0; idx < contents_list.length; idx++) {
|
for (idx = 0; idx < contents_list.length; idx++) {
|
||||||
/* Align the first one right, subsequent ones left */
|
/* If we have more than one, then align the first one right, subsequent ones left */
|
||||||
if (idx == 0) {
|
if (idx == 0 && contents_list.length > 1) {
|
||||||
cell_style = 'text-align: right; padding-right: 30px;'
|
cell = $('<td>', {
|
||||||
|
class: 'data_table_cell no_overflow',
|
||||||
|
style: 'text-align: right; padding-right: 30px;'
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cell_style = 'text-align: left;'
|
cell = $('<td>', {
|
||||||
|
class: 'data_table_cell no_overflow',
|
||||||
|
style: 'text-align: left',
|
||||||
|
onClick: "toggle_overflow(this)"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
row.append($('<td>', {
|
text_list = contents_list[idx].split("\n")
|
||||||
class: 'data_table_cell',
|
for (j=0; j < text_list.length; j++) {
|
||||||
style: cell_style,
|
cell.append($('<p>', {
|
||||||
text: contents_list[idx]
|
text: text_list[j]
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
row.append(cell)
|
||||||
}
|
}
|
||||||
$('#data_table').append(row)
|
$('#data_table').append(row)
|
||||||
}
|
}
|
||||||
@ -282,10 +307,10 @@ $(document).ready(function() {
|
|||||||
<span style="font-size: 68pt">fish</span>
|
<span style="font-size: 68pt">fish</span>
|
||||||
<div id="parent">
|
<div id="parent">
|
||||||
<div id="tab_parent">
|
<div id="tab_parent">
|
||||||
<div class="tab selected_tab" id="tab_colors" onClick="javascript: switch_tab('tab_colors')">colors</div>
|
<div class="tab selected_tab" id="tab_colors" onClick="switch_tab('tab_colors')">colors</div>
|
||||||
<div class="tab" id="tab_functions" onClick="javascript: switch_tab('tab_functions')">functions</div>
|
<div class="tab" id="tab_functions" onClick="switch_tab('tab_functions')">functions</div>
|
||||||
<div class="tab" id="tab_variables" onClick="javascript: switch_tab('tab_variables')">variables</div>
|
<div class="tab" id="tab_variables" onClick="switch_tab('tab_variables')">variables</div>
|
||||||
<div class="tab" id="tab_history" onClick="javascript: switch_tab('tab_history')">history</div>
|
<div class="tab" id="tab_history" onClick="switch_tab('tab_history')">history</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="master">
|
<div id="master">
|
||||||
<!--- <div class="master_element"><span class="master_element_text">command</span></div> -->
|
<!--- <div class="master_element"><span class="master_element_text">command</span></div> -->
|
||||||
|
@ -55,7 +55,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
return out.split('\n')
|
return out.split('\n')
|
||||||
|
|
||||||
def do_get_variables(self):
|
def do_get_variables(self):
|
||||||
out, err = run_fish_cmd('set')
|
out, err = run_fish_cmd('set -L')
|
||||||
|
|
||||||
# Put all the variables into a dictionary
|
# Put all the variables into a dictionary
|
||||||
vars = {}
|
vars = {}
|
||||||
@ -65,15 +65,20 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
fish_var = FishVar(comps[0], comps[1])
|
fish_var = FishVar(comps[0], comps[1])
|
||||||
vars[fish_var.name] = fish_var
|
vars[fish_var.name] = fish_var
|
||||||
|
|
||||||
# Mark universal variables
|
# Mark universal variables. L means don't abbreviate.
|
||||||
for name in self.do_get_variable_names('set -nU'):
|
for name in self.do_get_variable_names('set -nUL'):
|
||||||
if name in vars: vars[name].universal = True
|
if name in vars: vars[name].universal = True
|
||||||
# Mark exported variables
|
# Mark exported variables. L means don't abbreviate.
|
||||||
for name in self.do_get_variable_names('set -nx'):
|
for name in self.do_get_variable_names('set -nxL'):
|
||||||
if name in vars: vars[name].exported = True
|
if name in vars: vars[name].exported = True
|
||||||
|
|
||||||
return [vars[key].get_json_obj() for key in sorted(vars.keys(), key=str.lower)]
|
return [vars[key].get_json_obj() for key in sorted(vars.keys(), key=str.lower)]
|
||||||
|
|
||||||
|
def do_get_history(self):
|
||||||
|
# Use \x1e ("record separator") to distinguish between history items. The first
|
||||||
|
# backslash is so Python passes one backslash to fish
|
||||||
|
out, err = run_fish_cmd('for val in $history; echo -n $val \\x1e; end')
|
||||||
|
return out.split('\x1e')
|
||||||
|
|
||||||
|
|
||||||
def do_get_color_for_variable(self, name):
|
def do_get_color_for_variable(self, name):
|
||||||
@ -89,6 +94,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
output = self.do_get_functions()
|
output = self.do_get_functions()
|
||||||
elif p == '/variables/':
|
elif p == '/variables/':
|
||||||
output = self.do_get_variables()
|
output = self.do_get_variables()
|
||||||
|
elif p == '/history/':
|
||||||
|
output = self.do_get_history()
|
||||||
elif re.match(r"/color/(\w+)/", p):
|
elif re.match(r"/color/(\w+)/", p):
|
||||||
name = re.match(r"/color/(\w+)/", p).group(1)
|
name = re.match(r"/color/(\w+)/", p).group(1)
|
||||||
output = self.do_get_color_for_variable(name)
|
output = self.do_get_color_for_variable(name)
|
||||||
@ -101,8 +108,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
self.wfile.write('\n')
|
self.wfile.write('\n')
|
||||||
|
|
||||||
# Output JSON
|
# Output JSON
|
||||||
print len(output)
|
|
||||||
print output
|
|
||||||
json.dump(output, self.wfile)
|
json.dump(output, self.wfile)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user