annotate browser/sat_browser/menu.py @ 1128:6414fd795df4

server, pages: multi-sites refactoring: Libervia is now handling external sites (i.e. other sites than Libervia official site). The external site are declared in sites_path_public_dict (in [DEFAULT] section) which is read by template engine, then they are linked to virtual host with vhosts_dict (linking host name to site name) in [libervia] section. Sites are only instanced once, so adding an alias is just a matter of mapping the alias host name in vhosts_dict with the same site name. menu_json and url_redirections_dict can now accept keys named after site name, which will be linked to the data for the site. Data for default site can still be keyed at first level. Libervia official pages are added to external site (if pages are not overriden), allowing to call pages of the framework and to have facilities like login handling. Deprecated url_redirections_profile option has been removed.
author Goffi <goffi@goffi.org>
date Fri, 14 Sep 2018 21:41:28 +0200
parents 28e3eb3bb217
children 2af117bfe6cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
4 # Libervia: a Salut à Toi frontend
1054
f2170536ba23 date update
Goffi <goffi@goffi.org>
parents: 964
diff changeset
5 # Copyright (C) 2011-2018 Jérôme Poisson <goffi@goffi.org>
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
10 # (at your option) any later version.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
15 # GNU Affero General Public License for more details.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
19
387
933bce4cb816 browser_side: factorize the code from AvatarUpload to a new class FileUploadPanel
souliane <souliane@mailoo.org>
parents: 377
diff changeset
20 import pyjd # this is dummy in pyjs
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 432
diff changeset
21 from sat.core.log import getLogger
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 432
diff changeset
22 log = getLogger(__name__)
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
23
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.HTML import HTML
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.Frame import Frame
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
26
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
27 from constants import Const as C
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
28 import file_tools
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
29 import xmlui
616
1c0d5a87c554 browser_side: add and use method displayWidget to harmonize widget's management in Libervia (not completely done, there are some issues)
souliane <souliane@mailoo.org>
parents: 611
diff changeset
30 import chat
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
31 import dialog
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
32 import contact_group
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
33 import base_menu
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
34 from sat_browser import html_tools
788
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
35 from sat_browser import web_widget
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
36
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
37
627
30180021f203 browser_side: fixes MUC menus
souliane <souliane@mailoo.org>
parents: 616
diff changeset
38 unicode = str # FIXME: pyjamas workaround
30180021f203 browser_side: fixes MUC menus
souliane <souliane@mailoo.org>
parents: 616
diff changeset
39
30180021f203 browser_side: fixes MUC menus
souliane <souliane@mailoo.org>
parents: 616
diff changeset
40
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
41 class MainMenuBar(base_menu.GenericMenuBar):
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
42 """The main menu bar which is displayed on top of the document"""
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
43
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
44 ITEM_TPL = "<img src='media/icons/menu/%s_menu_red.png' />%s"
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
45
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
46 def __init__(self, host):
498
60be99de3808 browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents: 494
diff changeset
47 styles = {'moved_popup': 'menuLastPopup', 'menu_bar': 'mainMenuBar'}
60be99de3808 browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents: 494
diff changeset
48 base_menu.GenericMenuBar.__init__(self, host, vertical=False, styles=styles)
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
49
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
50 @classmethod
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
51 def getCategoryHTML(cls, category):
690
76a67d04c63e browser_side: improve comments for menus-related methods
souliane <souliane@mailoo.org>
parents: 686
diff changeset
52 """Build the html to be used for displaying a category item.
76a67d04c63e browser_side: improve comments for menus-related methods
souliane <souliane@mailoo.org>
parents: 686
diff changeset
53
76a67d04c63e browser_side: improve comments for menus-related methods
souliane <souliane@mailoo.org>
parents: 686
diff changeset
54 @param category (quick_menus.MenuCategory): category to add
76a67d04c63e browser_side: improve comments for menus-related methods
souliane <souliane@mailoo.org>
parents: 686
diff changeset
55 @return unicode: HTML to display
76a67d04c63e browser_side: improve comments for menus-related methods
souliane <souliane@mailoo.org>
parents: 686
diff changeset
56 """
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
57 name = html_tools.html_sanitize(category.name)
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
58 return cls.ITEM_TPL % (category.icon, name) if category.icon is not None else name
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
59
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
60 ## callbacks
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
61
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
62 # General menu
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
63
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
64 def onDisconnect(self):
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
65 def confirm_cb(answer):
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
66 if answer:
665
6a8a1103ad10 browser_side: OTR uses 'profilePlugged', 'disconnect' and 'gotMenus' listeners
souliane <souliane@mailoo.org>
parents: 654
diff changeset
67 self.host.disconnect(C.PROF_KEY_NONE)
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
68 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?")
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
69 _dialog.show()
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
70
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
71 #Contact menu
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
72
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
73 def onManageContactGroups(self):
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
74 """Open the contact groups manager."""
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
75
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
76 def onCloseCallback():
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
77 pass
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
78
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
79 contact_group.ContactGroupEditor(self.host, None, onCloseCallback)
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
80
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
81 #Group menu
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
82 def onJoinRoom(self):
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
83
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
84 def invite(room_jid, contacts):
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
85 for contact in contacts:
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
86 self.host.bridge.call('inviteMUC', None, unicode(contact), unicode(room_jid))
686
90a5a5af2550 browser_side: let the backend check for the validity of MUC JIDs that come from a user input
souliane <souliane@mailoo.org>
parents: 685
diff changeset
87
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
88 def join(room_jid, contacts):
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
89 if self.host.whoami:
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
90 nick = self.host.whoami.node
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
91 contact_list = self.host.contact_list
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
92 if room_jid is None or room_jid not in contact_list.getSpecials(C.CONTACT_SPECIAL_GROUP):
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
93 room_jid_s = unicode(room_jid) if room_jid else ''
839
09ace5cbcb9b browser (games, menu): rename showFailureRoomInvalid to onJoinMUCFailure and display a nice message when the room has already been joined (it is not a real error)
souliane <souliane@mailoo.org>
parents: 818
diff changeset
94 self.host.bridge.joinMUC(room_jid_s, nick, profile=C.PROF_KEY_NONE, callback=lambda room_jid: invite(room_jid, contacts), errback=self.host.onJoinMUCFailure)
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
95 else:
698
f1271f769ffd browser_side: don't open a new tab when inviting people to a MUC we already joined
souliane <souliane@mailoo.org>
parents: 690
diff changeset
96 self.host.displayWidget(chat.Chat, room_jid, type_="group")
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
97 invite(room_jid, contacts)
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
98
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
99 dialog.RoomAndContactsChooser(self.host, join, ok_button="Join", visible=(True, False))
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
100
686
90a5a5af2550 browser_side: let the backend check for the validity of MUC JIDs that come from a user input
souliane <souliane@mailoo.org>
parents: 685
diff changeset
101
676
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
102 # Help menu
849ffb24d5bf browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents: 669
diff changeset
103
776
627b9073a2ec browser side: the new menu 'help/official room chat' launch the default_muc room, which can be used to get some help
Goffi <goffi@goffi.org>
parents: 745
diff changeset
104 def onOfficialChatRoom(self):
627b9073a2ec browser side: the new menu 'help/official room chat' launch the default_muc room, which can be used to get some help
Goffi <goffi@goffi.org>
parents: 745
diff changeset
105 nick = self.host.whoami.node
839
09ace5cbcb9b browser (games, menu): rename showFailureRoomInvalid to onJoinMUCFailure and display a nice message when the room has already been joined (it is not a real error)
souliane <souliane@mailoo.org>
parents: 818
diff changeset
106 self.host.bridge.joinMUC(self.host.default_muc, nick, profile=C.PROF_KEY_NONE, callback=lambda dummy: None, errback=self.host.onJoinMUCFailure)
776
627b9073a2ec browser side: the new menu 'help/official room chat' launch the default_muc room, which can be used to get some help
Goffi <goffi@goffi.org>
parents: 745
diff changeset
107
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
108 def onSocialContract(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
109 _frame = Frame('contrat_social.html')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
110 _frame.setStyleName('infoFrame')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
111 _dialog = dialog.GenericDialog("Contrat Social", _frame)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
112 _dialog.setSize('80%', '80%')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
113 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
114
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def onAbout(self):
683
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
116 def gotVersions():
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
117 _about = HTML("""<b>Libervia</b>, a Salut &agrave; Toi project<br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
118 <br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
119 Libervia is a web frontend for Salut &agrave; Toi<br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
120 <span style='font-style: italic;'>S&agrave;T version:</span> {sat_version}<br/>
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
121 <span style='font-style: italic;'>Libervia version:</span> {libervia_version}<br/>
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
122 <br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
123 You can contact the authors at <a href="mailto:contact@salut-a-toi.org">contact@salut-a-toi.org</a><br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
124 Blog available (mainly in french) at <a href="http://www.goffi.org" target="_blank">http://www.goffi.org</a><br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
125 Project page: <a href="http://salut-a-toi.org"target="_blank">http://salut-a-toi.org</a><br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
126 <br />
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
127 Any help welcome :)
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
128 <p style='font-size:small;text-align:center'>This project is dedicated to Roger Poisson</p>
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
129 """.format(sat_version=self.host.sat_version, libervia_version=self.host.libervia_version))
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
130 _dialog = dialog.GenericDialog("About", _about)
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
131 _dialog.show()
801eb94aa869 browser side: versions management + version is shown in about dialog
Goffi <goffi@goffi.org>
parents: 676
diff changeset
132 self.host.getVersions(gotVersions)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
133
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
134 #Settings menu
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
135
391
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
136 def onAccount(self):
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
137 def gotUI(xml_ui):
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
138 if not xml_ui:
391
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
139 return
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 498
diff changeset
140 body = xmlui.create(self.host, xml_ui)
464
bea9788f3170 browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback:
souliane <souliane@mailoo.org>
parents: 449
diff changeset
141 _dialog = dialog.GenericDialog("Manage your account", body, options=['NO_CLOSE'])
391
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
142 body.setCloseCb(_dialog.close)
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
143 _dialog.show()
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
144 self.host.bridge.call('getAccountDialogUI', gotUI)
c86d7a8d2c1e browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents: 387
diff changeset
145
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
146 def onParameters(self):
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
147 def gotParams(xml_ui):
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 464
diff changeset
148 if not xml_ui:
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
149 return
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 498
diff changeset
150 body = xmlui.create(self.host, xml_ui)
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
151 _dialog = dialog.GenericDialog("Parameters", body, options=['NO_CLOSE'])
805
f2a76ee020f6 browser_side: improve CSS alignements of the dialogs' widgets
souliane <souliane@mailoo.org>
parents: 788
diff changeset
152 _dialog.addStyleName("parameters")
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
153 body.setCloseCb(_dialog.close)
816
0fd4b81972c0 browser (params): reverted size change from commit f2a76ee020f6
Goffi <goffi@goffi.org>
parents: 805
diff changeset
154 _dialog.setSize('80%', '80%')
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
155 _dialog.show()
745
ad733b670cc3 server side: fixed params, and removed self.authorized_params as authorisation is handled by the backend
Goffi <goffi@goffi.org>
parents: 698
diff changeset
156 self.host.bridge.getParamsUI(profile=C.PROF_KEY_NONE, callback=gotParams)
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
157
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
158 def removeItemParams(self):
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
159 """Remove the Parameters item from the Settings menu bar."""
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
160 self.menu_settings.removeItem(self.item_params)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
161
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
162 def onAvatarUpload(self):
494
5d8632a7bfde browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents: 492
diff changeset
163 body = file_tools.AvatarUpload()
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
164 _dialog = dialog.GenericDialog("Avatar upload", body, options=['NO_CLOSE'])
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
165 body.setCloseCb(_dialog.close)
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 391
diff changeset
166 _dialog.setWidth('40%')
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
167 _dialog.show()
788
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
168
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
169 def onPublicBlog(self, contact_box, data, profile):
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
170 # FIXME: Q&D way to check domain, need to be done in a cleaner way
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
171 if contact_box.jid.domain != self.host._defaultDomain:
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
172 self.host.showDialog(u"Public blogs from other domains are not managed yet", "Can't show public blog", "error")
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
173 return
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
174
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
175 url = '{}/blog/{}'.format(self.host.base_location, contact_box.jid.node)
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
176 widget = self.host.displayWidget(web_widget.WebWidget, url, show_url=False)
7ebde6d1a4bd browser side: fixed public blog menu (moved temporarily to frontend side)
Goffi <goffi@goffi.org>
parents: 776
diff changeset
177 self.host.setSelected(widget)