Rev571, Optional file sizes to sidebar, Download all optional files option in sidebar, Optional file number in peer stats, Delete removed or changed optional files, Auto download optional files if autodownloadoptional checked, SiteReload command, Peer use global file server if no site defined, Allow browser cache video files, Allow more keepalive connections, Gevent 1.1 ranged request bugfix, Dont sent optional files details on websocket, Remove files from workermanager tasks if no longer in bad_files, Notify local client about changes on external siteSign
This commit is contained in:
parent
2cf34c132f
commit
3587777ea8
17 changed files with 212 additions and 41 deletions
|
@ -201,6 +201,55 @@ class UiWebsocketPlugin(object):
|
|||
</li>
|
||||
""".format(**locals()))
|
||||
|
||||
|
||||
def sidebarRenderOptionalFileStats(self, body, site):
|
||||
size_total = 0.0
|
||||
size_downloaded = 0.0
|
||||
for content in site.content_manager.contents.values():
|
||||
if "files_optional" not in content:
|
||||
continue
|
||||
for file_name, file_details in content["files_optional"].items():
|
||||
size_total += file_details["size"]
|
||||
if site.content_manager.hashfield.hasHash(file_details["sha512"]):
|
||||
size_downloaded += file_details["size"]
|
||||
|
||||
|
||||
if not size_total:
|
||||
return False
|
||||
|
||||
percent_downloaded = size_downloaded / size_total
|
||||
|
||||
size_formatted_total = size_total / 1024 / 1024
|
||||
size_formatted_downloaded = size_downloaded / 1024 / 1024
|
||||
|
||||
body.append("""
|
||||
<li>
|
||||
<label>Optional files</label>
|
||||
<ul class='graph'>
|
||||
<li style='width: 100%' class='total back-black' title="Total size"></li>
|
||||
<li style='width: {percent_downloaded:.0%}' class='connected back-green' title='Downloaded files'></li>
|
||||
</ul>
|
||||
<ul class='graph-legend'>
|
||||
<li class='color-green'><span>Downloaded:</span><b>{size_formatted_downloaded:.2f}MB</b></li>
|
||||
<li class='color-black'><span>Total:</span><b>{size_formatted_total:.2f}MB</b></li>
|
||||
</ul>
|
||||
</li>
|
||||
""".format(**locals()))
|
||||
|
||||
return True
|
||||
|
||||
def sidebarRenderOptionalFileSettings(self, body, site):
|
||||
if self.site.settings.get("autodownloadoptional"):
|
||||
checked = "checked='checked'"
|
||||
else:
|
||||
checked = ""
|
||||
body.append("""
|
||||
<li>
|
||||
<label>Download and help distribute all files</label>
|
||||
<input type="checkbox" class="checkbox" id="checkbox-autodownloadoptional" {checked}/><div class="checkbox-skin"></div>
|
||||
</li>
|
||||
""".format(**locals()))
|
||||
|
||||
def sidebarRenderDbOptions(self, body, site):
|
||||
if not site.storage.db:
|
||||
return False
|
||||
|
@ -232,7 +281,7 @@ class UiWebsocketPlugin(object):
|
|||
checked = ""
|
||||
|
||||
body.append("""
|
||||
<h2 class='owned-title'>Owned site settings</h2>
|
||||
<h2 class='owned-title'>This is my site</h2>
|
||||
<input type="checkbox" class="checkbox" id="checkbox-owned" {checked}/><div class="checkbox-skin"></div>
|
||||
""".format(**locals()))
|
||||
|
||||
|
@ -296,6 +345,9 @@ class UiWebsocketPlugin(object):
|
|||
self.sidebarRenderTransferStats(body, site)
|
||||
self.sidebarRenderFileStats(body, site)
|
||||
self.sidebarRenderSizeLimit(body, site)
|
||||
has_optional = self.sidebarRenderOptionalFileStats(body, site)
|
||||
if has_optional:
|
||||
self.sidebarRenderOptionalFileSettings(body, site)
|
||||
self.sidebarRenderDbOptions(body, site)
|
||||
self.sidebarRenderIdentity(body, site)
|
||||
|
||||
|
@ -405,3 +457,12 @@ class UiWebsocketPlugin(object):
|
|||
if "ADMIN" not in permissions:
|
||||
return self.response(to, "You don't have permission to run this command")
|
||||
self.site.settings["own"] = bool(owned)
|
||||
|
||||
|
||||
def actionSiteSetAutodownloadoptional(self, to, owned):
|
||||
permissions = self.getPermissions(to)
|
||||
if "ADMIN" not in permissions:
|
||||
return self.response(to, "You don't have permission to run this command")
|
||||
self.site.settings["autodownloadoptional"] = bool(owned)
|
||||
self.site.update()
|
||||
self.site.worker_manager.removeGoodFileTasks()
|
||||
|
|
|
@ -15,9 +15,9 @@ window.initScrollable = function () {
|
|||
// *Calculation of how tall scroller should be
|
||||
var visibleRatio = scrollContainer.offsetHeight / scrollContentWrapper.scrollHeight;
|
||||
if (visibleRatio == 1)
|
||||
scroller.style.display = "none"
|
||||
scroller.style.display = "none";
|
||||
else
|
||||
scroller.style.display = "block"
|
||||
scroller.style.display = "block";
|
||||
return visibleRatio * scrollContainer.offsetHeight;
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,13 @@ window.initScrollable = function () {
|
|||
normalizedPosition = evt.pageY;
|
||||
contentPosition = scrollContentWrapper.scrollTop;
|
||||
scrollerBeingDragged = true;
|
||||
window.addEventListener('mousemove', scrollBarScroll)
|
||||
return false
|
||||
window.addEventListener('mousemove', scrollBarScroll);
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopDrag(evt) {
|
||||
scrollerBeingDragged = false;
|
||||
window.removeEventListener('mousemove', scrollBarScroll)
|
||||
window.removeEventListener('mousemove', scrollBarScroll);
|
||||
}
|
||||
|
||||
function scrollBarScroll(evt) {
|
||||
|
@ -51,7 +51,7 @@ window.initScrollable = function () {
|
|||
}
|
||||
|
||||
function updateHeight() {
|
||||
scrollerHeight = calculateScrollerHeight()-10;
|
||||
scrollerHeight = calculateScrollerHeight() - 10;
|
||||
scroller.style.height = scrollerHeight + 'px';
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ window.initScrollable = function () {
|
|||
scroller.className = 'scroller';
|
||||
|
||||
// determine how big scroller should be based on content
|
||||
scrollerHeight = calculateScrollerHeight()-10;
|
||||
scrollerHeight = calculateScrollerHeight() - 10;
|
||||
|
||||
if (scrollerHeight / scrollContainer.offsetHeight < 1){
|
||||
if (scrollerHeight / scrollContainer.offsetHeight < 1) {
|
||||
// *If there is a need to have scroll bar based on content size
|
||||
scroller.style.height = scrollerHeight + 'px';
|
||||
|
||||
|
@ -87,5 +87,5 @@ window.initScrollable = function () {
|
|||
// *** Listeners ***
|
||||
scrollContentWrapper.addEventListener('scroll', moveScroller);
|
||||
|
||||
return updateHeight
|
||||
return updateHeight;
|
||||
};
|
|
@ -220,6 +220,14 @@ class Sidebar extends Class
|
|||
@updateHtmlTag()
|
||||
return false
|
||||
|
||||
# Owned checkbox
|
||||
@tag.find("#checkbox-owned").on "click", =>
|
||||
wrapper.ws.cmd "siteSetOwned", [@tag.find("#checkbox-owned").is(":checked")]
|
||||
|
||||
# Owned checkbox
|
||||
@tag.find("#checkbox-autodownloadoptional").on "click", =>
|
||||
wrapper.ws.cmd "siteSetAutodownloadoptional", [@tag.find("#checkbox-autodownloadoptional").is(":checked")]
|
||||
|
||||
# Change identity button
|
||||
@tag.find("#button-identity").on "click", =>
|
||||
wrapper.ws.cmd "certSelect"
|
||||
|
|
|
@ -21,7 +21,10 @@
|
|||
.sidebar .fields { padding: 0px; list-style-type: none; width: 355px; }
|
||||
.sidebar .fields > li, .sidebar .fields .settings-owned > li { margin-bottom: 30px }
|
||||
.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: block; margin-bottom: 10px; }
|
||||
.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;
|
||||
}
|
||||
.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; }
|
||||
.sidebar .fields .text.long { width: 330px; font-size: 72%; }
|
||||
|
@ -52,7 +55,7 @@
|
|||
/* GRAPH */
|
||||
|
||||
.graph { padding: 0px; list-style-type: none; width: 351px; background-color: black; height: 10px; border-radius: 8px; overflow: hidden; position: relative;}
|
||||
.graph li { height: 100%; position: absolute; }
|
||||
.graph li { height: 100%; position: absolute; transition: all 0.3s; }
|
||||
.graph-stacked li { position: static; float: left; }
|
||||
|
||||
.graph-legend { padding: 0px; list-style-type: none; margin-top: 13px; font-family: Consolas, "Andale Mono", monospace; font-size: 13px; text-transform: capitalize; }
|
||||
|
|
|
@ -75,7 +75,10 @@
|
|||
.sidebar .fields { padding: 0px; list-style-type: none; width: 355px; }
|
||||
.sidebar .fields > li, .sidebar .fields .settings-owned > li { margin-bottom: 30px }
|
||||
.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: block; margin-bottom: 10px; }
|
||||
.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;
|
||||
}
|
||||
.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; }
|
||||
.sidebar .fields .text.long { width: 330px; font-size: 72%; }
|
||||
|
@ -106,7 +109,7 @@
|
|||
/* GRAPH */
|
||||
|
||||
.graph { padding: 0px; list-style-type: none; width: 351px; background-color: black; height: 10px; -webkit-border-radius: 8px; -moz-border-radius: 8px; -o-border-radius: 8px; -ms-border-radius: 8px; border-radius: 8px ; overflow: hidden; position: relative;}
|
||||
.graph li { height: 100%; position: absolute; }
|
||||
.graph li { height: 100%; position: absolute; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; }
|
||||
.graph-stacked li { position: static; float: left; }
|
||||
|
||||
.graph-legend { padding: 0px; list-style-type: none; margin-top: 13px; font-family: Consolas, "Andale Mono", monospace; font-size: 13px; text-transform: capitalize; }
|
||||
|
|
|
@ -77,9 +77,9 @@ window.initScrollable = function () {
|
|||
// *Calculation of how tall scroller should be
|
||||
var visibleRatio = scrollContainer.offsetHeight / scrollContentWrapper.scrollHeight;
|
||||
if (visibleRatio == 1)
|
||||
scroller.style.display = "none"
|
||||
scroller.style.display = "none";
|
||||
else
|
||||
scroller.style.display = "block"
|
||||
scroller.style.display = "block";
|
||||
return visibleRatio * scrollContainer.offsetHeight;
|
||||
}
|
||||
|
||||
|
@ -94,13 +94,13 @@ window.initScrollable = function () {
|
|||
normalizedPosition = evt.pageY;
|
||||
contentPosition = scrollContentWrapper.scrollTop;
|
||||
scrollerBeingDragged = true;
|
||||
window.addEventListener('mousemove', scrollBarScroll)
|
||||
return false
|
||||
window.addEventListener('mousemove', scrollBarScroll);
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopDrag(evt) {
|
||||
scrollerBeingDragged = false;
|
||||
window.removeEventListener('mousemove', scrollBarScroll)
|
||||
window.removeEventListener('mousemove', scrollBarScroll);
|
||||
}
|
||||
|
||||
function scrollBarScroll(evt) {
|
||||
|
@ -113,7 +113,7 @@ window.initScrollable = function () {
|
|||
}
|
||||
|
||||
function updateHeight() {
|
||||
scrollerHeight = calculateScrollerHeight()-10;
|
||||
scrollerHeight = calculateScrollerHeight() - 10;
|
||||
scroller.style.height = scrollerHeight + 'px';
|
||||
}
|
||||
|
||||
|
@ -124,9 +124,9 @@ window.initScrollable = function () {
|
|||
scroller.className = 'scroller';
|
||||
|
||||
// determine how big scroller should be based on content
|
||||
scrollerHeight = calculateScrollerHeight()-10;
|
||||
scrollerHeight = calculateScrollerHeight() - 10;
|
||||
|
||||
if (scrollerHeight / scrollContainer.offsetHeight < 1){
|
||||
if (scrollerHeight / scrollContainer.offsetHeight < 1) {
|
||||
// *If there is a need to have scroll bar based on content size
|
||||
scroller.style.height = scrollerHeight + 'px';
|
||||
|
||||
|
@ -149,7 +149,7 @@ window.initScrollable = function () {
|
|||
// *** Listeners ***
|
||||
scrollContentWrapper.addEventListener('scroll', moveScroller);
|
||||
|
||||
return updateHeight
|
||||
return updateHeight;
|
||||
};
|
||||
|
||||
|
||||
|
@ -398,6 +398,16 @@ window.initScrollable = function () {
|
|||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#checkbox-owned").on("click", (function(_this) {
|
||||
return function() {
|
||||
return wrapper.ws.cmd("siteSetOwned", [_this.tag.find("#checkbox-owned").is(":checked")]);
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#checkbox-autodownloadoptional").on("click", (function(_this) {
|
||||
return function() {
|
||||
return wrapper.ws.cmd("siteSetAutodownloadoptional", [_this.tag.find("#checkbox-autodownloadoptional").is(":checked")]);
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-identity").on("click", (function(_this) {
|
||||
return function() {
|
||||
wrapper.ws.cmd("certSelect");
|
||||
|
|
|
@ -133,7 +133,7 @@ class UiRequestPlugin(object):
|
|||
("%.0fkB", site.settings.get("bytes_sent", 0) / 1024),
|
||||
("%.0fkB", site.settings.get("bytes_recv", 0) / 1024),
|
||||
])
|
||||
yield "<tr><td id='peers_%s' style='display: none; white-space: pre'>" % site.address
|
||||
yield "<tr><td id='peers_%s' style='display: none; white-space: pre' colspan=2>" % site.address
|
||||
for key, peer in site.peers.items():
|
||||
if peer.time_found:
|
||||
time_found = int(time.time()-peer.time_found)/60
|
||||
|
@ -143,6 +143,7 @@ class UiRequestPlugin(object):
|
|||
connection_id = peer.connection.id
|
||||
else:
|
||||
connection_id = None
|
||||
yield "Optional files: %s " % len(peer.hashfield)
|
||||
yield "(#%s, err: %s, found: %s min ago) %22s -<br>" % (connection_id, peer.connection_error, time_found, key)
|
||||
yield "<br></td></tr>"
|
||||
yield "</table>"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue