@edifice.io/client 2.0.1-develop-hotfix.1736778374387 → 2.0.1-develop-hotfix.1736784778762
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/dist/configure/Service.d.ts +0 -1
- package/dist/data/WebBroker.d.ts +1 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.js +1 -0
- package/dist/index.js +1818 -1945
- package/dist/index.umd.cjs +1 -0
- package/dist/services/OdeServices.d.ts +8 -17
- package/dist/transport/Service.d.ts +3 -1
- package/package.json +1 -1
- package/dist/data/Service.d.ts +0 -25
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var T = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var D = (n, e, t) => e in n ? T(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var a = (n, e, t) => D(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
import { MimeTypeUtils } from "@edifice.io/utilities";
|
|
6
6
|
const ReactionTypes = [
|
|
@@ -101,125 +101,6 @@ const ReactionTypes = [
|
|
|
101
101
|
RGPD_COOKIES: "rgpdCookies"
|
|
102
102
|
// TODO compléter
|
|
103
103
|
};
|
|
104
|
-
class Subscription {
|
|
105
|
-
constructor(e, t) {
|
|
106
|
-
u(this, "revoke");
|
|
107
|
-
this._channel = e, this.revoke = this.setReceiver(
|
|
108
|
-
(s) => t == null ? void 0 : t(s.data)
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
setReceiver(e) {
|
|
112
|
-
var t;
|
|
113
|
-
return (t = this._channel) == null || t.addEventListener("message", e), () => {
|
|
114
|
-
this._channel && (this._channel.removeEventListener("message", e), this._channel.close(), delete this._channel);
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
class Subject {
|
|
119
|
-
constructor() {
|
|
120
|
-
/* A single BroadcastChannel cannot send AND receive messages, afaik.
|
|
121
|
-
* => We maintain here channels for *sending* messages.
|
|
122
|
-
* *Receiving* channels will be instantiated while subscribing.
|
|
123
|
-
*/
|
|
124
|
-
u(this, "publishChannels", /* @__PURE__ */ new Map());
|
|
125
|
-
}
|
|
126
|
-
getChannelName(e) {
|
|
127
|
-
return "Subject:" + e;
|
|
128
|
-
}
|
|
129
|
-
getPublishChannel(e) {
|
|
130
|
-
const t = this.getChannelName(e);
|
|
131
|
-
let s = this.publishChannels.get(t);
|
|
132
|
-
return s || (s = this.newChannel(e), this.publishChannels.set(t, s)), s;
|
|
133
|
-
}
|
|
134
|
-
newChannel(e) {
|
|
135
|
-
const t = this.getChannelName(e), s = new BroadcastChannel(t);
|
|
136
|
-
return s.addEventListener("messageerror", (r) => console.log(r.data)), s;
|
|
137
|
-
}
|
|
138
|
-
publish(e, t) {
|
|
139
|
-
typeof e == "string" && this.getPublishChannel(e).postMessage(t);
|
|
140
|
-
}
|
|
141
|
-
subscribe(e, t) {
|
|
142
|
-
if (typeof e == "string") {
|
|
143
|
-
const s = this.newChannel(e);
|
|
144
|
-
return new Subscription(s, t);
|
|
145
|
-
} else
|
|
146
|
-
return new Subscription();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const ASYNC_DATA_NAME = {
|
|
150
|
-
SESSION_READY: "sessionReady",
|
|
151
|
-
LANG_READY: "langReady",
|
|
152
|
-
SKIN_READY: "skinReady",
|
|
153
|
-
OVERRIDE_READY: "overrideReady",
|
|
154
|
-
APPCONF_READY: "appConfReady"
|
|
155
|
-
};
|
|
156
|
-
class Promisified {
|
|
157
|
-
constructor() {
|
|
158
|
-
//-------------------------------------
|
|
159
|
-
u(this, "_resolution");
|
|
160
|
-
u(this, "_rejection");
|
|
161
|
-
u(this, "_promise", new Promise((e, t) => {
|
|
162
|
-
this._resolution = e, this._rejection = t;
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
get promise() {
|
|
166
|
-
return this._promise;
|
|
167
|
-
}
|
|
168
|
-
resolve(e) {
|
|
169
|
-
this._resolution && this._resolution(e);
|
|
170
|
-
}
|
|
171
|
-
reject(e) {
|
|
172
|
-
this._rejection && this._rejection(e);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
class NotifyFramework {
|
|
176
|
-
constructor() {
|
|
177
|
-
//-------------------------------------
|
|
178
|
-
u(this, "promises", {});
|
|
179
|
-
u(this, "subject", new Subject());
|
|
180
|
-
}
|
|
181
|
-
asyncData(e) {
|
|
182
|
-
return typeof this.promises[e] > "u" && (this.promises[e] = new Promisified()), this.promises[e];
|
|
183
|
-
}
|
|
184
|
-
onSessionReady() {
|
|
185
|
-
return this.asyncData(ASYNC_DATA_NAME.SESSION_READY);
|
|
186
|
-
}
|
|
187
|
-
onLangReady() {
|
|
188
|
-
return this.asyncData(ASYNC_DATA_NAME.LANG_READY);
|
|
189
|
-
}
|
|
190
|
-
onSkinReady() {
|
|
191
|
-
return this.asyncData(ASYNC_DATA_NAME.SKIN_READY);
|
|
192
|
-
}
|
|
193
|
-
onOverridesReady() {
|
|
194
|
-
return this.asyncData(ASYNC_DATA_NAME.OVERRIDE_READY);
|
|
195
|
-
}
|
|
196
|
-
onAppConfReady() {
|
|
197
|
-
return this.asyncData(ASYNC_DATA_NAME.APPCONF_READY);
|
|
198
|
-
}
|
|
199
|
-
promisify() {
|
|
200
|
-
return new Promisified();
|
|
201
|
-
}
|
|
202
|
-
events() {
|
|
203
|
-
return this.subject;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const notify = new NotifyFramework();
|
|
207
|
-
class NotifyFrameworkFactory {
|
|
208
|
-
static instance() {
|
|
209
|
-
return notify;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const LAYER_NAME = {
|
|
213
|
-
WIDGETS: "widgets",
|
|
214
|
-
EXPLORER: "explorer",
|
|
215
|
-
TRANSPORT: "transport",
|
|
216
|
-
WEB_DATA: "webDataPipeline"
|
|
217
|
-
}, EVENT_NAME = {
|
|
218
|
-
USERPREF_CHANGED: "userprefChanged",
|
|
219
|
-
SEARCH_RESULTED: "searchResulted",
|
|
220
|
-
ERROR_OCCURED: "error",
|
|
221
|
-
DATA_TRACKED: "track"
|
|
222
|
-
};
|
|
223
104
|
class ServiceRegistry extends Map {
|
|
224
105
|
/** Register a service */
|
|
225
106
|
register({
|
|
@@ -262,7 +143,7 @@ const f = class f {
|
|
|
262
143
|
//
|
|
263
144
|
// PROTECTED HELPERS
|
|
264
145
|
//
|
|
265
|
-
|
|
146
|
+
a(this, "checkHttpResponse", (e) => {
|
|
266
147
|
if (this.http.latestResponse.status >= 300)
|
|
267
148
|
throw this.http.latestResponse.statusText;
|
|
268
149
|
return e;
|
|
@@ -480,8 +361,8 @@ const f = class f {
|
|
|
480
361
|
//
|
|
481
362
|
// STATIC REGISTRY
|
|
482
363
|
//
|
|
483
|
-
|
|
484
|
-
|
|
364
|
+
a(f, "registry", new ServiceRegistry()), // Expose some useful functions
|
|
365
|
+
a(f, "register", f.registry.register.bind(f.registry)), a(f, "findService", f.registry.findService.bind(f.registry)), a(f, "findMainService", f.registry.findMainService.bind(f.registry)), a(f, "isRegistered", f.registry.isRegistered.bind(f.registry));
|
|
485
366
|
let ResourceService = f;
|
|
486
367
|
const APP$1 = "scrapbook", RESOURCE$1 = "scrapbook";
|
|
487
368
|
class ScrapbookResourceService extends ResourceService {
|
|
@@ -574,70 +455,279 @@ ResourceService.register(
|
|
|
574
455
|
{ application: RESOURCE, resourceType: RESOURCE },
|
|
575
456
|
(n) => new HomeworksResourceService(n)
|
|
576
457
|
);
|
|
577
|
-
|
|
578
|
-
class
|
|
579
|
-
constructor(
|
|
580
|
-
this.context =
|
|
458
|
+
let ATTag;
|
|
459
|
+
class AnalyticsService {
|
|
460
|
+
constructor(n) {
|
|
461
|
+
this.context = n;
|
|
462
|
+
}
|
|
463
|
+
get conf() {
|
|
464
|
+
return this.context.conf();
|
|
581
465
|
}
|
|
582
466
|
get http() {
|
|
583
467
|
return this.context.http();
|
|
584
468
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
return globalCache[e];
|
|
588
|
-
try {
|
|
589
|
-
const r = t();
|
|
590
|
-
mutexPromise[e] = r;
|
|
591
|
-
const i = await r;
|
|
592
|
-
return s(i) && (globalCache[e] = i), i;
|
|
593
|
-
} catch (r) {
|
|
594
|
-
throw console.error(`Failed to retrieve value for: ${e}`, r), r;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
clearCache(e) {
|
|
598
|
-
if (e)
|
|
599
|
-
delete globalCache[e];
|
|
600
|
-
else
|
|
601
|
-
for (const t in globalCache)
|
|
602
|
-
globalCache.hasOwnProperty(t) && delete globalCache[t];
|
|
469
|
+
get session() {
|
|
470
|
+
return this.context.session();
|
|
603
471
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Xiti tracker for page loading.
|
|
474
|
+
* @param locationPath
|
|
475
|
+
* @param app
|
|
476
|
+
*/
|
|
477
|
+
async trackPageLoad(n, e) {
|
|
478
|
+
const [t] = await Promise.all([
|
|
479
|
+
// get Xiti configuration
|
|
480
|
+
this.getXitiConfig(e.name.toLowerCase()),
|
|
481
|
+
// load Xiti javascript file
|
|
482
|
+
this.loadXitiScript()
|
|
483
|
+
]);
|
|
484
|
+
if (!t || !ATInternet) return;
|
|
485
|
+
let s = t.LIBELLE_SERVICE.default || null;
|
|
486
|
+
for (const r in t.LIBELLE_SERVICE)
|
|
487
|
+
if (r !== "default" && n.indexOf(r) >= 0) {
|
|
488
|
+
s = t.LIBELLE_SERVICE[r];
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
ATTag = new ATInternet.Tracker.Tag({ site: t.STRUCT_ID }), ATTag.setProps(
|
|
492
|
+
{
|
|
493
|
+
SERVICE: s,
|
|
494
|
+
TYPE: t.TYPE,
|
|
495
|
+
OUTIL: t.OUTIL,
|
|
496
|
+
UAI: t.STRUCT_UAI,
|
|
497
|
+
PROJET: t.PROJET,
|
|
498
|
+
EXPLOITANT: t.EXPLOITANT,
|
|
499
|
+
PLATEFORME: t.PLATFORME,
|
|
500
|
+
PROFIL: t.PROFILE
|
|
610
501
|
},
|
|
611
|
-
|
|
612
|
-
)
|
|
502
|
+
!0
|
|
503
|
+
), ATTag.identifiedVisitor.set({
|
|
504
|
+
id: t.ID_PERSO,
|
|
505
|
+
category: t.PROFILE
|
|
506
|
+
}), ATTag.page.set({
|
|
507
|
+
name: (e == null ? void 0 : e.prefix) === "userbook" ? "directory" : e == null ? void 0 : e.prefix,
|
|
508
|
+
chapter1: "",
|
|
509
|
+
chapter2: "",
|
|
510
|
+
chapter3: "",
|
|
511
|
+
level2: t.STRUCT_UAI
|
|
512
|
+
}), ATTag.dispatch();
|
|
613
513
|
}
|
|
614
|
-
async
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
514
|
+
async getXitiConfig(n) {
|
|
515
|
+
const [e, t] = await Promise.all([
|
|
516
|
+
this.http.get("/analyticsConf"),
|
|
517
|
+
//FIXME change servers config to only keep the "all-in-one" query to /analyticsConf.
|
|
518
|
+
this.http.get("/xiti/config")
|
|
519
|
+
]);
|
|
520
|
+
if (!(e != null && e.type))
|
|
521
|
+
throw ERROR_CODE.MALFORMED_DATA;
|
|
522
|
+
return t != null && t.active && (e.xiti = await this.getXitiTrackingParams(t, n)), e.xiti;
|
|
523
|
+
}
|
|
524
|
+
async loadXitiScript() {
|
|
525
|
+
if (typeof ATInternet > "u") {
|
|
526
|
+
const scriptPath = "/xiti/public/js/lib/smarttag_ENT.js", response = await this.http.get(scriptPath, {
|
|
527
|
+
headers: { Accept: "application/javascript" }
|
|
528
|
+
});
|
|
529
|
+
if (this.http.latestResponse.status != 200)
|
|
530
|
+
throw "Error while loading XiTi script";
|
|
531
|
+
eval(response);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async getXitiTrackingParams(n, e) {
|
|
535
|
+
if (!n.structureMap || !e) return;
|
|
536
|
+
const t = await this.session.getUser(), s = await this.session.getUserProfile();
|
|
537
|
+
let r;
|
|
538
|
+
if (!(t != null && t.structures)) return;
|
|
539
|
+
for (const h of t.structures) {
|
|
540
|
+
const l = n.structureMap[h];
|
|
541
|
+
if (l && l.collectiviteId && l.UAI) {
|
|
542
|
+
r = l;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
if (!r || !r.active) return;
|
|
547
|
+
const i = await this.conf.getPublicConf(e);
|
|
548
|
+
if (!i) return;
|
|
549
|
+
const o = i.xiti;
|
|
550
|
+
if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
|
|
551
|
+
function u(h) {
|
|
552
|
+
let l = "";
|
|
553
|
+
for (let g = 0; g < h.length; g++)
|
|
554
|
+
l += h.charCodeAt(g);
|
|
555
|
+
return l;
|
|
556
|
+
}
|
|
557
|
+
const c = {
|
|
558
|
+
Student: "ELEVE",
|
|
559
|
+
Teacher: "ENSEIGNANT",
|
|
560
|
+
Relative: "PARENT",
|
|
561
|
+
Personnel: "ADMIN_VIE_SCOL_TECH",
|
|
562
|
+
Guest: "AUTRE"
|
|
563
|
+
};
|
|
564
|
+
return {
|
|
565
|
+
LIBELLE_SERVICE: o.LIBELLE_SERVICE,
|
|
566
|
+
// Which property of LIBELLE_SERVICE to use depends on the frontend.
|
|
567
|
+
TYPE: o.OUTIL ? "TIERS" : "NATIF",
|
|
568
|
+
OUTIL: o.OUTIL ? o.OUTIL : "",
|
|
569
|
+
STRUCT_ID: r.collectiviteId,
|
|
570
|
+
STRUCT_UAI: r.UAI,
|
|
571
|
+
PROJET: r.projetId ? r.projetId : n.ID_PROJET,
|
|
572
|
+
EXPLOITANT: n.ID_EXPLOITANT,
|
|
573
|
+
PLATFORME: r.plateformeId ? r.plateformeId : n.ID_PLATEFORME,
|
|
574
|
+
ID_PERSO: u(t.userId),
|
|
575
|
+
PROFILE: s && s.length > 0 ? c[s[0]] ?? "" : ""
|
|
576
|
+
};
|
|
619
577
|
}
|
|
620
578
|
}
|
|
621
|
-
class
|
|
622
|
-
constructor(e) {
|
|
623
|
-
|
|
624
|
-
deploymentTag: "",
|
|
625
|
-
cdnDomain: ""
|
|
626
|
-
});
|
|
627
|
-
this.context = e;
|
|
579
|
+
class ReactionsService {
|
|
580
|
+
constructor(e, t, s) {
|
|
581
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
628
582
|
}
|
|
629
583
|
get http() {
|
|
630
584
|
return this.context.http();
|
|
631
585
|
}
|
|
632
|
-
|
|
633
|
-
|
|
586
|
+
async loadAvailableReactions() {
|
|
587
|
+
try {
|
|
588
|
+
const { "reaction-types": e } = await this.context.conf().getPublicConf("audience");
|
|
589
|
+
return Array.isArray(e) ? e : void 0;
|
|
590
|
+
} catch {
|
|
591
|
+
console.error("Audience configuration not found");
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
async loadReactionSummaries(e) {
|
|
596
|
+
const t = await this.http.get(
|
|
597
|
+
`/audience/reactions/${this.module}/${this.resourceType}?resourceIds=${e.join(",")}`
|
|
598
|
+
);
|
|
599
|
+
return this.http.isResponseError() ? {} : t.reactionsByResource;
|
|
600
|
+
}
|
|
601
|
+
async loadReactionDetails(e, t, s) {
|
|
602
|
+
const r = await this.http.get(
|
|
603
|
+
`/audience/reactions/${this.module}/${this.resourceType}/${e}?page=${t}&size=${s}`
|
|
604
|
+
);
|
|
605
|
+
return this.http.isResponseError() ? void 0 : r;
|
|
606
|
+
}
|
|
607
|
+
async deleteReaction(e) {
|
|
608
|
+
await this.http.delete(
|
|
609
|
+
`/audience/reactions/${this.module}/${this.resourceType}/${e}`
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
async updateReaction(e, t) {
|
|
613
|
+
await this.http.putJson(
|
|
614
|
+
`/audience/reactions/${this.module}/${this.resourceType}`,
|
|
615
|
+
{
|
|
616
|
+
resourceId: e,
|
|
617
|
+
reactionType: t
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
async createReaction(e, t) {
|
|
622
|
+
await this.http.postJson(
|
|
623
|
+
`/audience/reactions/${this.module}/${this.resourceType}`,
|
|
624
|
+
{
|
|
625
|
+
resourceId: e,
|
|
626
|
+
reactionType: t
|
|
627
|
+
}
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
class ViewsService {
|
|
632
|
+
constructor(e, t, s) {
|
|
633
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
634
|
+
}
|
|
635
|
+
get http() {
|
|
636
|
+
return this.context.http();
|
|
637
|
+
}
|
|
638
|
+
async getCounters(e) {
|
|
639
|
+
const t = await this.http.get(
|
|
640
|
+
`/audience/views/count/${this.module}/${this.resourceType}?resourceIds=${e.join(",")}`
|
|
641
|
+
);
|
|
642
|
+
return this.http.isResponseError() ? {} : t;
|
|
643
|
+
}
|
|
644
|
+
async getDetails(e) {
|
|
645
|
+
const t = await this.http.get(
|
|
646
|
+
`/audience/views/details/${this.module}/${this.resourceType}/${e}`
|
|
647
|
+
);
|
|
648
|
+
return this.http.isResponseError() ? void 0 : t;
|
|
649
|
+
}
|
|
650
|
+
trigger(e) {
|
|
651
|
+
return this.http.post(
|
|
652
|
+
`/audience/views/${this.module}/${this.resourceType}/${e}`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
class AudienceService {
|
|
657
|
+
constructor(e, t, s) {
|
|
658
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
659
|
+
}
|
|
660
|
+
get views() {
|
|
661
|
+
return new ViewsService(this.context, this.module, this.resourceType);
|
|
662
|
+
}
|
|
663
|
+
get reactions() {
|
|
664
|
+
return new ReactionsService(this.context, this.module, this.resourceType);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
const globalCache = {}, mutexPromise = {};
|
|
668
|
+
class CacheService {
|
|
669
|
+
constructor(e) {
|
|
670
|
+
this.context = e;
|
|
671
|
+
}
|
|
672
|
+
get http() {
|
|
673
|
+
return this.context.http();
|
|
674
|
+
}
|
|
675
|
+
async fromCacheIfPossible(e, t, s) {
|
|
676
|
+
if (mutexPromise[e] && await mutexPromise[e], globalCache[e])
|
|
677
|
+
return globalCache[e];
|
|
678
|
+
try {
|
|
679
|
+
const r = t();
|
|
680
|
+
mutexPromise[e] = r;
|
|
681
|
+
const i = await r;
|
|
682
|
+
return s(i) && (globalCache[e] = i), i;
|
|
683
|
+
} catch (r) {
|
|
684
|
+
throw console.error(`Failed to retrieve value for: ${e}`, r), r;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
clearCache(e) {
|
|
688
|
+
if (e)
|
|
689
|
+
delete globalCache[e];
|
|
690
|
+
else
|
|
691
|
+
for (const t in globalCache)
|
|
692
|
+
globalCache.hasOwnProperty(t) && delete globalCache[t];
|
|
693
|
+
}
|
|
694
|
+
async httpGet(e, t) {
|
|
695
|
+
return this.fromCacheIfPossible(
|
|
696
|
+
e,
|
|
697
|
+
async () => {
|
|
698
|
+
const s = await this.http.get(e, t), r = { ...this.http.latestResponse };
|
|
699
|
+
return { value: s, response: r };
|
|
700
|
+
},
|
|
701
|
+
({ response: s }) => !(s.status < 200 || s.status >= 300)
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
async httpGetJson(e, t) {
|
|
705
|
+
const { response: s, value: r } = await this.httpGet(e, t);
|
|
706
|
+
if (s.status < 200 || s.status >= 300)
|
|
707
|
+
throw `Bad http status (${s.status}) for url: ${e}`;
|
|
708
|
+
return r;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
class ConfService {
|
|
712
|
+
constructor(e) {
|
|
713
|
+
a(this, "Platform", {
|
|
714
|
+
deploymentTag: "",
|
|
715
|
+
cdnDomain: ""
|
|
716
|
+
});
|
|
717
|
+
this.context = e;
|
|
718
|
+
}
|
|
719
|
+
get http() {
|
|
720
|
+
return this.context.http();
|
|
721
|
+
}
|
|
722
|
+
get cache() {
|
|
723
|
+
return this.context.cache();
|
|
634
724
|
}
|
|
635
725
|
get cdnDomain() {
|
|
636
726
|
return this.Platform.cdnDomain;
|
|
637
727
|
}
|
|
638
|
-
get notify() {
|
|
728
|
+
/* private get notify() {
|
|
639
729
|
return this.context.notify();
|
|
640
|
-
}
|
|
730
|
+
} */
|
|
641
731
|
async getConf(e) {
|
|
642
732
|
const [t, s] = await Promise.all([
|
|
643
733
|
this.getThemeConf(),
|
|
@@ -645,14 +735,14 @@ class ConfService {
|
|
|
645
735
|
]), [r, i] = await Promise.all([
|
|
646
736
|
this.getTheme({ conf: t, publicTheme: s === void 0 }),
|
|
647
737
|
this.getWebAppConf({ app: e, applications: s ?? [] })
|
|
648
|
-
])
|
|
738
|
+
]);
|
|
739
|
+
return {
|
|
649
740
|
app: e,
|
|
650
741
|
applications: s ?? [],
|
|
651
742
|
conf: t,
|
|
652
743
|
currentApp: i,
|
|
653
744
|
theme: r
|
|
654
745
|
};
|
|
655
|
-
return this.notify.onAppConfReady().resolve(o), o;
|
|
656
746
|
}
|
|
657
747
|
async getPublicConf(e) {
|
|
658
748
|
const { response: t, value: s } = await this.cache.httpGet(
|
|
@@ -707,19 +797,19 @@ class ConfService {
|
|
|
707
797
|
const { value: r } = await this.cache.httpGet("/theme", {
|
|
708
798
|
queryParams: { _: e }
|
|
709
799
|
}), i = s ? null : r, o = t == null ? void 0 : t.overriding.find(
|
|
710
|
-
(
|
|
800
|
+
(d) => (
|
|
711
801
|
// Public access => simply use the 1st override
|
|
712
|
-
i === null ||
|
|
802
|
+
i === null || d.child === i.themeName
|
|
713
803
|
)
|
|
714
|
-
),
|
|
804
|
+
), u = (i == null ? void 0 : i.skinName) || o.skins[0], c = (i == null ? void 0 : i.skin) || `/assets/themes/${o.child}/skins/${u}/`, h = o.skins, l = o.bootstrapVersion.split("-").slice(-1)[0], g = o.parent === "panda";
|
|
715
805
|
return {
|
|
716
806
|
basePath: `${this.cdnDomain}${c}../../`,
|
|
717
|
-
bootstrapVersion:
|
|
718
|
-
is1d:
|
|
807
|
+
bootstrapVersion: l,
|
|
808
|
+
is1d: g,
|
|
719
809
|
logoutCallback: (i == null ? void 0 : i.logoutCallback) || "/",
|
|
720
810
|
skin: o.child,
|
|
721
|
-
skinName:
|
|
722
|
-
skins:
|
|
811
|
+
skinName: u,
|
|
812
|
+
skins: h,
|
|
723
813
|
themeName: o.child,
|
|
724
814
|
themeUrl: c,
|
|
725
815
|
npmTheme: o.npmTheme ?? void 0
|
|
@@ -767,18 +857,18 @@ class DirectoryService {
|
|
|
767
857
|
return {
|
|
768
858
|
id: s,
|
|
769
859
|
displayName: r,
|
|
770
|
-
groups: t.map(({ name: o, id:
|
|
860
|
+
groups: t.map(({ name: o, id: u }) => ({
|
|
771
861
|
displayName: o,
|
|
772
|
-
id:
|
|
862
|
+
id: u
|
|
773
863
|
})),
|
|
774
|
-
users: i.map(({ displayName: o, id:
|
|
864
|
+
users: i.map(({ displayName: o, id: u, profile: c }) => ({
|
|
775
865
|
profile: c,
|
|
776
866
|
displayName: o,
|
|
777
867
|
// these info are missing from api
|
|
778
868
|
firstName: "",
|
|
779
869
|
lastName: "",
|
|
780
870
|
login: "",
|
|
781
|
-
id:
|
|
871
|
+
id: u
|
|
782
872
|
}))
|
|
783
873
|
};
|
|
784
874
|
}
|
|
@@ -788,564 +878,219 @@ class DirectoryService {
|
|
|
788
878
|
users: r
|
|
789
879
|
}) {
|
|
790
880
|
this.cache.clearCache("/directory/sharebookmark/all");
|
|
791
|
-
const i = r.map((
|
|
792
|
-
if (typeof
|
|
793
|
-
const { displayName:
|
|
881
|
+
const i = r.map((d) => typeof d == "string" ? d : d.id), o = s.map((d) => typeof d == "string" ? d : d.id), u = t.map(async (d) => {
|
|
882
|
+
if (typeof d == "string") {
|
|
883
|
+
const { displayName: p, groups: E, id: A, users: m } = await this.getBookMarkById(d), w = m.map((v) => v.id), C = E.map((v) => v.id);
|
|
794
884
|
return {
|
|
795
|
-
displayName:
|
|
885
|
+
displayName: p,
|
|
796
886
|
id: A,
|
|
797
|
-
members: [...
|
|
887
|
+
members: [...C, ...w]
|
|
798
888
|
};
|
|
799
889
|
} else
|
|
800
|
-
return Promise.resolve(
|
|
801
|
-
}),
|
|
890
|
+
return Promise.resolve(d);
|
|
891
|
+
}), h = (await Promise.all(u)).map((d) => d.members).reduce((d, p) => [...d, ...p], []), l = {
|
|
802
892
|
name: e,
|
|
803
|
-
members: [...i, ...o, ...
|
|
804
|
-
}, { id:
|
|
893
|
+
members: [...i, ...o, ...h]
|
|
894
|
+
}, { id: g } = await this.http.postJson(
|
|
805
895
|
"/directory/sharebookmark",
|
|
806
|
-
|
|
896
|
+
l
|
|
807
897
|
);
|
|
808
898
|
return {
|
|
809
|
-
id:
|
|
899
|
+
id: g,
|
|
810
900
|
displayName: e,
|
|
811
|
-
members:
|
|
901
|
+
members: l.members
|
|
812
902
|
};
|
|
813
903
|
}
|
|
814
904
|
}
|
|
815
|
-
|
|
816
|
-
class HttpService {
|
|
905
|
+
class EmbedderService {
|
|
817
906
|
constructor(e) {
|
|
818
|
-
|
|
819
|
-
u(this, "axios");
|
|
820
|
-
u(this, "baseUrl");
|
|
821
|
-
u(this, "headers", {});
|
|
822
|
-
u(this, "_latestResponse");
|
|
823
|
-
this.context = e, this.axios = axios;
|
|
907
|
+
this.context = e;
|
|
824
908
|
}
|
|
825
|
-
|
|
826
|
-
return
|
|
909
|
+
get http() {
|
|
910
|
+
return this.context.http();
|
|
827
911
|
}
|
|
828
|
-
|
|
829
|
-
|
|
912
|
+
/**
|
|
913
|
+
* Returns the default list of video embedder
|
|
914
|
+
* @returns the default list of video embedder
|
|
915
|
+
*/
|
|
916
|
+
async getDefault() {
|
|
917
|
+
return this.http.get("/infra/embed/default");
|
|
830
918
|
}
|
|
831
|
-
|
|
832
|
-
|
|
919
|
+
/**
|
|
920
|
+
* Returns the custom list of video embedder
|
|
921
|
+
* @returns the custom list of video embedder
|
|
922
|
+
*/
|
|
923
|
+
async getCustom() {
|
|
924
|
+
return this.http.get("/infra/embed/custom");
|
|
833
925
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
926
|
+
/**
|
|
927
|
+
* The provider matching with the URL
|
|
928
|
+
* @param {Embedder[]} embedderList - The list of video providers to test with
|
|
929
|
+
* @param {String} url - The URL for the video
|
|
930
|
+
* @returns The provider matching with the URL or undefined
|
|
931
|
+
*/
|
|
932
|
+
getProviderFromUrl(e, t) {
|
|
933
|
+
for (const s of e)
|
|
934
|
+
if (this.isUrlFromProvider(t, s))
|
|
935
|
+
return s;
|
|
839
936
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
937
|
+
urlIsFromPattern(e, t) {
|
|
938
|
+
const s = new RegExp("[^{}]+(?=(?:[^{}]*{[^}]*})*[^}]*$)", "g"), r = new RegExp("{[^}]*}", "g");
|
|
939
|
+
let i = !0;
|
|
940
|
+
const o = t.match(s) || [], u = [];
|
|
941
|
+
return (t.match(r) || []).forEach((h, l) => {
|
|
942
|
+
h.includes("ignore") || u.push(o[l]);
|
|
943
|
+
}), u.forEach((h) => {
|
|
944
|
+
if (!e.includes(h)) {
|
|
945
|
+
i = !1;
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
}), i;
|
|
849
949
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
950
|
+
/**
|
|
951
|
+
* Check if a given URL correspond to one of the URL pattern of the provider
|
|
952
|
+
* @param {String} url - The URL for the video
|
|
953
|
+
* @param {Embedder} embedder - The video provider to test with
|
|
954
|
+
* @returns boolean depending if a given URL correspond to one of the URL pattern of the provider
|
|
955
|
+
*/
|
|
956
|
+
isUrlFromProvider(e, t) {
|
|
957
|
+
typeof t.url == "string" && (t.url = [t.url]);
|
|
958
|
+
for (const s of t.url)
|
|
959
|
+
if (this.urlIsFromPattern(e, s))
|
|
960
|
+
return !0;
|
|
961
|
+
return !1;
|
|
858
962
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
963
|
+
/**
|
|
964
|
+
* Get embed code to display the video for an URL and a provider
|
|
965
|
+
* @param {Embedder} embedder - The video provider for the URL
|
|
966
|
+
* @param {String} url - The URL for the video
|
|
967
|
+
* @returns embed code to display the video for an URL and a provider
|
|
968
|
+
*/
|
|
969
|
+
getEmbedCodeForProvider(e, t) {
|
|
970
|
+
for (const s of e.url)
|
|
971
|
+
if (this.urlIsFromPattern(t, s)) {
|
|
972
|
+
const r = new RegExp("{[a-zA-Z0-9_.]+}", "g"), i = s.match(r) || [];
|
|
973
|
+
let o = e.embed;
|
|
974
|
+
for (const u of i) {
|
|
975
|
+
let c = s.split(u)[0];
|
|
976
|
+
const h = c.split("}");
|
|
977
|
+
h.length > 1 && (c = h[h.length - 1]);
|
|
978
|
+
let l = t.split(c)[1];
|
|
979
|
+
if (!l)
|
|
980
|
+
continue;
|
|
981
|
+
const g = s.split(u)[1].split("{")[0];
|
|
982
|
+
g && (l = l.split(g)[0]);
|
|
983
|
+
const d = new RegExp("\\" + u.replace(/}/, "\\}"), "g");
|
|
984
|
+
o = o.replace(d, l);
|
|
985
|
+
}
|
|
986
|
+
return o;
|
|
874
987
|
}
|
|
875
|
-
|
|
988
|
+
return "";
|
|
876
989
|
}
|
|
877
|
-
|
|
878
|
-
|
|
990
|
+
}
|
|
991
|
+
class Subscription {
|
|
992
|
+
constructor(e, t) {
|
|
993
|
+
a(this, "revoke");
|
|
994
|
+
this._channel = e, this.revoke = this.setReceiver(
|
|
995
|
+
(s) => t == null ? void 0 : t(s.data)
|
|
996
|
+
);
|
|
879
997
|
}
|
|
880
|
-
|
|
881
|
-
|
|
998
|
+
setReceiver(e) {
|
|
999
|
+
var t;
|
|
1000
|
+
return (t = this._channel) == null || t.addEventListener("message", e), () => {
|
|
1001
|
+
this._channel && (this._channel.removeEventListener("message", e), this._channel.close(), delete this._channel);
|
|
1002
|
+
};
|
|
882
1003
|
}
|
|
883
|
-
|
|
884
|
-
|
|
1004
|
+
}
|
|
1005
|
+
class Subject {
|
|
1006
|
+
constructor() {
|
|
1007
|
+
/* A single BroadcastChannel cannot send AND receive messages, afaik.
|
|
1008
|
+
* => We maintain here channels for *sending* messages.
|
|
1009
|
+
* *Receiving* channels will be instantiated while subscribing.
|
|
1010
|
+
*/
|
|
1011
|
+
a(this, "publishChannels", /* @__PURE__ */ new Map());
|
|
885
1012
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
const s = await this.axios.get(
|
|
889
|
-
this.toCdnUrl(e),
|
|
890
|
-
this.toAxiosConfig(t)
|
|
891
|
-
);
|
|
892
|
-
return this.mapAxiosResponse(s, t);
|
|
893
|
-
} catch (s) {
|
|
894
|
-
throw this.mapAxiosError(s, t);
|
|
895
|
-
}
|
|
1013
|
+
getChannelName(e) {
|
|
1014
|
+
return "Subject:" + e;
|
|
896
1015
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
t,
|
|
902
|
-
this.toAxiosConfig(s)
|
|
903
|
-
);
|
|
904
|
-
return this.mapAxiosResponse(r, s);
|
|
905
|
-
} catch (r) {
|
|
906
|
-
throw this.mapAxiosError(r, s);
|
|
907
|
-
}
|
|
1016
|
+
getPublishChannel(e) {
|
|
1017
|
+
const t = this.getChannelName(e);
|
|
1018
|
+
let s = this.publishChannels.get(t);
|
|
1019
|
+
return s || (s = this.newChannel(e), this.publishChannels.set(t, s)), s;
|
|
908
1020
|
}
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
try {
|
|
913
|
-
const i = await this.axios.post(this.fixBaseUrl(e), t, {
|
|
914
|
-
...r,
|
|
915
|
-
headers: {
|
|
916
|
-
"Content-Type": "multipart/form-data"
|
|
917
|
-
}
|
|
918
|
-
});
|
|
919
|
-
return this.mapAxiosResponse(i, s);
|
|
920
|
-
} catch (i) {
|
|
921
|
-
throw this.mapAxiosError(i, s);
|
|
922
|
-
}
|
|
1021
|
+
newChannel(e) {
|
|
1022
|
+
const t = this.getChannelName(e), s = new BroadcastChannel(t);
|
|
1023
|
+
return s.addEventListener("messageerror", (r) => console.log(r.data)), s;
|
|
923
1024
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
927
|
-
try {
|
|
928
|
-
const i = await this.axios.post(
|
|
929
|
-
this.fixBaseUrl(e),
|
|
930
|
-
t,
|
|
931
|
-
this.toAxiosConfig(s)
|
|
932
|
-
);
|
|
933
|
-
return this.mapAxiosResponse(i, s);
|
|
934
|
-
} catch (i) {
|
|
935
|
-
throw this.mapAxiosError(i, s);
|
|
936
|
-
}
|
|
1025
|
+
publish(e, t) {
|
|
1026
|
+
typeof e == "string" && this.getPublishChannel(e).postMessage(t);
|
|
937
1027
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
);
|
|
945
|
-
return this.mapAxiosResponse(r, s);
|
|
946
|
-
} catch (r) {
|
|
947
|
-
throw this.mapAxiosError(r, s);
|
|
948
|
-
}
|
|
1028
|
+
subscribe(e, t) {
|
|
1029
|
+
if (typeof e == "string") {
|
|
1030
|
+
const s = this.newChannel(e);
|
|
1031
|
+
return new Subscription(s, t);
|
|
1032
|
+
} else
|
|
1033
|
+
return new Subscription();
|
|
949
1034
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1035
|
+
}
|
|
1036
|
+
const ASYNC_DATA_NAME = {
|
|
1037
|
+
SESSION_READY: "sessionReady",
|
|
1038
|
+
LANG_READY: "langReady",
|
|
1039
|
+
SKIN_READY: "skinReady",
|
|
1040
|
+
OVERRIDE_READY: "overrideReady",
|
|
1041
|
+
APPCONF_READY: "appConfReady"
|
|
1042
|
+
};
|
|
1043
|
+
class Promisified {
|
|
1044
|
+
constructor() {
|
|
1045
|
+
//-------------------------------------
|
|
1046
|
+
a(this, "_resolution");
|
|
1047
|
+
a(this, "_rejection");
|
|
1048
|
+
a(this, "_promise", new Promise((e, t) => {
|
|
1049
|
+
this._resolution = e, this._rejection = t;
|
|
1050
|
+
}));
|
|
964
1051
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
968
|
-
try {
|
|
969
|
-
const i = await this.axios.put(this.fixBaseUrl(e), t, r);
|
|
970
|
-
return this.mapAxiosResponse(i, s);
|
|
971
|
-
} catch (i) {
|
|
972
|
-
throw this.mapAxiosError(i, s);
|
|
973
|
-
}
|
|
1052
|
+
get promise() {
|
|
1053
|
+
return this._promise;
|
|
974
1054
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const s = await this.axios.delete(
|
|
978
|
-
this.fixBaseUrl(e),
|
|
979
|
-
this.toAxiosConfig(t)
|
|
980
|
-
);
|
|
981
|
-
return this.mapAxiosResponse(s, t);
|
|
982
|
-
} catch (s) {
|
|
983
|
-
throw this.mapAxiosError(s, t);
|
|
984
|
-
}
|
|
1055
|
+
resolve(e) {
|
|
1056
|
+
this._resolution && this._resolution(e);
|
|
985
1057
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const s = await this.axios.delete(this.fixBaseUrl(e), {
|
|
989
|
-
data: t
|
|
990
|
-
});
|
|
991
|
-
return this.mapAxiosResponse(s);
|
|
992
|
-
} catch (s) {
|
|
993
|
-
throw this.mapAxiosError(s);
|
|
994
|
-
}
|
|
1058
|
+
reject(e) {
|
|
1059
|
+
this._rejection && this._rejection(e);
|
|
995
1060
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
} catch {
|
|
1003
|
-
return o;
|
|
1004
|
-
}
|
|
1005
|
-
}).catch((o) => {
|
|
1006
|
-
throw this.mapAxiosError(o, t), o;
|
|
1007
|
-
});
|
|
1061
|
+
}
|
|
1062
|
+
class NotifyFramework {
|
|
1063
|
+
constructor() {
|
|
1064
|
+
//-------------------------------------
|
|
1065
|
+
a(this, "promises", {});
|
|
1066
|
+
a(this, "subject", new Subject());
|
|
1008
1067
|
}
|
|
1009
|
-
|
|
1010
|
-
return
|
|
1011
|
-
loadedScripts[e] = !0;
|
|
1012
|
-
});
|
|
1068
|
+
asyncData(e) {
|
|
1069
|
+
return typeof this.promises[e] > "u" && (this.promises[e] = new Promisified()), this.promises[e];
|
|
1013
1070
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
constructor(e) {
|
|
1017
|
-
this.context = e;
|
|
1071
|
+
onSessionReady() {
|
|
1072
|
+
return this.asyncData(ASYNC_DATA_NAME.SESSION_READY);
|
|
1018
1073
|
}
|
|
1019
|
-
|
|
1020
|
-
return this.
|
|
1074
|
+
onLangReady() {
|
|
1075
|
+
return this.asyncData(ASYNC_DATA_NAME.LANG_READY);
|
|
1021
1076
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
* $TYPE = user | group | creator
|
|
1025
|
-
* $ID: id of the resource
|
|
1026
|
-
* $RIGHT: read | contrib | manage
|
|
1027
|
-
*
|
|
1028
|
-
* @param right a concat right
|
|
1029
|
-
* @returns Right parsed
|
|
1030
|
-
*/
|
|
1031
|
-
parseResourceRight(e) {
|
|
1032
|
-
const t = e.split(":");
|
|
1033
|
-
if (t.length === 2) {
|
|
1034
|
-
if (t[0] === "creator")
|
|
1035
|
-
return {
|
|
1036
|
-
id: t[1],
|
|
1037
|
-
right: "creator",
|
|
1038
|
-
type: "creator"
|
|
1039
|
-
};
|
|
1040
|
-
} else return t.length === 3 ? {
|
|
1041
|
-
id: t[1],
|
|
1042
|
-
right: t[2],
|
|
1043
|
-
type: t[0]
|
|
1044
|
-
} : void 0;
|
|
1077
|
+
onSkinReady() {
|
|
1078
|
+
return this.asyncData(ASYNC_DATA_NAME.SKIN_READY);
|
|
1045
1079
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
* $TYPE = user | group | creator
|
|
1049
|
-
* $ID: id of the resource
|
|
1050
|
-
* $RIGHT: read | contrib | manage
|
|
1051
|
-
*
|
|
1052
|
-
* @param rights a list of concat rights
|
|
1053
|
-
* @returns Array of Right parsed
|
|
1054
|
-
*/
|
|
1055
|
-
parseResourceRights(e) {
|
|
1056
|
-
return e.map((s) => this.parseResourceRight(s)).filter((s) => s !== void 0);
|
|
1080
|
+
onOverridesReady() {
|
|
1081
|
+
return this.asyncData(ASYNC_DATA_NAME.OVERRIDE_READY);
|
|
1057
1082
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
* @param user the userId and groupId concerned by the check
|
|
1061
|
-
* @param expect the expected right to check
|
|
1062
|
-
* @param rights array of Right for the resource
|
|
1063
|
-
* @returns true if has rights
|
|
1064
|
-
*/
|
|
1065
|
-
hasResourceRight({ id: e, groupIds: t }, s, r) {
|
|
1066
|
-
const i = r.map((o) => typeof o == "string" ? this.parseResourceRight(o) : o).filter((o) => o !== void 0);
|
|
1067
|
-
for (const o of i) {
|
|
1068
|
-
if (o.id === e && o.type === "creator")
|
|
1069
|
-
return !0;
|
|
1070
|
-
if (o.id === e && o.type === "user" && o.right === s)
|
|
1071
|
-
return !0;
|
|
1072
|
-
if (t.includes(o.id) && o.type === "group" && o.right === s)
|
|
1073
|
-
return !0;
|
|
1074
|
-
}
|
|
1075
|
-
return !1;
|
|
1083
|
+
onAppConfReady() {
|
|
1084
|
+
return this.asyncData(ASYNC_DATA_NAME.APPCONF_READY);
|
|
1076
1085
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
* @param expect the expected right to check
|
|
1080
|
-
* @param rights array of Right for the resource
|
|
1081
|
-
* @returns true if has rights
|
|
1082
|
-
*/
|
|
1083
|
-
async sessionHasResourceRight(e, t) {
|
|
1084
|
-
try {
|
|
1085
|
-
const s = await this.session.getUser();
|
|
1086
|
-
return !!s && this.hasResourceRight(
|
|
1087
|
-
{ groupIds: s.groupsIds, id: s.userId },
|
|
1088
|
-
e,
|
|
1089
|
-
t
|
|
1090
|
-
);
|
|
1091
|
-
} catch (s) {
|
|
1092
|
-
return console.error(`Unexpected error ${s} in sessionHasResourceRight()`), !1;
|
|
1093
|
-
}
|
|
1086
|
+
promisify() {
|
|
1087
|
+
return new Promisified();
|
|
1094
1088
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
* @param expects array of expected right to check
|
|
1098
|
-
* @param rights array of Right for the resource
|
|
1099
|
-
* @returns true if has rights
|
|
1100
|
-
*/
|
|
1101
|
-
async sessionHasAtLeastOneResourceRight(e, t) {
|
|
1102
|
-
for (const s of e)
|
|
1103
|
-
if (await this.sessionHasResourceRight(s, t))
|
|
1104
|
-
return !0;
|
|
1105
|
-
return !1;
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Check wether the current user has resource right for each right list
|
|
1109
|
-
* @param expect expected right to check
|
|
1110
|
-
* @param rightsArray array of array of Right for multiple resources
|
|
1111
|
-
* @returns true if has rights
|
|
1112
|
-
*/
|
|
1113
|
-
async sessionHasResourceRightForEachList(e, t) {
|
|
1114
|
-
let s = 0;
|
|
1115
|
-
for (const r of t)
|
|
1116
|
-
await this.sessionHasResourceRight(e, r) && s++;
|
|
1117
|
-
return s === t.length;
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* Check wether the current user have at least one of resource right for each right list
|
|
1121
|
-
* @param expects array of expected right to check
|
|
1122
|
-
* @param rightsArray array of array of Right for multiple resources
|
|
1123
|
-
* @returns true if has rights
|
|
1124
|
-
*/
|
|
1125
|
-
async sessionHasAtLeastOneResourceRightForEachList(e, t) {
|
|
1126
|
-
for (const s of e) {
|
|
1127
|
-
let r = 0;
|
|
1128
|
-
for (const i of t)
|
|
1129
|
-
await this.sessionHasResourceRight(s, i) && r++;
|
|
1130
|
-
if (r === t.length)
|
|
1131
|
-
return !0;
|
|
1132
|
-
}
|
|
1133
|
-
return !1;
|
|
1134
|
-
}
|
|
1135
|
-
hasWorkflowRight(e, t) {
|
|
1136
|
-
return t.findIndex((s) => s === e) !== -1;
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* @param expect a workflow right
|
|
1140
|
-
* @returns true if current session has right on it
|
|
1141
|
-
*/
|
|
1142
|
-
async sessionHasWorkflowRight(e) {
|
|
1143
|
-
try {
|
|
1144
|
-
const t = await this.session.getUser();
|
|
1145
|
-
return !!t && this.hasWorkflowRight(
|
|
1146
|
-
e,
|
|
1147
|
-
t.authorizedActions.map(
|
|
1148
|
-
(s) => s.name
|
|
1149
|
-
)
|
|
1150
|
-
);
|
|
1151
|
-
} catch (t) {
|
|
1152
|
-
return console.error(`Unexpected error ${t} in sessionHasWorkflowRight()`), !1;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* @param expect a workflow right
|
|
1157
|
-
* @returns a record with right as key and boolean as value if current session has right on it
|
|
1158
|
-
*/
|
|
1159
|
-
async sessionHasWorkflowRights(e) {
|
|
1160
|
-
const t = {};
|
|
1161
|
-
try {
|
|
1162
|
-
const s = await this.session.getUser();
|
|
1163
|
-
for (const r of e)
|
|
1164
|
-
t[r] = !!s && this.hasWorkflowRight(
|
|
1165
|
-
r,
|
|
1166
|
-
s.authorizedActions.map(
|
|
1167
|
-
(i) => i.name
|
|
1168
|
-
)
|
|
1169
|
-
);
|
|
1170
|
-
} catch (s) {
|
|
1171
|
-
console.error(`Unexpected error ${s} in sessionHasWorkflowRights()`);
|
|
1172
|
-
for (const r of e)
|
|
1173
|
-
t[r] = !1;
|
|
1174
|
-
}
|
|
1175
|
-
return t;
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
class SessionService {
|
|
1179
|
-
constructor(e) {
|
|
1180
|
-
this.context = e;
|
|
1181
|
-
}
|
|
1182
|
-
get http() {
|
|
1183
|
-
return this.context.http();
|
|
1184
|
-
}
|
|
1185
|
-
get cache() {
|
|
1186
|
-
return this.context.cache();
|
|
1187
|
-
}
|
|
1188
|
-
get conf() {
|
|
1189
|
-
return this.context.conf();
|
|
1190
|
-
}
|
|
1191
|
-
/**
|
|
1192
|
-
* Callback to call when user logout
|
|
1193
|
-
*/
|
|
1194
|
-
onLogout() {
|
|
1195
|
-
this.cache.clearCache();
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Callback to call when session change
|
|
1199
|
-
*/
|
|
1200
|
-
onRefreshSession() {
|
|
1201
|
-
this.cache.clearCache();
|
|
1202
|
-
}
|
|
1203
|
-
async getSession() {
|
|
1204
|
-
const e = await this.getUser(), [
|
|
1205
|
-
t,
|
|
1206
|
-
s,
|
|
1207
|
-
r,
|
|
1208
|
-
i,
|
|
1209
|
-
o
|
|
1210
|
-
] = await Promise.all([
|
|
1211
|
-
this.getCurrentLanguage(e),
|
|
1212
|
-
this.latestQuotaAndUsage(e),
|
|
1213
|
-
this.loadDescription(e),
|
|
1214
|
-
this.getUserProfile(),
|
|
1215
|
-
this.getBookmarks(e)
|
|
1216
|
-
]);
|
|
1217
|
-
return {
|
|
1218
|
-
user: e,
|
|
1219
|
-
quotaAndUsage: s,
|
|
1220
|
-
currentLanguage: t,
|
|
1221
|
-
userDescription: r,
|
|
1222
|
-
userProfile: i,
|
|
1223
|
-
bookmarkedApps: o
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
login(e, t, s, r) {
|
|
1227
|
-
const i = new FormData();
|
|
1228
|
-
return i.append("email", e), i.append("password", t), typeof s < "u" && i.append("rememberMe", "" + s), typeof r < "u" && i.append("secureLocation", "" + r), this.http.post("/auth/login", i, {
|
|
1229
|
-
headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
1230
|
-
}).finally(() => {
|
|
1231
|
-
switch (this.http.latestResponse.status) {
|
|
1232
|
-
case 200:
|
|
1233
|
-
throw ERROR_CODE.MALFORMED_DATA;
|
|
1234
|
-
}
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
async logout() {
|
|
1238
|
-
const e = await this.conf.getLogoutCallback();
|
|
1239
|
-
return this.http.get("/auth/logout?callback=" + e).finally(() => {
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
async latestQuotaAndUsage(e) {
|
|
1243
|
-
const t = { quota: 0, storage: 0 };
|
|
1244
|
-
if (!e) return t;
|
|
1245
|
-
try {
|
|
1246
|
-
return await this.http.get(
|
|
1247
|
-
`/workspace/quota/user/${e == null ? void 0 : e.userId}`
|
|
1248
|
-
);
|
|
1249
|
-
} catch (s) {
|
|
1250
|
-
return console.error(s), t;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
async getCurrentLanguage(e) {
|
|
1254
|
-
const t = (e == null ? void 0 : e.sessionMetadata) && (e == null ? void 0 : e.sessionMetadata.userId);
|
|
1255
|
-
try {
|
|
1256
|
-
let s;
|
|
1257
|
-
return t ? s = await this.loadUserLanguage() : s = await this.loadDefaultLanguage(), s;
|
|
1258
|
-
} catch (s) {
|
|
1259
|
-
console.error(s);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
async loadUserLanguage() {
|
|
1263
|
-
try {
|
|
1264
|
-
const e = await this.http.get(
|
|
1265
|
-
"/userbook/preference/language"
|
|
1266
|
-
);
|
|
1267
|
-
return JSON.parse(e.preference)["default-domain"];
|
|
1268
|
-
} catch {
|
|
1269
|
-
return await this.loadDefaultLanguage();
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
async loadDefaultLanguage() {
|
|
1273
|
-
return (await this.cache.httpGetJson(
|
|
1274
|
-
"/locale"
|
|
1275
|
-
)).locale;
|
|
1276
|
-
}
|
|
1277
|
-
async getUser() {
|
|
1278
|
-
const { response: e, value: t } = await this.cache.httpGet(
|
|
1279
|
-
"/auth/oauth2/userinfo"
|
|
1280
|
-
);
|
|
1281
|
-
if (!(e.status < 200 || e.status >= 300) && typeof t == "object")
|
|
1282
|
-
return t;
|
|
1283
|
-
throw ERROR_CODE.NOT_LOGGED_IN;
|
|
1284
|
-
}
|
|
1285
|
-
hasWorkflow({
|
|
1286
|
-
workflowName: e,
|
|
1287
|
-
user: t
|
|
1288
|
-
}) {
|
|
1289
|
-
return e === void 0 || (t == null ? void 0 : t.authorizedActions.findIndex((s) => s.name === e)) !== -1;
|
|
1290
|
-
}
|
|
1291
|
-
async loadDescription(e) {
|
|
1292
|
-
if (!e) return {};
|
|
1293
|
-
try {
|
|
1294
|
-
const [t, s] = await Promise.all([
|
|
1295
|
-
// FIXME The full user's description should be obtainable from a single endpoint in the backend.
|
|
1296
|
-
this.getUserProfile({
|
|
1297
|
-
options: { requestName: "refreshAvatar" }
|
|
1298
|
-
}),
|
|
1299
|
-
this.http.get("/directory/userbook/" + (e == null ? void 0 : e.userId))
|
|
1300
|
-
]);
|
|
1301
|
-
return { ...s, profiles: t };
|
|
1302
|
-
} catch (t) {
|
|
1303
|
-
return console.error(t), {};
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
async getBookmarks(e) {
|
|
1307
|
-
if (!e) return [];
|
|
1308
|
-
const t = await this.http.get("/userbook/preference/apps");
|
|
1309
|
-
t.preference || (t.preference = null);
|
|
1310
|
-
const s = JSON.parse(t.preference);
|
|
1311
|
-
let r;
|
|
1312
|
-
r = s, r || (r = {
|
|
1313
|
-
bookmarks: [],
|
|
1314
|
-
applications: []
|
|
1315
|
-
});
|
|
1316
|
-
const i = [];
|
|
1317
|
-
return r.bookmarks.forEach((o, a) => {
|
|
1318
|
-
const c = ((e == null ? void 0 : e.apps) || []).find(
|
|
1319
|
-
(l) => l.name === o
|
|
1320
|
-
);
|
|
1321
|
-
if (c) {
|
|
1322
|
-
const l = Object.assign({}, c);
|
|
1323
|
-
i.push(l);
|
|
1324
|
-
}
|
|
1325
|
-
}), i;
|
|
1326
|
-
}
|
|
1327
|
-
async getUserProfile(e = {}) {
|
|
1328
|
-
var c, l;
|
|
1329
|
-
const { options: t = {}, params: s = {} } = e, r = new URLSearchParams(s).toString(), i = `/userbook/api/person${r ? `?${r}` : ""}`, { response: o, value: a } = await this.cache.httpGet(i, t);
|
|
1330
|
-
return o.status < 200 || o.status >= 300 || typeof a == "string" ? ["Guest"] : ((l = (c = a == null ? void 0 : a.result) == null ? void 0 : c[0]) == null ? void 0 : l.type) || ["Guest"];
|
|
1331
|
-
}
|
|
1332
|
-
async isAdml() {
|
|
1333
|
-
const e = await this.getUser();
|
|
1334
|
-
return (e == null ? void 0 : e.functions.ADMIN_LOCAL) !== void 0;
|
|
1335
|
-
}
|
|
1336
|
-
/**
|
|
1337
|
-
* Get details of an application if the user can access it.
|
|
1338
|
-
* @return undefined if no access, or app not found
|
|
1339
|
-
*/
|
|
1340
|
-
async getWebApp(e) {
|
|
1341
|
-
const t = await this.getUser();
|
|
1342
|
-
return t == null ? void 0 : t.apps.find((s) => {
|
|
1343
|
-
var r;
|
|
1344
|
-
return s != null && s.prefix ? (s == null ? void 0 : s.prefix.replace("/", "")) === e || !1 : s != null && s.address && ((r = s.address) == null ? void 0 : r.split("/")[1]) === e || !1;
|
|
1345
|
-
});
|
|
1089
|
+
events() {
|
|
1090
|
+
return this.subject;
|
|
1346
1091
|
}
|
|
1347
1092
|
}
|
|
1348
|
-
const bundle = {}, promises = {}, defaultDiacriticsRemovalMap = [
|
|
1093
|
+
const notify = new NotifyFramework(), bundle = {}, promises = {}, defaultDiacriticsRemovalMap = [
|
|
1349
1094
|
{
|
|
1350
1095
|
base: "A",
|
|
1351
1096
|
letters: /[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g
|
|
@@ -1592,9 +1337,9 @@ class IdiomService {
|
|
|
1592
1337
|
const i = new Promisified();
|
|
1593
1338
|
promises[t] = i.promise;
|
|
1594
1339
|
const o = {};
|
|
1595
|
-
e && (o["Accept-Language"] = e), this.http.get(t, { headers: o }).then((
|
|
1596
|
-
Object.assign(bundle,
|
|
1597
|
-
}).catch((
|
|
1340
|
+
e && (o["Accept-Language"] = e), this.http.get(t, { headers: o }).then((u) => {
|
|
1341
|
+
Object.assign(bundle, u), typeof s == "function" && s(), i.resolve();
|
|
1342
|
+
}).catch((u) => {
|
|
1598
1343
|
typeof s == "function" && s(), i.reject();
|
|
1599
1344
|
});
|
|
1600
1345
|
}
|
|
@@ -1627,1409 +1372,1540 @@ class IdiomService {
|
|
|
1627
1372
|
return e;
|
|
1628
1373
|
}
|
|
1629
1374
|
}
|
|
1630
|
-
class
|
|
1631
|
-
static removeAccents(e) {
|
|
1632
|
-
for (let t = 0; t < defaultDiacriticsRemovalMap.length; t++)
|
|
1633
|
-
e = e.replace(
|
|
1634
|
-
defaultDiacriticsRemovalMap[t].letters,
|
|
1635
|
-
defaultDiacriticsRemovalMap[t].base
|
|
1636
|
-
);
|
|
1637
|
-
return e;
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
class ShareService {
|
|
1375
|
+
class AbstractBehaviourService {
|
|
1641
1376
|
//
|
|
1642
1377
|
// IMPLEMENTATION
|
|
1643
1378
|
//
|
|
1644
1379
|
constructor(e) {
|
|
1645
|
-
|
|
1380
|
+
//-----------------
|
|
1381
|
+
//--- Utilities ---
|
|
1382
|
+
//-----------------
|
|
1383
|
+
a(this, "_cache");
|
|
1384
|
+
this.context = e, this._cache = new CacheService(this.context);
|
|
1646
1385
|
}
|
|
1647
|
-
|
|
1648
|
-
return this.
|
|
1386
|
+
getApplication() {
|
|
1387
|
+
return this.APP;
|
|
1649
1388
|
}
|
|
1650
|
-
|
|
1651
|
-
return this.
|
|
1652
|
-
}
|
|
1653
|
-
get cache() {
|
|
1654
|
-
return this.context.cache();
|
|
1655
|
-
}
|
|
1656
|
-
async searchShareSubjects(e, t, s) {
|
|
1657
|
-
const r = StringUtils.removeAccents(s).toLowerCase(), i = await this.cache.httpGetJson(
|
|
1658
|
-
`/${e}/share/json/${t}?search=${s}`
|
|
1659
|
-
), o = i.users.visibles.filter(({ username: h, firstName: E, lastName: p, login: d }) => {
|
|
1660
|
-
const g = StringUtils.removeAccents(
|
|
1661
|
-
p || ""
|
|
1662
|
-
).toLowerCase(), A = StringUtils.removeAccents(
|
|
1663
|
-
E || ""
|
|
1664
|
-
).toLowerCase(), m = StringUtils.removeAccents(
|
|
1665
|
-
h || ""
|
|
1666
|
-
).toLowerCase(), R = StringUtils.removeAccents(d || "").toLowerCase();
|
|
1667
|
-
return m.includes(r) || A.includes(r) || g.includes(r) || R.includes(r);
|
|
1668
|
-
}).map((h) => ({
|
|
1669
|
-
avatarUrl: this.directory.getAvatarUrl(h.id, "user"),
|
|
1670
|
-
directoryUrl: this.directory.getDirectoryUrl(h.id, "user"),
|
|
1671
|
-
displayName: h.username,
|
|
1672
|
-
id: h.id,
|
|
1673
|
-
profile: h.profile,
|
|
1674
|
-
type: "user"
|
|
1675
|
-
})), a = i.groups.visibles.filter(({ name: h }) => StringUtils.removeAccents(h || "").toLowerCase().includes(r)).map((h) => ({
|
|
1676
|
-
avatarUrl: this.directory.getAvatarUrl(h.id, "group"),
|
|
1677
|
-
directoryUrl: this.directory.getDirectoryUrl(h.id, "group"),
|
|
1678
|
-
displayName: h.name,
|
|
1679
|
-
id: h.id,
|
|
1680
|
-
type: "group",
|
|
1681
|
-
structureName: h.structureName
|
|
1682
|
-
}));
|
|
1683
|
-
return [...(await this.directory.getBookMarks()).filter(({ displayName: h }) => StringUtils.removeAccents(
|
|
1684
|
-
h || ""
|
|
1685
|
-
).toLowerCase().includes(r)).map((h) => ({
|
|
1686
|
-
avatarUrl: "",
|
|
1687
|
-
directoryUrl: "",
|
|
1688
|
-
profile: "",
|
|
1689
|
-
displayName: h.displayName,
|
|
1690
|
-
id: h.id,
|
|
1691
|
-
type: "sharebookmark"
|
|
1692
|
-
})), ...o, ...a];
|
|
1693
|
-
}
|
|
1694
|
-
async getShareMapping(e) {
|
|
1695
|
-
const t = await this.cache.httpGetJson(
|
|
1696
|
-
`/${e}/rights/sharing`
|
|
1697
|
-
);
|
|
1698
|
-
for (const s of Object.keys(t))
|
|
1699
|
-
if (s.includes(".")) {
|
|
1700
|
-
const r = s.split(".")[1], i = t[s];
|
|
1701
|
-
delete t[s], t[r] = i;
|
|
1702
|
-
}
|
|
1703
|
-
return t;
|
|
1389
|
+
getResourceType() {
|
|
1390
|
+
return this.RESOURCE;
|
|
1704
1391
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
for (const l of a)
|
|
1708
|
-
r[l].filter(
|
|
1709
|
-
(p) => o.includes(p)
|
|
1710
|
-
).length > 0 && c.push(l);
|
|
1711
|
-
return c;
|
|
1392
|
+
httpGet(e, t) {
|
|
1393
|
+
return this._cache.httpGetJson(e, t);
|
|
1712
1394
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
const g = this.getActionsAvailableFor(
|
|
1720
|
-
{ id: d.id, type: "user" },
|
|
1721
|
-
i,
|
|
1722
|
-
o
|
|
1723
|
-
);
|
|
1724
|
-
return {
|
|
1725
|
-
id: d.id,
|
|
1726
|
-
type: "user",
|
|
1727
|
-
displayName: d.username,
|
|
1728
|
-
profile: d.profile,
|
|
1729
|
-
avatarUrl: this.directory.getAvatarUrl(d.id, "user"),
|
|
1730
|
-
directoryUrl: this.directory.getDirectoryUrl(d.id, "user"),
|
|
1731
|
-
actions: g.map((m) => {
|
|
1732
|
-
const R = a[m];
|
|
1733
|
-
return {
|
|
1734
|
-
displayName: m,
|
|
1735
|
-
id: m,
|
|
1736
|
-
priority: R.priority
|
|
1737
|
-
};
|
|
1738
|
-
})
|
|
1739
|
-
};
|
|
1740
|
-
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), l = Object.keys(i.groups.checked).map((d) => i.groups.visibles.find(
|
|
1741
|
-
(A) => A.id === d
|
|
1742
|
-
)).filter((d) => d !== void 0).map((d) => {
|
|
1743
|
-
const g = this.getActionsAvailableFor(
|
|
1744
|
-
{ id: d.id, type: "group" },
|
|
1745
|
-
i,
|
|
1746
|
-
o
|
|
1747
|
-
);
|
|
1748
|
-
return {
|
|
1749
|
-
id: d.id,
|
|
1750
|
-
type: "group",
|
|
1751
|
-
displayName: d.name,
|
|
1752
|
-
profile: void 0,
|
|
1753
|
-
avatarUrl: this.directory.getAvatarUrl(d.id, "group"),
|
|
1754
|
-
directoryUrl: this.directory.getDirectoryUrl(d.id, "group"),
|
|
1755
|
-
actions: g.map((m) => {
|
|
1756
|
-
const R = a[m];
|
|
1757
|
-
return {
|
|
1758
|
-
displayName: m,
|
|
1759
|
-
id: m,
|
|
1760
|
-
priority: R.priority
|
|
1761
|
-
};
|
|
1762
|
-
})
|
|
1763
|
-
};
|
|
1764
|
-
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), h = [...c, ...l], E = i.groups.visibles.map(
|
|
1765
|
-
({ groupDisplayName: d, id: g, name: A }) => ({
|
|
1766
|
-
displayName: d || A,
|
|
1767
|
-
id: g
|
|
1768
|
-
})
|
|
1769
|
-
), p = i.users.visibles.map(
|
|
1770
|
-
({ id: d, profile: g, username: A, firstName: m, lastName: R, login: v }) => ({
|
|
1771
|
-
displayName: A,
|
|
1772
|
-
firstName: m,
|
|
1773
|
-
lastName: R,
|
|
1774
|
-
login: v,
|
|
1775
|
-
profile: g,
|
|
1776
|
-
id: d
|
|
1777
|
-
})
|
|
1778
|
-
);
|
|
1395
|
+
/* Utility to map data between linker model and search model. */
|
|
1396
|
+
dataToResource({
|
|
1397
|
+
modified: e,
|
|
1398
|
+
...t
|
|
1399
|
+
}) {
|
|
1400
|
+
const s = typeof e == "string" ? e : e != null && e.$date ? "" + e.$date : "";
|
|
1779
1401
|
return {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1402
|
+
application: this.RESOURCE,
|
|
1403
|
+
name: t.title,
|
|
1404
|
+
creatorId: t.owner,
|
|
1405
|
+
creatorName: t.ownerName,
|
|
1406
|
+
thumbnail: t.icon,
|
|
1407
|
+
assetId: t._id,
|
|
1408
|
+
modifiedAt: s,
|
|
1409
|
+
shared: t.shared,
|
|
1410
|
+
path: t.path
|
|
1784
1411
|
};
|
|
1785
1412
|
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
for (const c of s) {
|
|
1793
|
-
const l = c.actions.map((E) => r[E.id]).reduce((E, p) => Array.isArray(p) ? [...E, ...p] : E, []), h = [...new Set(l)];
|
|
1794
|
-
h.length > 0 && (c.type === "user" ? i.users[c.id] = h : c.type === "group" ? i.groups[c.id] = h : i.bookmarks[c.id] = h);
|
|
1795
|
-
}
|
|
1796
|
-
const o = `/${e}/share/resource/${t}`;
|
|
1797
|
-
return this.cache.clearCache(`/${e}/share/json/${t}?search=`), await this.http.putJson(o, i);
|
|
1413
|
+
}
|
|
1414
|
+
class ActualitesBehaviour extends AbstractBehaviourService {
|
|
1415
|
+
constructor() {
|
|
1416
|
+
super(...arguments);
|
|
1417
|
+
a(this, "APP", "actualites");
|
|
1418
|
+
a(this, "RESOURCE", "actualites");
|
|
1798
1419
|
}
|
|
1799
|
-
async
|
|
1800
|
-
|
|
1801
|
-
"/
|
|
1802
|
-
)
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
})
|
|
1420
|
+
async loadResources() {
|
|
1421
|
+
return (await this.httpGet(
|
|
1422
|
+
"/actualites/linker/infos"
|
|
1423
|
+
)).map((s) => {
|
|
1424
|
+
var r;
|
|
1425
|
+
return s.thread_icon ? r = s.thread_icon + "?thumbnail=48x48" : r = "/img/icons/glyphicons_036_file.png", this.dataToResource({
|
|
1426
|
+
title: s.title + " [" + s.thread_title + "]",
|
|
1427
|
+
ownerName: s.username,
|
|
1428
|
+
owner: s.owner,
|
|
1429
|
+
icon: r,
|
|
1430
|
+
path: "/actualites#/view/thread/" + s.thread_id + "/info/" + s._id,
|
|
1431
|
+
_id: `${s.thread_id}#${s._id}`,
|
|
1432
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1433
|
+
modified: s.modified
|
|
1434
|
+
});
|
|
1435
|
+
});
|
|
1815
1436
|
}
|
|
1816
1437
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
return MimeTypeUtils.INSTANCE.isWordLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("wordprocessing") !== -1;
|
|
1823
|
-
},
|
|
1824
|
-
xls: function({ type: n, extension: e }) {
|
|
1825
|
-
return MimeTypeUtils.INSTANCE.isExcelLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("spreadsheet") !== -1 || n.indexOf("ms-excel") !== -1;
|
|
1826
|
-
},
|
|
1827
|
-
img: function({ type: n }) {
|
|
1828
|
-
return n.indexOf("image") !== -1;
|
|
1829
|
-
},
|
|
1830
|
-
pdf: function({ type: n }) {
|
|
1831
|
-
return n.indexOf("pdf") !== -1 || n === "application/x-download";
|
|
1832
|
-
},
|
|
1833
|
-
ppt: function({ type: n, extension: e }) {
|
|
1834
|
-
return MimeTypeUtils.INSTANCE.isPowerpointLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("presentation") !== -1 || n.indexOf("powerpoint") !== -1;
|
|
1835
|
-
},
|
|
1836
|
-
txt: function({ type: n, extension: e }) {
|
|
1837
|
-
return MimeTypeUtils.INSTANCE.isTxtLike(n, e);
|
|
1838
|
-
},
|
|
1839
|
-
md: function({ type: n, extension: e }) {
|
|
1840
|
-
return MimeTypeUtils.INSTANCE.isMdLike(n, e);
|
|
1841
|
-
},
|
|
1842
|
-
video: function({ type: n }) {
|
|
1843
|
-
return n.indexOf("video") !== -1;
|
|
1844
|
-
},
|
|
1845
|
-
audio: function({ type: n }) {
|
|
1846
|
-
return n.indexOf("audio") !== -1;
|
|
1847
|
-
},
|
|
1848
|
-
zip: function({ type: n }) {
|
|
1849
|
-
return n.indexOf("zip") !== -1 || n.indexOf("rar") !== -1 || n.indexOf("tar") !== -1 || n.indexOf("7z") !== -1;
|
|
1438
|
+
class BlogBehaviour extends AbstractBehaviourService {
|
|
1439
|
+
constructor() {
|
|
1440
|
+
super(...arguments);
|
|
1441
|
+
a(this, "APP", "blog");
|
|
1442
|
+
a(this, "RESOURCE", "blog");
|
|
1850
1443
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1444
|
+
loadResources() {
|
|
1445
|
+
return new Promise(async (t, s) => {
|
|
1446
|
+
try {
|
|
1447
|
+
const r = await this.httpGet("/blog/linker"), i = [];
|
|
1448
|
+
r.forEach((o) => {
|
|
1449
|
+
o.thumbnail ? o.thumbnail = o.thumbnail + "?thumbnail=48x48" : o.thumbnail = "/img/illustrations/blog.svg";
|
|
1450
|
+
const u = o.fetchPosts.map((c) => this.dataToResource({
|
|
1451
|
+
owner: o.author.userId,
|
|
1452
|
+
ownerName: o.author.username,
|
|
1453
|
+
title: c.title + " [" + o.title + "]",
|
|
1454
|
+
_id: `${o._id}#${c._id}`,
|
|
1455
|
+
icon: o.thumbnail,
|
|
1456
|
+
path: `/blog/id/${o._id}/post/${c._id}`,
|
|
1457
|
+
shared: !!(o.shared && o.shared.length >= 0),
|
|
1458
|
+
modified: o.modified
|
|
1459
|
+
}));
|
|
1460
|
+
i.push(...u);
|
|
1461
|
+
}), t(i);
|
|
1462
|
+
} catch (r) {
|
|
1463
|
+
s(r);
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
class CollaborativewallBehaviour extends AbstractBehaviourService {
|
|
1469
|
+
constructor() {
|
|
1470
|
+
super(...arguments);
|
|
1471
|
+
a(this, "APP", "collaborativewall");
|
|
1472
|
+
a(this, "RESOURCE", "collaborativewall");
|
|
1473
|
+
}
|
|
1474
|
+
async loadResources() {
|
|
1475
|
+
return (await this.httpGet(
|
|
1476
|
+
"/collaborativewall/list/all"
|
|
1477
|
+
)).map(
|
|
1478
|
+
(s) => this.dataToResource({
|
|
1479
|
+
title: s.name,
|
|
1480
|
+
ownerName: s.owner.displayName,
|
|
1481
|
+
owner: s.owner.userId,
|
|
1482
|
+
icon: s.icon ? s.icon : "/img/illustrations/collaborative-wall-default.png",
|
|
1483
|
+
path: "/collaborativewall#/view/" + s._id,
|
|
1484
|
+
_id: s._id,
|
|
1485
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1486
|
+
modified: s.modified
|
|
1487
|
+
})
|
|
1859
1488
|
);
|
|
1860
1489
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
const o = i(r);
|
|
1868
|
-
if (o)
|
|
1869
|
-
return o;
|
|
1870
|
-
}
|
|
1871
|
-
return "unknown";
|
|
1490
|
+
}
|
|
1491
|
+
class CommunityBehaviour extends AbstractBehaviourService {
|
|
1492
|
+
constructor() {
|
|
1493
|
+
super(...arguments);
|
|
1494
|
+
a(this, "APP", "community");
|
|
1495
|
+
a(this, "RESOURCE", "community");
|
|
1872
1496
|
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1497
|
+
async loadResources() {
|
|
1498
|
+
return (await this.httpGet(
|
|
1499
|
+
"/community/listallpages"
|
|
1500
|
+
)).map((s) => {
|
|
1501
|
+
var r;
|
|
1502
|
+
return typeof s.thumbnail > "u" || s.thumbnail === "" ? r = "/img/icons/glyphicons_036_file.png" : r = s.thumbnail + "?thumbnail=48x48", this.dataToResource({
|
|
1503
|
+
title: s.name,
|
|
1504
|
+
icon: r,
|
|
1505
|
+
path: "/community#/view/" + s.id,
|
|
1506
|
+
_id: s.id,
|
|
1507
|
+
owner: "",
|
|
1508
|
+
ownerName: "",
|
|
1509
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1510
|
+
modified: s.name
|
|
1511
|
+
// FIXME date ?
|
|
1512
|
+
});
|
|
1513
|
+
});
|
|
1882
1514
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1515
|
+
}
|
|
1516
|
+
class ExercizerBehaviour extends AbstractBehaviourService {
|
|
1517
|
+
constructor() {
|
|
1518
|
+
super(...arguments);
|
|
1519
|
+
a(this, "APP", "exercizer");
|
|
1520
|
+
a(this, "RESOURCE", "exercizer");
|
|
1885
1521
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
"
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1522
|
+
async loadResources() {
|
|
1523
|
+
return (await this.httpGet(
|
|
1524
|
+
"/exercizer/subjects-scheduled"
|
|
1525
|
+
)).map((s) => {
|
|
1526
|
+
const r = s.picture ? s.picture + "?thumbnail=48x48" : "/img/illustrations/exercizer.svg";
|
|
1527
|
+
let i, o = !1, u = JSON.parse(s.scheduled_at);
|
|
1528
|
+
return u.groupList.length > 0 ? (o = !0, i = u.groupList[0].name) : u.userList.length > 0 ? (o = !0, i = u.userList[0].name) : i = "", u.groupList.length + u.userList.length > 1 && (i += "..."), this.dataToResource({
|
|
1529
|
+
title: s.title,
|
|
1530
|
+
owner: s.owner,
|
|
1531
|
+
ownerName: i,
|
|
1532
|
+
icon: r,
|
|
1533
|
+
path: "/exercizer#/linker/" + s.id,
|
|
1534
|
+
_id: "" + s.id,
|
|
1535
|
+
shared: o,
|
|
1536
|
+
modified: s.modified
|
|
1537
|
+
});
|
|
1538
|
+
});
|
|
1895
1539
|
}
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
(
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1540
|
+
}
|
|
1541
|
+
class FormulaireBehaviour extends AbstractBehaviourService {
|
|
1542
|
+
constructor() {
|
|
1543
|
+
super(...arguments);
|
|
1544
|
+
a(this, "APP", "formulaire");
|
|
1545
|
+
a(this, "RESOURCE", "formulaire");
|
|
1546
|
+
}
|
|
1547
|
+
async loadResources() {
|
|
1548
|
+
return (await this.httpGet(
|
|
1549
|
+
"/formulaire/forms/linker"
|
|
1550
|
+
)).map((s) => (s.picture || (s.picture = "/formulaire/public/img/logo.svg"), this.dataToResource({
|
|
1551
|
+
_id: "" + s.id,
|
|
1552
|
+
icon: s.picture,
|
|
1553
|
+
title: s.title,
|
|
1554
|
+
ownerName: s.owner_name,
|
|
1555
|
+
owner: s.owner_id,
|
|
1556
|
+
path: s.is_public ? `${window.location.origin}/formulaire-public#/form/${s.public_key}` : `${window.location.origin}/formulaire#/form/${s.id}/${s.rgpd ? "rgpd" : "new"}`,
|
|
1557
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1558
|
+
modified: "" + s.date_modification
|
|
1559
|
+
})));
|
|
1908
1560
|
}
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1561
|
+
}
|
|
1562
|
+
class ForumBehaviour extends AbstractBehaviourService {
|
|
1563
|
+
constructor() {
|
|
1564
|
+
super(...arguments);
|
|
1565
|
+
a(this, "APP", "forum");
|
|
1566
|
+
a(this, "RESOURCE", "forum");
|
|
1567
|
+
}
|
|
1568
|
+
async loadResources() {
|
|
1569
|
+
return (await this.httpGet("/forum/categories")).map(
|
|
1570
|
+
(s) => this.dataToResource({
|
|
1571
|
+
_id: s._id,
|
|
1572
|
+
title: s.name,
|
|
1573
|
+
icon: s.icon || "/img/illustrations/forum.svg",
|
|
1574
|
+
path: "/forum#/view/" + s._id,
|
|
1575
|
+
ownerName: s.owner.displayName,
|
|
1576
|
+
owner: s.owner.userId,
|
|
1577
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1578
|
+
modified: s.modified
|
|
1579
|
+
})
|
|
1917
1580
|
);
|
|
1918
|
-
if (this.http.isResponseError())
|
|
1919
|
-
throw this.http.latestResponse.statusText;
|
|
1920
|
-
return c;
|
|
1921
1581
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
}), this.http.isResponseError())
|
|
1929
|
-
throw this.http.latestResponse.statusText;
|
|
1582
|
+
}
|
|
1583
|
+
class HomeworksBehaviour extends AbstractBehaviourService {
|
|
1584
|
+
constructor() {
|
|
1585
|
+
super(...arguments);
|
|
1586
|
+
a(this, "APP", "homeworks");
|
|
1587
|
+
a(this, "RESOURCE", "homeworks");
|
|
1930
1588
|
}
|
|
1931
|
-
async
|
|
1932
|
-
|
|
1933
|
-
|
|
1589
|
+
async loadResources() {
|
|
1590
|
+
return (await this.httpGet("/homeworks/list")).filter((t) => t.owner && t.trashed === 0).map((t) => this.dataToResource({
|
|
1591
|
+
title: t.title,
|
|
1592
|
+
ownerName: t.owner.displayName,
|
|
1593
|
+
owner: t.owner.userId,
|
|
1594
|
+
icon: t.thumbnail || "/img/illustrations/homeworks.svg",
|
|
1595
|
+
path: "/homeworks#/view-homeworks/" + t._id,
|
|
1596
|
+
_id: "" + t._id,
|
|
1597
|
+
shared: typeof t.shared < "u",
|
|
1598
|
+
modified: t.modified
|
|
1599
|
+
}));
|
|
1934
1600
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1601
|
+
}
|
|
1602
|
+
class MagnetoBehaviour extends AbstractBehaviourService {
|
|
1603
|
+
constructor() {
|
|
1604
|
+
super(...arguments);
|
|
1605
|
+
a(this, "APP", "magneto");
|
|
1606
|
+
a(this, "RESOURCE", "magneto");
|
|
1940
1607
|
}
|
|
1941
|
-
async
|
|
1942
|
-
|
|
1608
|
+
async loadResources() {
|
|
1609
|
+
const { all: t } = await this.httpGet(
|
|
1610
|
+
"/magneto/boards/editable"
|
|
1611
|
+
);
|
|
1612
|
+
return t.map((s) => this.dataToResource({
|
|
1613
|
+
_id: s._id,
|
|
1614
|
+
title: s.title,
|
|
1615
|
+
icon: s.imageUrl,
|
|
1616
|
+
owner: s.ownerId,
|
|
1617
|
+
ownerName: s.ownerName,
|
|
1618
|
+
path: `/magneto#/board/${s._id}/view`,
|
|
1619
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1620
|
+
modified: "" + s.modificationDate
|
|
1621
|
+
}));
|
|
1943
1622
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
*/
|
|
1951
|
-
async transferDocuments(e, t, s = "protected") {
|
|
1952
|
-
const r = [];
|
|
1953
|
-
if (e.forEach((i) => {
|
|
1954
|
-
(s === "public" && !i.public || !i.public && !i.protected) && r.push(i);
|
|
1955
|
-
}), r.length > 0) {
|
|
1956
|
-
const i = await this.http.post(
|
|
1957
|
-
"/workspace/documents/transfer",
|
|
1958
|
-
{
|
|
1959
|
-
application: t,
|
|
1960
|
-
visibility: s,
|
|
1961
|
-
ids: r.map((o) => o._id)
|
|
1962
|
-
}
|
|
1963
|
-
);
|
|
1964
|
-
if (this.http.isResponseError())
|
|
1965
|
-
throw this.http.latestResponse.statusText;
|
|
1966
|
-
return r.forEach((o, a) => {
|
|
1967
|
-
const c = e.findIndex(
|
|
1968
|
-
(l) => l._id === o._id
|
|
1969
|
-
);
|
|
1970
|
-
0 <= c && c < e.length && (e[c] = i[a]);
|
|
1971
|
-
}), e.filter((o) => !!o);
|
|
1972
|
-
}
|
|
1973
|
-
return e;
|
|
1623
|
+
}
|
|
1624
|
+
class MindmapBehaviour extends AbstractBehaviourService {
|
|
1625
|
+
constructor() {
|
|
1626
|
+
super(...arguments);
|
|
1627
|
+
a(this, "APP", "mindmap");
|
|
1628
|
+
a(this, "RESOURCE", "mindmap");
|
|
1974
1629
|
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
return l ? a + l : null;
|
|
1989
|
-
} else
|
|
1990
|
-
return a + r;
|
|
1991
|
-
}
|
|
1630
|
+
async loadResources() {
|
|
1631
|
+
return (await this.httpGet("/mindmap/list/all")).map(
|
|
1632
|
+
(s) => this.dataToResource({
|
|
1633
|
+
title: s.name,
|
|
1634
|
+
ownerName: s.owner.displayName,
|
|
1635
|
+
owner: s.owner.userId,
|
|
1636
|
+
icon: s.thumbnail || "/img/illustrations/mindmap-default.png",
|
|
1637
|
+
path: "/mindmap#/view/" + s._id,
|
|
1638
|
+
_id: s._id,
|
|
1639
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1640
|
+
modified: s.modified
|
|
1641
|
+
})
|
|
1642
|
+
);
|
|
1992
1643
|
}
|
|
1993
1644
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
this
|
|
1998
|
-
|
|
1999
|
-
get conf() {
|
|
2000
|
-
return this.context.conf();
|
|
1645
|
+
class PagesBehaviour extends AbstractBehaviourService {
|
|
1646
|
+
constructor() {
|
|
1647
|
+
super(...arguments);
|
|
1648
|
+
a(this, "APP", "pages");
|
|
1649
|
+
a(this, "RESOURCE", "pages");
|
|
2001
1650
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
1651
|
+
async loadResources() {
|
|
1652
|
+
const t = await this.httpGet("/pages/list/all"), s = [];
|
|
1653
|
+
return t.forEach((r) => {
|
|
1654
|
+
var o;
|
|
1655
|
+
const i = r.thumbnail ? r.thumbnail + "?thumbnail=48x48" : "/img/illustrations/pages.svg";
|
|
1656
|
+
s.push(
|
|
1657
|
+
this.dataToResource({
|
|
1658
|
+
title: r.title,
|
|
1659
|
+
owner: r.owner.userId,
|
|
1660
|
+
ownerName: r.owner.displayName,
|
|
1661
|
+
icon: i,
|
|
1662
|
+
path: "/pages#/website/" + r._id,
|
|
1663
|
+
_id: r._id,
|
|
1664
|
+
shared: typeof r.shared < "u",
|
|
1665
|
+
modified: r.modified
|
|
1666
|
+
})
|
|
1667
|
+
), (o = r.pages) == null || o.forEach((u) => {
|
|
1668
|
+
s.push(
|
|
1669
|
+
this.dataToResource({
|
|
1670
|
+
title: u.title,
|
|
1671
|
+
owner: r.owner.userId,
|
|
1672
|
+
ownerName: r.owner.displayName,
|
|
1673
|
+
icon: i,
|
|
1674
|
+
path: "/pages#/website/" + r._id + "/" + u.titleLink,
|
|
1675
|
+
_id: r._id + "/" + u.titleLink,
|
|
1676
|
+
shared: typeof r.shared < "u",
|
|
1677
|
+
modified: r.modified
|
|
1678
|
+
})
|
|
1679
|
+
);
|
|
1680
|
+
});
|
|
1681
|
+
}), s;
|
|
2004
1682
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
1683
|
+
}
|
|
1684
|
+
class PollBehaviour extends AbstractBehaviourService {
|
|
1685
|
+
constructor() {
|
|
1686
|
+
super(...arguments);
|
|
1687
|
+
a(this, "APP", "poll");
|
|
1688
|
+
a(this, "RESOURCE", "poll");
|
|
2007
1689
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
for (const r in t.LIBELLE_SERVICE)
|
|
2023
|
-
if (r !== "default" && n.indexOf(r) >= 0) {
|
|
2024
|
-
s = t.LIBELLE_SERVICE[r];
|
|
2025
|
-
break;
|
|
2026
|
-
}
|
|
2027
|
-
ATTag = new ATInternet.Tracker.Tag({ site: t.STRUCT_ID }), ATTag.setProps(
|
|
2028
|
-
{
|
|
2029
|
-
SERVICE: s,
|
|
2030
|
-
TYPE: t.TYPE,
|
|
2031
|
-
OUTIL: t.OUTIL,
|
|
2032
|
-
UAI: t.STRUCT_UAI,
|
|
2033
|
-
PROJET: t.PROJET,
|
|
2034
|
-
EXPLOITANT: t.EXPLOITANT,
|
|
2035
|
-
PLATEFORME: t.PLATFORME,
|
|
2036
|
-
PROFIL: t.PROFILE
|
|
2037
|
-
},
|
|
2038
|
-
!0
|
|
2039
|
-
), ATTag.identifiedVisitor.set({
|
|
2040
|
-
id: t.ID_PERSO,
|
|
2041
|
-
category: t.PROFILE
|
|
2042
|
-
}), ATTag.page.set({
|
|
2043
|
-
name: (e == null ? void 0 : e.prefix) === "userbook" ? "directory" : e == null ? void 0 : e.prefix,
|
|
2044
|
-
chapter1: "",
|
|
2045
|
-
chapter2: "",
|
|
2046
|
-
chapter3: "",
|
|
2047
|
-
level2: t.STRUCT_UAI
|
|
2048
|
-
}), ATTag.dispatch();
|
|
1690
|
+
async loadResources() {
|
|
1691
|
+
return (await this.httpGet("/poll/list/all")).map((s) => {
|
|
1692
|
+
const r = s.icon ? s.icon + "?thumbnail=48x48" : "/img/icons/glyphicons_036_file.png";
|
|
1693
|
+
return this.dataToResource({
|
|
1694
|
+
title: s.question,
|
|
1695
|
+
ownerName: s.owner.displayName,
|
|
1696
|
+
icon: r,
|
|
1697
|
+
path: "/poll#/view/" + s._id,
|
|
1698
|
+
_id: s._id,
|
|
1699
|
+
owner: s.owner.userId,
|
|
1700
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1701
|
+
modified: s.modified
|
|
1702
|
+
});
|
|
1703
|
+
});
|
|
2049
1704
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
if (!(e != null && e.type))
|
|
2057
|
-
throw ERROR_CODE.MALFORMED_DATA;
|
|
2058
|
-
return t != null && t.active && (e.xiti = await this.getXitiTrackingParams(t, n)), e.xiti;
|
|
1705
|
+
}
|
|
1706
|
+
class ScrapbookBehaviour extends AbstractBehaviourService {
|
|
1707
|
+
constructor() {
|
|
1708
|
+
super(...arguments);
|
|
1709
|
+
a(this, "APP", "scrapbook");
|
|
1710
|
+
a(this, "RESOURCE", "scrapbook");
|
|
2059
1711
|
}
|
|
2060
|
-
async
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
1712
|
+
async loadResources() {
|
|
1713
|
+
return (await this.httpGet(
|
|
1714
|
+
"/scrapbook/list/all"
|
|
1715
|
+
)).map((s) => {
|
|
1716
|
+
const r = s.icon || "/img/illustrations/scrapbook.svg";
|
|
1717
|
+
return this.dataToResource({
|
|
1718
|
+
title: s.name,
|
|
1719
|
+
owner: s.owner.userId,
|
|
1720
|
+
ownerName: s.owner.displayName,
|
|
1721
|
+
icon: r,
|
|
1722
|
+
path: "/scrapbook#/view-scrapbook/" + s._id,
|
|
1723
|
+
_id: s._id,
|
|
1724
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
1725
|
+
modified: s.modified
|
|
2064
1726
|
});
|
|
2065
|
-
|
|
2066
|
-
throw "Error while loading XiTi script";
|
|
2067
|
-
eval(response);
|
|
2068
|
-
}
|
|
1727
|
+
});
|
|
2069
1728
|
}
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
1729
|
+
}
|
|
1730
|
+
class TimelinegeneratorBehaviour extends AbstractBehaviourService {
|
|
1731
|
+
constructor() {
|
|
1732
|
+
super(...arguments);
|
|
1733
|
+
a(this, "APP", "timelinegenerator");
|
|
1734
|
+
a(this, "RESOURCE", "timelinegenerator");
|
|
1735
|
+
}
|
|
1736
|
+
loadResources() {
|
|
1737
|
+
return new Promise(async (t, s) => {
|
|
1738
|
+
try {
|
|
1739
|
+
const i = (await this.httpGet(
|
|
1740
|
+
"/timelinegenerator/timelines"
|
|
1741
|
+
)).map((o) => {
|
|
1742
|
+
const u = o.icon || "/img/illustrations/timeline-default.png";
|
|
1743
|
+
return this.dataToResource({
|
|
1744
|
+
title: o.headline,
|
|
1745
|
+
ownerName: o.owner.displayName,
|
|
1746
|
+
owner: o.owner.userId,
|
|
1747
|
+
icon: u,
|
|
1748
|
+
path: "/timelinegenerator#/view/" + o._id,
|
|
1749
|
+
_id: o._id,
|
|
1750
|
+
shared: typeof o.shared < "u",
|
|
1751
|
+
modified: o.modified
|
|
1752
|
+
});
|
|
1753
|
+
});
|
|
1754
|
+
t(i);
|
|
1755
|
+
} catch (r) {
|
|
1756
|
+
s(r);
|
|
2080
1757
|
}
|
|
2081
|
-
}
|
|
2082
|
-
if (!r || !r.active) return;
|
|
2083
|
-
const i = await this.conf.getPublicConf(e);
|
|
2084
|
-
if (!i) return;
|
|
2085
|
-
const o = i.xiti;
|
|
2086
|
-
if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
|
|
2087
|
-
function a(l) {
|
|
2088
|
-
let h = "";
|
|
2089
|
-
for (let E = 0; E < l.length; E++)
|
|
2090
|
-
h += l.charCodeAt(E);
|
|
2091
|
-
return h;
|
|
2092
|
-
}
|
|
2093
|
-
const c = {
|
|
2094
|
-
Student: "ELEVE",
|
|
2095
|
-
Teacher: "ENSEIGNANT",
|
|
2096
|
-
Relative: "PARENT",
|
|
2097
|
-
Personnel: "ADMIN_VIE_SCOL_TECH",
|
|
2098
|
-
Guest: "AUTRE"
|
|
2099
|
-
};
|
|
2100
|
-
return {
|
|
2101
|
-
LIBELLE_SERVICE: o.LIBELLE_SERVICE,
|
|
2102
|
-
// Which property of LIBELLE_SERVICE to use depends on the frontend.
|
|
2103
|
-
TYPE: o.OUTIL ? "TIERS" : "NATIF",
|
|
2104
|
-
OUTIL: o.OUTIL ? o.OUTIL : "",
|
|
2105
|
-
STRUCT_ID: r.collectiviteId,
|
|
2106
|
-
STRUCT_UAI: r.UAI,
|
|
2107
|
-
PROJET: r.projetId ? r.projetId : n.ID_PROJET,
|
|
2108
|
-
EXPLOITANT: n.ID_EXPLOITANT,
|
|
2109
|
-
PLATFORME: r.plateformeId ? r.plateformeId : n.ID_PLATEFORME,
|
|
2110
|
-
ID_PERSO: a(t.userId),
|
|
2111
|
-
PROFILE: s && s.length > 0 ? c[s[0]] ?? "" : ""
|
|
2112
|
-
};
|
|
1758
|
+
});
|
|
2113
1759
|
}
|
|
2114
1760
|
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
this
|
|
1761
|
+
class WikiBehaviour extends AbstractBehaviourService {
|
|
1762
|
+
constructor() {
|
|
1763
|
+
super(...arguments);
|
|
1764
|
+
a(this, "APP", "wiki");
|
|
1765
|
+
a(this, "RESOURCE", "wiki");
|
|
2119
1766
|
}
|
|
2120
|
-
|
|
2121
|
-
return this.
|
|
1767
|
+
async loadResources() {
|
|
1768
|
+
return (await this.httpGet(
|
|
1769
|
+
"/wiki/listallpages?visible=true"
|
|
1770
|
+
)).map((s) => s.pages.map((r) => {
|
|
1771
|
+
let i;
|
|
1772
|
+
return typeof s.thumbnail > "u" || s.thumbnail === "" ? i = "/img/icons/glyphicons_036_file.png" : i = s.thumbnail + "?thumbnail=48x48", this.dataToResource({
|
|
1773
|
+
title: r.title + " [" + s.title + "]",
|
|
1774
|
+
ownerName: s.owner.displayName,
|
|
1775
|
+
owner: s.owner.userId,
|
|
1776
|
+
icon: i,
|
|
1777
|
+
path: "/wiki#/view/" + s._id + "/" + r._id,
|
|
1778
|
+
_id: `${s._id}#${r._id}`,
|
|
1779
|
+
shared: typeof s.shared < "u",
|
|
1780
|
+
modified: r.modified
|
|
1781
|
+
});
|
|
1782
|
+
})).flat();
|
|
2122
1783
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
1784
|
+
}
|
|
1785
|
+
class WorkspaceBehaviour extends AbstractBehaviourService {
|
|
1786
|
+
constructor() {
|
|
1787
|
+
super(...arguments);
|
|
1788
|
+
a(this, "APP", "workspace");
|
|
1789
|
+
a(this, "RESOURCE", "workspace");
|
|
2125
1790
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
1791
|
+
loadResources({ search: t, asset_id: s }) {
|
|
1792
|
+
return new Promise(async (r, i) => {
|
|
1793
|
+
try {
|
|
1794
|
+
let o = "/workspace/documents?filter=all&hierarchical=true";
|
|
1795
|
+
s && s.length ? o += `&search=${t}` : t && t.length && (o += `&search=${t}`);
|
|
1796
|
+
const c = (await this.httpGet(o)).filter((h) => !h.deleted).map((h) => {
|
|
1797
|
+
const l = h.metadata["content-type"] && h.metadata["content-type"].indexOf("image") !== -1 ? `/workspace/document/${h._id}?thumbnail=120x120` : "/img/icons/unknown-large.png";
|
|
1798
|
+
return this.dataToResource({
|
|
1799
|
+
title: h.name,
|
|
1800
|
+
ownerName: h.ownerName,
|
|
1801
|
+
owner: h.owner,
|
|
1802
|
+
icon: l,
|
|
1803
|
+
path: `/workspace/document/${h._id}`,
|
|
1804
|
+
_id: h._id,
|
|
1805
|
+
shared: !!(h.shared && h.shared.length >= 0),
|
|
1806
|
+
modified: h.modified
|
|
1807
|
+
});
|
|
1808
|
+
});
|
|
1809
|
+
r(c);
|
|
1810
|
+
} catch (o) {
|
|
1811
|
+
i(o);
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
2142
1814
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
let a = `/video/encode?captation=${s}`;
|
|
2161
|
-
r && (a += `&duration=${r}`);
|
|
2162
|
-
const c = await this.http.post(
|
|
2163
|
-
a,
|
|
2164
|
-
o,
|
|
2165
|
-
{ headers: { "Content-Type": "multipart/form-data" } }
|
|
2166
|
-
);
|
|
2167
|
-
if (c.state == "running") {
|
|
2168
|
-
let l = 0, h = 1;
|
|
2169
|
-
do {
|
|
2170
|
-
const E = h + l;
|
|
2171
|
-
await new Promise(
|
|
2172
|
-
(d) => setTimeout(d, E * 1e3)
|
|
2173
|
-
), l = h, h = Math.min(8, E);
|
|
2174
|
-
const p = await this.http.get(
|
|
2175
|
-
`/video/status/${c.processid}`
|
|
2176
|
-
);
|
|
2177
|
-
if (p.state == "succeed")
|
|
2178
|
-
return p.videoworkspaceid && p.videosize && this.context.data().trackVideoSave(
|
|
2179
|
-
p.videoworkspaceid,
|
|
2180
|
-
Math.round(r),
|
|
2181
|
-
p.videosize,
|
|
2182
|
-
s,
|
|
2183
|
-
e.url,
|
|
2184
|
-
i,
|
|
2185
|
-
e.device
|
|
2186
|
-
), p;
|
|
2187
|
-
if (p.state == "error")
|
|
2188
|
-
break;
|
|
2189
|
-
} while (!0);
|
|
1815
|
+
}
|
|
1816
|
+
const y = class y {
|
|
1817
|
+
static async initialize(e, t) {
|
|
1818
|
+
const s = e.http();
|
|
1819
|
+
if (!this.resourceProducingApps.length) {
|
|
1820
|
+
this.resourceProducingApps = [t, "workspace"];
|
|
1821
|
+
try {
|
|
1822
|
+
const [r, i] = await Promise.all([
|
|
1823
|
+
s.get("/resources-applications"),
|
|
1824
|
+
e.session().getUser()
|
|
1825
|
+
]);
|
|
1826
|
+
i != null && i.apps && (r != null && r.length) && (this.resourceProducingApps = r.filter(
|
|
1827
|
+
(o) => i.apps.some((u) => u.address.includes(o))
|
|
1828
|
+
));
|
|
1829
|
+
} catch (r) {
|
|
1830
|
+
console.warn("Failed to load resource-producing apps:", r);
|
|
1831
|
+
}
|
|
2190
1832
|
}
|
|
2191
|
-
|
|
1833
|
+
return this.resourceProducingApps;
|
|
1834
|
+
}
|
|
1835
|
+
static async registerBehaviours(e) {
|
|
1836
|
+
this.resourceProducingApps.forEach((t) => {
|
|
1837
|
+
const s = { application: e, resourceType: t };
|
|
1838
|
+
this.registry.register(
|
|
1839
|
+
s,
|
|
1840
|
+
(r) => this.serviceFor(r, e, t)
|
|
1841
|
+
);
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
static serviceFor(e, t, s) {
|
|
1845
|
+
let r;
|
|
1846
|
+
switch (s) {
|
|
1847
|
+
case "timelinegenerator":
|
|
1848
|
+
r = new TimelinegeneratorBehaviour(e);
|
|
1849
|
+
break;
|
|
1850
|
+
case "workspace":
|
|
1851
|
+
r = new WorkspaceBehaviour(e);
|
|
1852
|
+
break;
|
|
1853
|
+
case "blog":
|
|
1854
|
+
r = new BlogBehaviour(e);
|
|
1855
|
+
break;
|
|
1856
|
+
case "actualites":
|
|
1857
|
+
r = new ActualitesBehaviour(e);
|
|
1858
|
+
break;
|
|
1859
|
+
case "wiki":
|
|
1860
|
+
r = new WikiBehaviour(e);
|
|
1861
|
+
break;
|
|
1862
|
+
case "pages":
|
|
1863
|
+
r = new PagesBehaviour(e);
|
|
1864
|
+
break;
|
|
1865
|
+
case "poll":
|
|
1866
|
+
r = new PollBehaviour(e);
|
|
1867
|
+
break;
|
|
1868
|
+
case "community":
|
|
1869
|
+
r = new CommunityBehaviour(e);
|
|
1870
|
+
break;
|
|
1871
|
+
case "mindmap":
|
|
1872
|
+
r = new MindmapBehaviour(e);
|
|
1873
|
+
break;
|
|
1874
|
+
case "forum":
|
|
1875
|
+
r = new ForumBehaviour(e);
|
|
1876
|
+
break;
|
|
1877
|
+
case "homeworks":
|
|
1878
|
+
r = new HomeworksBehaviour(e);
|
|
1879
|
+
break;
|
|
1880
|
+
case "scrapbook":
|
|
1881
|
+
r = new ScrapbookBehaviour(e);
|
|
1882
|
+
break;
|
|
1883
|
+
case "collaborativewall":
|
|
1884
|
+
r = new CollaborativewallBehaviour(e);
|
|
1885
|
+
break;
|
|
1886
|
+
case "exercizer":
|
|
1887
|
+
r = new ExercizerBehaviour(e);
|
|
1888
|
+
break;
|
|
1889
|
+
case "formulaire":
|
|
1890
|
+
r = new FormulaireBehaviour(e);
|
|
1891
|
+
break;
|
|
1892
|
+
case "magneto":
|
|
1893
|
+
r = new MagnetoBehaviour(e);
|
|
1894
|
+
break;
|
|
1895
|
+
default:
|
|
1896
|
+
throw ERROR_CODE.NOT_SUPPORTED;
|
|
1897
|
+
}
|
|
1898
|
+
return r.APP = t, r;
|
|
2192
1899
|
}
|
|
2193
1900
|
};
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
1901
|
+
//
|
|
1902
|
+
// STATIC REGISTRY
|
|
1903
|
+
//
|
|
1904
|
+
a(y, "registry", new ServiceRegistry()), // Expose some useful functions
|
|
1905
|
+
a(y, "findBehaviour", y.registry.findService.bind(y.registry)), a(y, "hasBehaviour", y.registry.isRegistered.bind(y.registry)), a(y, "resourceProducingApps", []);
|
|
1906
|
+
let SnipletsService = y;
|
|
1907
|
+
class RightService {
|
|
2198
1908
|
constructor(e) {
|
|
2199
1909
|
this.context = e;
|
|
2200
1910
|
}
|
|
2201
|
-
get
|
|
2202
|
-
return this.context.
|
|
1911
|
+
get session() {
|
|
1912
|
+
return this.context.session();
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Parse right concat as "$TYPE:$ID:$RIGHT"
|
|
1916
|
+
* $TYPE = user | group | creator
|
|
1917
|
+
* $ID: id of the resource
|
|
1918
|
+
* $RIGHT: read | contrib | manage
|
|
1919
|
+
*
|
|
1920
|
+
* @param right a concat right
|
|
1921
|
+
* @returns Right parsed
|
|
1922
|
+
*/
|
|
1923
|
+
parseResourceRight(e) {
|
|
1924
|
+
const t = e.split(":");
|
|
1925
|
+
if (t.length === 2) {
|
|
1926
|
+
if (t[0] === "creator")
|
|
1927
|
+
return {
|
|
1928
|
+
id: t[1],
|
|
1929
|
+
right: "creator",
|
|
1930
|
+
type: "creator"
|
|
1931
|
+
};
|
|
1932
|
+
} else return t.length === 3 ? {
|
|
1933
|
+
id: t[1],
|
|
1934
|
+
right: t[2],
|
|
1935
|
+
type: t[0]
|
|
1936
|
+
} : void 0;
|
|
2203
1937
|
}
|
|
2204
1938
|
/**
|
|
2205
|
-
*
|
|
2206
|
-
*
|
|
1939
|
+
* Parse an array of rights concat as "$TYPE:$ID:$RIGHT"
|
|
1940
|
+
* $TYPE = user | group | creator
|
|
1941
|
+
* $ID: id of the resource
|
|
1942
|
+
* $RIGHT: read | contrib | manage
|
|
1943
|
+
*
|
|
1944
|
+
* @param rights a list of concat rights
|
|
1945
|
+
* @returns Array of Right parsed
|
|
2207
1946
|
*/
|
|
2208
|
-
|
|
2209
|
-
return this.
|
|
1947
|
+
parseResourceRights(e) {
|
|
1948
|
+
return e.map((s) => this.parseResourceRight(s)).filter((s) => s !== void 0);
|
|
2210
1949
|
}
|
|
2211
1950
|
/**
|
|
2212
|
-
*
|
|
2213
|
-
* @
|
|
1951
|
+
* Check wether a user has the expected right for a ressource
|
|
1952
|
+
* @param user the userId and groupId concerned by the check
|
|
1953
|
+
* @param expect the expected right to check
|
|
1954
|
+
* @param rights array of Right for the resource
|
|
1955
|
+
* @returns true if has rights
|
|
2214
1956
|
*/
|
|
2215
|
-
|
|
2216
|
-
|
|
1957
|
+
hasResourceRight({ id: e, groupIds: t }, s, r) {
|
|
1958
|
+
const i = r.map((o) => typeof o == "string" ? this.parseResourceRight(o) : o).filter((o) => o !== void 0);
|
|
1959
|
+
for (const o of i) {
|
|
1960
|
+
if (o.id === e && o.type === "creator")
|
|
1961
|
+
return !0;
|
|
1962
|
+
if (o.id === e && o.type === "user" && o.right === s)
|
|
1963
|
+
return !0;
|
|
1964
|
+
if (t.includes(o.id) && o.type === "group" && o.right === s)
|
|
1965
|
+
return !0;
|
|
1966
|
+
}
|
|
1967
|
+
return !1;
|
|
2217
1968
|
}
|
|
2218
1969
|
/**
|
|
2219
|
-
*
|
|
2220
|
-
* @param
|
|
2221
|
-
* @param
|
|
2222
|
-
* @returns
|
|
1970
|
+
* Check wether the current user have resource right
|
|
1971
|
+
* @param expect the expected right to check
|
|
1972
|
+
* @param rights array of Right for the resource
|
|
1973
|
+
* @returns true if has rights
|
|
2223
1974
|
*/
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
}), a.forEach((l) => {
|
|
2236
|
-
if (!e.includes(l)) {
|
|
2237
|
-
i = !1;
|
|
2238
|
-
return;
|
|
2239
|
-
}
|
|
2240
|
-
}), i;
|
|
1975
|
+
async sessionHasResourceRight(e, t) {
|
|
1976
|
+
try {
|
|
1977
|
+
const s = await this.session.getUser();
|
|
1978
|
+
return !!s && this.hasResourceRight(
|
|
1979
|
+
{ groupIds: s.groupsIds, id: s.userId },
|
|
1980
|
+
e,
|
|
1981
|
+
t
|
|
1982
|
+
);
|
|
1983
|
+
} catch (s) {
|
|
1984
|
+
return console.error(`Unexpected error ${s} in sessionHasResourceRight()`), !1;
|
|
1985
|
+
}
|
|
2241
1986
|
}
|
|
2242
1987
|
/**
|
|
2243
|
-
* Check
|
|
2244
|
-
* @param
|
|
2245
|
-
* @param
|
|
2246
|
-
* @returns
|
|
1988
|
+
* Check wether the current user have at least one of resource right expected
|
|
1989
|
+
* @param expects array of expected right to check
|
|
1990
|
+
* @param rights array of Right for the resource
|
|
1991
|
+
* @returns true if has rights
|
|
2247
1992
|
*/
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
if (this.urlIsFromPattern(e, s))
|
|
1993
|
+
async sessionHasAtLeastOneResourceRight(e, t) {
|
|
1994
|
+
for (const s of e)
|
|
1995
|
+
if (await this.sessionHasResourceRight(s, t))
|
|
2252
1996
|
return !0;
|
|
2253
1997
|
return !1;
|
|
2254
1998
|
}
|
|
2255
1999
|
/**
|
|
2256
|
-
*
|
|
2257
|
-
* @param
|
|
2258
|
-
* @param
|
|
2259
|
-
* @returns
|
|
2000
|
+
* Check wether the current user has resource right for each right list
|
|
2001
|
+
* @param expect expected right to check
|
|
2002
|
+
* @param rightsArray array of array of Right for multiple resources
|
|
2003
|
+
* @returns true if has rights
|
|
2260
2004
|
*/
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
for (const a of i) {
|
|
2267
|
-
let c = s.split(a)[0];
|
|
2268
|
-
const l = c.split("}");
|
|
2269
|
-
l.length > 1 && (c = l[l.length - 1]);
|
|
2270
|
-
let h = t.split(c)[1];
|
|
2271
|
-
if (!h)
|
|
2272
|
-
continue;
|
|
2273
|
-
const E = s.split(a)[1].split("{")[0];
|
|
2274
|
-
E && (h = h.split(E)[0]);
|
|
2275
|
-
const p = new RegExp("\\" + a.replace(/}/, "\\}"), "g");
|
|
2276
|
-
o = o.replace(p, h);
|
|
2277
|
-
}
|
|
2278
|
-
return o;
|
|
2279
|
-
}
|
|
2280
|
-
return "";
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
class AbstractBehaviourService {
|
|
2284
|
-
//
|
|
2285
|
-
// IMPLEMENTATION
|
|
2286
|
-
//
|
|
2287
|
-
constructor(e) {
|
|
2288
|
-
//-----------------
|
|
2289
|
-
//--- Utilities ---
|
|
2290
|
-
//-----------------
|
|
2291
|
-
u(this, "_cache");
|
|
2292
|
-
this.context = e, this._cache = new CacheService(this.context);
|
|
2005
|
+
async sessionHasResourceRightForEachList(e, t) {
|
|
2006
|
+
let s = 0;
|
|
2007
|
+
for (const r of t)
|
|
2008
|
+
await this.sessionHasResourceRight(e, r) && s++;
|
|
2009
|
+
return s === t.length;
|
|
2293
2010
|
}
|
|
2294
|
-
|
|
2295
|
-
|
|
2011
|
+
/**
|
|
2012
|
+
* Check wether the current user have at least one of resource right for each right list
|
|
2013
|
+
* @param expects array of expected right to check
|
|
2014
|
+
* @param rightsArray array of array of Right for multiple resources
|
|
2015
|
+
* @returns true if has rights
|
|
2016
|
+
*/
|
|
2017
|
+
async sessionHasAtLeastOneResourceRightForEachList(e, t) {
|
|
2018
|
+
for (const s of e) {
|
|
2019
|
+
let r = 0;
|
|
2020
|
+
for (const i of t)
|
|
2021
|
+
await this.sessionHasResourceRight(s, i) && r++;
|
|
2022
|
+
if (r === t.length)
|
|
2023
|
+
return !0;
|
|
2024
|
+
}
|
|
2025
|
+
return !1;
|
|
2296
2026
|
}
|
|
2297
|
-
|
|
2298
|
-
return
|
|
2027
|
+
hasWorkflowRight(e, t) {
|
|
2028
|
+
return t.findIndex((s) => s === e) !== -1;
|
|
2299
2029
|
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2030
|
+
/**
|
|
2031
|
+
* @param expect a workflow right
|
|
2032
|
+
* @returns true if current session has right on it
|
|
2033
|
+
*/
|
|
2034
|
+
async sessionHasWorkflowRight(e) {
|
|
2035
|
+
try {
|
|
2036
|
+
const t = await this.session.getUser();
|
|
2037
|
+
return !!t && this.hasWorkflowRight(
|
|
2038
|
+
e,
|
|
2039
|
+
t.authorizedActions.map(
|
|
2040
|
+
(s) => s.name
|
|
2041
|
+
)
|
|
2042
|
+
);
|
|
2043
|
+
} catch (t) {
|
|
2044
|
+
return console.error(`Unexpected error ${t} in sessionHasWorkflowRight()`), !1;
|
|
2045
|
+
}
|
|
2302
2046
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2047
|
+
/**
|
|
2048
|
+
* @param expect a workflow right
|
|
2049
|
+
* @returns a record with right as key and boolean as value if current session has right on it
|
|
2050
|
+
*/
|
|
2051
|
+
async sessionHasWorkflowRights(e) {
|
|
2052
|
+
const t = {};
|
|
2053
|
+
try {
|
|
2054
|
+
const s = await this.session.getUser();
|
|
2055
|
+
for (const r of e)
|
|
2056
|
+
t[r] = !!s && this.hasWorkflowRight(
|
|
2057
|
+
r,
|
|
2058
|
+
s.authorizedActions.map(
|
|
2059
|
+
(i) => i.name
|
|
2060
|
+
)
|
|
2061
|
+
);
|
|
2062
|
+
} catch (s) {
|
|
2063
|
+
console.error(`Unexpected error ${s} in sessionHasWorkflowRights()`);
|
|
2064
|
+
for (const r of e)
|
|
2065
|
+
t[r] = !1;
|
|
2066
|
+
}
|
|
2067
|
+
return t;
|
|
2320
2068
|
}
|
|
2321
2069
|
}
|
|
2322
|
-
class
|
|
2323
|
-
constructor() {
|
|
2324
|
-
|
|
2325
|
-
u(this, "APP", "actualites");
|
|
2326
|
-
u(this, "RESOURCE", "actualites");
|
|
2070
|
+
class SessionService {
|
|
2071
|
+
constructor(e) {
|
|
2072
|
+
this.context = e;
|
|
2327
2073
|
}
|
|
2328
|
-
|
|
2329
|
-
return
|
|
2330
|
-
"/actualites/linker/infos"
|
|
2331
|
-
)).map((s) => {
|
|
2332
|
-
var r;
|
|
2333
|
-
return s.thread_icon ? r = s.thread_icon + "?thumbnail=48x48" : r = "/img/icons/glyphicons_036_file.png", this.dataToResource({
|
|
2334
|
-
title: s.title + " [" + s.thread_title + "]",
|
|
2335
|
-
ownerName: s.username,
|
|
2336
|
-
owner: s.owner,
|
|
2337
|
-
icon: r,
|
|
2338
|
-
path: "/actualites#/view/thread/" + s.thread_id + "/info/" + s._id,
|
|
2339
|
-
_id: `${s.thread_id}#${s._id}`,
|
|
2340
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2341
|
-
modified: s.modified
|
|
2342
|
-
});
|
|
2343
|
-
});
|
|
2074
|
+
get http() {
|
|
2075
|
+
return this.context.http();
|
|
2344
2076
|
}
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
constructor() {
|
|
2348
|
-
super(...arguments);
|
|
2349
|
-
u(this, "APP", "blog");
|
|
2350
|
-
u(this, "RESOURCE", "blog");
|
|
2077
|
+
get cache() {
|
|
2078
|
+
return this.context.cache();
|
|
2351
2079
|
}
|
|
2352
|
-
|
|
2353
|
-
return
|
|
2354
|
-
try {
|
|
2355
|
-
const r = await this.httpGet("/blog/linker"), i = [];
|
|
2356
|
-
r.forEach((o) => {
|
|
2357
|
-
o.thumbnail ? o.thumbnail = o.thumbnail + "?thumbnail=48x48" : o.thumbnail = "/img/illustrations/blog.svg";
|
|
2358
|
-
const a = o.fetchPosts.map((c) => this.dataToResource({
|
|
2359
|
-
owner: o.author.userId,
|
|
2360
|
-
ownerName: o.author.username,
|
|
2361
|
-
title: c.title + " [" + o.title + "]",
|
|
2362
|
-
_id: `${o._id}#${c._id}`,
|
|
2363
|
-
icon: o.thumbnail,
|
|
2364
|
-
path: `/blog/id/${o._id}/post/${c._id}`,
|
|
2365
|
-
shared: !!(o.shared && o.shared.length >= 0),
|
|
2366
|
-
modified: o.modified
|
|
2367
|
-
}));
|
|
2368
|
-
i.push(...a);
|
|
2369
|
-
}), t(i);
|
|
2370
|
-
} catch (r) {
|
|
2371
|
-
s(r);
|
|
2372
|
-
}
|
|
2373
|
-
});
|
|
2080
|
+
get conf() {
|
|
2081
|
+
return this.context.conf();
|
|
2374
2082
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
u(this, "RESOURCE", "collaborativewall");
|
|
2083
|
+
/**
|
|
2084
|
+
* Callback to call when user logout
|
|
2085
|
+
*/
|
|
2086
|
+
onLogout() {
|
|
2087
|
+
this.cache.clearCache();
|
|
2381
2088
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
title: s.name,
|
|
2388
|
-
ownerName: s.owner.displayName,
|
|
2389
|
-
owner: s.owner.userId,
|
|
2390
|
-
icon: s.icon ? s.icon : "/img/illustrations/collaborative-wall-default.png",
|
|
2391
|
-
path: "/collaborativewall#/view/" + s._id,
|
|
2392
|
-
_id: s._id,
|
|
2393
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2394
|
-
modified: s.modified
|
|
2395
|
-
})
|
|
2396
|
-
);
|
|
2089
|
+
/**
|
|
2090
|
+
* Callback to call when session change
|
|
2091
|
+
*/
|
|
2092
|
+
onRefreshSession() {
|
|
2093
|
+
this.cache.clearCache();
|
|
2397
2094
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2095
|
+
async getSession() {
|
|
2096
|
+
const e = await this.getUser(), [
|
|
2097
|
+
t,
|
|
2098
|
+
s,
|
|
2099
|
+
r,
|
|
2100
|
+
i,
|
|
2101
|
+
o
|
|
2102
|
+
] = await Promise.all([
|
|
2103
|
+
this.getCurrentLanguage(e),
|
|
2104
|
+
this.latestQuotaAndUsage(e),
|
|
2105
|
+
this.loadDescription(e),
|
|
2106
|
+
this.getUserProfile(),
|
|
2107
|
+
this.getBookmarks(e)
|
|
2108
|
+
]);
|
|
2109
|
+
return {
|
|
2110
|
+
user: e,
|
|
2111
|
+
quotaAndUsage: s,
|
|
2112
|
+
currentLanguage: t,
|
|
2113
|
+
userDescription: r,
|
|
2114
|
+
userProfile: i,
|
|
2115
|
+
bookmarkedApps: o
|
|
2116
|
+
};
|
|
2404
2117
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
_id: s.id,
|
|
2415
|
-
owner: "",
|
|
2416
|
-
ownerName: "",
|
|
2417
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2418
|
-
modified: s.name
|
|
2419
|
-
// FIXME date ?
|
|
2420
|
-
});
|
|
2118
|
+
login(e, t, s, r) {
|
|
2119
|
+
const i = new FormData();
|
|
2120
|
+
return i.append("email", e), i.append("password", t), typeof s < "u" && i.append("rememberMe", "" + s), typeof r < "u" && i.append("secureLocation", "" + r), this.http.post("/auth/login", i, {
|
|
2121
|
+
headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
2122
|
+
}).finally(() => {
|
|
2123
|
+
switch (this.http.latestResponse.status) {
|
|
2124
|
+
case 200:
|
|
2125
|
+
throw ERROR_CODE.MALFORMED_DATA;
|
|
2126
|
+
}
|
|
2421
2127
|
});
|
|
2422
2128
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
super(...arguments);
|
|
2427
|
-
u(this, "APP", "exercizer");
|
|
2428
|
-
u(this, "RESOURCE", "exercizer");
|
|
2429
|
-
}
|
|
2430
|
-
async loadResources() {
|
|
2431
|
-
return (await this.httpGet(
|
|
2432
|
-
"/exercizer/subjects-scheduled"
|
|
2433
|
-
)).map((s) => {
|
|
2434
|
-
const r = s.picture ? s.picture + "?thumbnail=48x48" : "/img/illustrations/exercizer.svg";
|
|
2435
|
-
let i, o = !1, a = JSON.parse(s.scheduled_at);
|
|
2436
|
-
return a.groupList.length > 0 ? (o = !0, i = a.groupList[0].name) : a.userList.length > 0 ? (o = !0, i = a.userList[0].name) : i = "", a.groupList.length + a.userList.length > 1 && (i += "..."), this.dataToResource({
|
|
2437
|
-
title: s.title,
|
|
2438
|
-
owner: s.owner,
|
|
2439
|
-
ownerName: i,
|
|
2440
|
-
icon: r,
|
|
2441
|
-
path: "/exercizer#/linker/" + s.id,
|
|
2442
|
-
_id: "" + s.id,
|
|
2443
|
-
shared: o,
|
|
2444
|
-
modified: s.modified
|
|
2445
|
-
});
|
|
2129
|
+
async logout() {
|
|
2130
|
+
const e = await this.conf.getLogoutCallback();
|
|
2131
|
+
return this.http.get("/auth/logout?callback=" + e).finally(() => {
|
|
2446
2132
|
});
|
|
2447
2133
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2134
|
+
async latestQuotaAndUsage(e) {
|
|
2135
|
+
const t = { quota: 0, storage: 0 };
|
|
2136
|
+
if (!e) return t;
|
|
2137
|
+
try {
|
|
2138
|
+
return await this.http.get(
|
|
2139
|
+
`/workspace/quota/user/${e == null ? void 0 : e.userId}`
|
|
2140
|
+
);
|
|
2141
|
+
} catch (s) {
|
|
2142
|
+
return console.error(s), t;
|
|
2143
|
+
}
|
|
2454
2144
|
}
|
|
2455
|
-
async
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
owner: s.owner_id,
|
|
2464
|
-
path: s.is_public ? `${window.location.origin}/formulaire-public#/form/${s.public_key}` : `${window.location.origin}/formulaire#/form/${s.id}/${s.rgpd ? "rgpd" : "new"}`,
|
|
2465
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2466
|
-
modified: "" + s.date_modification
|
|
2467
|
-
})));
|
|
2145
|
+
async getCurrentLanguage(e) {
|
|
2146
|
+
const t = (e == null ? void 0 : e.sessionMetadata) && (e == null ? void 0 : e.sessionMetadata.userId);
|
|
2147
|
+
try {
|
|
2148
|
+
let s;
|
|
2149
|
+
return t ? s = await this.loadUserLanguage() : s = await this.loadDefaultLanguage(), s;
|
|
2150
|
+
} catch (s) {
|
|
2151
|
+
console.error(s);
|
|
2152
|
+
}
|
|
2468
2153
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2154
|
+
async loadUserLanguage() {
|
|
2155
|
+
try {
|
|
2156
|
+
const e = await this.http.get(
|
|
2157
|
+
"/userbook/preference/language"
|
|
2158
|
+
);
|
|
2159
|
+
return JSON.parse(e.preference)["default-domain"];
|
|
2160
|
+
} catch {
|
|
2161
|
+
return await this.loadDefaultLanguage();
|
|
2162
|
+
}
|
|
2475
2163
|
}
|
|
2476
|
-
async
|
|
2477
|
-
return (await this.
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
owner: s.owner.userId,
|
|
2485
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2486
|
-
modified: s.modified
|
|
2487
|
-
})
|
|
2164
|
+
async loadDefaultLanguage() {
|
|
2165
|
+
return (await this.cache.httpGetJson(
|
|
2166
|
+
"/locale"
|
|
2167
|
+
)).locale;
|
|
2168
|
+
}
|
|
2169
|
+
async getUser() {
|
|
2170
|
+
const { response: e, value: t } = await this.cache.httpGet(
|
|
2171
|
+
"/auth/oauth2/userinfo"
|
|
2488
2172
|
);
|
|
2173
|
+
if (!(e.status < 200 || e.status >= 300) && typeof t == "object")
|
|
2174
|
+
return t;
|
|
2175
|
+
throw ERROR_CODE.NOT_LOGGED_IN;
|
|
2489
2176
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
u(this, "RESOURCE", "homeworks");
|
|
2177
|
+
hasWorkflow({
|
|
2178
|
+
workflowName: e,
|
|
2179
|
+
user: t
|
|
2180
|
+
}) {
|
|
2181
|
+
return e === void 0 || (t == null ? void 0 : t.authorizedActions.findIndex((s) => s.name === e)) !== -1;
|
|
2496
2182
|
}
|
|
2497
|
-
async
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2183
|
+
async loadDescription(e) {
|
|
2184
|
+
if (!e) return {};
|
|
2185
|
+
try {
|
|
2186
|
+
const [t, s] = await Promise.all([
|
|
2187
|
+
// FIXME The full user's description should be obtainable from a single endpoint in the backend.
|
|
2188
|
+
this.getUserProfile({
|
|
2189
|
+
options: { requestName: "refreshAvatar" }
|
|
2190
|
+
}),
|
|
2191
|
+
this.http.get("/directory/userbook/" + (e == null ? void 0 : e.userId))
|
|
2192
|
+
]);
|
|
2193
|
+
return { ...s, profiles: t };
|
|
2194
|
+
} catch (t) {
|
|
2195
|
+
return console.error(t), {};
|
|
2196
|
+
}
|
|
2508
2197
|
}
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2198
|
+
async getBookmarks(e) {
|
|
2199
|
+
if (!e) return [];
|
|
2200
|
+
const t = await this.http.get("/userbook/preference/apps");
|
|
2201
|
+
t.preference || (t.preference = null);
|
|
2202
|
+
const s = JSON.parse(t.preference);
|
|
2203
|
+
let r;
|
|
2204
|
+
r = s, r || (r = {
|
|
2205
|
+
bookmarks: [],
|
|
2206
|
+
applications: []
|
|
2207
|
+
});
|
|
2208
|
+
const i = [];
|
|
2209
|
+
return r.bookmarks.forEach((o, u) => {
|
|
2210
|
+
const c = ((e == null ? void 0 : e.apps) || []).find(
|
|
2211
|
+
(h) => h.name === o
|
|
2212
|
+
);
|
|
2213
|
+
if (c) {
|
|
2214
|
+
const h = Object.assign({}, c);
|
|
2215
|
+
i.push(h);
|
|
2216
|
+
}
|
|
2217
|
+
}), i;
|
|
2515
2218
|
}
|
|
2516
|
-
async
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
);
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2219
|
+
async getUserProfile(e = {}) {
|
|
2220
|
+
var c, h;
|
|
2221
|
+
const { options: t = {}, params: s = {} } = e, r = new URLSearchParams(s).toString(), i = `/userbook/api/person${r ? `?${r}` : ""}`, { response: o, value: u } = await this.cache.httpGet(i, t);
|
|
2222
|
+
return o.status < 200 || o.status >= 300 || typeof u == "string" ? ["Guest"] : ((h = (c = u == null ? void 0 : u.result) == null ? void 0 : c[0]) == null ? void 0 : h.type) || ["Guest"];
|
|
2223
|
+
}
|
|
2224
|
+
async isAdml() {
|
|
2225
|
+
const e = await this.getUser();
|
|
2226
|
+
return (e == null ? void 0 : e.functions.ADMIN_LOCAL) !== void 0;
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Get details of an application if the user can access it.
|
|
2230
|
+
* @return undefined if no access, or app not found
|
|
2231
|
+
*/
|
|
2232
|
+
async getWebApp(e) {
|
|
2233
|
+
const t = await this.getUser();
|
|
2234
|
+
return t == null ? void 0 : t.apps.find((s) => {
|
|
2235
|
+
var r;
|
|
2236
|
+
return s != null && s.prefix ? (s == null ? void 0 : s.prefix.replace("/", "")) === e || !1 : s != null && s.address && ((r = s.address) == null ? void 0 : r.split("/")[1]) === e || !1;
|
|
2237
|
+
});
|
|
2530
2238
|
}
|
|
2531
2239
|
}
|
|
2532
|
-
class
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
return
|
|
2540
|
-
(s) => this.dataToResource({
|
|
2541
|
-
title: s.name,
|
|
2542
|
-
ownerName: s.owner.displayName,
|
|
2543
|
-
owner: s.owner.userId,
|
|
2544
|
-
icon: s.thumbnail || "/img/illustrations/mindmap-default.png",
|
|
2545
|
-
path: "/mindmap#/view/" + s._id,
|
|
2546
|
-
_id: s._id,
|
|
2547
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2548
|
-
modified: s.modified
|
|
2549
|
-
})
|
|
2550
|
-
);
|
|
2240
|
+
class StringUtils {
|
|
2241
|
+
static removeAccents(e) {
|
|
2242
|
+
for (let t = 0; t < defaultDiacriticsRemovalMap.length; t++)
|
|
2243
|
+
e = e.replace(
|
|
2244
|
+
defaultDiacriticsRemovalMap[t].letters,
|
|
2245
|
+
defaultDiacriticsRemovalMap[t].base
|
|
2246
|
+
);
|
|
2247
|
+
return e;
|
|
2551
2248
|
}
|
|
2552
2249
|
}
|
|
2553
|
-
class
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2250
|
+
class ShareService {
|
|
2251
|
+
//
|
|
2252
|
+
// IMPLEMENTATION
|
|
2253
|
+
//
|
|
2254
|
+
constructor(e) {
|
|
2255
|
+
this.context = e;
|
|
2558
2256
|
}
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
return t.forEach((r) => {
|
|
2562
|
-
var o;
|
|
2563
|
-
const i = r.thumbnail ? r.thumbnail + "?thumbnail=48x48" : "/img/illustrations/pages.svg";
|
|
2564
|
-
s.push(
|
|
2565
|
-
this.dataToResource({
|
|
2566
|
-
title: r.title,
|
|
2567
|
-
owner: r.owner.userId,
|
|
2568
|
-
ownerName: r.owner.displayName,
|
|
2569
|
-
icon: i,
|
|
2570
|
-
path: "/pages#/website/" + r._id,
|
|
2571
|
-
_id: r._id,
|
|
2572
|
-
shared: typeof r.shared < "u",
|
|
2573
|
-
modified: r.modified
|
|
2574
|
-
})
|
|
2575
|
-
), (o = r.pages) == null || o.forEach((a) => {
|
|
2576
|
-
s.push(
|
|
2577
|
-
this.dataToResource({
|
|
2578
|
-
title: a.title,
|
|
2579
|
-
owner: r.owner.userId,
|
|
2580
|
-
ownerName: r.owner.displayName,
|
|
2581
|
-
icon: i,
|
|
2582
|
-
path: "/pages#/website/" + r._id + "/" + a.titleLink,
|
|
2583
|
-
_id: r._id + "/" + a.titleLink,
|
|
2584
|
-
shared: typeof r.shared < "u",
|
|
2585
|
-
modified: r.modified
|
|
2586
|
-
})
|
|
2587
|
-
);
|
|
2588
|
-
});
|
|
2589
|
-
}), s;
|
|
2257
|
+
get directory() {
|
|
2258
|
+
return this.context.directory();
|
|
2590
2259
|
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
constructor() {
|
|
2594
|
-
super(...arguments);
|
|
2595
|
-
u(this, "APP", "poll");
|
|
2596
|
-
u(this, "RESOURCE", "poll");
|
|
2260
|
+
get http() {
|
|
2261
|
+
return this.context.http();
|
|
2597
2262
|
}
|
|
2598
|
-
|
|
2599
|
-
return
|
|
2600
|
-
const r = s.icon ? s.icon + "?thumbnail=48x48" : "/img/icons/glyphicons_036_file.png";
|
|
2601
|
-
return this.dataToResource({
|
|
2602
|
-
title: s.question,
|
|
2603
|
-
ownerName: s.owner.displayName,
|
|
2604
|
-
icon: r,
|
|
2605
|
-
path: "/poll#/view/" + s._id,
|
|
2606
|
-
_id: s._id,
|
|
2607
|
-
owner: s.owner.userId,
|
|
2608
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2609
|
-
modified: s.modified
|
|
2610
|
-
});
|
|
2611
|
-
});
|
|
2263
|
+
get cache() {
|
|
2264
|
+
return this.context.cache();
|
|
2612
2265
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2266
|
+
async searchShareSubjects(e, t, s) {
|
|
2267
|
+
const r = StringUtils.removeAccents(s).toLowerCase(), i = await this.cache.httpGetJson(
|
|
2268
|
+
`/${e}/share/json/${t}?search=${s}`
|
|
2269
|
+
), o = i.users.visibles.filter(({ username: l, firstName: g, lastName: d, login: p }) => {
|
|
2270
|
+
const E = StringUtils.removeAccents(
|
|
2271
|
+
d || ""
|
|
2272
|
+
).toLowerCase(), A = StringUtils.removeAccents(
|
|
2273
|
+
g || ""
|
|
2274
|
+
).toLowerCase(), m = StringUtils.removeAccents(
|
|
2275
|
+
l || ""
|
|
2276
|
+
).toLowerCase(), w = StringUtils.removeAccents(p || "").toLowerCase();
|
|
2277
|
+
return m.includes(r) || A.includes(r) || E.includes(r) || w.includes(r);
|
|
2278
|
+
}).map((l) => ({
|
|
2279
|
+
avatarUrl: this.directory.getAvatarUrl(l.id, "user"),
|
|
2280
|
+
directoryUrl: this.directory.getDirectoryUrl(l.id, "user"),
|
|
2281
|
+
displayName: l.username,
|
|
2282
|
+
id: l.id,
|
|
2283
|
+
profile: l.profile,
|
|
2284
|
+
type: "user"
|
|
2285
|
+
})), u = i.groups.visibles.filter(({ name: l }) => StringUtils.removeAccents(l || "").toLowerCase().includes(r)).map((l) => ({
|
|
2286
|
+
avatarUrl: this.directory.getAvatarUrl(l.id, "group"),
|
|
2287
|
+
directoryUrl: this.directory.getDirectoryUrl(l.id, "group"),
|
|
2288
|
+
displayName: l.name,
|
|
2289
|
+
id: l.id,
|
|
2290
|
+
type: "group",
|
|
2291
|
+
structureName: l.structureName
|
|
2292
|
+
}));
|
|
2293
|
+
return [...(await this.directory.getBookMarks()).filter(({ displayName: l }) => StringUtils.removeAccents(
|
|
2294
|
+
l || ""
|
|
2295
|
+
).toLowerCase().includes(r)).map((l) => ({
|
|
2296
|
+
avatarUrl: "",
|
|
2297
|
+
directoryUrl: "",
|
|
2298
|
+
profile: "",
|
|
2299
|
+
displayName: l.displayName,
|
|
2300
|
+
id: l.id,
|
|
2301
|
+
type: "sharebookmark"
|
|
2302
|
+
})), ...o, ...u];
|
|
2619
2303
|
}
|
|
2620
|
-
async
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
)
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
path: "/scrapbook#/view-scrapbook/" + s._id,
|
|
2631
|
-
_id: s._id,
|
|
2632
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
2633
|
-
modified: s.modified
|
|
2634
|
-
});
|
|
2635
|
-
});
|
|
2304
|
+
async getShareMapping(e) {
|
|
2305
|
+
const t = await this.cache.httpGetJson(
|
|
2306
|
+
`/${e}/rights/sharing`
|
|
2307
|
+
);
|
|
2308
|
+
for (const s of Object.keys(t))
|
|
2309
|
+
if (s.includes(".")) {
|
|
2310
|
+
const r = s.split(".")[1], i = t[s];
|
|
2311
|
+
delete t[s], t[r] = i;
|
|
2312
|
+
}
|
|
2313
|
+
return t;
|
|
2636
2314
|
}
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2315
|
+
getActionsAvailableFor({ id: e, type: t }, s, r) {
|
|
2316
|
+
const o = (t === "user" ? s.users.checked[e] : s.groups.checked[e]) || [], u = Object.keys(r), c = [];
|
|
2317
|
+
for (const h of u)
|
|
2318
|
+
r[h].filter(
|
|
2319
|
+
(d) => o.includes(d)
|
|
2320
|
+
).length > 0 && c.push(h);
|
|
2321
|
+
return c;
|
|
2643
2322
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2323
|
+
async getRightsForResource(e, t) {
|
|
2324
|
+
const s = await this.directory.getBookMarks(), r = `/${e}/share/json/${t}?search=`, i = await this.cache.httpGetJson(r), o = await this.getShareMapping(e), u = await this.cache.httpGetJson(
|
|
2325
|
+
"/infra/public/json/sharing-rights.json"
|
|
2326
|
+
), c = Object.keys(i.users.checked).map((p) => i.users.visibles.find(
|
|
2327
|
+
(A) => A.id === p
|
|
2328
|
+
)).filter((p) => p !== void 0).map((p) => {
|
|
2329
|
+
const E = this.getActionsAvailableFor(
|
|
2330
|
+
{ id: p.id, type: "user" },
|
|
2331
|
+
i,
|
|
2332
|
+
o
|
|
2333
|
+
);
|
|
2334
|
+
return {
|
|
2335
|
+
id: p.id,
|
|
2336
|
+
type: "user",
|
|
2337
|
+
displayName: p.username,
|
|
2338
|
+
profile: p.profile,
|
|
2339
|
+
avatarUrl: this.directory.getAvatarUrl(p.id, "user"),
|
|
2340
|
+
directoryUrl: this.directory.getDirectoryUrl(p.id, "user"),
|
|
2341
|
+
actions: E.map((m) => {
|
|
2342
|
+
const w = u[m];
|
|
2343
|
+
return {
|
|
2344
|
+
displayName: m,
|
|
2345
|
+
id: m,
|
|
2346
|
+
priority: w.priority
|
|
2347
|
+
};
|
|
2348
|
+
})
|
|
2349
|
+
};
|
|
2350
|
+
}).sort((p, E) => (p.displayName || "").localeCompare(E.displayName)), h = Object.keys(i.groups.checked).map((p) => i.groups.visibles.find(
|
|
2351
|
+
(A) => A.id === p
|
|
2352
|
+
)).filter((p) => p !== void 0).map((p) => {
|
|
2353
|
+
const E = this.getActionsAvailableFor(
|
|
2354
|
+
{ id: p.id, type: "group" },
|
|
2355
|
+
i,
|
|
2356
|
+
o
|
|
2357
|
+
);
|
|
2358
|
+
return {
|
|
2359
|
+
id: p.id,
|
|
2360
|
+
type: "group",
|
|
2361
|
+
displayName: p.name,
|
|
2362
|
+
profile: void 0,
|
|
2363
|
+
avatarUrl: this.directory.getAvatarUrl(p.id, "group"),
|
|
2364
|
+
directoryUrl: this.directory.getDirectoryUrl(p.id, "group"),
|
|
2365
|
+
actions: E.map((m) => {
|
|
2366
|
+
const w = u[m];
|
|
2367
|
+
return {
|
|
2368
|
+
displayName: m,
|
|
2369
|
+
id: m,
|
|
2370
|
+
priority: w.priority
|
|
2371
|
+
};
|
|
2372
|
+
})
|
|
2373
|
+
};
|
|
2374
|
+
}).sort((p, E) => (p.displayName || "").localeCompare(E.displayName)), l = [...c, ...h], g = i.groups.visibles.map(
|
|
2375
|
+
({ groupDisplayName: p, id: E, name: A }) => ({
|
|
2376
|
+
displayName: p || A,
|
|
2377
|
+
id: E
|
|
2378
|
+
})
|
|
2379
|
+
), d = i.users.visibles.map(
|
|
2380
|
+
({ id: p, profile: E, username: A, firstName: m, lastName: w, login: C }) => ({
|
|
2381
|
+
displayName: A,
|
|
2382
|
+
firstName: m,
|
|
2383
|
+
lastName: w,
|
|
2384
|
+
login: C,
|
|
2385
|
+
profile: E,
|
|
2386
|
+
id: p
|
|
2387
|
+
})
|
|
2388
|
+
);
|
|
2389
|
+
return {
|
|
2390
|
+
rights: l,
|
|
2391
|
+
visibleBookmarks: s,
|
|
2392
|
+
visibleGroups: g,
|
|
2393
|
+
visibleUsers: d
|
|
2394
|
+
};
|
|
2667
2395
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2396
|
+
async saveRights(e, t, s) {
|
|
2397
|
+
const r = await this.getShareMapping(e), i = {
|
|
2398
|
+
bookmarks: {},
|
|
2399
|
+
groups: {},
|
|
2400
|
+
users: {}
|
|
2401
|
+
};
|
|
2402
|
+
for (const c of s) {
|
|
2403
|
+
const h = c.actions.map((g) => r[g.id]).reduce((g, d) => Array.isArray(d) ? [...g, ...d] : g, []), l = [...new Set(h)];
|
|
2404
|
+
l.length > 0 && (c.type === "user" ? i.users[c.id] = l : c.type === "group" ? i.groups[c.id] = l : i.bookmarks[c.id] = l);
|
|
2405
|
+
}
|
|
2406
|
+
const o = `/${e}/share/resource/${t}`;
|
|
2407
|
+
return this.cache.clearCache(`/${e}/share/json/${t}?search=`), await this.http.putJson(o, i);
|
|
2674
2408
|
}
|
|
2675
|
-
async
|
|
2676
|
-
|
|
2677
|
-
"/
|
|
2678
|
-
)
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
})
|
|
2409
|
+
async getActionsForApp(e) {
|
|
2410
|
+
const t = await this.cache.httpGetJson(
|
|
2411
|
+
"/infra/public/json/sharing-rights.json"
|
|
2412
|
+
), s = await this.getShareMapping(e);
|
|
2413
|
+
return Object.keys(t).map((i) => {
|
|
2414
|
+
const o = t[i];
|
|
2415
|
+
return {
|
|
2416
|
+
displayName: i,
|
|
2417
|
+
id: i,
|
|
2418
|
+
priority: o.priority,
|
|
2419
|
+
requires: o.requires
|
|
2420
|
+
};
|
|
2421
|
+
}).filter((i) => {
|
|
2422
|
+
var o;
|
|
2423
|
+
return ((o = s[i.id]) == null ? void 0 : o.length) > 0;
|
|
2424
|
+
}).sort((i, o) => i.priority - o.priority);
|
|
2691
2425
|
}
|
|
2692
2426
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
icon: h,
|
|
2711
|
-
path: `/workspace/document/${l._id}`,
|
|
2712
|
-
_id: l._id,
|
|
2713
|
-
shared: !!(l.shared && l.shared.length >= 0),
|
|
2714
|
-
modified: l.modified
|
|
2715
|
-
});
|
|
2716
|
-
});
|
|
2717
|
-
r(c);
|
|
2718
|
-
} catch (o) {
|
|
2719
|
-
i(o);
|
|
2720
|
-
}
|
|
2721
|
-
});
|
|
2427
|
+
const loadedScripts = {};
|
|
2428
|
+
axios.create({
|
|
2429
|
+
baseURL: "https://api.example.com",
|
|
2430
|
+
// Remplacez par l'URL de votre API
|
|
2431
|
+
timeout: 1e4,
|
|
2432
|
+
headers: {
|
|
2433
|
+
"Content-Type": "application/json"
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
class HttpService {
|
|
2437
|
+
constructor(e, t) {
|
|
2438
|
+
// Axios automatically manages the XSRF-TOKEN cookie and the X-XSRF-TOKEN HTTP header.
|
|
2439
|
+
a(this, "axios");
|
|
2440
|
+
a(this, "baseUrl");
|
|
2441
|
+
a(this, "headers", {});
|
|
2442
|
+
a(this, "_latestResponse");
|
|
2443
|
+
this.context = e, this.axios = axios.create(t);
|
|
2722
2444
|
}
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
static async initialize(e, t) {
|
|
2726
|
-
const s = e.http();
|
|
2727
|
-
if (!this.resourceProducingApps.length) {
|
|
2728
|
-
this.resourceProducingApps = [t, "workspace"];
|
|
2729
|
-
try {
|
|
2730
|
-
const [r, i] = await Promise.all([
|
|
2731
|
-
s.get("/resources-applications"),
|
|
2732
|
-
e.session().getUser()
|
|
2733
|
-
]);
|
|
2734
|
-
i != null && i.apps && (r != null && r.length) && (this.resourceProducingApps = r.filter(
|
|
2735
|
-
(o) => i.apps.some((a) => a.address.includes(o))
|
|
2736
|
-
));
|
|
2737
|
-
} catch (r) {
|
|
2738
|
-
console.warn("Failed to load resource-producing apps:", r);
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
return this.resourceProducingApps;
|
|
2445
|
+
fixBaseUrl(e) {
|
|
2446
|
+
return e.startsWith("http://") || e.startsWith("https://") ? e : this.baseUrl ? this.baseUrl.endsWith("/") || e.startsWith("/") ? `${this.baseUrl}${e}` : `${this.baseUrl}/${e}` : e;
|
|
2742
2447
|
}
|
|
2743
|
-
|
|
2744
|
-
this.
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2448
|
+
useAxiosInstance(e) {
|
|
2449
|
+
return this.axios = e, this;
|
|
2450
|
+
}
|
|
2451
|
+
useBaseUrl(e) {
|
|
2452
|
+
return this.baseUrl = e, this;
|
|
2453
|
+
}
|
|
2454
|
+
useHeaders(e) {
|
|
2455
|
+
return this.headers = e, this;
|
|
2456
|
+
}
|
|
2457
|
+
setCdn(e) {
|
|
2458
|
+
e && XMLHttpRequest && !XMLHttpRequest.prototype.cdnUrl && (XMLHttpRequest.prototype.cdnUrl = e, XMLHttpRequest.prototype.baseOpen = XMLHttpRequest.prototype.open, XMLHttpRequest.prototype.open = function() {
|
|
2459
|
+
const t = arguments[1];
|
|
2460
|
+
return t.startsWith("/infra/public") && (arguments[1] = e + t), /^\/([^\/]*)\/public/.test(t) && (arguments[1] = e + t), t.startsWith("/assets") && (arguments[1] = e + t), t == "/conf/public" && (arguments[1] = t), t.startsWith("http") && (arguments[1] = t), this.baseOpen.apply(this, arguments);
|
|
2750
2461
|
});
|
|
2751
2462
|
}
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
r = new WikiBehaviour(e);
|
|
2769
|
-
break;
|
|
2770
|
-
case "pages":
|
|
2771
|
-
r = new PagesBehaviour(e);
|
|
2772
|
-
break;
|
|
2773
|
-
case "poll":
|
|
2774
|
-
r = new PollBehaviour(e);
|
|
2775
|
-
break;
|
|
2776
|
-
case "community":
|
|
2777
|
-
r = new CommunityBehaviour(e);
|
|
2778
|
-
break;
|
|
2779
|
-
case "mindmap":
|
|
2780
|
-
r = new MindmapBehaviour(e);
|
|
2781
|
-
break;
|
|
2782
|
-
case "forum":
|
|
2783
|
-
r = new ForumBehaviour(e);
|
|
2784
|
-
break;
|
|
2785
|
-
case "homeworks":
|
|
2786
|
-
r = new HomeworksBehaviour(e);
|
|
2787
|
-
break;
|
|
2788
|
-
case "scrapbook":
|
|
2789
|
-
r = new ScrapbookBehaviour(e);
|
|
2790
|
-
break;
|
|
2791
|
-
case "collaborativewall":
|
|
2792
|
-
r = new CollaborativewallBehaviour(e);
|
|
2793
|
-
break;
|
|
2794
|
-
case "exercizer":
|
|
2795
|
-
r = new ExercizerBehaviour(e);
|
|
2796
|
-
break;
|
|
2797
|
-
case "formulaire":
|
|
2798
|
-
r = new FormulaireBehaviour(e);
|
|
2799
|
-
break;
|
|
2800
|
-
case "magneto":
|
|
2801
|
-
r = new MagnetoBehaviour(e);
|
|
2802
|
-
break;
|
|
2803
|
-
default:
|
|
2804
|
-
throw ERROR_CODE.NOT_SUPPORTED;
|
|
2463
|
+
// private toAxiosConfig(params?: IHttpParams): AxiosRequestConfig {
|
|
2464
|
+
toAxiosConfig(e) {
|
|
2465
|
+
if (e) {
|
|
2466
|
+
const t = Object.assign({}, this.axios.defaults);
|
|
2467
|
+
e.headers && (t.headers = Object.assign({}, this.axios.defaults.headers), Object.assign(t.headers, e.headers)), e.responseType && (t.responseType = e.responseType), e.queryParams && (t.params = Object.assign({}, e.queryParams));
|
|
2468
|
+
const s = t.headers ?? {};
|
|
2469
|
+
return t.headers = { ...s, ...this.headers }, t;
|
|
2470
|
+
} else
|
|
2471
|
+
return this.axios.defaults;
|
|
2472
|
+
}
|
|
2473
|
+
toCdnUrl(e) {
|
|
2474
|
+
e = this.fixBaseUrl(e);
|
|
2475
|
+
const t = this.context.conf().getCdnUrl() || "";
|
|
2476
|
+
if (t.length > 0 && e !== "/conf/public") {
|
|
2477
|
+
const s = "" + e;
|
|
2478
|
+
(s.startsWith("/infra/public") || s.startsWith("/assets") || /^\/([^\/]*)\/public/.test(s)) && (e = t + s);
|
|
2805
2479
|
}
|
|
2806
|
-
return
|
|
2480
|
+
return e;
|
|
2807
2481
|
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2482
|
+
mapAxiosError(e, t) {
|
|
2483
|
+
e.response ? this._latestResponse = e.response : e.request ? this._latestResponse = {
|
|
2484
|
+
status: 408,
|
|
2485
|
+
statusText: ERROR_CODE.TIME_OUT
|
|
2486
|
+
} : this._latestResponse = {
|
|
2487
|
+
status: 500,
|
|
2488
|
+
statusText: ERROR_CODE.UNKNOWN
|
|
2489
|
+
};
|
|
2490
|
+
const {
|
|
2491
|
+
/* status, statusText, headers, */
|
|
2492
|
+
data: s
|
|
2493
|
+
} = this._latestResponse;
|
|
2494
|
+
return s;
|
|
2820
2495
|
}
|
|
2821
|
-
|
|
2822
|
-
return this.
|
|
2496
|
+
mapAxiosResponse(e, t) {
|
|
2497
|
+
return this._latestResponse = e, e.data;
|
|
2823
2498
|
}
|
|
2824
|
-
get
|
|
2825
|
-
return this.
|
|
2499
|
+
get latestResponse() {
|
|
2500
|
+
return this._latestResponse;
|
|
2826
2501
|
}
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
(r) => SEND_ALL === r || e.data["event-type"] === r
|
|
2830
|
-
) >= 0 && this.http.post("/infra/event/web/store", e.data, {
|
|
2831
|
-
disableNotifications: !0
|
|
2832
|
-
});
|
|
2502
|
+
isResponseError() {
|
|
2503
|
+
return this.latestResponse.status < 200 || this.latestResponse.status >= 300;
|
|
2833
2504
|
}
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
(s) => this.dispatchEvent(s, t)
|
|
2505
|
+
async get(e, t) {
|
|
2506
|
+
try {
|
|
2507
|
+
const s = await this.axios.get(
|
|
2508
|
+
this.toCdnUrl(e),
|
|
2509
|
+
this.toAxiosConfig(t)
|
|
2840
2510
|
);
|
|
2511
|
+
return console.log({
|
|
2512
|
+
r: s,
|
|
2513
|
+
url: this.toCdnUrl(e),
|
|
2514
|
+
params: this.toAxiosConfig(t)
|
|
2515
|
+
}), this.mapAxiosResponse(s, t);
|
|
2516
|
+
} catch (s) {
|
|
2517
|
+
throw this.mapAxiosError(s, t);
|
|
2841
2518
|
}
|
|
2842
|
-
return this;
|
|
2843
2519
|
}
|
|
2844
|
-
|
|
2845
|
-
|
|
2520
|
+
async post(e, t, s) {
|
|
2521
|
+
try {
|
|
2522
|
+
const r = await this.axios.post(
|
|
2523
|
+
this.fixBaseUrl(e),
|
|
2524
|
+
t,
|
|
2525
|
+
this.toAxiosConfig(s)
|
|
2526
|
+
);
|
|
2527
|
+
return this.mapAxiosResponse(r, s);
|
|
2528
|
+
} catch (r) {
|
|
2529
|
+
throw this.mapAxiosError(r, s);
|
|
2530
|
+
}
|
|
2846
2531
|
}
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2532
|
+
async postFile(e, t, s) {
|
|
2533
|
+
const r = this.toAxiosConfig(s);
|
|
2534
|
+
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
2535
|
+
try {
|
|
2536
|
+
const i = await this.axios.post(this.fixBaseUrl(e), t, {
|
|
2537
|
+
...r,
|
|
2538
|
+
headers: {
|
|
2539
|
+
"Content-Type": "multipart/form-data"
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
return this.mapAxiosResponse(i, s);
|
|
2543
|
+
} catch (i) {
|
|
2544
|
+
throw this.mapAxiosError(i, s);
|
|
2545
|
+
}
|
|
2855
2546
|
}
|
|
2856
|
-
|
|
2857
|
-
|
|
2547
|
+
async postJson(e, t, s) {
|
|
2548
|
+
const r = this.toAxiosConfig();
|
|
2549
|
+
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
2550
|
+
try {
|
|
2551
|
+
const i = await this.axios.post(
|
|
2552
|
+
this.fixBaseUrl(e),
|
|
2553
|
+
t,
|
|
2554
|
+
this.toAxiosConfig(s)
|
|
2555
|
+
);
|
|
2556
|
+
return this.mapAxiosResponse(i, s);
|
|
2557
|
+
} catch (i) {
|
|
2558
|
+
throw this.mapAxiosError(i, s);
|
|
2559
|
+
}
|
|
2858
2560
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
2561
|
+
async put(e, t, s) {
|
|
2562
|
+
try {
|
|
2563
|
+
const r = await this.axios.put(
|
|
2564
|
+
this.fixBaseUrl(e),
|
|
2565
|
+
t,
|
|
2566
|
+
this.toAxiosConfig(s)
|
|
2567
|
+
);
|
|
2568
|
+
return this.mapAxiosResponse(r, s);
|
|
2569
|
+
} catch (r) {
|
|
2570
|
+
throw this.mapAxiosError(r, s);
|
|
2571
|
+
}
|
|
2861
2572
|
}
|
|
2862
|
-
|
|
2863
|
-
async initialize() {
|
|
2573
|
+
async putFile(e, t, s) {
|
|
2864
2574
|
try {
|
|
2865
|
-
const
|
|
2866
|
-
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2575
|
+
const r = this.toAxiosConfig(s);
|
|
2576
|
+
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
2577
|
+
const i = await this.axios.put(this.fixBaseUrl(e), t, {
|
|
2578
|
+
...r,
|
|
2579
|
+
headers: {
|
|
2580
|
+
"Content-Type": "multipart/form-data"
|
|
2581
|
+
}
|
|
2582
|
+
});
|
|
2583
|
+
return this.mapAxiosResponse(i, s);
|
|
2584
|
+
} catch (r) {
|
|
2585
|
+
throw this.mapAxiosError(r, s);
|
|
2871
2586
|
}
|
|
2872
2587
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2588
|
+
async putJson(e, t, s) {
|
|
2589
|
+
const r = this.toAxiosConfig(s);
|
|
2590
|
+
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
2591
|
+
try {
|
|
2592
|
+
const i = await this.axios.put(this.fixBaseUrl(e), t, r);
|
|
2593
|
+
return this.mapAxiosResponse(i, s);
|
|
2594
|
+
} catch (i) {
|
|
2595
|
+
throw this.mapAxiosError(i, s);
|
|
2596
|
+
}
|
|
2876
2597
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2598
|
+
async delete(e, t) {
|
|
2599
|
+
try {
|
|
2600
|
+
const s = await this.axios.delete(
|
|
2601
|
+
this.fixBaseUrl(e),
|
|
2602
|
+
this.toAxiosConfig(t)
|
|
2603
|
+
);
|
|
2604
|
+
return this.mapAxiosResponse(s, t);
|
|
2605
|
+
} catch (s) {
|
|
2606
|
+
throw this.mapAxiosError(s, t);
|
|
2607
|
+
}
|
|
2883
2608
|
}
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
duration: Math.round(t),
|
|
2894
|
-
weight: s,
|
|
2895
|
-
source: r ? "CAPTURED" : "UPLOADED",
|
|
2896
|
-
url: i
|
|
2897
|
-
});
|
|
2898
|
-
this.app && (c["override-module"] = this.app), a && (c.device_type = a), this.trackWebEvent(c);
|
|
2899
|
-
}
|
|
2900
|
-
trackVideoRead(e, t, s, r, i) {
|
|
2901
|
-
const o = this.addUserInfos({
|
|
2902
|
-
"event-type": "VIDEO_READ",
|
|
2903
|
-
module: "video",
|
|
2904
|
-
video_id: e,
|
|
2905
|
-
browser: r,
|
|
2906
|
-
source: t ? "CAPTURED" : "UPLOADED",
|
|
2907
|
-
url: s
|
|
2908
|
-
});
|
|
2909
|
-
this.app && (o["override-module"] = this.app), i && (o.device_type = i), this.trackWebEvent(o);
|
|
2609
|
+
async deleteJson(e, t) {
|
|
2610
|
+
try {
|
|
2611
|
+
const s = await this.axios.delete(this.fixBaseUrl(e), {
|
|
2612
|
+
data: t
|
|
2613
|
+
});
|
|
2614
|
+
return this.mapAxiosResponse(s);
|
|
2615
|
+
} catch (s) {
|
|
2616
|
+
throw this.mapAxiosError(s);
|
|
2617
|
+
}
|
|
2910
2618
|
}
|
|
2911
|
-
|
|
2912
|
-
const
|
|
2913
|
-
|
|
2914
|
-
|
|
2619
|
+
getScript(e, t, s) {
|
|
2620
|
+
const r = s ?? "exports", i = this.toAxiosConfig(t);
|
|
2621
|
+
return i.headers && (i.headers.Accept = "application/javascript"), this.axios.get(this.toCdnUrl(e), i).then((o) => this.mapAxiosResponse(o, t)).then((o) => {
|
|
2622
|
+
try {
|
|
2623
|
+
const u = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
|
|
2624
|
+
return Function(u)();
|
|
2625
|
+
} catch {
|
|
2626
|
+
return o;
|
|
2627
|
+
}
|
|
2628
|
+
}).catch((o) => {
|
|
2629
|
+
throw this.mapAxiosError(o, t), o;
|
|
2915
2630
|
});
|
|
2916
|
-
this.app && (t.module = this.app), this.trackWebEvent(t);
|
|
2917
2631
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2632
|
+
loadScript(e, t) {
|
|
2633
|
+
return loadedScripts[e] ? Promise.resolve() : this.getScript(e, t).then((s) => {
|
|
2634
|
+
loadedScripts[e] = !0;
|
|
2921
2635
|
});
|
|
2922
|
-
this.app && (e.module = this.app), this.trackWebEvent(e);
|
|
2923
2636
|
}
|
|
2924
|
-
}
|
|
2925
|
-
class
|
|
2926
|
-
|
|
2927
|
-
|
|
2637
|
+
}
|
|
2638
|
+
const R = class R {
|
|
2639
|
+
// in minutes. Applies to recorded videos.
|
|
2640
|
+
constructor(e) {
|
|
2641
|
+
this.context = e;
|
|
2928
2642
|
}
|
|
2929
2643
|
get http() {
|
|
2930
2644
|
return this.context.http();
|
|
2931
2645
|
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
const { "reaction-types": e } = await this.context.conf().getPublicConf("audience");
|
|
2935
|
-
return Array.isArray(e) ? e : void 0;
|
|
2936
|
-
} catch {
|
|
2937
|
-
console.error("Audience configuration not found");
|
|
2938
|
-
return;
|
|
2939
|
-
}
|
|
2646
|
+
get conf() {
|
|
2647
|
+
return this.context.conf();
|
|
2940
2648
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2649
|
+
/**
|
|
2650
|
+
* Returns the video app public conf (maxWeight, maxDuration and accepted extensions)
|
|
2651
|
+
* @returns the Video app public conf
|
|
2652
|
+
*/
|
|
2653
|
+
async getVideoConf() {
|
|
2654
|
+
var t;
|
|
2655
|
+
const e = await this.conf.getPublicConf(
|
|
2656
|
+
APP$2.VIDEO
|
|
2944
2657
|
);
|
|
2945
|
-
return
|
|
2658
|
+
return {
|
|
2659
|
+
maxWeight: (e == null ? void 0 : e["max-videosize-mbytes"]) ?? R.MAX_WEIGHT,
|
|
2660
|
+
maxDuration: (e == null ? void 0 : e["max-videoduration-minutes"]) ?? R.MAX_DURATION,
|
|
2661
|
+
acceptVideoUploadExtensions: ((t = e == null ? void 0 : e["accept-videoupload-extensions"]) == null ? void 0 : t.map(
|
|
2662
|
+
(s) => s.toUpperCase()
|
|
2663
|
+
)) ?? []
|
|
2664
|
+
};
|
|
2946
2665
|
}
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2666
|
+
/**
|
|
2667
|
+
* Starts the encoding process and check when video is fully processed.
|
|
2668
|
+
* @param params cf VideoUploadParams
|
|
2669
|
+
* @returns a VideoCheckResponse
|
|
2670
|
+
*/
|
|
2671
|
+
async upload({
|
|
2672
|
+
data: e,
|
|
2673
|
+
appCode: t,
|
|
2674
|
+
captation: s,
|
|
2675
|
+
duration: r
|
|
2676
|
+
}) {
|
|
2677
|
+
if (!e.file)
|
|
2678
|
+
throw new Error("Invalid video file.");
|
|
2679
|
+
if (!e.filename)
|
|
2680
|
+
throw new Error("Invalid video filename");
|
|
2681
|
+
const i = `${e.browser.name} ${e.browser.version}`, o = new FormData();
|
|
2682
|
+
o.append("device", e.device || ""), o.append("browser", i), o.append("url", e.url), o.append("app", t), o.append("file", e.file, e.filename), o.append("weight", "" + e.file.size), o.append("captation", "" + s);
|
|
2683
|
+
let u = `/video/encode?captation=${s}`;
|
|
2684
|
+
r && (u += `&duration=${r}`);
|
|
2685
|
+
const c = await this.http.post(
|
|
2686
|
+
u,
|
|
2687
|
+
o,
|
|
2688
|
+
{ headers: { "Content-Type": "multipart/form-data" } }
|
|
2950
2689
|
);
|
|
2951
|
-
|
|
2690
|
+
if (c.state == "running") {
|
|
2691
|
+
let h = 0, l = 1;
|
|
2692
|
+
do {
|
|
2693
|
+
const g = l + h;
|
|
2694
|
+
await new Promise(
|
|
2695
|
+
(p) => setTimeout(p, g * 1e3)
|
|
2696
|
+
), h = l, l = Math.min(8, g);
|
|
2697
|
+
const d = await this.http.get(
|
|
2698
|
+
`/video/status/${c.processid}`
|
|
2699
|
+
);
|
|
2700
|
+
if (d.state == "succeed")
|
|
2701
|
+
return d;
|
|
2702
|
+
if (d.state == "error")
|
|
2703
|
+
break;
|
|
2704
|
+
} while (!0);
|
|
2705
|
+
}
|
|
2706
|
+
throw new Error("Video cannot be uploaded.");
|
|
2952
2707
|
}
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2708
|
+
};
|
|
2709
|
+
a(R, "MAX_WEIGHT", 50), // in Mbytes. Applies to uploaded videos.
|
|
2710
|
+
a(R, "MAX_DURATION", 3);
|
|
2711
|
+
let VideoService = R;
|
|
2712
|
+
const defaultMappers = {
|
|
2713
|
+
csv: function({ type: n, extension: e }) {
|
|
2714
|
+
return MimeTypeUtils.INSTANCE.isCsvLike(n, e);
|
|
2715
|
+
},
|
|
2716
|
+
doc: function({ type: n, extension: e }) {
|
|
2717
|
+
return MimeTypeUtils.INSTANCE.isWordLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("wordprocessing") !== -1;
|
|
2718
|
+
},
|
|
2719
|
+
xls: function({ type: n, extension: e }) {
|
|
2720
|
+
return MimeTypeUtils.INSTANCE.isExcelLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("spreadsheet") !== -1 || n.indexOf("ms-excel") !== -1;
|
|
2721
|
+
},
|
|
2722
|
+
img: function({ type: n }) {
|
|
2723
|
+
return n.indexOf("image") !== -1;
|
|
2724
|
+
},
|
|
2725
|
+
pdf: function({ type: n }) {
|
|
2726
|
+
return n.indexOf("pdf") !== -1 || n === "application/x-download";
|
|
2727
|
+
},
|
|
2728
|
+
ppt: function({ type: n, extension: e }) {
|
|
2729
|
+
return MimeTypeUtils.INSTANCE.isPowerpointLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("presentation") !== -1 || n.indexOf("powerpoint") !== -1;
|
|
2730
|
+
},
|
|
2731
|
+
txt: function({ type: n, extension: e }) {
|
|
2732
|
+
return MimeTypeUtils.INSTANCE.isTxtLike(n, e);
|
|
2733
|
+
},
|
|
2734
|
+
md: function({ type: n, extension: e }) {
|
|
2735
|
+
return MimeTypeUtils.INSTANCE.isMdLike(n, e);
|
|
2736
|
+
},
|
|
2737
|
+
video: function({ type: n }) {
|
|
2738
|
+
return n.indexOf("video") !== -1;
|
|
2739
|
+
},
|
|
2740
|
+
audio: function({ type: n }) {
|
|
2741
|
+
return n.indexOf("audio") !== -1;
|
|
2742
|
+
},
|
|
2743
|
+
zip: function({ type: n }) {
|
|
2744
|
+
return n.indexOf("zip") !== -1 || n.indexOf("rar") !== -1 || n.indexOf("tar") !== -1 || n.indexOf("7z") !== -1;
|
|
2957
2745
|
}
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2746
|
+
}, b = class b {
|
|
2747
|
+
/* Similar role notion as in infra-front > workspace > Model.ts */
|
|
2748
|
+
static getRole(e) {
|
|
2749
|
+
var t, s;
|
|
2750
|
+
return b.role(
|
|
2751
|
+
(t = e.metadata) == null ? void 0 : t["content-type"],
|
|
2752
|
+
!1,
|
|
2753
|
+
(s = e.metadata) == null ? void 0 : s.extension
|
|
2965
2754
|
);
|
|
2966
2755
|
}
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2756
|
+
/* Similar role notion as in infra-front > workspace > Model.ts */
|
|
2757
|
+
static role(e, t = !1, s) {
|
|
2758
|
+
if (s && (s = s.trim()), !e) return "unknown";
|
|
2759
|
+
this.roleMappers || console.warn("[DocumentHelper.role] should not have empty roles", this);
|
|
2760
|
+
const r = { type: e, previewRole: t, extension: s };
|
|
2761
|
+
for (const i of this.roleMappers) {
|
|
2762
|
+
const o = i(r);
|
|
2763
|
+
if (o)
|
|
2764
|
+
return o;
|
|
2765
|
+
}
|
|
2766
|
+
return "unknown";
|
|
2975
2767
|
}
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2768
|
+
};
|
|
2769
|
+
// FIXME add edumedia support
|
|
2770
|
+
a(b, "roleMappers", [
|
|
2771
|
+
(e) => Object.keys(defaultMappers).find((s) => defaultMappers[s](e))
|
|
2772
|
+
]);
|
|
2773
|
+
let DocumentHelper = b;
|
|
2774
|
+
class WorkspaceService {
|
|
2775
|
+
constructor(e) {
|
|
2776
|
+
this.context = e;
|
|
2980
2777
|
}
|
|
2981
2778
|
get http() {
|
|
2982
2779
|
return this.context.http();
|
|
2983
2780
|
}
|
|
2984
|
-
|
|
2985
|
-
const t =
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2781
|
+
extractMetadata(e) {
|
|
2782
|
+
const t = e.name || "", s = t.split("."), r = e.type || "application/octet-stream", i = s.length > 1 ? s[s.length - 1] : "", o = {
|
|
2783
|
+
"content-type": r,
|
|
2784
|
+
filename: t,
|
|
2785
|
+
size: e.size,
|
|
2786
|
+
extension: i,
|
|
2787
|
+
role: DocumentHelper.role(r, !1, i)
|
|
2788
|
+
}, u = t.replace("." + o.extension, ""), c = o.extension ? u + "." + o.extension : u;
|
|
2789
|
+
return { basename: u, fullname: c, metadata: o };
|
|
2989
2790
|
}
|
|
2990
|
-
async
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2791
|
+
async saveFile(e, t) {
|
|
2792
|
+
const { fullname: s, metadata: r } = this.extractMetadata(e), i = new FormData();
|
|
2793
|
+
i.append("file", e, s);
|
|
2794
|
+
const o = [];
|
|
2795
|
+
((t == null ? void 0 : t.visibility) === "public" || (t == null ? void 0 : t.visibility) === "protected") && o.push(`${t.visibility}=true`), t != null && t.application && o.push(`application=${t.application}`), r.role === "img" && o.push("quality=1"), t != null && t.parentId && o.push(`parentId=${t.parentId}`);
|
|
2796
|
+
const u = await this.http.postFile(
|
|
2797
|
+
`/workspace/document?${o.join("&")}`,
|
|
2798
|
+
i
|
|
2993
2799
|
);
|
|
2994
|
-
|
|
2800
|
+
if (this.http.isResponseError())
|
|
2801
|
+
throw this.http.latestResponse.statusText;
|
|
2802
|
+
return u;
|
|
2995
2803
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2804
|
+
async updateFile(e, t, s) {
|
|
2805
|
+
const { fullname: r, metadata: i } = this.extractMetadata(t), o = new FormData();
|
|
2806
|
+
o.append("file", t, r);
|
|
2807
|
+
const u = [];
|
|
2808
|
+
i.role === "img" && u.push("quality=1"), s != null && s.alt && u.push(`alt=${s.alt}`), s != null && s.legend && u.push(`legend=${s.legend}`), s != null && s.name && u.push(`name=${s.name}`);
|
|
2809
|
+
const c = await this.http.putFile(
|
|
2810
|
+
`/workspace/document/${e}?${u.join("&")}`,
|
|
2811
|
+
o
|
|
2999
2812
|
);
|
|
2813
|
+
if (this.http.isResponseError())
|
|
2814
|
+
throw this.http.latestResponse.statusText;
|
|
2815
|
+
return c;
|
|
3000
2816
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
2817
|
+
async deleteFile(e) {
|
|
2818
|
+
const t = e.map((s) => s._id);
|
|
2819
|
+
if (t.length == 0)
|
|
2820
|
+
Promise.resolve(null);
|
|
2821
|
+
else if (await this.http.deleteJson("/workspace/documents", {
|
|
2822
|
+
ids: t
|
|
2823
|
+
}), this.http.isResponseError())
|
|
2824
|
+
throw this.http.latestResponse.statusText;
|
|
3005
2825
|
}
|
|
3006
|
-
|
|
3007
|
-
|
|
2826
|
+
async acceptDocuments(e) {
|
|
2827
|
+
const t = await this.context.session().getUser();
|
|
2828
|
+
return (s) => s.deleted && s.trasher ? (t == null ? void 0 : t.userId) == s.trasher : !0;
|
|
3008
2829
|
}
|
|
3009
|
-
|
|
3010
|
-
|
|
2830
|
+
async searchDocuments(e) {
|
|
2831
|
+
const t = e.filter !== "external" || e.parentId ? await this.http.get("/workspace/documents", {
|
|
2832
|
+
queryParams: { ...e, _: (/* @__PURE__ */ new Date()).getTime() }
|
|
2833
|
+
}) : [], s = await this.acceptDocuments(e);
|
|
2834
|
+
return t.filter(s);
|
|
2835
|
+
}
|
|
2836
|
+
async listDocuments(e, t) {
|
|
2837
|
+
return this.searchDocuments({ filter: e, parentId: t, includeall: !0 });
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Duplicate and transfers documents if needed to a different folder with the specified application and visibility.
|
|
2841
|
+
* @param documents - The array of documents to transfer.
|
|
2842
|
+
* @param application - The application to associate with the transferred documents.
|
|
2843
|
+
* @param visibility - The visibility of the transferred documents. Defaults to "protected".
|
|
2844
|
+
* @returns A Promise that resolves to an array of transferred WorkspaceElements.
|
|
2845
|
+
*/
|
|
2846
|
+
async transferDocuments(e, t, s = "protected") {
|
|
2847
|
+
const r = [];
|
|
2848
|
+
if (e.forEach((i) => {
|
|
2849
|
+
(s === "public" && !i.public || !i.public && !i.protected) && r.push(i);
|
|
2850
|
+
}), r.length > 0) {
|
|
2851
|
+
const i = await this.http.post(
|
|
2852
|
+
"/workspace/documents/transfer",
|
|
2853
|
+
{
|
|
2854
|
+
application: t,
|
|
2855
|
+
visibility: s,
|
|
2856
|
+
ids: r.map((o) => o._id)
|
|
2857
|
+
}
|
|
2858
|
+
);
|
|
2859
|
+
if (this.http.isResponseError())
|
|
2860
|
+
throw this.http.latestResponse.statusText;
|
|
2861
|
+
return r.forEach((o, u) => {
|
|
2862
|
+
const c = e.findIndex(
|
|
2863
|
+
(h) => h._id === o._id
|
|
2864
|
+
);
|
|
2865
|
+
0 <= c && c < e.length && (e[c] = i[u]);
|
|
2866
|
+
}), e.filter((o) => !!o);
|
|
2867
|
+
}
|
|
2868
|
+
return e;
|
|
2869
|
+
}
|
|
2870
|
+
/**
|
|
2871
|
+
* Get the URL of the thumbnail of a workspace element (or its URL),
|
|
2872
|
+
* or `null` if none exists or can be created.
|
|
2873
|
+
*/
|
|
2874
|
+
getThumbnailUrl(e, t = 0, s = 0) {
|
|
2875
|
+
var i, o;
|
|
2876
|
+
const r = t > 0 || s > 0 ? `${t}x${s}` : "120x120";
|
|
2877
|
+
if (typeof e == "string")
|
|
2878
|
+
return e.includes("data:image") || e.includes("thumbnail") ? e : `${e}${e.includes("?") ? "&" : "?"}thumbnail=${r}`;
|
|
2879
|
+
{
|
|
2880
|
+
const u = `/workspace/${e.public ? "pub/" : ""}document/${e._id}?thumbnail=`, c = e.thumbnails;
|
|
2881
|
+
if ((o = (i = e.metadata) == null ? void 0 : i["content-type"]) != null && o.includes("video")) {
|
|
2882
|
+
const h = c && Object.keys(c).length > 0 ? Object.keys(c)[0] : null;
|
|
2883
|
+
return h ? u + h : null;
|
|
2884
|
+
} else
|
|
2885
|
+
return u + r;
|
|
2886
|
+
}
|
|
3011
2887
|
}
|
|
3012
2888
|
}
|
|
3013
2889
|
class OdeServices {
|
|
3014
2890
|
constructor() {
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this.
|
|
2891
|
+
a(this, "_analytics");
|
|
2892
|
+
a(this, "_cache");
|
|
2893
|
+
a(this, "_conf");
|
|
2894
|
+
// private _data: DataService;
|
|
2895
|
+
a(this, "_directory");
|
|
2896
|
+
a(this, "_http");
|
|
2897
|
+
a(this, "_idiom");
|
|
2898
|
+
// private _notify: INotifyFramework;
|
|
2899
|
+
a(this, "_rights");
|
|
2900
|
+
a(this, "_session");
|
|
2901
|
+
a(this, "_share");
|
|
2902
|
+
a(this, "_video");
|
|
2903
|
+
a(this, "_workspace");
|
|
2904
|
+
a(this, "_embedder");
|
|
2905
|
+
this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this._directory = new DirectoryService(this), this._http = new HttpService(this), this._idiom = new IdiomService(this), this._rights = new RightService(this), this._session = new SessionService(this), this._share = new ShareService(this), this._video = new VideoService(this), this._workspace = new WorkspaceService(this), this._embedder = new EmbedderService(this);
|
|
3030
2906
|
}
|
|
3031
2907
|
initialize() {
|
|
3032
|
-
return this
|
|
2908
|
+
return this;
|
|
3033
2909
|
}
|
|
3034
2910
|
analytics() {
|
|
3035
2911
|
return this._analytics;
|
|
@@ -3043,9 +2919,9 @@ class OdeServices {
|
|
|
3043
2919
|
conf() {
|
|
3044
2920
|
return this._conf;
|
|
3045
2921
|
}
|
|
3046
|
-
data() {
|
|
2922
|
+
/* data() {
|
|
3047
2923
|
return this._data;
|
|
3048
|
-
}
|
|
2924
|
+
} */
|
|
3049
2925
|
directory() {
|
|
3050
2926
|
return this._directory;
|
|
3051
2927
|
}
|
|
@@ -3055,9 +2931,9 @@ class OdeServices {
|
|
|
3055
2931
|
idiom() {
|
|
3056
2932
|
return this._idiom;
|
|
3057
2933
|
}
|
|
3058
|
-
notify() {
|
|
2934
|
+
/* notify() {
|
|
3059
2935
|
return this._notify;
|
|
3060
|
-
}
|
|
2936
|
+
} */
|
|
3061
2937
|
resource(e, t) {
|
|
3062
2938
|
return t ? ResourceService.findService({ application: e, resourceType: t }, this) : ResourceService.findMainService({ application: e }, this);
|
|
3063
2939
|
}
|
|
@@ -3196,11 +3072,8 @@ export {
|
|
|
3196
3072
|
BOOLEAN_FILTER,
|
|
3197
3073
|
DocumentHelper,
|
|
3198
3074
|
ERROR_CODE,
|
|
3199
|
-
EVENT_NAME,
|
|
3200
3075
|
FOLDER,
|
|
3201
|
-
LAYER_NAME,
|
|
3202
3076
|
LastInfosWidget,
|
|
3203
|
-
NotifyFrameworkFactory,
|
|
3204
3077
|
ReactionTypes,
|
|
3205
3078
|
ResourceService,
|
|
3206
3079
|
SORT_BY,
|