Skip to content

Commit

Permalink
Add Clear button for server import
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Oct 30, 2024
1 parent a2f82fc commit c487d81
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
photo-importer (1.2.6) stable; urgency=medium

* Add Clear button for server import
* Disable log for unmounted devices

-- Alexander Bushnev <[email protected]> Thu, 31 Oct 2024 00:37:55 +0100

photo-importer (1.2.5) stable; urgency=medium

* Package refactoring
Expand Down
7 changes: 7 additions & 0 deletions photo_importer/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def __import_stop(self, dev):
def __import_get_log(self, in_path):
return self.server.get_log(in_path)

def __import_done(self, in_path):
return self.server.import_done(in_path)

def __import_request(self, params):
try:
action = params['a'][0]
Expand All @@ -281,6 +284,9 @@ def __import_request(self, params):
elif action == 'getlog':
result = self.__import_get_log(in_path)
self.__text_response(result)
elif action == 'done':
result = self.__import_done(in_path)
self.__ok_response(result)
else:
raise HTTPError(HTTPStatus.BAD_REQUEST, f'unknown action {action}')

Expand Down Expand Up @@ -422,6 +428,7 @@ def import_done(self, in_path):
logging.info('import_done: %s', in_path)
if in_path in self.__importers:
del self.__importers[in_path]
return None

def get_log(self, in_path):
if in_path in self.__importers:
Expand Down
10 changes: 8 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
name = ""
if (state == "mounted" || state == "done") {
action += "<input onclick=\"sendCommand('start', '" + path + "');\" type=button class=\"btn btn-success btn-sm\" value=\"Import\"/> ";
} else if (state == "done" || state == "error") {
action = "<input onclick=\"sendCommand('done', '" + path + "');\" type=button class=\"btn btn-primary btn-sm\" value=\"Clear\"/> ";
}
} else {
if (state == "mounted") {
Expand All @@ -80,14 +82,18 @@
if (data[dev].read_only) {
name += "<br/><font size=\"-2\">(read only)<font>"
}
var log = ""
if (path != "") {
log = "<a href=\"import?a=getlog&p=" + path + "\"><img src=\"log.png\"/></a>"
}
html += "<tr>"
+ "<td>" + name + "</td>"
+ "<td>" + data[dev].path + "</td>"
+ "<td>" + stat + "</td>"
+ "<td>" + action + "</td>"
+ "<td>" + data[dev].size + "&nbsp;GB</td>"
+ "<td>" + progress(data[dev].usage, "", "bg-info") + "</td>"
+ "<td><a href=\"import?a=getlog&p=" + path + "\"><img src=\"log.png\"/></a></td>"
+ "<td>" + log + "</td>"
+ "</tr>"
}
html += "</table>"
Expand Down Expand Up @@ -147,7 +153,7 @@
}
});
} else
if (cmd == "start") {
if (cmd == "start" || cmd == "done") {
var argpath = "";
if (g_outpath) {
argpath = "&o=" + g_outpath;
Expand Down

0 comments on commit c487d81

Please sign in to comment.