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 @@