nodebb-plugin-equipment-calendar 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library.js
CHANGED
|
@@ -564,6 +564,8 @@ plugin.init = async function (params) {
|
|
|
564
564
|
if (mid && mid.admin) {
|
|
565
565
|
router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
|
|
566
566
|
router.get('/admin/plugins/equipment-calendar/reservations', middleware.applyCSRF, mid.admin.buildHeader, renderAdminReservationsPage);
|
|
567
|
+
router.get('/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, mid.admin.buildHeader, handleHelloAssoTest);
|
|
568
|
+
router.get('/api/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, handleHelloAssoTest);
|
|
567
569
|
router.get('/api/admin/plugins/equipment-calendar/reservations', middleware.applyCSRF, renderAdminReservationsPage);
|
|
568
570
|
router.get('/api/admin/plugins/equipment-calendar', middleware.applyCSRF, renderAdminPage);
|
|
569
571
|
router.post('/admin/plugins/equipment-calendar/save', middleware.applyCSRF, handleAdminSave);
|
|
@@ -652,6 +654,8 @@ plugin.addAdminRoutes = async function (params) {
|
|
|
652
654
|
const { router, middleware: mid } = params;
|
|
653
655
|
router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
|
|
654
656
|
router.get('/admin/plugins/equipment-calendar/reservations', middleware.applyCSRF, mid.admin.buildHeader, renderAdminReservationsPage);
|
|
657
|
+
router.get('/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, mid.admin.buildHeader, handleHelloAssoTest);
|
|
658
|
+
router.get('/api/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, handleHelloAssoTest);
|
|
655
659
|
router.get('/api/admin/plugins/equipment-calendar/reservations', middleware.applyCSRF, renderAdminReservationsPage);
|
|
656
660
|
router.get('/api/admin/plugins/equipment-calendar', middleware.applyCSRF, renderAdminPage);
|
|
657
661
|
};
|
|
@@ -781,6 +785,37 @@ async function handleAdminDelete(req, res) {
|
|
|
781
785
|
return res.redirect('/admin/plugins/equipment-calendar/reservations?updated=1');
|
|
782
786
|
}
|
|
783
787
|
|
|
788
|
+
|
|
789
|
+
async function handleHelloAssoTest(req, res) {
|
|
790
|
+
const isAdmin = req.uid ? await groups.isMember(req.uid, 'administrators') : false;
|
|
791
|
+
if (!isAdmin) return helpers.notAllowed(req, res);
|
|
792
|
+
|
|
793
|
+
const settings = await getSettings();
|
|
794
|
+
let ok = false;
|
|
795
|
+
let message = '';
|
|
796
|
+
let count = 0;
|
|
797
|
+
|
|
798
|
+
try {
|
|
799
|
+
await getHelloAssoAccessToken(settings);
|
|
800
|
+
const items = await fetchHelloAssoItems(settings);
|
|
801
|
+
const list = Array.isArray(items) ? items : (Array.isArray(items.data) ? items.data : []);
|
|
802
|
+
count = list.length;
|
|
803
|
+
ok = true;
|
|
804
|
+
message = `OK: token valide. Items récupérés: ${count}.`;
|
|
805
|
+
} catch (e) {
|
|
806
|
+
ok = false;
|
|
807
|
+
message = (e && e.message) ? e.message : String(e);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
res.render('admin/plugins/equipment-calendar-helloasso-test', {
|
|
811
|
+
title: 'Equipment Calendar - Test HelloAsso',
|
|
812
|
+
ok,
|
|
813
|
+
message,
|
|
814
|
+
count,
|
|
815
|
+
settings,
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
784
819
|
async function renderAdminPage(req, res) {
|
|
785
820
|
const settings = await getSettings();
|
|
786
821
|
res.render('admin/plugins/equipment-calendar', {
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div class="acp-page-container">
|
|
2
|
+
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2">
|
|
3
|
+
<h1 class="mb-0">Equipment Calendar</h1>
|
|
4
|
+
<div class="btn-group">
|
|
5
|
+
<a class="btn btn-outline-secondary" href="/admin/plugins/equipment-calendar">Paramètres</a>
|
|
6
|
+
<a class="btn btn-outline-secondary" href="/admin/plugins/equipment-calendar/reservations">Réservations</a>
|
|
7
|
+
<a class="btn btn-secondary active" href="/admin/plugins/equipment-calendar/helloasso-test">Test HelloAsso</a>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="card card-body mt-3">
|
|
12
|
+
{{{ if ok }}}
|
|
13
|
+
<div class="alert alert-success">{message}</div>
|
|
14
|
+
{{{ else }}}
|
|
15
|
+
<div class="alert alert-danger">Échec : {message}</div>
|
|
16
|
+
{{{ end }}}
|
|
17
|
+
|
|
18
|
+
<div class="small text-muted">
|
|
19
|
+
Form: <code>{settings.ha_itemsFormType}</code> / <code>{settings.ha_itemsFormSlug}</code> — Orga: <code>{settings.ha_organizationSlug}</code>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<div class="btn-group">
|
|
5
5
|
<a class="btn btn-secondary active" href="/admin/plugins/equipment-calendar">Paramètres</a>
|
|
6
6
|
<a class="btn btn-outline-secondary" href="/admin/plugins/equipment-calendar/reservations">Réservations</a>
|
|
7
|
+
<a class="btn btn-outline-secondary" href="/admin/plugins/equipment-calendar/helloasso-test">Test HelloAsso</a>
|
|
7
8
|
</div>
|
|
8
9
|
</div>
|
|
9
10
|
|