Mercurial > libervia-web
annotate libervia/pages/photos/album/_browser/__init__.py @ 1415:8415d882b686
browser: new `editor` module:
This module provide tools for dynamtic item edition.
For now it implements forms autosave, and a tags editor.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Apr 2021 16:45:39 +0200 |
parents | 19eb8b6c02d4 |
children | b028a1256a09 |
rev | line source |
---|---|
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
1 from browser import document, window, bind, html, DOMNode, aio |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 from javascript import JSON |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 from bridge import Bridge |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
4 from aio_bridge import Bridge as AIOBridge |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from template import Template |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 import dialog |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
7 from slideshow import SlideShow |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
8 from invitation import InvitationManager |
1346
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
9 import alt_media_player |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
10 # we use tmp_aio because `blob` is not handled in Brython's aio |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
11 import tmp_aio |
1372
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
12 import loading |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
13 |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
15 cache_path = window.cache_path |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 files_service = window.files_service |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 files_path = window.files_path |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
18 try: |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
19 affiliations = window.affiliations.to_dict() |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
20 except AttributeError: |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
21 pass |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 bridge = Bridge() |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
23 aio_bridge = AIOBridge() |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
1346
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
25 alt_media_player.install_if_needed() |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
26 |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
27 photo_tpl = Template('photo/item.html') |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
28 player_tpl = Template('components/media_player.html') |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
29 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
30 # file upload |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 def on_progress(ev, photo_elt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 if ev.lengthComputable: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 percent = int(ev.loaded/ev.total*100) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 update_progress(photo_elt, percent) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 def on_load(file_, photo_elt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 update_progress(photo_elt, 100) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 photo_elt.classList.add("progress_finished") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 photo_elt.classList.remove("progress_started") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 photo_elt.select_one('.action_delete').bind("click", on_delete) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 print(f"file {file_.name} uploaded correctly") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 def on_error(failure, file_, photo_elt): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
47 dialog.notification.show( |
1345
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
48 f"can't upload {file_.name}: failure", |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
49 level="error" |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
50 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 def update_progress(photo_elt, new_value): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 progress_elt = photo_elt.select_one("progress") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 progress_elt.value = new_value |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 progress_elt.text = f"{new_value}%" |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 def on_slot_cb(file_, upload_slot, photo_elt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 put_url, get_url, headers = upload_slot |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 xhr = window.XMLHttpRequest.new() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 xhr.open("PUT", put_url, True) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 xhr.upload.bind('progress', lambda ev: on_progress(ev, photo_elt)) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 xhr.upload.bind('load', lambda ev: on_load(file_, photo_elt)) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 xhr.upload.bind('error', lambda ev: on_error(xhr.response, file_, photo_elt)) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 xhr.setRequestHeader('Xmpp-File-Path', window.encodeURIComponent(files_path)) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 xhr.setRequestHeader('Xmpp-File-No-Http', "true") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 xhr.send(file_) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 def on_slot_eb(file_, failure, photo_elt): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
72 dialog.notification.show( |
1345
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
73 f"Can't get upload slot: {failure}", |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
74 level="error" |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
75 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 def upload_files(files): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 print(f"uploading {len(files)} files") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 album_items = document['album_items'] |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 for file_ in files: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 url = window.URL.createObjectURL(file_) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 photo_elt = photo_tpl.get_elt({ |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 "file": { |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 "name": file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 # we don't want to open the file on click, it's not yet the |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 # uploaded URL |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 "url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 # we have no thumb yet, so we use the whole image |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 # TODO: reduce image for preview |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 "thumb_url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 }, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 "uploading": True, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 }) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 photo_elt.classList.add("progress_started") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 album_items <= photo_elt |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 bridge.fileHTTPUploadGetSlot( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 file_.size, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 file_.type or '', |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 callback=lambda upload_slot, file_=file_, photo_elt=photo_elt: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 on_slot_cb(file_, upload_slot, photo_elt), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 errback=lambda failure, file_=file_, photo_elt=photo_elt: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 on_slot_eb(file_, failure, photo_elt), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 ) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 @bind("#file_drop", "drop") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 def on_file_select(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 files = evt.dataTransfer.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 upload_files(files) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 @bind("#file_drop", "dragover") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 def on_drag_over(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 evt.dataTransfer.dropEffect = 'copy' |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 @bind("#file_input", "change") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 def on_file_input_change(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 files = evt.currentTarget.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 upload_files(files) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
130 # delete |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 def file_delete_cb(item_elt, item): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 item_elt.classList.add("state_deleted") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 item_elt.bind("transitionend", lambda evt: item_elt.remove()) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 print(f"deleted {item['name']}") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 def file_delete_eb(failure, item_elt, item): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
139 dialog.notification.show( |
1345
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
140 f"error while deleting {item['name']}: failure", |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
141 level="error" |
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
142 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 def delete_ok(evt, notif_elt, item_elt, item): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 file_path = f"{files_path.rstrip('/')}/{item['name']}" |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 bridge.fileSharingDelete( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 file_path, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 "", |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 callback=lambda : file_delete_cb(item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 errback=lambda failure: file_delete_eb(failure, item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 ) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 def delete_cancel(evt, notif_elt, item_elt, item): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 notif_elt.remove() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 item_elt.classList.remove("selected_for_deletion") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 def on_delete(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
164 item_elt = DOMNode(target.closest('.item')) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 item_elt.classList.add("selected_for_deletion") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 item = JSON.parse(item_elt.dataset.item) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 dialog.Confirm( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 f"{item['name']!r} will be deleted, are you sure?", |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 ok_label="delete", |
1345
ce1217e3a9c0
browser (photos/album): use notifications to show error messages + use `ok_color` argument for delete confirmation
Goffi <goffi@goffi.org>
parents:
1332
diff
changeset
|
170 ok_color="danger", |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 ).show( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 ok_cb=lambda evt, notif_elt: delete_ok(evt, notif_elt, item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 cancel_cb=lambda evt, notif_elt: delete_cancel(evt, notif_elt, item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 ) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
176 # cover |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
177 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
178 async def cover_ok(evt, notif_elt, item_elt, item): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
179 # we first need to get a blob of the image |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
180 img_elt = item_elt.select_one("img") |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
181 # the simplest way is to download it |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
182 r = await tmp_aio.ajax("GET", img_elt.src, "blob") |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
183 if r.status != 200: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
184 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
185 f"can't retrieve cover: {r.status}: {r.statusText}", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
186 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
187 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
188 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
189 img_blob = r.response |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
190 # now we'll upload it via HTTP Upload, we need a slow |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
191 img_name = img_elt.src.rsplit('/', 1)[-1] |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
192 img_size = img_blob.size |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
193 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
194 slot = await aio_bridge.fileHTTPUploadGetSlot( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
195 img_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
196 img_size, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
197 '', |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
198 files_service |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
199 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
200 get_url, put_url, headers = slot |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
201 # we have the slot, we can upload image |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
202 r = await tmp_aio.ajax("PUT", put_url, "", img_blob) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
203 if r.status != 201: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
204 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
205 f"can't upload cover: {r.status}: {r.statusText}", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
206 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
207 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
208 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
209 extra = {"thumb_url": get_url} |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
210 album_name = files_path.rsplit('/', 1)[-1] |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
211 await aio_bridge.interestsRegisterFileSharing( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
212 files_service, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
213 "photos", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
214 "", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
215 files_path, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
216 album_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
217 JSON.stringify(extra), |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
218 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
219 dialog.notification.show("Album cover has been changed") |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
220 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
221 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
222 def cover_cancel(evt, notif_elt, item_elt, item): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
223 notif_elt.remove() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
224 item_elt.classList.remove("selected_for_action") |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
225 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
226 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
227 def on_cover(evt): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
228 evt.stopPropagation() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
229 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
230 item_elt = DOMNode(target.closest('.item')) |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
231 item_elt.classList.add("selected_for_action") |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
232 item = JSON.parse(item_elt.dataset.item) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
233 dialog.Confirm( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
234 f"use {item['name']!r} for this album cover?", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
235 ok_label="use as cover", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
236 ).show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
237 ok_cb=lambda evt, notif_elt: aio.run(cover_ok(evt, notif_elt, item_elt, item)), |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
238 cancel_cb=lambda evt, notif_elt: cover_cancel(evt, notif_elt, item_elt, item), |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
239 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
240 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
241 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
242 # slideshow |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
244 @bind(".photo_thumb_click", "click") |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
245 def photo_click(evt): |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
246 evt.stopPropagation() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
247 evt.preventDefault() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
248 slideshow = SlideShow() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
249 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
250 clicked_item_elt = DOMNode(target.closest('.item')) |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
251 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
252 slideshow.attach() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
253 for idx, item_elt in enumerate(document.select('.item')): |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
254 item = JSON.parse(item_elt.dataset.item) |
1330
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
255 try: |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
256 biggest_thumb = item['extra']['thumbnails'][-1] |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
257 thumb_url = f"{cache_path}{biggest_thumb['filename']}" |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
258 except (KeyError, IndexError) as e: |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
259 print(f"Can't get full screen thumbnail URL: {e}") |
1346
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
260 thumb_url = None |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
261 if item.get("mime_type", "")[:5] == "video": |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
262 player = alt_media_player.MediaPlayer( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
263 [item['url']], |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
264 poster = thumb_url, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
265 reduce_click_area = True |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
266 ) |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
267 elt = player.elt |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
268 elt.classList.add("slide_video", "no_fullscreen") |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
269 slideshow.add_slide( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
270 elt, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
271 item, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
272 options={ |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
273 "flags": (alt_media_player.NO_PAGINATION, alt_media_player.NO_SCROLLBAR), |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
274 "exit_callback": player.reset, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
275 } |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
276 ) |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
277 else: |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
278 slideshow.add_slide(html.IMG(src=thumb_url or item['url'], Class="slide_img"), item) |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
279 if item_elt == clicked_item_elt: |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
280 slideshow.index = idx |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
281 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
282 |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 for elt in document.select('.action_delete'): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
284 elt.bind("click", on_delete) |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
285 for elt in document.select('.action_cover'): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
286 elt.bind("click", on_cover) |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
287 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
288 # manage |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
289 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
290 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
291 @bind("#button_manage", "click") |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
292 def manage_click(evt): |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
293 evt.stopPropagation() |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
294 evt.preventDefault() |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
295 manager = InvitationManager("photos", {"service": files_service, "path": files_path}) |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
296 manager.attach(affiliations=affiliations) |
1332
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
297 |
1372
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
298 |
1332
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
299 # hint |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
300 @bind("#hint .click_to_delete", "click") |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
301 def remove_hint(evt): |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
302 document['hint'].remove() |
1372
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
303 |
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
304 |
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
305 loading.remove_loading_screen() |