Mercurial > libervia-web
annotate libervia/pages/photos/album/_browser/__init__.py @ 1364:df40708c4c76
server: renamed `--dev_mode` to `--dev-mode` and set it as a flag:
good practice is to use a dash instead of underscode for CLI arguments.
This options is actually a flag, no need to specify the value.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 20 Nov 2020 17:53:01 +0100 |
parents | dbd573b0bc9c |
children | 19eb8b6c02d4 |
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 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
12 |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
14 cache_path = window.cache_path |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 files_service = window.files_service |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 files_path = window.files_path |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
17 try: |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
18 affiliations = window.affiliations.to_dict() |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
19 except AttributeError: |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
20 pass |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 bridge = Bridge() |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
22 aio_bridge = AIOBridge() |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
1346
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
24 alt_media_player.install_if_needed() |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
25 |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
26 photo_tpl = Template('photo/item.html') |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
27 player_tpl = Template('components/media_player.html') |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
28 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
29 # file upload |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 def on_progress(ev, photo_elt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 if ev.lengthComputable: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 percent = int(ev.loaded/ev.total*100) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 update_progress(photo_elt, percent) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
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 def on_load(file_, photo_elt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 update_progress(photo_elt, 100) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 photo_elt.classList.add("progress_finished") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 photo_elt.classList.remove("progress_started") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 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
|
42 print(f"file {file_.name} uploaded correctly") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 |
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 def on_error(failure, file_, photo_elt): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
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 def update_progress(photo_elt, new_value): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 progress_elt = photo_elt.select_one("progress") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 progress_elt.value = new_value |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 progress_elt.text = f"{new_value}%" |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
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 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
|
59 put_url, get_url, headers = upload_slot |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 xhr = window.XMLHttpRequest.new() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 xhr.open("PUT", put_url, True) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 xhr.setRequestHeader('Xmpp-File-No-Http', "true") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 xhr.send(file_) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 |
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 def on_slot_eb(file_, failure, photo_elt): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
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 def upload_files(files): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 print(f"uploading {len(files)} files") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 album_items = document['album_items'] |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 for file_ in files: |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 url = window.URL.createObjectURL(file_) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 photo_elt = photo_tpl.get_elt({ |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 "file": { |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 "name": file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 # 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
|
86 # uploaded URL |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 "url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 # 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
|
89 # TODO: reduce image for preview |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 "thumb_url": url, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 }, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 "uploading": True, |
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 photo_elt.classList.add("progress_started") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 album_items <= photo_elt |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 bridge.fileHTTPUploadGetSlot( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 file_.name, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 file_.size, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 file_.type or '', |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 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
|
103 on_slot_cb(file_, upload_slot, photo_elt), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 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
|
105 on_slot_eb(file_, failure, photo_elt), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 ) |
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 @bind("#file_drop", "drop") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 def on_file_select(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 files = evt.dataTransfer.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 upload_files(files) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 |
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 @bind("#file_drop", "dragover") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 def on_drag_over(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 evt.preventDefault() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 evt.dataTransfer.dropEffect = 'copy' |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 |
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 @bind("#file_input", "change") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 def on_file_input_change(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 files = evt.currentTarget.files |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 upload_files(files) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
129 # delete |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 def file_delete_cb(item_elt, item): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 item_elt.classList.add("state_deleted") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 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
|
134 print(f"deleted {item['name']}") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 |
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 def file_delete_eb(failure, item_elt, item): |
1351
2c3bc7284992
browser (photos/album): fixed notifications
Goffi <goffi@goffi.org>
parents:
1346
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 ) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 |
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 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
|
145 file_path = f"{files_path.rstrip('/')}/{item['name']}" |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 bridge.fileSharingDelete( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 files_service, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 file_path, |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 "", |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 callback=lambda : file_delete_cb(item_elt, item), |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 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
|
152 ) |
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 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
|
156 notif_elt.remove() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 item_elt.classList.remove("selected_for_deletion") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 |
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 def on_delete(evt): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 evt.stopPropagation() |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
163 item_elt = DOMNode(target.closest('.item')) |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 item_elt.classList.add("selected_for_deletion") |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 item = JSON.parse(item_elt.dataset.item) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 dialog.Confirm( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 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
|
168 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
|
169 ok_color="danger", |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 ).show( |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 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
|
172 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
|
173 ) |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
175 # cover |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
176 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
177 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
|
178 # 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
|
179 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
|
180 # 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
|
181 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
|
182 if r.status != 200: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
183 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
184 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
|
185 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
186 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
187 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
188 img_blob = r.response |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
189 # 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
|
190 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
|
191 img_size = img_blob.size |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
192 |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
193 slot = await aio_bridge.fileHTTPUploadGetSlot( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
194 img_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
195 img_size, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
196 '', |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
197 files_service |
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 get_url, put_url, headers = slot |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
200 # 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
|
201 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
|
202 if r.status != 201: |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
203 dialog.notification.show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
204 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
|
205 level="error" |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
206 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
207 return |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
208 extra = {"thumb_url": get_url} |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
209 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
|
210 await aio_bridge.interestsRegisterFileSharing( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
211 files_service, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
212 "photos", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
213 "", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
214 files_path, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
215 album_name, |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
216 JSON.stringify(extra), |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
217 ) |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
218 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
|
219 |
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 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
|
222 notif_elt.remove() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
223 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
|
224 |
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 def on_cover(evt): |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
227 evt.stopPropagation() |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
228 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 dialog.Confirm( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
233 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
|
234 ok_label="use as cover", |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
235 ).show( |
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
236 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
|
237 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
|
238 ) |
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 |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
241 # slideshow |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
242 |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
243 @bind(".photo_thumb_click", "click") |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
244 def photo_click(evt): |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
245 evt.stopPropagation() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
246 evt.preventDefault() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
247 slideshow = SlideShow() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
248 target = evt.currentTarget |
1357
dbd573b0bc9c
browser: updated code to work with new Brython 3.8.10:
Goffi <goffi@goffi.org>
parents:
1352
diff
changeset
|
249 clicked_item_elt = DOMNode(target.closest('.item')) |
1308
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
250 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
251 slideshow.attach() |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
252 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
|
253 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
|
254 try: |
b525fdcb393b
browser (photos/album): used biggest thumbnails instead of original image for slideshow:
Goffi <goffi@goffi.org>
parents:
1320
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 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
|
259 thumb_url = None |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
260 if item.get("mime_type", "")[:5] == "video": |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
261 player = alt_media_player.MediaPlayer( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
262 [item['url']], |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
263 poster = thumb_url, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
264 reduce_click_area = True |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
265 ) |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
266 elt = player.elt |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
267 elt.classList.add("slide_video", "no_fullscreen") |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
268 slideshow.add_slide( |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
269 elt, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
270 item, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
271 options={ |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
272 "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
|
273 "exit_callback": player.reset, |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
274 } |
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 else: |
cda5537c71d6
browser (photos/album): videos integrations:
Goffi <goffi@goffi.org>
parents:
1345
diff
changeset
|
277 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
|
278 if item_elt == clicked_item_elt: |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
279 slideshow.index = idx |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
280 |
7a4a92cf5b2b
browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents:
1300
diff
changeset
|
281 |
1300
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
282 for elt in document.select('.action_delete'): |
6e110baa707f
browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 elt.bind("click", on_delete) |
1352
d100d3a07dd7
browser (photos/album): change cover on "cover" button click:
Goffi <goffi@goffi.org>
parents:
1351
diff
changeset
|
284 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
|
285 elt.bind("click", on_cover) |
1320
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
286 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
287 # manage |
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 |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
290 @bind("#button_manage", "click") |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
291 def manage_click(evt): |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
292 evt.stopPropagation() |
0cbf86b1dcca
browser (photos/album): invitation manager first draft.
Goffi <goffi@goffi.org>
parents:
1312
diff
changeset
|
293 evt.preventDefault() |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1330
diff
changeset
|
294 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
|
295 manager.attach(affiliations=affiliations) |
1332
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
296 |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
297 # hint |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
298 @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
|
299 def remove_hint(evt): |
a75d82713a02
browser (photos/album): remove hint when delete button is pressed
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
300 document['hint'].remove() |