Skip to content

Commit

Permalink
Merge pull request #14 from sashacmc/clear-button
Browse files Browse the repository at this point in the history
Add Clear button for server import
  • Loading branch information
sashacmc authored Oct 30, 2024
2 parents a2f82fc + 95ffc14 commit 73b5294
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-debian-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
photo-importer -h
- name: Upload Debian package as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: debian-package
path: artifacts/*.deb
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
pip install .
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py') --disable missing-function-docstring,missing-module-docstring,missing-class-docstring,broad-exception-caught
pylint $(git ls-files '*.py') --disable missing-function-docstring,missing-module-docstring,missing-class-docstring,broad-exception-caught,too-many-positional-arguments
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 ''

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 73b5294

Please sign in to comment.