Rev957, Sidebar displays onion peers in graph, Sidebar display bad file retry number, Sidebar site Update/Pause/Delete, Ratelimit sidebar update, Encoded typo, Fix onion findHashId, More retry for bad files, Log file path errors, Testcase for self findhashIds, Testcase for Tor findHashId, Better Tor version parse, UiWebsocket callback on update/pause/resume/delete, Skip invalid postMessage messages
This commit is contained in:
parent
ea3257dc09
commit
e891a10e54
18 changed files with 204 additions and 36 deletions
|
@ -65,14 +65,16 @@ class UiWebsocketPlugin(object):
|
|||
if peers_total:
|
||||
percent_connected = float(connected) / peers_total
|
||||
percent_connectable = float(connectable) / peers_total
|
||||
percent_onion = float(onion) / peers_total
|
||||
else:
|
||||
percent_connectable = percent_connected = 0
|
||||
percent_connectable = percent_connected = percent_onion = 0
|
||||
body.append("""
|
||||
<li>
|
||||
<label>Peers</label>
|
||||
<ul class='graph'>
|
||||
<li style='width: 100%' class='total back-black' title="Total peers"></li>
|
||||
<li style='width: {percent_connectable:.0%}' class='connectable back-blue' title='Connectable peers'></li>
|
||||
<li style='width: {percent_onion:.0%}' class='connected back-purple' title='Onion'></li>
|
||||
<li style='width: {percent_connected:.0%}' class='connected back-green' title='Connected peers'></li>
|
||||
</ul>
|
||||
<ul class='graph-legend'>
|
||||
|
@ -264,8 +266,8 @@ class UiWebsocketPlugin(object):
|
|||
<ul class='filelist'>
|
||||
""")
|
||||
|
||||
for bad_file in site.bad_files.keys():
|
||||
body.append("""<li class='color-red' title="%s">%s</li>""" % (cgi.escape(bad_file, True), cgi.escape(bad_file, True)))
|
||||
for bad_file, tries in site.bad_files.iteritems():
|
||||
body.append("""<li class='color-red' title="%s (%s tries)">%s</li>""" % (cgi.escape(bad_file, True), tries, cgi.escape(bad_file, True)))
|
||||
|
||||
body.append("""
|
||||
</ul>
|
||||
|
@ -296,6 +298,25 @@ class UiWebsocketPlugin(object):
|
|||
</li>
|
||||
""".format(**locals()))
|
||||
|
||||
def sidebarRenderControls(self, body, site):
|
||||
auth_address = self.user.getAuthAddress(self.site.address)
|
||||
if self.site.settings["serving"]:
|
||||
class_pause = ""
|
||||
class_resume = "hidden"
|
||||
else:
|
||||
class_pause = "hidden"
|
||||
class_resume = ""
|
||||
|
||||
body.append("""
|
||||
<li>
|
||||
<label>Site control</label>
|
||||
<a href='#Update' class='button noupdate' id='button-update'>Update</a>
|
||||
<a href='#Pause' class='button {class_pause}' id='button-pause'>Pause</a>
|
||||
<a href='#Resume' class='button {class_resume}' id='button-resume'>Resume</a>
|
||||
<a href='#Delete' class='button noupdate' id='button-delete'>Delete</a>
|
||||
</li>
|
||||
""".format(**locals()))
|
||||
|
||||
def sidebarRenderOwnedCheckbox(self, body, site):
|
||||
if self.site.settings["own"]:
|
||||
checked = "checked='checked'"
|
||||
|
@ -362,10 +383,11 @@ class UiWebsocketPlugin(object):
|
|||
has_optional = self.sidebarRenderOptionalFileStats(body, site)
|
||||
if has_optional:
|
||||
self.sidebarRenderOptionalFileSettings(body, site)
|
||||
if site.bad_files:
|
||||
self.sidebarRenderBadFiles(body, site)
|
||||
self.sidebarRenderDbOptions(body, site)
|
||||
self.sidebarRenderIdentity(body, site)
|
||||
self.sidebarRenderControls(body, site)
|
||||
if site.bad_files:
|
||||
self.sidebarRenderBadFiles(body, site)
|
||||
|
||||
self.sidebarRenderOwnedCheckbox(body, site)
|
||||
body.append("<div class='settings-owned'>")
|
||||
|
|
|
@ -432,5 +432,4 @@ DAT.Globe = function(container, opts) {
|
|||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
};
|
|
@ -108,7 +108,8 @@ class Sidebar extends Class
|
|||
@original_set_site_info.apply(wrapper, arguments)
|
||||
|
||||
setSiteInfo: (site_info) ->
|
||||
@updateHtmlTag()
|
||||
RateLimit 1000, =>
|
||||
@updateHtmlTag()
|
||||
@displayGlobe()
|
||||
|
||||
|
||||
|
@ -137,7 +138,7 @@ class Sidebar extends Class
|
|||
@log "Patching content"
|
||||
morphdom @tag.find(".content")[0], '<div class="content">'+res+'</div>', {
|
||||
onBeforeMorphEl: (from_el, to_el) -> # Ignore globe loaded state
|
||||
if from_el.className == "globe"
|
||||
if from_el.className == "globe" or from_el.className.indexOf("noupdate") >= 0
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
@ -234,6 +235,34 @@ class Sidebar extends Class
|
|||
@updateHtmlTag()
|
||||
return false
|
||||
|
||||
# Update site
|
||||
@tag.find("#button-update").off("click").on "click", =>
|
||||
@tag.find("#button-update").addClass("loading")
|
||||
wrapper.ws.cmd "siteUpdate", wrapper.site_info.address, =>
|
||||
wrapper.notifications.add "done-updated", "done", "Site updated!", 5000
|
||||
@tag.find("#button-update").removeClass("loading")
|
||||
return false
|
||||
|
||||
# Pause site
|
||||
@tag.find("#button-pause").off("click").on "click", =>
|
||||
@tag.find("#button-pause").addClass("hidden")
|
||||
wrapper.ws.cmd "sitePause", wrapper.site_info.address
|
||||
return false
|
||||
|
||||
# Resume site
|
||||
@tag.find("#button-resume").off("click").on "click", =>
|
||||
@tag.find("#button-resume").addClass("hidden")
|
||||
wrapper.ws.cmd "siteResume", wrapper.site_info.address
|
||||
return false
|
||||
|
||||
# Delete site
|
||||
@tag.find("#button-delete").off("click").on "click", =>
|
||||
wrapper.displayConfirm "Are you sure?", "Delete this site", =>
|
||||
@tag.find("#button-delete").addClass("loading")
|
||||
wrapper.ws.cmd "siteDelete", wrapper.site_info.address, ->
|
||||
document.location = $(".fixbutton-bg").attr("href")
|
||||
return false
|
||||
|
||||
# Owned checkbox
|
||||
@tag.find("#checkbox-owned").off("click").on "click", =>
|
||||
wrapper.ws.cmd "siteSetOwned", [@tag.find("#checkbox-owned").is(":checked")]
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
.sidebar { background-color: #212121; position: fixed; backface-visibility: hidden; right: -1200px; height: 100%; width: 1200px; } /*box-shadow: inset 0px 0px 10px #000*/
|
||||
.sidebar .content { margin: 30px; font-family: "Segoe UI Light", "Segoe UI", "Helvetica Neue"; color: white; width: 375px; height: 300px; font-weight: 200 }
|
||||
.sidebar h1, .sidebar h2 { font-weight: lighter; }
|
||||
.sidebar .button { margin: 0px; display: inline-block; }
|
||||
|
||||
.sidebar .button { margin: 0px; display: inline-block; transition: all 0.3s; box-sizing: border-box; max-width: 160px }
|
||||
.sidebar .button.hidden { padding: 0px; max-width: 0px; opacity: 0; pointer-events: none }
|
||||
.sidebar #button-delete { background-color: transparent; border: 1px solid #333; color: #AAA; margin-left: 10px }
|
||||
.sidebar #button-delete:hover { border: 1px solid #666; color: white }
|
||||
|
||||
/* FIELDS */
|
||||
|
||||
|
@ -23,7 +25,7 @@
|
|||
.sidebar .fields > li:after, .sidebar .fields .settings-owned > li:after { clear: both; content: ''; display: block }
|
||||
.sidebar .fields label {
|
||||
font-family: Consolas, monospace; text-transform: uppercase; font-size: 13px; color: #ACACAC; display: inline-block; margin-bottom: 10px;
|
||||
vertical-align: text-bottom; margin-right: 10px;
|
||||
vertical-align: text-bottom; margin-right: 10px; width: 100%
|
||||
}
|
||||
.sidebar .fields label small { font-weight: normal; color: white; text-transform: none; }
|
||||
.sidebar .fields .text { background-color: black; border: 0px; padding: 10px; color: white; border-radius: 3px; width: 250px; font-family: Consolas, monospace; }
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
.sidebar { background-color: #212121; position: fixed; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; right: -1200px; height: 100%; width: 1200px; } /*box-shadow: inset 0px 0px 10px #000*/
|
||||
.sidebar .content { margin: 30px; font-family: "Segoe UI Light", "Segoe UI", "Helvetica Neue"; color: white; width: 375px; height: 300px; font-weight: 200 }
|
||||
.sidebar h1, .sidebar h2 { font-weight: lighter; }
|
||||
.sidebar .button { margin: 0px; display: inline-block; }
|
||||
|
||||
.sidebar .button { margin: 0px; display: inline-block; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; max-width: 160px }
|
||||
.sidebar .button.hidden { padding: 0px; max-width: 0px; opacity: 0; pointer-events: none }
|
||||
.sidebar #button-delete { background-color: transparent; border: 1px solid #333; color: #AAA; margin-left: 10px }
|
||||
.sidebar #button-delete:hover { border: 1px solid #666; color: white }
|
||||
|
||||
/* FIELDS */
|
||||
|
||||
|
@ -77,7 +79,7 @@
|
|||
.sidebar .fields > li:after, .sidebar .fields .settings-owned > li:after { clear: both; content: ''; display: block }
|
||||
.sidebar .fields label {
|
||||
font-family: Consolas, monospace; text-transform: uppercase; font-size: 13px; color: #ACACAC; display: inline-block; margin-bottom: 10px;
|
||||
vertical-align: text-bottom; margin-right: 10px;
|
||||
vertical-align: text-bottom; margin-right: 10px; width: 100%
|
||||
}
|
||||
.sidebar .fields label small { font-weight: normal; color: white; text-transform: none; }
|
||||
.sidebar .fields .text { background-color: black; border: 0px; padding: 10px; color: white; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; width: 250px; font-family: Consolas, monospace; }
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
}).call(this);
|
||||
|
||||
|
||||
|
||||
/* ---- plugins/Sidebar/media/Scrollable.js ---- */
|
||||
|
||||
|
||||
|
@ -316,7 +315,11 @@ window.initScrollable = function () {
|
|||
};
|
||||
|
||||
Sidebar.prototype.setSiteInfo = function(site_info) {
|
||||
this.updateHtmlTag();
|
||||
RateLimit(1000, (function(_this) {
|
||||
return function() {
|
||||
return _this.updateHtmlTag();
|
||||
};
|
||||
})(this));
|
||||
return this.displayGlobe();
|
||||
};
|
||||
|
||||
|
@ -341,7 +344,7 @@ window.initScrollable = function () {
|
|||
_this.log("Patching content");
|
||||
morphdom(_this.tag.find(".content")[0], '<div class="content">' + res + '</div>', {
|
||||
onBeforeMorphEl: function(from_el, to_el) {
|
||||
if (from_el.className === "globe") {
|
||||
if (from_el.className === "globe" || from_el.className.indexOf("noupdate") >= 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -449,6 +452,41 @@ window.initScrollable = function () {
|
|||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-update").off("click").on("click", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-update").addClass("loading");
|
||||
wrapper.ws.cmd("siteUpdate", wrapper.site_info.address, function() {
|
||||
wrapper.notifications.add("done-updated", "done", "Site updated!", 5000);
|
||||
return _this.tag.find("#button-update").removeClass("loading");
|
||||
});
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-pause").off("click").on("click", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-pause").addClass("hidden");
|
||||
wrapper.ws.cmd("sitePause", wrapper.site_info.address);
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-resume").off("click").on("click", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-resume").addClass("hidden");
|
||||
wrapper.ws.cmd("siteResume", wrapper.site_info.address);
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-delete").off("click").on("click", (function(_this) {
|
||||
return function() {
|
||||
wrapper.displayConfirm("Are you sure?", "Delete this site", function() {
|
||||
_this.tag.find("#button-delete").addClass("loading");
|
||||
return wrapper.ws.cmd("siteDelete", wrapper.site_info.address, function() {
|
||||
return document.location = $(".fixbutton-bg").attr("href");
|
||||
});
|
||||
});
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#checkbox-owned").off("click").on("click", (function(_this) {
|
||||
return function() {
|
||||
return wrapper.ws.cmd("siteSetOwned", [_this.tag.find("#checkbox-owned").is(":checked")]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue