Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2a4e9ae2cf
3 changed files with 63 additions and 1 deletions
|
@ -415,11 +415,26 @@ class UiWebsocketPlugin(object):
|
|||
class_pause = "hidden"
|
||||
class_resume = ""
|
||||
|
||||
dashboard = config.homepage
|
||||
dsite = self.user.sites.get(dashboard, None)
|
||||
if not dsite:
|
||||
print('No dashboard found, cannot favourite')
|
||||
class_favourite = "hidden"
|
||||
class_unfavourite = "hidden"
|
||||
elif dsite.get('sittings', {}).get('favorite_sites', {}).get(self.site.address, False):
|
||||
class_favourite = ""
|
||||
class_unfavourite = "hidden"
|
||||
else:
|
||||
class_favourite = "hidden"
|
||||
class_unfavourite = ""
|
||||
|
||||
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='#Favourite' class='button {class_favourite}' id='button-favourite'>{_[Favourite]}</a>
|
||||
<a href='#Unfavourite' class='button {class_unfavourite}' id='button-unfavourite'>{_[Unfavourite]}</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>
|
||||
|
|
|
@ -1137,6 +1137,22 @@ window.initScrollable = function () {
|
|||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-favourite").off("click touched").on("click touched", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-favourite").addClass("hidden");
|
||||
_this.tag.find("#button-unfavourite").removeClass("hidden");
|
||||
_this.wrapper.ws.cmd("siteFavourite", _this.wrapper.site_info.address);
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-unfavourite").off("click touched").on("click touched", (function(_this) {
|
||||
return function() {
|
||||
_this.tag.find("#button-favourite").removeClass("hidden");
|
||||
_this.tag.find("#button-unfavourite").addClass("hidden");
|
||||
_this.wrapper.ws.cmd("siteUnfavourite", _this.wrapper.site_info.address);
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
this.tag.find("#button-delete").off("click touchend").on("click touchend", (function(_this) {
|
||||
return function() {
|
||||
_this.handleSiteDeleteClick();
|
||||
|
@ -1767,4 +1783,4 @@ function morphdom(fromNode, toNode, options) {
|
|||
|
||||
module.exports = morphdom;
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,8 @@ import stat
|
|||
|
||||
import gevent
|
||||
|
||||
from rich import print
|
||||
|
||||
from Config import config
|
||||
from Site import SiteManager
|
||||
from Crypt import CryptBitcoin
|
||||
|
@ -950,6 +952,35 @@ class UiWebsocket(object):
|
|||
else:
|
||||
self.response(to, {"error": "Unknown site: %s" % address})
|
||||
|
||||
def siteFavUnfav(self, to, address, action, response):
|
||||
dashboard = config.homepage
|
||||
dsite = self.user.sites.get(dashboard, None)
|
||||
if not dsite:
|
||||
raise RuntimeError(f'No dashboard {dashboard} found to add site to favourites')
|
||||
if 'settings' not in dsite:
|
||||
dsite['settings'] = {}
|
||||
dsettings = dsite['settings']
|
||||
if 'favorite_sites' not in dsettings:
|
||||
dsettings['favorite_sites'] = {}
|
||||
favs = dsettings['favorite_sites']
|
||||
action(favs)
|
||||
self.user.setSiteSettings(dashboard, dsettings)
|
||||
self.response(to, response)
|
||||
|
||||
@flag.admin
|
||||
@flag.no_multiuser
|
||||
def actionSiteFavourite(self, to, address):
|
||||
def do_add(favs):
|
||||
favs[address] = True
|
||||
self.siteFavUnfav(to, address, do_add, "Added to favourites")
|
||||
|
||||
@flag.admin
|
||||
@flag.no_multiuser
|
||||
def actionSiteUnfavourite(self, to, address):
|
||||
def do_del(favs):
|
||||
del favs[address]
|
||||
self.siteFavUnfav(to, address, do_del, "Removed from favourites")
|
||||
|
||||
@flag.admin
|
||||
@flag.no_multiuser
|
||||
def actionSiteDelete(self, to, address):
|
||||
|
|
Loading…
Reference in a new issue