Mercurial > libervia-web
annotate libervia/pages/photos/album/_browser/__init__.py @ 1436:d21fbdb33c1d
i18n: initial messages extraction
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 15 Jun 2021 14:29:09 +0200 |
parents | b028a1256a09 |
children | 106bae41f5c8 |
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( |
1428
b028a1256a09
browser (photos/album): show directly failure's message on upload error, and remove photo
Goffi <goffi@goffi.org>
parents:
1372
diff
changeset
|
48 f"can't upload {file_.name}: {failure}", |
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
|
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( |
1428
b028a1256a09
browser (photos/album): show directly failure's message on upload error, and remove photo
Goffi <goffi@goffi.org>
parents:
1372
diff
changeset
|
73 f"Can't get upload slot: {failure['message']}", |
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
|
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 ) |
1428
b028a1256a09
browser (photos/album): show directly failure's message on upload error, and remove photo
Goffi <goffi@goffi.org>
parents:
1372
diff
changeset
|
76 photo_elt.remove() |
1300
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 def upload_files(files): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 print(f"uploading {len(files)} files") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 album_items = document['album_items'] |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 for file_ in files: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 url = window.URL.createObjectURL(file_) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 photo_elt = photo_tpl.get_elt({ |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 "file": { |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 "name": file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 # 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
|
88 # uploaded URL |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 "url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 # 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
|
91 # TODO: reduce image for preview |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 "thumb_url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 }, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 "uploading": True, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 }) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 photo_elt.classList.add("progress_started") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 album_items <= photo_elt |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 bridge.fileHTTPUploadGetSlot( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 file_.size, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 file_.type or '', |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 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
|
105 on_slot_cb(file_, upload_slot, photo_elt), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 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
|
107 on_slot_eb(file_, failure, photo_elt), |
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 @bind("#file_drop", "drop") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 def on_file_select(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 files = evt.dataTransfer.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 upload_files(files) |
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 @bind("#file_drop", "dragover") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 def on_drag_over(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 evt.dataTransfer.dropEffect = 'copy' |
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 @bind("#file_input", "change") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 def on_file_input_change(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 files = evt.currentTarget.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 upload_files(files) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
131 # delete |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 def file_delete_cb(item_elt, item): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 item_elt.classList.add("state_deleted") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 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
|
136 print(f"deleted {item['name']}") |
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 def file_delete_eb(failure, item_elt, item): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 ) |
1300
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 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
|
147 file_path = f"{files_path.rstrip('/')}/{item['name']}" |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 bridge.fileSharingDelete( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 file_path, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 "", |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 callback=lambda : file_delete_cb(item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 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
|
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 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
|
158 notif_elt.remove() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 item_elt.classList.remove("selected_for_deletion") |
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 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 def on_delete(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
165 item_elt = DOMNode(target.closest('.item')) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 item_elt.classList.add("selected_for_deletion") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 item = JSON.parse(item_elt.dataset.item) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 dialog.Confirm( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 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
|
170 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
|
171 ok_color="danger", |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 ).show( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 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
|
174 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
|
175 ) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
177 # cover |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
178 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
179 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
|
180 # 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
|
181 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
|
182 # 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
|
183 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
|
184 if r.status != 200: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
185 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
186 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
|
187 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
188 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
189 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
190 img_blob = r.response |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
191 # 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
|
192 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
|
193 img_size = img_blob.size |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
194 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
195 slot = await aio_bridge.fileHTTPUploadGetSlot( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
196 img_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
197 img_size, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
198 '', |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
199 files_service |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
200 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
201 get_url, put_url, headers = slot |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
202 # 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
|
203 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
|
204 if r.status != 201: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
205 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
206 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
|
207 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
208 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
209 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
210 extra = {"thumb_url": get_url} |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
211 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
|
212 await aio_bridge.interestsRegisterFileSharing( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
213 files_service, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
214 "photos", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
215 "", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
216 files_path, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
217 album_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
218 JSON.stringify(extra), |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
219 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
220 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
|
221 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
222 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
223 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
|
224 notif_elt.remove() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
225 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
|
226 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
227 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
228 def on_cover(evt): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
229 evt.stopPropagation() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
230 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 dialog.Confirm( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
235 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
|
236 ok_label="use as cover", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
237 ).show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
238 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
|
239 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
|
240 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
241 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
242 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
243 # slideshow |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
244 |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
245 @bind(".photo_thumb_click", "click") |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
246 def photo_click(evt): |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
247 evt.stopPropagation() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
248 evt.preventDefault() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
249 slideshow = SlideShow() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
250 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
251 clicked_item_elt = DOMNode(target.closest('.item')) |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
252 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
253 slideshow.attach() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
254 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
|
255 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
|
256 try: |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 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
|
261 thumb_url = None |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
262 if item.get("mime_type", "")[:5] == "video": |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
263 player = alt_media_player.MediaPlayer( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
264 [item['url']], |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
265 poster = thumb_url, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
266 reduce_click_area = True |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
267 ) |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
268 elt = player.elt |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
269 elt.classList.add("slide_video", "no_fullscreen") |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
270 slideshow.add_slide( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
271 elt, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
272 item, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
273 options={ |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
274 "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
|
275 "exit_callback": player.reset, |
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 ) |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
278 else: |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
279 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
|
280 if item_elt == clicked_item_elt: |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
281 slideshow.index = idx |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
282 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
283 |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
284 for elt in document.select('.action_delete'): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
285 elt.bind("click", on_delete) |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
286 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
|
287 elt.bind("click", on_cover) |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
288 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
289 # manage |
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 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
292 @bind("#button_manage", "click") |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
293 def manage_click(evt): |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
294 evt.stopPropagation() |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
295 evt.preventDefault() |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
296 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
|
297 manager.attach(affiliations=affiliations) |
1332
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
298 |
1372
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
299 |
1332
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
300 # hint |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
301 @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
|
302 def remove_hint(evt): |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
303 document['hint'].remove() |
1372
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 |
19eb8b6c02d4
browser (album): remove loading screen at the end of the script
Goffi <goffi@goffi.org>
parents:
1357
diff
changeset
|
306 loading.remove_loading_screen() |