From 5f5f27e79db7813ce189236372829409eb90bcaf Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 21 Apr 2021 16:48:50 +0200 Subject: [PATCH] Load users presence --- assets/css/pages/groups/pages/presence.css | 7 ++++ .../js/components/presence/PresenceHelper.js | 32 +++++++++++++++++++ assets/js/pages/groups/main.js | 6 ++++ assets/js/pages/groups/pages/presence.js | 22 +++++++++++++ assets/js/pages/groups/sections/tabs.js | 1 + .../pages/groups/sections/GroupTabs.html | 3 ++ system/config/dev.config.php | 5 +++ 7 files changed, 76 insertions(+) create mode 100644 assets/css/pages/groups/pages/presence.css create mode 100644 assets/js/components/presence/PresenceHelper.js create mode 100644 assets/js/pages/groups/pages/presence.js diff --git a/assets/css/pages/groups/pages/presence.css b/assets/css/pages/groups/pages/presence.css new file mode 100644 index 00000000..938bbe0d --- /dev/null +++ b/assets/css/pages/groups/pages/presence.css @@ -0,0 +1,7 @@ +/** + * Groups presence stylesheet + * + * This is a Forez feature + * + * @author Pierre Hubert + */ \ No newline at end of file diff --git a/assets/js/components/presence/PresenceHelper.js b/assets/js/components/presence/PresenceHelper.js new file mode 100644 index 00000000..f7b9e5df --- /dev/null +++ b/assets/js/components/presence/PresenceHelper.js @@ -0,0 +1,32 @@ +/** + * Forez Presence Helper + * + * @author Pierre Hubert + */ + +class Presence { + constructor(userID, year, month, day) { + this.userID = userID; + this.year = year; + this.month = month; + this.day = day; + } +} + + +class ForezPresenceHelper { + /** + * Load the list of presence + * + * @param {number} groupID Target group ID + * @returns {Promise} + */ + static async GetList(groupID) { + const list = await ws("forez_presence/list", {group: groupID}); + + return list.map(el => { + const infos = el.split(",").map(e => Number(e)); + return new Presence(...infos) + }); + } +} \ No newline at end of file diff --git a/assets/js/pages/groups/main.js b/assets/js/pages/groups/main.js index a3961073..015d7fc1 100644 --- a/assets/js/pages/groups/main.js +++ b/assets/js/pages/groups/main.js @@ -119,6 +119,12 @@ const GroupsPage = { GroupConversationPage.show(conv, target) return; } + + case "presence": + if (group.is_forez_group) { + await GroupPresencePage.Show(group, target) + return; + } default: ComunicWeb.common.error.pageNotFound(null, target); diff --git a/assets/js/pages/groups/pages/presence.js b/assets/js/pages/groups/pages/presence.js new file mode 100644 index 00000000..f6237a17 --- /dev/null +++ b/assets/js/pages/groups/pages/presence.js @@ -0,0 +1,22 @@ +/** + * Group presence tab + * + * This is a Forez feature + * + * @author Pierre Hubert + */ + +class GroupPresencePage { + /** + * Show the page + * + * @param {AdvancedGroupInfo} group + * @param {HTMLElement} target + */ + static async Show(group, target) { + const presence = await ForezPresenceHelper.GetList(group.id); + const users = await getUsers([...new Set(presence.map(e => e.userID))]); + + console.error(presence, users) + } +} \ No newline at end of file diff --git a/assets/js/pages/groups/sections/tabs.js b/assets/js/pages/groups/sections/tabs.js index dc3c427a..ad4a2297 100644 --- a/assets/js/pages/groups/sections/tabs.js +++ b/assets/js/pages/groups/sections/tabs.js @@ -28,6 +28,7 @@ const GroupTabs = { activePage: activePage, firstArgument: firstArgument, conversations: group.conversations, + is_forez: group.is_forez_group } }, diff --git a/assets/templates/pages/groups/sections/GroupTabs.html b/assets/templates/pages/groups/sections/GroupTabs.html index 871b6027..05cccb40 100644 --- a/assets/templates/pages/groups/sections/GroupTabs.html +++ b/assets/templates/pages/groups/sections/GroupTabs.html @@ -5,6 +5,9 @@