Load users presence

This commit is contained in:
Pierre HUBERT 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,7 @@
/**
* Groups presence stylesheet
*
* This is a Forez feature
*
* @author Pierre Hubert
*/

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

@ -120,6 +120,12 @@ const GroupsPage = {
return; return;
} }
case "presence":
if (group.is_forez_group) {
await GroupPresencePage.Show(group, target)
return;
}
default: default:
ComunicWeb.common.error.pageNotFound(null, target); 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, activePage: activePage,
firstArgument: firstArgument, firstArgument: firstArgument,
conversations: group.conversations, conversations: group.conversations,
is_forez: group.is_forez_group
} }
}, },

View File

@ -5,6 +5,9 @@
<ul class="nav nav-tabs group-page-tabs" style="display: flex; flex-wrap: wrap; justify-content: start;"> <ul class="nav nav-tabs group-page-tabs" style="display: flex; flex-wrap: wrap; justify-content: start;">
<li v-bind:class="activePage == 'posts' ? 'active': ''"><a @click="openPage('posts')">tr("Posts")</a></li> <li v-bind:class="activePage == 'posts' ? 'active': ''"><a @click="openPage('posts')">tr("Posts")</a></li>
<!-- Forez presence -->
<li v-bind:class="activePage == 'presence' ? 'active': ''"><a @click="openPage('presence')" v-if="is_forez">tr("Presence")</a></li>
<!-- Group conversations --> <!-- Group conversations -->
<li v-for="conv in conversations" v-bind:class="activePage == 'conversation' && firstArgument == conv.id ? 'active': ''"> <li v-for="conv in conversations" v-bind:class="activePage == 'conversation' && firstArgument == conv.id ? 'active': ''">
<a @click="openPage('conversation/' + conv.id)">{{conv.name}}</a></li> <a @click="openPage('conversation/' + conv.id)">{{conv.name}}</a></li>

View File

@ -272,6 +272,7 @@ class Dev {
"css/pages/groups/pages/members.css", "css/pages/groups/pages/members.css",
"css/pages/groups/pages/forbidden.css", "css/pages/groups/pages/forbidden.css",
"css/pages/groups/pages/about.css", "css/pages/groups/pages/about.css",
"css/pages/groups/pages/presence.css",
//Groups sections //Groups sections
"css/pages/groups/sections/header.css", "css/pages/groups/sections/header.css",
@ -495,6 +496,9 @@ class Dev {
// Small media player // Small media player
"js/components/smallMediaPlayer.js", "js/components/smallMediaPlayer.js",
// Presence helper
"js/components/presence/PresenceHelper.js",
//User scripts //User scripts
"js/user/loginTokens.js", "js/user/loginTokens.js",
"js/user/userLogin.js", "js/user/userLogin.js",
@ -539,6 +543,7 @@ class Dev {
"js/pages/groups/pages/members.js", "js/pages/groups/pages/members.js",
"js/pages/groups/pages/forbidden.js", "js/pages/groups/pages/forbidden.js",
"js/pages/groups/pages/about.js", "js/pages/groups/pages/about.js",
"js/pages/groups/pages/presence.js",
//Groups sections //Groups sections
"js/pages/groups/sections/header.js", "js/pages/groups/sections/header.js",