ability to restore original image
This commit is contained in:
@ -94,8 +94,8 @@ class OwrxAssetsController(AssetsController):
|
||||
"gfx/openwebrx-avatar.png": "receiver_avatar",
|
||||
"gfx/openwebrx-top-photo.jpg": "receiver_top_photo",
|
||||
}
|
||||
config = CoreConfig()
|
||||
if file in mappedFiles:
|
||||
if file in mappedFiles and ("mapped" not in self.request.query or self.request.query["mapped"][0] != "false"):
|
||||
config = CoreConfig()
|
||||
user_file = config.get_data_directory() + "/" + mappedFiles[file]
|
||||
if os.path.exists(user_file) and os.path.isfile(user_file):
|
||||
return user_file
|
||||
|
@ -26,6 +26,7 @@ from owrx.wsjt import Fst4Profile, Fst4wProfile
|
||||
import json
|
||||
import logging
|
||||
import shutil
|
||||
import os
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -370,11 +371,15 @@ class GeneralSettingsController(AuthorizationMixin, WebpageController):
|
||||
return variables
|
||||
|
||||
def handle_image(self, data, image_id):
|
||||
if image_id in data and data[image_id]:
|
||||
if image_id in data:
|
||||
config = CoreConfig()
|
||||
filename = "{}-{}".format(image_id, data[image_id])
|
||||
shutil.copy(config.get_temporary_directory() + "/" + filename, config.get_data_directory() + "/" + image_id)
|
||||
del data[image_id]
|
||||
data_file = config.get_data_directory() + "/" + image_id
|
||||
if data[image_id] == "restore":
|
||||
os.unlink(data_file)
|
||||
elif data[image_id]:
|
||||
filename = "{}-{}".format(image_id, data[image_id])
|
||||
shutil.copy(config.get_temporary_directory() + "/" + filename, data_file)
|
||||
del data[image_id]
|
||||
|
||||
def processFormData(self):
|
||||
data = parse_qs(self.get_body().decode("utf-8"), keep_blank_values=True)
|
||||
|
@ -3,7 +3,6 @@ from owrx.form import Input
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# TODO: ability to restore the original image
|
||||
class ImageInput(Input, metaclass=ABCMeta):
|
||||
def render_input(self, value):
|
||||
return """
|
||||
@ -12,7 +11,8 @@ class ImageInput(Input, metaclass=ABCMeta):
|
||||
<div class="image-container">
|
||||
<img class="{classes}" src="{url}" alt="{label}"/>
|
||||
</div>
|
||||
<button class="btn btn-primary">Upload new image...</button>
|
||||
<button class="btn btn-primary upload">Upload new image...</button>
|
||||
<button class="btn btn-secondary restore">Restore original image</button>
|
||||
</div>
|
||||
""".format(
|
||||
id=self.id, label=self.label, url=self.cachebuster(self.getUrl()), classes=" ".join(self.getImgClasses())
|
||||
|
Reference in New Issue
Block a user