Load users presence

This commit is contained in:
2021-04-21 16:48:50 +02:00
parent 8705fc6581
commit 5f5f27e79d
7 changed files with 76 additions and 0 deletions

View File

@ -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<Presence[]>}
*/
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)
});
}
}

View File

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

View File

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

View File

@ -28,6 +28,7 @@ const GroupTabs = {
activePage: activePage,
firstArgument: firstArgument,
conversations: group.conversations,
is_forez: group.is_forez_group
}
},