@edifice.io/client 2.5.22-develop-b2school.20260608181736 → 2.5.22-develop-b2school.20260622143038
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/apps/timeline/interfaces.d.ts +36 -17
- package/dist/index.cjs +1 -1
- package/dist/index.js +2121 -2092
- package/dist/services/OdeServices.d.ts +15 -11
- package/dist/services/index.d.ts +1 -0
- package/dist/session/Service.d.ts +1 -0
- package/dist/session/interfaces.d.ts +5 -2
- package/dist/widget/Service.d.ts +13 -0
- package/dist/widget/interfaces.d.ts +0 -1
- package/package.json +5 -6
- package/dist/widget/LastInfos.widget.d.ts +0 -15
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (n, e, t) =>
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var I = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var u = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
import { MimeTypeUtils } from "@edifice.io/utilities";
|
|
6
6
|
import { UAParser } from "ua-parser-js";
|
|
@@ -1082,9 +1082,9 @@ class Analytics {
|
|
|
1082
1082
|
const t = await notify.onSessionReady().promise, s = session.session.description;
|
|
1083
1083
|
let r;
|
|
1084
1084
|
for (const l of t.structures) {
|
|
1085
|
-
const
|
|
1086
|
-
if (
|
|
1087
|
-
r =
|
|
1085
|
+
const h = e.structureMap[l];
|
|
1086
|
+
if (h && h.collectiviteId && h.UAI) {
|
|
1087
|
+
r = h;
|
|
1088
1088
|
break;
|
|
1089
1089
|
}
|
|
1090
1090
|
}
|
|
@@ -1096,10 +1096,10 @@ class Analytics {
|
|
|
1096
1096
|
const o = i.xiti;
|
|
1097
1097
|
if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
|
|
1098
1098
|
function a(l) {
|
|
1099
|
-
let
|
|
1099
|
+
let h = "";
|
|
1100
1100
|
for (let E = 0; E < l.length; E++)
|
|
1101
|
-
|
|
1102
|
-
return
|
|
1101
|
+
h += l.charCodeAt(E);
|
|
1102
|
+
return h;
|
|
1103
1103
|
}
|
|
1104
1104
|
const c = {
|
|
1105
1105
|
Student: "ELEVE",
|
|
@@ -1635,22 +1635,27 @@ const m = class m {
|
|
|
1635
1635
|
u(m, "registry", new ServiceRegistry()), // Expose some useful functions
|
|
1636
1636
|
u(m, "register", m.registry.register.bind(m.registry)), u(m, "findService", m.registry.findService.bind(m.registry)), u(m, "findMainService", m.registry.findMainService.bind(m.registry)), u(m, "isRegistered", m.registry.isRegistered.bind(m.registry));
|
|
1637
1637
|
let ResourceService = m;
|
|
1638
|
-
const APP$3 = "
|
|
1639
|
-
class
|
|
1640
|
-
create(e) {
|
|
1641
|
-
|
|
1638
|
+
const APP$3 = "collaborativeeditor", RESOURCE$3 = "collaborativeeditor";
|
|
1639
|
+
class CollaborativeEditorResourceService extends ResourceService {
|
|
1640
|
+
async create(e) {
|
|
1641
|
+
const { name: t, description: s, thumbnail: r, folder: i } = e, o = r ? await this.getThumbnailPath(r) : "", a = await this.http.post("/collaborativeeditor", {
|
|
1642
|
+
name: t,
|
|
1643
|
+
description: s,
|
|
1644
|
+
thumbnail: o,
|
|
1645
|
+
folder: i
|
|
1646
|
+
});
|
|
1647
|
+
return this.checkHttpResponse(a), a;
|
|
1642
1648
|
}
|
|
1643
1649
|
async update(e) {
|
|
1644
|
-
const t = await this.getThumbnailPath(
|
|
1645
|
-
`/
|
|
1650
|
+
const { name: t, description: s, thumbnail: r, entId: i } = e, o = await this.getThumbnailPath(r), a = await this.http.put(
|
|
1651
|
+
`/collaborativeeditor/${i}`,
|
|
1646
1652
|
{
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
subTitle: e.description
|
|
1653
|
+
name: t,
|
|
1654
|
+
description: s,
|
|
1655
|
+
thumbnail: o
|
|
1651
1656
|
}
|
|
1652
1657
|
);
|
|
1653
|
-
return this.checkHttpResponse(
|
|
1658
|
+
return this.checkHttpResponse(a), { thumbnail: o, entId: i };
|
|
1654
1659
|
}
|
|
1655
1660
|
getResourceType() {
|
|
1656
1661
|
return RESOURCE$3;
|
|
@@ -1658,25 +1663,25 @@ class ScrapbookResourceService extends ResourceService {
|
|
|
1658
1663
|
getApplication() {
|
|
1659
1664
|
return APP$3;
|
|
1660
1665
|
}
|
|
1661
|
-
getFormUrl(
|
|
1662
|
-
|
|
1666
|
+
getFormUrl() {
|
|
1667
|
+
throw new Error("Method not implemented.");
|
|
1663
1668
|
}
|
|
1664
1669
|
getViewUrl(e) {
|
|
1665
|
-
return `/
|
|
1670
|
+
return `/collaborativeeditor#/view/${e}`;
|
|
1666
1671
|
}
|
|
1667
|
-
getPrintUrl(
|
|
1668
|
-
|
|
1672
|
+
getPrintUrl() {
|
|
1673
|
+
throw new Error("Method not implemented.");
|
|
1669
1674
|
}
|
|
1670
|
-
getEditUrl(
|
|
1671
|
-
|
|
1675
|
+
getEditUrl() {
|
|
1676
|
+
throw new Error("Method not implemented.");
|
|
1672
1677
|
}
|
|
1673
|
-
getExportUrl(
|
|
1674
|
-
|
|
1678
|
+
getExportUrl() {
|
|
1679
|
+
throw new Error("Method not implemented.");
|
|
1675
1680
|
}
|
|
1676
1681
|
}
|
|
1677
1682
|
ResourceService.register(
|
|
1678
1683
|
{ application: RESOURCE$3, resourceType: RESOURCE$3 },
|
|
1679
|
-
(n) => new
|
|
1684
|
+
(n) => new CollaborativeEditorResourceService(n)
|
|
1680
1685
|
);
|
|
1681
1686
|
const APP$2 = "homeworks", RESOURCE$2 = "homeworks";
|
|
1682
1687
|
class HomeworksResourceService extends ResourceService {
|
|
@@ -1728,31 +1733,19 @@ ResourceService.register(
|
|
|
1728
1733
|
{ application: RESOURCE$2, resourceType: RESOURCE$2 },
|
|
1729
1734
|
(n) => new HomeworksResourceService(n)
|
|
1730
1735
|
);
|
|
1731
|
-
const APP$1 = "
|
|
1732
|
-
class
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
"/timelinegenerator/timelines",
|
|
1736
|
-
{
|
|
1737
|
-
headline: e.name,
|
|
1738
|
-
text: e.description,
|
|
1739
|
-
icon: t,
|
|
1740
|
-
type: "default",
|
|
1741
|
-
folder: e.folder
|
|
1742
|
-
}
|
|
1743
|
-
);
|
|
1744
|
-
return this.checkHttpResponse(s), s;
|
|
1736
|
+
const APP$1 = "scrapbook", RESOURCE$1 = "scrapbook";
|
|
1737
|
+
class ScrapbookResourceService extends ResourceService {
|
|
1738
|
+
create(e) {
|
|
1739
|
+
throw new Error("Method not implemented.");
|
|
1745
1740
|
}
|
|
1746
1741
|
async update(e) {
|
|
1747
1742
|
const t = await this.getThumbnailPath(e.thumbnail), s = await this.http.put(
|
|
1748
|
-
`/
|
|
1743
|
+
`/scrapbook/${e.entId}`,
|
|
1749
1744
|
{
|
|
1750
|
-
|
|
1751
|
-
|
|
1745
|
+
trashed: e.trashed ? 1 : 0,
|
|
1746
|
+
title: e.name,
|
|
1752
1747
|
icon: t,
|
|
1753
|
-
|
|
1754
|
-
_id: e.entId,
|
|
1755
|
-
type: "default"
|
|
1748
|
+
subTitle: e.description
|
|
1756
1749
|
}
|
|
1757
1750
|
);
|
|
1758
1751
|
return this.checkHttpResponse(s), { thumbnail: t, entId: e.entId };
|
|
@@ -1763,47 +1756,54 @@ class TimelineGeneratorResourceService extends ResourceService {
|
|
|
1763
1756
|
getApplication() {
|
|
1764
1757
|
return APP$1;
|
|
1765
1758
|
}
|
|
1766
|
-
getFormUrl() {
|
|
1767
|
-
|
|
1759
|
+
getFormUrl(e) {
|
|
1760
|
+
return e ? `/scrapbook?folderid=${e}#/create-scrapbook/` : "/scrapbook#/create-scrapbook/";
|
|
1768
1761
|
}
|
|
1769
1762
|
getViewUrl(e) {
|
|
1770
|
-
return `/
|
|
1763
|
+
return `/scrapbook#/view-scrapbook/${e}`;
|
|
1771
1764
|
}
|
|
1772
1765
|
getPrintUrl(e) {
|
|
1773
|
-
return `/
|
|
1766
|
+
return `/scrapbook/print#/print-scrapbook/${e}`;
|
|
1774
1767
|
}
|
|
1775
|
-
getEditUrl() {
|
|
1776
|
-
|
|
1768
|
+
getEditUrl(e) {
|
|
1769
|
+
return `/scrapbook#/edit-scrapbook/${e}`;
|
|
1777
1770
|
}
|
|
1778
|
-
getExportUrl() {
|
|
1779
|
-
|
|
1771
|
+
getExportUrl(e) {
|
|
1772
|
+
return `/scrapbook/exportHtml/${e}`;
|
|
1780
1773
|
}
|
|
1781
1774
|
}
|
|
1782
1775
|
ResourceService.register(
|
|
1783
1776
|
{ application: RESOURCE$1, resourceType: RESOURCE$1 },
|
|
1784
|
-
(n) => new
|
|
1777
|
+
(n) => new ScrapbookResourceService(n)
|
|
1785
1778
|
);
|
|
1786
|
-
const APP = "
|
|
1787
|
-
class
|
|
1779
|
+
const APP = "timelinegenerator", RESOURCE = "timelinegenerator";
|
|
1780
|
+
class TimelineGeneratorResourceService extends ResourceService {
|
|
1788
1781
|
async create(e) {
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1782
|
+
const t = e.thumbnail ? await this.getThumbnailPath(e.thumbnail) : "", s = await this.http.post(
|
|
1783
|
+
"/timelinegenerator/timelines",
|
|
1784
|
+
{
|
|
1785
|
+
headline: e.name,
|
|
1786
|
+
text: e.description,
|
|
1787
|
+
icon: t,
|
|
1788
|
+
type: "default",
|
|
1789
|
+
folder: e.folder
|
|
1790
|
+
}
|
|
1791
|
+
);
|
|
1792
|
+
return this.checkHttpResponse(s), s;
|
|
1796
1793
|
}
|
|
1797
1794
|
async update(e) {
|
|
1798
|
-
const
|
|
1799
|
-
`/
|
|
1795
|
+
const t = await this.getThumbnailPath(e.thumbnail), s = await this.http.put(
|
|
1796
|
+
`/timelinegenerator/timeline/${e.entId}`,
|
|
1800
1797
|
{
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1798
|
+
headline: e.name,
|
|
1799
|
+
text: e.description,
|
|
1800
|
+
icon: t,
|
|
1801
|
+
trashed: !!e.trashed,
|
|
1802
|
+
_id: e.entId,
|
|
1803
|
+
type: "default"
|
|
1804
1804
|
}
|
|
1805
1805
|
);
|
|
1806
|
-
return this.checkHttpResponse(
|
|
1806
|
+
return this.checkHttpResponse(s), { thumbnail: t, entId: e.entId };
|
|
1807
1807
|
}
|
|
1808
1808
|
getResourceType() {
|
|
1809
1809
|
return RESOURCE;
|
|
@@ -1815,10 +1815,10 @@ class CollaborativeEditorResourceService extends ResourceService {
|
|
|
1815
1815
|
throw new Error("Method not implemented.");
|
|
1816
1816
|
}
|
|
1817
1817
|
getViewUrl(e) {
|
|
1818
|
-
return `/
|
|
1818
|
+
return `/timelinegenerator#/view/${e}`;
|
|
1819
1819
|
}
|
|
1820
|
-
getPrintUrl() {
|
|
1821
|
-
|
|
1820
|
+
getPrintUrl(e) {
|
|
1821
|
+
return `/timelinegenerator/print#/print/${e}`;
|
|
1822
1822
|
}
|
|
1823
1823
|
getEditUrl() {
|
|
1824
1824
|
throw new Error("Method not implemented.");
|
|
@@ -1829,77 +1829,283 @@ class CollaborativeEditorResourceService extends ResourceService {
|
|
|
1829
1829
|
}
|
|
1830
1830
|
ResourceService.register(
|
|
1831
1831
|
{ application: RESOURCE, resourceType: RESOURCE },
|
|
1832
|
-
(n) => new
|
|
1832
|
+
(n) => new TimelineGeneratorResourceService(n)
|
|
1833
1833
|
);
|
|
1834
|
-
|
|
1835
|
-
class
|
|
1836
|
-
constructor(
|
|
1837
|
-
this.context =
|
|
1834
|
+
let ATTag;
|
|
1835
|
+
class AnalyticsService {
|
|
1836
|
+
constructor(n) {
|
|
1837
|
+
this.context = n;
|
|
1838
1838
|
}
|
|
1839
1839
|
get http() {
|
|
1840
1840
|
return this.context.http();
|
|
1841
1841
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
return globalCache[e];
|
|
1845
|
-
try {
|
|
1846
|
-
const r = t();
|
|
1847
|
-
mutexPromise[e] = r;
|
|
1848
|
-
const i = await r;
|
|
1849
|
-
return s(i) && (globalCache[e] = i), i;
|
|
1850
|
-
} catch (r) {
|
|
1851
|
-
throw console.error(`Failed to retrieve value for: ${e}`, r), r;
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
clearCache(e) {
|
|
1855
|
-
if (e)
|
|
1856
|
-
delete globalCache[e];
|
|
1857
|
-
else
|
|
1858
|
-
for (const t in globalCache)
|
|
1859
|
-
globalCache.hasOwnProperty(t) && delete globalCache[t];
|
|
1842
|
+
get session() {
|
|
1843
|
+
return this.context.session();
|
|
1860
1844
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1845
|
+
/**
|
|
1846
|
+
* Xiti tracker for page loading.
|
|
1847
|
+
* @param locationPath
|
|
1848
|
+
* @param app
|
|
1849
|
+
*/
|
|
1850
|
+
async trackPageLoad(n, e) {
|
|
1851
|
+
const [t] = await Promise.all([
|
|
1852
|
+
// get Xiti configuration
|
|
1853
|
+
this.getXitiConfig(e.name.toLowerCase()),
|
|
1854
|
+
// load Xiti javascript file
|
|
1855
|
+
this.loadXitiScript()
|
|
1856
|
+
]);
|
|
1857
|
+
if (!t || !ATInternet) return;
|
|
1858
|
+
let s = t.LIBELLE_SERVICE.default || null;
|
|
1859
|
+
for (const r in t.LIBELLE_SERVICE)
|
|
1860
|
+
if (r !== "default" && n.indexOf(r) >= 0) {
|
|
1861
|
+
s = t.LIBELLE_SERVICE[r];
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
ATTag = new ATInternet.Tracker.Tag({ site: t.STRUCT_ID }), ATTag.setProps(
|
|
1865
|
+
{
|
|
1866
|
+
SERVICE: s,
|
|
1867
|
+
TYPE: t.TYPE,
|
|
1868
|
+
OUTIL: t.OUTIL,
|
|
1869
|
+
UAI: t.STRUCT_UAI,
|
|
1870
|
+
PROJET: t.PROJET,
|
|
1871
|
+
EXPLOITANT: t.EXPLOITANT,
|
|
1872
|
+
PLATEFORME: t.PLATFORME,
|
|
1873
|
+
PROFIL: t.PROFILE
|
|
1867
1874
|
},
|
|
1868
|
-
|
|
1869
|
-
)
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
constructor(e) {
|
|
1880
|
-
this.context = e;
|
|
1881
|
-
}
|
|
1882
|
-
get http() {
|
|
1883
|
-
return this.context.http();
|
|
1884
|
-
}
|
|
1885
|
-
get cache() {
|
|
1886
|
-
return this.context.cache();
|
|
1875
|
+
!0
|
|
1876
|
+
), ATTag.identifiedVisitor.set({
|
|
1877
|
+
id: t.ID_PERSO,
|
|
1878
|
+
category: t.PROFILE
|
|
1879
|
+
}), ATTag.page.set({
|
|
1880
|
+
name: (e == null ? void 0 : e.prefix) === "userbook" ? "directory" : e == null ? void 0 : e.prefix,
|
|
1881
|
+
chapter1: "",
|
|
1882
|
+
chapter2: "",
|
|
1883
|
+
chapter3: "",
|
|
1884
|
+
level2: t.STRUCT_UAI
|
|
1885
|
+
}), ATTag.dispatch();
|
|
1887
1886
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1887
|
+
async getXitiConfig(n) {
|
|
1888
|
+
const [e, t] = await Promise.all([
|
|
1889
|
+
this.http.get("/analyticsConf"),
|
|
1890
|
+
//FIXME change servers config to only keep the "all-in-one" query to /analyticsConf.
|
|
1891
|
+
this.http.get("/xiti/config")
|
|
1892
|
+
]);
|
|
1893
|
+
if (!(e != null && e.type))
|
|
1894
|
+
throw ERROR_CODE.MALFORMED_DATA;
|
|
1895
|
+
return t != null && t.active && (e.xiti = await this.getXitiTrackingParams(t, n)), e.xiti;
|
|
1890
1896
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1897
|
+
async loadXitiScript() {
|
|
1898
|
+
if (typeof ATInternet > "u") {
|
|
1899
|
+
const scriptPath = "/xiti/public/js/lib/smarttag_ENT.js", response = await this.http.get(scriptPath, {
|
|
1900
|
+
headers: { Accept: "application/javascript" }
|
|
1901
|
+
});
|
|
1902
|
+
if (this.http.latestResponse.status != 200)
|
|
1903
|
+
throw "Error while loading XiTi script";
|
|
1904
|
+
eval(response);
|
|
1905
|
+
}
|
|
1893
1906
|
}
|
|
1894
|
-
async
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1907
|
+
async getXitiTrackingParams(n, e) {
|
|
1908
|
+
if (!n.structureMap || !e) return;
|
|
1909
|
+
const t = await this.session.getUser(), s = await this.session.getUserProfile();
|
|
1910
|
+
let r;
|
|
1911
|
+
if (!(t != null && t.structures)) return;
|
|
1912
|
+
for (const l of t.structures) {
|
|
1913
|
+
const h = n.structureMap[l];
|
|
1914
|
+
if (h && h.collectiviteId && h.UAI) {
|
|
1915
|
+
r = h;
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
if (!r || !r.active) return;
|
|
1920
|
+
const i = await configure.Platform.apps.getPublicConf(e);
|
|
1921
|
+
if (!i) return;
|
|
1922
|
+
const o = i.xiti;
|
|
1923
|
+
if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
|
|
1924
|
+
function a(l) {
|
|
1925
|
+
let h = "";
|
|
1926
|
+
for (let E = 0; E < l.length; E++)
|
|
1927
|
+
h += l.charCodeAt(E);
|
|
1928
|
+
return h;
|
|
1929
|
+
}
|
|
1930
|
+
const c = {
|
|
1931
|
+
Student: "ELEVE",
|
|
1932
|
+
Teacher: "ENSEIGNANT",
|
|
1933
|
+
Relative: "PARENT",
|
|
1934
|
+
Personnel: "ADMIN_VIE_SCOL_TECH",
|
|
1935
|
+
Guest: "AUTRE"
|
|
1936
|
+
};
|
|
1937
|
+
return {
|
|
1938
|
+
LIBELLE_SERVICE: o.LIBELLE_SERVICE,
|
|
1939
|
+
// Which property of LIBELLE_SERVICE to use depends on the frontend.
|
|
1940
|
+
TYPE: o.OUTIL ? "TIERS" : "NATIF",
|
|
1941
|
+
OUTIL: o.OUTIL ? o.OUTIL : "",
|
|
1942
|
+
STRUCT_ID: r.collectiviteId,
|
|
1943
|
+
STRUCT_UAI: r.UAI,
|
|
1944
|
+
PROJET: r.projetId ? r.projetId : n.ID_PROJET,
|
|
1945
|
+
EXPLOITANT: n.ID_EXPLOITANT,
|
|
1946
|
+
PLATFORME: r.plateformeId ? r.plateformeId : n.ID_PLATEFORME,
|
|
1947
|
+
ID_PERSO: a(t.userId),
|
|
1948
|
+
PROFILE: s && s.length > 0 ? c[s[0]] ?? "" : ""
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
class ReactionsService {
|
|
1953
|
+
constructor(e, t, s) {
|
|
1954
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
1955
|
+
}
|
|
1956
|
+
get http() {
|
|
1957
|
+
return this.context.http();
|
|
1958
|
+
}
|
|
1959
|
+
async loadAvailableReactions() {
|
|
1960
|
+
try {
|
|
1961
|
+
const { "reaction-types": e } = await this.context.conf().getPublicConf("audience");
|
|
1962
|
+
return Array.isArray(e) ? e : void 0;
|
|
1963
|
+
} catch {
|
|
1964
|
+
console.error("Audience configuration not found");
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
async loadReactionSummaries(e) {
|
|
1969
|
+
const t = await this.http.get(
|
|
1970
|
+
`/audience/reactions/${this.module}/${this.resourceType}?resourceIds=${e.join(",")}`
|
|
1971
|
+
);
|
|
1972
|
+
return this.http.isResponseError() ? {} : t.reactionsByResource;
|
|
1973
|
+
}
|
|
1974
|
+
async loadReactionDetails(e, t, s) {
|
|
1975
|
+
const r = await this.http.get(
|
|
1976
|
+
`/audience/reactions/${this.module}/${this.resourceType}/${e}?page=${t}&size=${s}`
|
|
1977
|
+
);
|
|
1978
|
+
return this.http.isResponseError() ? void 0 : r;
|
|
1979
|
+
}
|
|
1980
|
+
async deleteReaction(e) {
|
|
1981
|
+
await this.http.delete(
|
|
1982
|
+
`/audience/reactions/${this.module}/${this.resourceType}/${e}`
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
async updateReaction(e, t) {
|
|
1986
|
+
await this.http.putJson(
|
|
1987
|
+
`/audience/reactions/${this.module}/${this.resourceType}`,
|
|
1988
|
+
{
|
|
1989
|
+
resourceId: e,
|
|
1990
|
+
reactionType: t
|
|
1991
|
+
}
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
async createReaction(e, t) {
|
|
1995
|
+
await this.http.postJson(
|
|
1996
|
+
`/audience/reactions/${this.module}/${this.resourceType}`,
|
|
1997
|
+
{
|
|
1998
|
+
resourceId: e,
|
|
1999
|
+
reactionType: t
|
|
2000
|
+
}
|
|
2001
|
+
);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
class ViewsService {
|
|
2005
|
+
constructor(e, t, s) {
|
|
2006
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
2007
|
+
}
|
|
2008
|
+
get http() {
|
|
2009
|
+
return this.context.http();
|
|
2010
|
+
}
|
|
2011
|
+
async getCounters(e) {
|
|
2012
|
+
const t = await this.http.get(
|
|
2013
|
+
`/audience/views/count/${this.module}/${this.resourceType}?resourceIds=${e.join(",")}`
|
|
2014
|
+
);
|
|
2015
|
+
return this.http.isResponseError() ? {} : t;
|
|
2016
|
+
}
|
|
2017
|
+
async getDetails(e) {
|
|
2018
|
+
const t = await this.http.get(
|
|
2019
|
+
`/audience/views/details/${this.module}/${this.resourceType}/${e}`
|
|
2020
|
+
);
|
|
2021
|
+
return this.http.isResponseError() ? void 0 : t;
|
|
2022
|
+
}
|
|
2023
|
+
trigger(e) {
|
|
2024
|
+
return this.http.post(
|
|
2025
|
+
`/audience/views/${this.module}/${this.resourceType}/${e}`
|
|
2026
|
+
);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
class AudienceService {
|
|
2030
|
+
constructor(e, t, s) {
|
|
2031
|
+
this.context = e, this.module = t, this.resourceType = s;
|
|
2032
|
+
}
|
|
2033
|
+
get views() {
|
|
2034
|
+
return new ViewsService(this.context, this.module, this.resourceType);
|
|
2035
|
+
}
|
|
2036
|
+
get reactions() {
|
|
2037
|
+
return new ReactionsService(this.context, this.module, this.resourceType);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
const globalCache = {}, mutexPromise = {};
|
|
2041
|
+
class CacheService {
|
|
2042
|
+
constructor(e) {
|
|
2043
|
+
this.context = e;
|
|
2044
|
+
}
|
|
2045
|
+
get http() {
|
|
2046
|
+
return this.context.http();
|
|
2047
|
+
}
|
|
2048
|
+
async fromCacheIfPossible(e, t, s) {
|
|
2049
|
+
if (mutexPromise[e] !== void 0 && await mutexPromise[e], globalCache[e])
|
|
2050
|
+
return globalCache[e];
|
|
2051
|
+
try {
|
|
2052
|
+
const r = t();
|
|
2053
|
+
mutexPromise[e] = r;
|
|
2054
|
+
const i = await r;
|
|
2055
|
+
return s(i) && (globalCache[e] = i), i;
|
|
2056
|
+
} catch (r) {
|
|
2057
|
+
throw console.error(`Failed to retrieve value for: ${e}`, r), r;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
clearCache(e) {
|
|
2061
|
+
if (e)
|
|
2062
|
+
delete globalCache[e];
|
|
2063
|
+
else
|
|
2064
|
+
for (const t in globalCache)
|
|
2065
|
+
globalCache.hasOwnProperty(t) && delete globalCache[t];
|
|
2066
|
+
}
|
|
2067
|
+
async httpGet(e, t) {
|
|
2068
|
+
return this.fromCacheIfPossible(
|
|
2069
|
+
e,
|
|
2070
|
+
async () => {
|
|
2071
|
+
const s = await this.http.get(e, t), r = { ...this.http.latestResponse };
|
|
2072
|
+
return { value: s, response: r };
|
|
2073
|
+
},
|
|
2074
|
+
({ response: s }) => !(s.status < 200 || s.status >= 300)
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
async httpGetJson(e, t) {
|
|
2078
|
+
const { response: s, value: r } = await this.httpGet(e, t);
|
|
2079
|
+
if (s.status < 200 || s.status >= 300)
|
|
2080
|
+
throw `Bad http status (${s.status}) for url: ${e}`;
|
|
2081
|
+
return r;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
class ConfService {
|
|
2085
|
+
constructor(e) {
|
|
2086
|
+
this.context = e;
|
|
2087
|
+
}
|
|
2088
|
+
get http() {
|
|
2089
|
+
return this.context.http();
|
|
2090
|
+
}
|
|
2091
|
+
get cache() {
|
|
2092
|
+
return this.context.cache();
|
|
2093
|
+
}
|
|
2094
|
+
get cdnDomain() {
|
|
2095
|
+
return configure.Platform.cdnDomain;
|
|
2096
|
+
}
|
|
2097
|
+
get notify() {
|
|
2098
|
+
return this.context.notify();
|
|
2099
|
+
}
|
|
2100
|
+
async getConf(e) {
|
|
2101
|
+
const [t, s] = await Promise.all([
|
|
2102
|
+
this.getThemeConf(),
|
|
2103
|
+
this.getApplicationsList()
|
|
2104
|
+
]), [r, i] = await Promise.all([
|
|
2105
|
+
this.getTheme({ conf: t, publicTheme: s === void 0 }),
|
|
2106
|
+
this.getWebAppConf({ app: e, applications: s ?? [] })
|
|
2107
|
+
]), o = {
|
|
2108
|
+
app: e,
|
|
1903
2109
|
applications: s ?? [],
|
|
1904
2110
|
conf: t,
|
|
1905
2111
|
currentApp: i,
|
|
@@ -1959,17 +2165,17 @@ class ConfService {
|
|
|
1959
2165
|
}) {
|
|
1960
2166
|
var E;
|
|
1961
2167
|
const r = await this.http.get("/theme"), i = (E = t == null ? void 0 : t.overriding) == null ? void 0 : E.find(
|
|
1962
|
-
(
|
|
2168
|
+
(p) => (
|
|
1963
2169
|
// Fix #WB2-2660:
|
|
1964
2170
|
// If Public access => get the neo theme
|
|
1965
2171
|
// Else get the theme from the user preference
|
|
1966
|
-
s ?
|
|
2172
|
+
s ? p.parent === "theme-open-ent" && p.bootstrapVersion === "ode-bootstrap-neo" : p.child === (r == null ? void 0 : r.themeName)
|
|
1967
2173
|
)
|
|
1968
|
-
), o = s ? "default" : (r == null ? void 0 : r.skinName) || (i == null ? void 0 : i.skins[0]), a = (r == null ? void 0 : r.skin) || `/assets/themes/${i == null ? void 0 : i.child}/skins/${o}/`, c = i == null ? void 0 : i.skins, l = i == null ? void 0 : i.bootstrapVersion.split("-").slice(-1)[0],
|
|
2174
|
+
), o = s ? "default" : (r == null ? void 0 : r.skinName) || (i == null ? void 0 : i.skins[0]), a = (r == null ? void 0 : r.skin) || `/assets/themes/${i == null ? void 0 : i.child}/skins/${o}/`, c = i == null ? void 0 : i.skins, l = i == null ? void 0 : i.bootstrapVersion.split("-").slice(-1)[0], h = (i == null ? void 0 : i.parent) === "panda";
|
|
1969
2175
|
return {
|
|
1970
2176
|
basePath: `${this.cdnDomain}${a}../../`,
|
|
1971
2177
|
bootstrapVersion: l,
|
|
1972
|
-
is1d:
|
|
2178
|
+
is1d: h,
|
|
1973
2179
|
logoutCallback: (r == null ? void 0 : r.logoutCallback) || "",
|
|
1974
2180
|
skin: i == null ? void 0 : i.child,
|
|
1975
2181
|
skinName: o,
|
|
@@ -1988,54 +2194,165 @@ class ConfService {
|
|
|
1988
2194
|
return s.logoutCallback;
|
|
1989
2195
|
}
|
|
1990
2196
|
}
|
|
1991
|
-
|
|
2197
|
+
const SEND_ALL = "*";
|
|
2198
|
+
class WebBroker {
|
|
1992
2199
|
constructor(e) {
|
|
2200
|
+
u(this, "subscription");
|
|
1993
2201
|
this.odeServices = e;
|
|
1994
2202
|
}
|
|
1995
2203
|
get http() {
|
|
1996
2204
|
return this.odeServices.http();
|
|
1997
2205
|
}
|
|
1998
|
-
get
|
|
1999
|
-
return this.odeServices.
|
|
2206
|
+
get events() {
|
|
2207
|
+
return this.odeServices.notify().events();
|
|
2000
2208
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2209
|
+
dispatchEvent(e, t) {
|
|
2210
|
+
t.findIndex(
|
|
2211
|
+
(r) => SEND_ALL === r || e.data["event-type"] === r
|
|
2212
|
+
) >= 0 && this.http.post("/infra/event/web/store", e.data, {
|
|
2213
|
+
disableNotifications: !0
|
|
2214
|
+
});
|
|
2003
2215
|
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2216
|
+
initialize(e) {
|
|
2217
|
+
if (e === void 0 || e.send === void 0 || e.send.length > 0) {
|
|
2218
|
+
const t = (e == null ? void 0 : e.send) ?? [SEND_ALL];
|
|
2219
|
+
this.subscription = this.events.subscribe(
|
|
2220
|
+
LAYER_NAME.WEB_DATA,
|
|
2221
|
+
(s) => this.dispatchEvent(s, t)
|
|
2222
|
+
);
|
|
2223
|
+
}
|
|
2224
|
+
return this;
|
|
2006
2225
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
"/directory/sharebookmark/all"
|
|
2010
|
-
)).map(({ id: t, name: s }) => ({
|
|
2011
|
-
id: t,
|
|
2012
|
-
displayName: s,
|
|
2013
|
-
members: []
|
|
2014
|
-
// this api does not return members
|
|
2015
|
-
}));
|
|
2226
|
+
destroy() {
|
|
2227
|
+
this.subscription && (this.subscription.revoke(), delete this.subscription);
|
|
2016
2228
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
);
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2229
|
+
}
|
|
2230
|
+
class DataService {
|
|
2231
|
+
constructor(e) {
|
|
2232
|
+
u(this, "_webBroker");
|
|
2233
|
+
u(this, "app");
|
|
2234
|
+
u(this, "user");
|
|
2235
|
+
u(this, "profile");
|
|
2236
|
+
this.odeServices = e;
|
|
2237
|
+
}
|
|
2238
|
+
get conf() {
|
|
2239
|
+
return this.odeServices.conf();
|
|
2240
|
+
}
|
|
2241
|
+
get notify() {
|
|
2242
|
+
return this.odeServices.notify();
|
|
2243
|
+
}
|
|
2244
|
+
// This method is called once, by the service container.
|
|
2245
|
+
async initialize() {
|
|
2246
|
+
try {
|
|
2247
|
+
const { app: e } = await this.notify.onAppConfReady().promise;
|
|
2248
|
+
this.app = e, this.user = await this.odeServices.session().getUser(), this.profile = await this.odeServices.session().getUserProfile();
|
|
2249
|
+
const { ["data-service"]: t } = await this.conf.getPublicConf(e);
|
|
2250
|
+
this._webBroker = new WebBroker(this.odeServices).initialize(t == null ? void 0 : t.web);
|
|
2251
|
+
} catch {
|
|
2252
|
+
console.log("DataService not initialized, usage data unavailable.");
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
//FIXME When to call that ??
|
|
2256
|
+
predestroy() {
|
|
2257
|
+
this._webBroker && (this._webBroker.destroy(), delete this._webBroker);
|
|
2258
|
+
}
|
|
2259
|
+
/** Send a web-user-level event to the data pipeline. */
|
|
2260
|
+
trackWebEvent(e) {
|
|
2261
|
+
this.notify.events().publish(LAYER_NAME.WEB_DATA, {
|
|
2262
|
+
name: EVENT_NAME.DATA_TRACKED,
|
|
2263
|
+
data: e
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
addUserInfos(e) {
|
|
2267
|
+
return this.user && (e.userId = this.user.userId, e.structure = this.user.structureNames[0]), this.profile && (e.profil = this.profile[0]), e;
|
|
2268
|
+
}
|
|
2269
|
+
trackVideoSave(e, t, s, r, i, o, a) {
|
|
2270
|
+
const c = this.addUserInfos({
|
|
2271
|
+
"event-type": "VIDEO_SAVE",
|
|
2272
|
+
module: this.app || "video",
|
|
2273
|
+
video_id: e,
|
|
2274
|
+
browser: o,
|
|
2275
|
+
duration: Math.round(t),
|
|
2276
|
+
weight: s,
|
|
2277
|
+
source: r ? "CAPTURED" : "UPLOADED",
|
|
2278
|
+
url: i
|
|
2279
|
+
});
|
|
2280
|
+
a && (c.device_type = a), this.trackWebEvent(c);
|
|
2281
|
+
}
|
|
2282
|
+
trackVideoRead(e, t, s, r, i) {
|
|
2283
|
+
const o = this.addUserInfos({
|
|
2284
|
+
"event-type": "VIDEO_READ",
|
|
2285
|
+
module: "video",
|
|
2286
|
+
video_id: e,
|
|
2287
|
+
browser: r,
|
|
2288
|
+
source: t ? "CAPTURED" : "UPLOADED",
|
|
2289
|
+
url: s
|
|
2290
|
+
});
|
|
2291
|
+
this.app && (o["override-module"] = this.app), i && (o.device_type = i), this.trackWebEvent(o);
|
|
2292
|
+
}
|
|
2293
|
+
trackSpeechAndText(e) {
|
|
2294
|
+
const t = this.addUserInfos({
|
|
2295
|
+
"event-type": "SPEECH_AND_TEXT",
|
|
2296
|
+
function: e
|
|
2297
|
+
});
|
|
2298
|
+
this.app && (t.module = this.app), this.trackWebEvent(t);
|
|
2299
|
+
}
|
|
2300
|
+
trackAccessLibraryFromExplorer() {
|
|
2301
|
+
const e = this.addUserInfos({
|
|
2302
|
+
"event-type": "ACCESS_LIBRARY_FROM_EXPLORER"
|
|
2303
|
+
});
|
|
2304
|
+
this.app && (e.module = this.app), this.trackWebEvent(e);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
class DirectoryService {
|
|
2308
|
+
constructor(e) {
|
|
2309
|
+
this.odeServices = e;
|
|
2310
|
+
}
|
|
2311
|
+
get http() {
|
|
2312
|
+
return this.odeServices.http();
|
|
2313
|
+
}
|
|
2314
|
+
get cache() {
|
|
2315
|
+
return this.odeServices.cache();
|
|
2316
|
+
}
|
|
2317
|
+
getAvatarUrl(e, t, s = "100x100") {
|
|
2318
|
+
return t === "user" ? `/userbook/avatar/${e}?thumbnail=${s}` : "/assets/img/illustrations/group-avatar.svg";
|
|
2319
|
+
}
|
|
2320
|
+
getDirectoryUrl(e, t) {
|
|
2321
|
+
return t === "user" ? `/userbook/annuaire#/${e}` : `/userbook/annuaire#/group-view/${e}`;
|
|
2322
|
+
}
|
|
2323
|
+
async getBookMarks() {
|
|
2324
|
+
return (await this.cache.httpGetJson(
|
|
2325
|
+
"/directory/sharebookmark/all"
|
|
2326
|
+
)).map(({ id: t, name: s }) => ({
|
|
2327
|
+
id: t,
|
|
2328
|
+
displayName: s,
|
|
2329
|
+
notVisibleCount: 0,
|
|
2330
|
+
members: []
|
|
2331
|
+
// this api does not return members
|
|
2332
|
+
}));
|
|
2333
|
+
}
|
|
2334
|
+
async getBookMarkById(e) {
|
|
2335
|
+
const { groups: t, id: s, name: r, users: i, notVisibleCount: o } = await this.http.get(
|
|
2336
|
+
`/directory/sharebookmark/${e}`
|
|
2337
|
+
);
|
|
2338
|
+
return {
|
|
2339
|
+
id: s,
|
|
2340
|
+
displayName: r,
|
|
2341
|
+
notVisibleCount: o,
|
|
2342
|
+
groups: t.map(({ name: a, id: c, nbUsers: l }) => ({
|
|
2343
|
+
nbUsers: l,
|
|
2344
|
+
displayName: a,
|
|
2345
|
+
id: c
|
|
2346
|
+
})),
|
|
2347
|
+
users: i.map(({ displayName: a, id: c, profile: l }) => ({
|
|
2348
|
+
profile: l,
|
|
2349
|
+
displayName: a,
|
|
2350
|
+
// these info are missing from api
|
|
2351
|
+
firstName: "",
|
|
2352
|
+
lastName: "",
|
|
2353
|
+
login: "",
|
|
2354
|
+
id: c
|
|
2355
|
+
}))
|
|
2039
2356
|
};
|
|
2040
2357
|
}
|
|
2041
2358
|
async saveBookmarks(e, {
|
|
@@ -2044,598 +2361,116 @@ class DirectoryService {
|
|
|
2044
2361
|
users: r
|
|
2045
2362
|
}) {
|
|
2046
2363
|
this.cache.clearCache("/directory/sharebookmark/all");
|
|
2047
|
-
const i = r.map((
|
|
2048
|
-
if (typeof
|
|
2049
|
-
const { displayName: y, groups: d, id: g,
|
|
2364
|
+
const i = r.map((p) => typeof p == "string" ? p : p.id), o = s.map((p) => typeof p == "string" ? p : p.id), a = t.map(async (p) => {
|
|
2365
|
+
if (typeof p == "string") {
|
|
2366
|
+
const { displayName: y, groups: d, id: g, notVisibleCount: A, users: f } = await this.getBookMarkById(p), w = f.map((D) => D.id), F = d.map((D) => D.id);
|
|
2050
2367
|
return {
|
|
2051
2368
|
displayName: y,
|
|
2052
2369
|
id: g,
|
|
2053
|
-
|
|
2370
|
+
notVisibleCount: A,
|
|
2371
|
+
members: [...F, ...w]
|
|
2054
2372
|
};
|
|
2055
2373
|
} else
|
|
2056
|
-
return Promise.resolve(
|
|
2057
|
-
}), l = (await Promise.all(a)).map((
|
|
2374
|
+
return Promise.resolve(p);
|
|
2375
|
+
}), l = (await Promise.all(a)).map((p) => p.members).reduce((p, y) => [...p, ...y], []), h = {
|
|
2058
2376
|
name: e,
|
|
2059
2377
|
members: [...i, ...o, ...l]
|
|
2060
2378
|
}, { id: E } = await this.http.postJson(
|
|
2061
2379
|
"/directory/sharebookmark",
|
|
2062
|
-
|
|
2380
|
+
h
|
|
2063
2381
|
);
|
|
2064
2382
|
return {
|
|
2065
2383
|
id: E,
|
|
2066
2384
|
displayName: e,
|
|
2067
|
-
|
|
2385
|
+
notVisibleCount: 0,
|
|
2386
|
+
members: h.members
|
|
2068
2387
|
};
|
|
2069
2388
|
}
|
|
2070
2389
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
// Axios automatically manages the XSRF-TOKEN cookie and the X-XSRF-TOKEN HTTP header.
|
|
2075
|
-
u(this, "axios");
|
|
2076
|
-
u(this, "baseUrl");
|
|
2077
|
-
u(this, "headers", {});
|
|
2078
|
-
u(this, "_latestResponse");
|
|
2079
|
-
this.context = e, this.axios = axios.create(t);
|
|
2080
|
-
}
|
|
2081
|
-
fixBaseUrl(e) {
|
|
2082
|
-
return e.startsWith("http://") || e.startsWith("https://") ? e : this.baseUrl ? this.baseUrl.endsWith("/") || e.startsWith("/") ? `${this.baseUrl}${e}` : `${this.baseUrl}/${e}` : e;
|
|
2083
|
-
}
|
|
2084
|
-
useBaseUrl(e) {
|
|
2085
|
-
return this.baseUrl = e, this;
|
|
2390
|
+
class EmbedderService {
|
|
2391
|
+
constructor(e) {
|
|
2392
|
+
this.context = e;
|
|
2086
2393
|
}
|
|
2087
|
-
|
|
2088
|
-
return this.
|
|
2394
|
+
get http() {
|
|
2395
|
+
return this.context.http();
|
|
2089
2396
|
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2397
|
+
/**
|
|
2398
|
+
* Returns the default list of video embedder
|
|
2399
|
+
* @returns the default list of video embedder
|
|
2400
|
+
*/
|
|
2401
|
+
async getDefault() {
|
|
2402
|
+
return this.http.get("/infra/embed/default");
|
|
2095
2403
|
}
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
return t.headers = { ...s, ...this.headers }, t;
|
|
2103
|
-
} else
|
|
2104
|
-
return this.axios.defaults;
|
|
2404
|
+
/**
|
|
2405
|
+
* Returns the custom list of video embedder
|
|
2406
|
+
* @returns the custom list of video embedder
|
|
2407
|
+
*/
|
|
2408
|
+
async getCustom() {
|
|
2409
|
+
return this.http.get("/infra/embed/custom");
|
|
2105
2410
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2411
|
+
/**
|
|
2412
|
+
* The provider matching with the URL
|
|
2413
|
+
* @param {Embedder[]} embedderList - The list of video providers to test with
|
|
2414
|
+
* @param {String} url - The URL for the video
|
|
2415
|
+
* @returns The provider matching with the URL or undefined
|
|
2416
|
+
*/
|
|
2417
|
+
getProviderFromUrl(e, t) {
|
|
2418
|
+
for (const s of e)
|
|
2419
|
+
if (this.isUrlFromProvider(t, s))
|
|
2420
|
+
return s;
|
|
2114
2421
|
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
name: EVENT_NAME.ERROR_OCCURED,
|
|
2126
|
-
data: {
|
|
2127
|
-
params: t,
|
|
2128
|
-
response: { status: s, statusText: r, headers: i },
|
|
2129
|
-
payload: o
|
|
2422
|
+
urlIsFromPattern(e, t) {
|
|
2423
|
+
const s = new RegExp("[^{}]+(?=(?:[^{}]*{[^}]*})*[^}]*$)", "g"), r = new RegExp("{[^}]*}", "g");
|
|
2424
|
+
let i = !0;
|
|
2425
|
+
const o = t.match(s) || [], a = [];
|
|
2426
|
+
return (t.match(r) || []).forEach((l, h) => {
|
|
2427
|
+
l.includes("ignore") || a.push(o[h]);
|
|
2428
|
+
}), a.forEach((l) => {
|
|
2429
|
+
if (!e.includes(l)) {
|
|
2430
|
+
i = !1;
|
|
2431
|
+
return;
|
|
2130
2432
|
}
|
|
2131
|
-
}),
|
|
2433
|
+
}), i;
|
|
2132
2434
|
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2435
|
+
/**
|
|
2436
|
+
* Check if a given URL correspond to one of the URL pattern of the provider
|
|
2437
|
+
* @param {String} url - The URL for the video
|
|
2438
|
+
* @param {Embedder} embedder - The video provider to test with
|
|
2439
|
+
* @returns boolean depending if a given URL correspond to one of the URL pattern of the provider
|
|
2440
|
+
*/
|
|
2441
|
+
isUrlFromProvider(e, t) {
|
|
2442
|
+
typeof t.url == "string" && (t.url = [t.url]);
|
|
2443
|
+
for (const s of t.url)
|
|
2444
|
+
if (this.urlIsFromPattern(e, s))
|
|
2445
|
+
return !0;
|
|
2446
|
+
return !1;
|
|
2135
2447
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
throw this.mapAxiosError(r, s);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
async postFile(e, t, s) {
|
|
2166
|
-
const r = this.toAxiosConfig(s);
|
|
2167
|
-
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
2168
|
-
try {
|
|
2169
|
-
const i = await this.axios.post(this.fixBaseUrl(e), t, {
|
|
2170
|
-
...r,
|
|
2171
|
-
headers: {
|
|
2172
|
-
"Content-Type": "multipart/form-data"
|
|
2173
|
-
}
|
|
2174
|
-
});
|
|
2175
|
-
return this.mapAxiosResponse(i, s);
|
|
2176
|
-
} catch (i) {
|
|
2177
|
-
throw this.mapAxiosError(i, s);
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
async postJson(e, t, s) {
|
|
2181
|
-
const r = this.toAxiosConfig();
|
|
2182
|
-
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
2183
|
-
try {
|
|
2184
|
-
const i = await this.axios.post(
|
|
2185
|
-
this.fixBaseUrl(e),
|
|
2186
|
-
t,
|
|
2187
|
-
this.toAxiosConfig(s)
|
|
2188
|
-
);
|
|
2189
|
-
return this.mapAxiosResponse(i, s);
|
|
2190
|
-
} catch (i) {
|
|
2191
|
-
throw this.mapAxiosError(i, s);
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
async put(e, t, s) {
|
|
2195
|
-
try {
|
|
2196
|
-
const r = await this.axios.put(
|
|
2197
|
-
this.fixBaseUrl(e),
|
|
2198
|
-
t,
|
|
2199
|
-
this.toAxiosConfig(s)
|
|
2200
|
-
);
|
|
2201
|
-
return this.mapAxiosResponse(r, s);
|
|
2202
|
-
} catch (r) {
|
|
2203
|
-
throw this.mapAxiosError(r, s);
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
async putFile(e, t, s) {
|
|
2207
|
-
try {
|
|
2208
|
-
const r = this.toAxiosConfig(s);
|
|
2209
|
-
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
2210
|
-
const i = await this.axios.put(this.fixBaseUrl(e), t, {
|
|
2211
|
-
...r,
|
|
2212
|
-
headers: {
|
|
2213
|
-
"Content-Type": "multipart/form-data"
|
|
2214
|
-
}
|
|
2215
|
-
});
|
|
2216
|
-
return this.mapAxiosResponse(i, s);
|
|
2217
|
-
} catch (r) {
|
|
2218
|
-
throw this.mapAxiosError(r, s);
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
async putJson(e, t, s) {
|
|
2222
|
-
const r = this.toAxiosConfig(s);
|
|
2223
|
-
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
2224
|
-
try {
|
|
2225
|
-
const i = await this.axios.put(this.fixBaseUrl(e), t, r);
|
|
2226
|
-
return this.mapAxiosResponse(i, s);
|
|
2227
|
-
} catch (i) {
|
|
2228
|
-
throw this.mapAxiosError(i, s);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
async patch(e, t, s) {
|
|
2232
|
-
try {
|
|
2233
|
-
const r = await this.axios.patch(
|
|
2234
|
-
this.fixBaseUrl(e),
|
|
2235
|
-
t,
|
|
2236
|
-
this.toAxiosConfig(s)
|
|
2237
|
-
);
|
|
2238
|
-
return this.mapAxiosResponse(r, s);
|
|
2239
|
-
} catch (r) {
|
|
2240
|
-
throw this.mapAxiosError(r, s);
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
async patchFile(e, t, s) {
|
|
2244
|
-
try {
|
|
2245
|
-
const r = this.toAxiosConfig(s);
|
|
2246
|
-
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
2247
|
-
const i = await this.axios.patch(this.fixBaseUrl(e), t, {
|
|
2248
|
-
...r,
|
|
2249
|
-
headers: {
|
|
2250
|
-
"Content-Type": "multipart/form-data"
|
|
2251
|
-
}
|
|
2252
|
-
});
|
|
2253
|
-
return this.mapAxiosResponse(i, s);
|
|
2254
|
-
} catch (r) {
|
|
2255
|
-
throw this.mapAxiosError(r, s);
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
|
-
async patchJson(e, t, s) {
|
|
2259
|
-
const r = this.toAxiosConfig(s);
|
|
2260
|
-
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
2261
|
-
try {
|
|
2262
|
-
const i = await this.axios.patch(this.fixBaseUrl(e), t, r);
|
|
2263
|
-
return this.mapAxiosResponse(i, s);
|
|
2264
|
-
} catch (i) {
|
|
2265
|
-
throw this.mapAxiosError(i, s);
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
async delete(e, t) {
|
|
2269
|
-
try {
|
|
2270
|
-
const s = await this.axios.delete(
|
|
2271
|
-
this.fixBaseUrl(e),
|
|
2272
|
-
this.toAxiosConfig(t)
|
|
2273
|
-
);
|
|
2274
|
-
return this.mapAxiosResponse(s, t);
|
|
2275
|
-
} catch (s) {
|
|
2276
|
-
throw this.mapAxiosError(s, t);
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
async deleteJson(e, t) {
|
|
2280
|
-
try {
|
|
2281
|
-
const s = await this.axios.delete(this.fixBaseUrl(e), {
|
|
2282
|
-
data: t
|
|
2283
|
-
});
|
|
2284
|
-
return this.mapAxiosResponse(s);
|
|
2285
|
-
} catch (s) {
|
|
2286
|
-
throw this.mapAxiosError(s);
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
getScript(e, t, s) {
|
|
2290
|
-
const r = s ?? "exports", i = this.toAxiosConfig(t);
|
|
2291
|
-
return i.headers && (i.headers.Accept = "application/javascript"), this.axios.get(this.toCdnUrl(e), i).then((o) => this.mapAxiosResponse(o, t)).then((o) => {
|
|
2292
|
-
try {
|
|
2293
|
-
const a = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
|
|
2294
|
-
return Function(a)();
|
|
2295
|
-
} catch {
|
|
2296
|
-
return o;
|
|
2297
|
-
}
|
|
2298
|
-
}).catch((o) => {
|
|
2299
|
-
throw this.mapAxiosError(o, t), o;
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
loadScript(e, t) {
|
|
2303
|
-
return loadedScripts[e] ? Promise.resolve() : this.getScript(e, t).then((s) => {
|
|
2304
|
-
loadedScripts[e] = !0;
|
|
2305
|
-
});
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
class RightService {
|
|
2309
|
-
constructor(e) {
|
|
2310
|
-
this.context = e;
|
|
2311
|
-
}
|
|
2312
|
-
get session() {
|
|
2313
|
-
return this.context.session();
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* Parse right concat as "$TYPE:$ID:$RIGHT"
|
|
2317
|
-
* $TYPE = user | group | creator
|
|
2318
|
-
* $ID: id of the resource
|
|
2319
|
-
* $RIGHT: read | contrib | manage
|
|
2320
|
-
*
|
|
2321
|
-
* @param right a concat right
|
|
2322
|
-
* @returns Right parsed
|
|
2323
|
-
*/
|
|
2324
|
-
parseResourceRight(e) {
|
|
2325
|
-
const t = e.split(":");
|
|
2326
|
-
if (t.length === 2) {
|
|
2327
|
-
if (t[0] === "creator")
|
|
2328
|
-
return {
|
|
2329
|
-
id: t[1],
|
|
2330
|
-
right: "creator",
|
|
2331
|
-
type: "creator"
|
|
2332
|
-
};
|
|
2333
|
-
} else return t.length === 3 ? {
|
|
2334
|
-
id: t[1],
|
|
2335
|
-
right: t[2],
|
|
2336
|
-
type: t[0]
|
|
2337
|
-
} : void 0;
|
|
2338
|
-
}
|
|
2339
|
-
/**
|
|
2340
|
-
* Parse an array of rights concat as "$TYPE:$ID:$RIGHT"
|
|
2341
|
-
* $TYPE = user | group | creator
|
|
2342
|
-
* $ID: id of the resource
|
|
2343
|
-
* $RIGHT: read | contrib | manage
|
|
2344
|
-
*
|
|
2345
|
-
* @param rights a list of concat rights
|
|
2346
|
-
* @returns Array of Right parsed
|
|
2347
|
-
*/
|
|
2348
|
-
parseResourceRights(e) {
|
|
2349
|
-
return e.map((s) => this.parseResourceRight(s)).filter((s) => s !== void 0);
|
|
2350
|
-
}
|
|
2351
|
-
/**
|
|
2352
|
-
* Check wether a user has the expected right for a resource
|
|
2353
|
-
* @param user the userId and groupId concerned by the check
|
|
2354
|
-
* @param expect the expected right to check
|
|
2355
|
-
* @param rights array of Right for the resource
|
|
2356
|
-
* @returns true if has rights
|
|
2357
|
-
*/
|
|
2358
|
-
hasResourceRight({ id: e, groupIds: t }, s, r) {
|
|
2359
|
-
const i = r.map((o) => typeof o == "string" ? this.parseResourceRight(o) : o).filter((o) => o !== void 0);
|
|
2360
|
-
for (const o of i) {
|
|
2361
|
-
if (o.id === e && o.type === "creator")
|
|
2362
|
-
return !0;
|
|
2363
|
-
if (o.id === e && o.type === "user" && o.right === s)
|
|
2364
|
-
return !0;
|
|
2365
|
-
if (t.includes(o.id) && o.type === "group" && o.right === s)
|
|
2366
|
-
return !0;
|
|
2367
|
-
}
|
|
2368
|
-
return !1;
|
|
2369
|
-
}
|
|
2370
|
-
/**
|
|
2371
|
-
* Check wether the current user have resource right
|
|
2372
|
-
* @param expect the expected right to check
|
|
2373
|
-
* @param rights array of Right for the resource
|
|
2374
|
-
* @returns true if has rights
|
|
2375
|
-
*/
|
|
2376
|
-
async sessionHasResourceRight(e, t) {
|
|
2377
|
-
try {
|
|
2378
|
-
const s = await this.session.getUser();
|
|
2379
|
-
return !!s && this.hasResourceRight(
|
|
2380
|
-
{ groupIds: s.groupsIds, id: s.userId },
|
|
2381
|
-
e,
|
|
2382
|
-
t
|
|
2383
|
-
);
|
|
2384
|
-
} catch (s) {
|
|
2385
|
-
return console.error(`Unexpected error ${s} in sessionHasResourceRight()`), !1;
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
/**
|
|
2389
|
-
* Check wether the current user have at least one of resource right expected
|
|
2390
|
-
* @param expects array of expected right to check
|
|
2391
|
-
* @param rights array of Right for the resource
|
|
2392
|
-
* @returns true if has rights
|
|
2393
|
-
*/
|
|
2394
|
-
async sessionHasAtLeastOneResourceRight(e, t) {
|
|
2395
|
-
for (const s of e)
|
|
2396
|
-
if (await this.sessionHasResourceRight(s, t))
|
|
2397
|
-
return !0;
|
|
2398
|
-
return !1;
|
|
2399
|
-
}
|
|
2400
|
-
/**
|
|
2401
|
-
* Check wether the current user has resource right for each right list
|
|
2402
|
-
* @param expect expected right to check
|
|
2403
|
-
* @param rightsArray array of array of Right for multiple resources
|
|
2404
|
-
* @returns true if has rights
|
|
2405
|
-
*/
|
|
2406
|
-
async sessionHasResourceRightForEachList(e, t) {
|
|
2407
|
-
let s = 0;
|
|
2408
|
-
for (const r of t)
|
|
2409
|
-
await this.sessionHasResourceRight(e, r) && s++;
|
|
2410
|
-
return s === t.length;
|
|
2411
|
-
}
|
|
2412
|
-
/**
|
|
2413
|
-
* Check wether the current user have at least one of resource right for each right list
|
|
2414
|
-
* @param expects array of expected right to check
|
|
2415
|
-
* @param rightsArray array of array of Right for multiple resources
|
|
2416
|
-
* @returns true if has rights
|
|
2417
|
-
*/
|
|
2418
|
-
async sessionHasAtLeastOneResourceRightForEachList(e, t) {
|
|
2419
|
-
for (const s of e) {
|
|
2420
|
-
let r = 0;
|
|
2421
|
-
for (const i of t)
|
|
2422
|
-
await this.sessionHasResourceRight(s, i) && r++;
|
|
2423
|
-
if (r === t.length)
|
|
2424
|
-
return !0;
|
|
2425
|
-
}
|
|
2426
|
-
return !1;
|
|
2427
|
-
}
|
|
2428
|
-
hasWorkflowRight(e, t) {
|
|
2429
|
-
return t.findIndex((s) => s === e) !== -1;
|
|
2430
|
-
}
|
|
2431
|
-
/**
|
|
2432
|
-
* @param expect a workflow right
|
|
2433
|
-
* @returns true if current session has right on it
|
|
2434
|
-
*/
|
|
2435
|
-
async sessionHasWorkflowRight(e) {
|
|
2436
|
-
try {
|
|
2437
|
-
const t = await this.session.getUser();
|
|
2438
|
-
return !!t && this.hasWorkflowRight(
|
|
2439
|
-
e,
|
|
2440
|
-
t.authorizedActions.map(
|
|
2441
|
-
(s) => s.name
|
|
2442
|
-
)
|
|
2443
|
-
);
|
|
2444
|
-
} catch (t) {
|
|
2445
|
-
return console.error(`Unexpected error ${t} in sessionHasWorkflowRight()`), !1;
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
/**
|
|
2449
|
-
* @param expect a workflow right
|
|
2450
|
-
* @returns a record with right as key and boolean as value if current session has right on it
|
|
2451
|
-
*/
|
|
2452
|
-
async sessionHasWorkflowRights(e) {
|
|
2453
|
-
const t = {};
|
|
2454
|
-
try {
|
|
2455
|
-
const s = await this.session.getUser();
|
|
2456
|
-
for (const r of e)
|
|
2457
|
-
t[r] = !!s && this.hasWorkflowRight(
|
|
2458
|
-
r,
|
|
2459
|
-
s.authorizedActions.map(
|
|
2460
|
-
(i) => i.name
|
|
2461
|
-
)
|
|
2462
|
-
);
|
|
2463
|
-
} catch (s) {
|
|
2464
|
-
console.error(`Unexpected error ${s} in sessionHasWorkflowRights()`);
|
|
2465
|
-
for (const r of e)
|
|
2466
|
-
t[r] = !1;
|
|
2467
|
-
}
|
|
2468
|
-
return t;
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
class SessionService {
|
|
2472
|
-
constructor(e) {
|
|
2473
|
-
this.context = e;
|
|
2474
|
-
}
|
|
2475
|
-
get http() {
|
|
2476
|
-
return this.context.http();
|
|
2477
|
-
}
|
|
2478
|
-
get cache() {
|
|
2479
|
-
return this.context.cache();
|
|
2480
|
-
}
|
|
2481
|
-
get conf() {
|
|
2482
|
-
return this.context.conf();
|
|
2483
|
-
}
|
|
2484
|
-
/**
|
|
2485
|
-
* Callback to call when user logout
|
|
2486
|
-
*/
|
|
2487
|
-
onLogout() {
|
|
2488
|
-
this.cache.clearCache();
|
|
2489
|
-
}
|
|
2490
|
-
/**
|
|
2491
|
-
* Callback to call when session change
|
|
2492
|
-
*/
|
|
2493
|
-
onRefreshSession() {
|
|
2494
|
-
this.cache.clearCache();
|
|
2495
|
-
}
|
|
2496
|
-
async getSession() {
|
|
2497
|
-
const e = await this.getUser(), [
|
|
2498
|
-
t,
|
|
2499
|
-
s,
|
|
2500
|
-
r,
|
|
2501
|
-
i,
|
|
2502
|
-
o
|
|
2503
|
-
] = await Promise.all([
|
|
2504
|
-
this.getCurrentLanguage(e),
|
|
2505
|
-
this.latestQuotaAndUsage(e),
|
|
2506
|
-
this.loadDescription(e),
|
|
2507
|
-
this.getUserProfile(),
|
|
2508
|
-
this.getBookmarks(e)
|
|
2509
|
-
]);
|
|
2510
|
-
return {
|
|
2511
|
-
user: e,
|
|
2512
|
-
quotaAndUsage: s,
|
|
2513
|
-
currentLanguage: t,
|
|
2514
|
-
userDescription: r,
|
|
2515
|
-
userProfile: i,
|
|
2516
|
-
bookmarkedApps: o
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
login(e, t, s, r) {
|
|
2520
|
-
const i = new FormData();
|
|
2521
|
-
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, {
|
|
2522
|
-
headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
2523
|
-
}).finally(() => {
|
|
2524
|
-
switch (this.http.latestResponse.status) {
|
|
2525
|
-
case 200:
|
|
2526
|
-
throw ERROR_CODE.MALFORMED_DATA;
|
|
2527
|
-
}
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
async logout() {
|
|
2531
|
-
const e = await this.conf.getLogoutCallback();
|
|
2532
|
-
return this.http.get("/auth/logout?callback=" + e).finally(() => {
|
|
2533
|
-
});
|
|
2534
|
-
}
|
|
2535
|
-
async latestQuotaAndUsage(e) {
|
|
2536
|
-
const t = { quota: 0, storage: 0 };
|
|
2537
|
-
if (!e) return t;
|
|
2538
|
-
try {
|
|
2539
|
-
return await this.http.get(
|
|
2540
|
-
`/workspace/quota/user/${e == null ? void 0 : e.userId}`
|
|
2541
|
-
);
|
|
2542
|
-
} catch (s) {
|
|
2543
|
-
return console.error(s), t;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
async getCurrentLanguage(e) {
|
|
2547
|
-
const t = (e == null ? void 0 : e.sessionMetadata) && (e == null ? void 0 : e.sessionMetadata.userId);
|
|
2548
|
-
try {
|
|
2549
|
-
let s;
|
|
2550
|
-
return t ? s = await this.loadUserLanguage() : s = await this.loadDefaultLanguage(), s;
|
|
2551
|
-
} catch (s) {
|
|
2552
|
-
console.error(s);
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
async loadUserLanguage() {
|
|
2556
|
-
try {
|
|
2557
|
-
const e = await this.http.get(
|
|
2558
|
-
"/userbook/preference/language"
|
|
2559
|
-
);
|
|
2560
|
-
return JSON.parse(e.preference)["default-domain"];
|
|
2561
|
-
} catch {
|
|
2562
|
-
return await this.loadDefaultLanguage();
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
async loadDefaultLanguage() {
|
|
2566
|
-
return (await this.cache.httpGetJson(
|
|
2567
|
-
"/locale"
|
|
2568
|
-
)).locale;
|
|
2569
|
-
}
|
|
2570
|
-
async getUser() {
|
|
2571
|
-
const { response: e, value: t } = await this.cache.httpGet(
|
|
2572
|
-
"/auth/oauth2/userinfo"
|
|
2573
|
-
);
|
|
2574
|
-
if (!(e.status < 200 || e.status >= 300) && typeof t == "object")
|
|
2575
|
-
return t;
|
|
2576
|
-
throw ERROR_CODE.NOT_LOGGED_IN;
|
|
2577
|
-
}
|
|
2578
|
-
hasWorkflow({
|
|
2579
|
-
workflowName: e,
|
|
2580
|
-
user: t
|
|
2581
|
-
}) {
|
|
2582
|
-
return e === void 0 || (t == null ? void 0 : t.authorizedActions.findIndex((s) => s.name === e)) !== -1;
|
|
2583
|
-
}
|
|
2584
|
-
async loadDescription(e) {
|
|
2585
|
-
if (!e) return {};
|
|
2586
|
-
try {
|
|
2587
|
-
const [t, s] = await Promise.all([
|
|
2588
|
-
// FIXME The full user's description should be obtainable from a single endpoint in the backend.
|
|
2589
|
-
this.getUserProfile({
|
|
2590
|
-
options: { requestName: "refreshAvatar" }
|
|
2591
|
-
}),
|
|
2592
|
-
this.http.get("/directory/userbook/" + (e == null ? void 0 : e.userId))
|
|
2593
|
-
]);
|
|
2594
|
-
return { ...s, profiles: t };
|
|
2595
|
-
} catch (t) {
|
|
2596
|
-
return console.error(t), {};
|
|
2597
|
-
}
|
|
2598
|
-
}
|
|
2599
|
-
async getBookmarks(e) {
|
|
2600
|
-
if (!e) return [];
|
|
2601
|
-
const t = await this.http.get("/userbook/preference/apps");
|
|
2602
|
-
t.preference || (t.preference = null);
|
|
2603
|
-
const s = JSON.parse(t.preference);
|
|
2604
|
-
let r;
|
|
2605
|
-
r = s, r || (r = {
|
|
2606
|
-
bookmarks: [],
|
|
2607
|
-
applications: []
|
|
2608
|
-
});
|
|
2609
|
-
const i = [];
|
|
2610
|
-
return r.bookmarks.forEach((o, a) => {
|
|
2611
|
-
const c = ((e == null ? void 0 : e.apps) || []).find(
|
|
2612
|
-
(l) => l.name === o
|
|
2613
|
-
);
|
|
2614
|
-
if (c) {
|
|
2615
|
-
const l = Object.assign({}, c);
|
|
2616
|
-
i.push(l);
|
|
2617
|
-
}
|
|
2618
|
-
}), i;
|
|
2619
|
-
}
|
|
2620
|
-
async getUserProfile(e = {}) {
|
|
2621
|
-
var c, l;
|
|
2622
|
-
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);
|
|
2623
|
-
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"];
|
|
2624
|
-
}
|
|
2625
|
-
async isAdml() {
|
|
2626
|
-
const e = await this.getUser();
|
|
2627
|
-
return (e == null ? void 0 : e.functions.ADMIN_LOCAL) !== void 0;
|
|
2628
|
-
}
|
|
2629
|
-
/**
|
|
2630
|
-
* Get details of an application if the user can access it.
|
|
2631
|
-
* @return undefined if no access, or app not found
|
|
2632
|
-
*/
|
|
2633
|
-
async getWebApp(e) {
|
|
2634
|
-
const t = await this.getUser();
|
|
2635
|
-
return t == null ? void 0 : t.apps.find((s) => {
|
|
2636
|
-
var r;
|
|
2637
|
-
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;
|
|
2638
|
-
});
|
|
2448
|
+
/**
|
|
2449
|
+
* Get embed code to display the video for an URL and a provider
|
|
2450
|
+
* @param {Embedder} embedder - The video provider for the URL
|
|
2451
|
+
* @param {String} url - The URL for the video
|
|
2452
|
+
* @returns embed code to display the video for an URL and a provider
|
|
2453
|
+
*/
|
|
2454
|
+
getEmbedCodeForProvider(e, t) {
|
|
2455
|
+
for (const s of e.url)
|
|
2456
|
+
if (this.urlIsFromPattern(t, s)) {
|
|
2457
|
+
const r = new RegExp("{[a-zA-Z0-9_.]+}", "g"), i = s.match(r) || [];
|
|
2458
|
+
let o = e.embed;
|
|
2459
|
+
for (const a of i) {
|
|
2460
|
+
let c = s.split(a)[0];
|
|
2461
|
+
const l = c.split("}");
|
|
2462
|
+
l.length > 1 && (c = l[l.length - 1]);
|
|
2463
|
+
let h = t.split(c)[1];
|
|
2464
|
+
if (!h)
|
|
2465
|
+
continue;
|
|
2466
|
+
const E = s.split(a)[1].split("{")[0];
|
|
2467
|
+
E && (h = h.split(E)[0]);
|
|
2468
|
+
const p = new RegExp("\\" + a.replace(/}/, "\\}"), "g");
|
|
2469
|
+
o = o.replace(p, h);
|
|
2470
|
+
}
|
|
2471
|
+
return o;
|
|
2472
|
+
}
|
|
2473
|
+
return "";
|
|
2639
2474
|
}
|
|
2640
2475
|
}
|
|
2641
2476
|
const bundle = {}, promises = {}, defaultDiacriticsRemovalMap = [
|
|
@@ -2920,1504 +2755,1710 @@ class IdiomService {
|
|
|
2920
2755
|
return e;
|
|
2921
2756
|
}
|
|
2922
2757
|
}
|
|
2923
|
-
class
|
|
2924
|
-
static removeAccents(e) {
|
|
2925
|
-
for (let t = 0; t < defaultDiacriticsRemovalMap.length; t++)
|
|
2926
|
-
e = e.replace(
|
|
2927
|
-
defaultDiacriticsRemovalMap[t].letters,
|
|
2928
|
-
defaultDiacriticsRemovalMap[t].base
|
|
2929
|
-
);
|
|
2930
|
-
return e;
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
class ShareService {
|
|
2758
|
+
class AbstractBehaviourService {
|
|
2934
2759
|
//
|
|
2935
2760
|
// IMPLEMENTATION
|
|
2936
2761
|
//
|
|
2937
2762
|
constructor(e) {
|
|
2938
|
-
|
|
2763
|
+
//-----------------
|
|
2764
|
+
//--- Utilities ---
|
|
2765
|
+
//-----------------
|
|
2766
|
+
u(this, "_cache");
|
|
2767
|
+
this.context = e, this._cache = new CacheService(this.context);
|
|
2939
2768
|
}
|
|
2940
|
-
|
|
2941
|
-
return this.
|
|
2769
|
+
getApplication() {
|
|
2770
|
+
return this.APP;
|
|
2942
2771
|
}
|
|
2943
|
-
|
|
2944
|
-
return this.
|
|
2772
|
+
getResourceType() {
|
|
2773
|
+
return this.RESOURCE;
|
|
2945
2774
|
}
|
|
2946
|
-
|
|
2947
|
-
return this.
|
|
2775
|
+
httpGet(e, t) {
|
|
2776
|
+
return this._cache.httpGetJson(e, t);
|
|
2948
2777
|
}
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2778
|
+
/* Utility to map data between linker model and search model. */
|
|
2779
|
+
dataToResource({
|
|
2780
|
+
modified: e,
|
|
2781
|
+
...t
|
|
2782
|
+
}) {
|
|
2783
|
+
const s = typeof e == "string" ? e : e != null && e.$date ? "" + e.$date : "";
|
|
2784
|
+
return {
|
|
2785
|
+
application: this.RESOURCE,
|
|
2786
|
+
name: t.title,
|
|
2787
|
+
creatorId: t.owner,
|
|
2788
|
+
creatorName: t.ownerName,
|
|
2789
|
+
thumbnail: t.icon,
|
|
2790
|
+
assetId: t._id,
|
|
2791
|
+
modifiedAt: s,
|
|
2792
|
+
shared: t.shared,
|
|
2793
|
+
path: t.path
|
|
2794
|
+
};
|
|
2956
2795
|
}
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
), a = await this.cache.httpGetJson(o), c = a.users.visibles.filter(({ username: h, firstName: y, lastName: d, login: g }) => {
|
|
2964
|
-
const A = StringUtils.removeAccents(
|
|
2965
|
-
d || ""
|
|
2966
|
-
).toLowerCase(), f = StringUtils.removeAccents(
|
|
2967
|
-
y || ""
|
|
2968
|
-
).toLowerCase(), w = StringUtils.removeAccents(
|
|
2969
|
-
h || ""
|
|
2970
|
-
).toLowerCase(), F = StringUtils.removeAccents(g || "").toLowerCase();
|
|
2971
|
-
return w.includes(i) || f.includes(i) || A.includes(i) || F.includes(i);
|
|
2972
|
-
}).map((h) => ({
|
|
2973
|
-
avatarUrl: this.directory.getAvatarUrl(h.id, "user"),
|
|
2974
|
-
directoryUrl: this.directory.getDirectoryUrl(h.id, "user"),
|
|
2975
|
-
displayName: h.username,
|
|
2976
|
-
id: h.id,
|
|
2977
|
-
profile: h.profile,
|
|
2978
|
-
type: "user"
|
|
2979
|
-
})), l = a.groups.visibles.filter(({ name: h }) => StringUtils.removeAccents(h || "").toLowerCase().includes(i)).map((h) => ({
|
|
2980
|
-
avatarUrl: this.directory.getAvatarUrl(h.id, "group"),
|
|
2981
|
-
directoryUrl: this.directory.getDirectoryUrl(h.id, "group"),
|
|
2982
|
-
displayName: h.name,
|
|
2983
|
-
id: h.id,
|
|
2984
|
-
type: "group",
|
|
2985
|
-
structureName: h.structureName
|
|
2986
|
-
}));
|
|
2987
|
-
return [...(await this.directory.getBookMarks()).filter(({ displayName: h }) => StringUtils.removeAccents(
|
|
2988
|
-
h || ""
|
|
2989
|
-
).toLowerCase().includes(i)).map((h) => ({
|
|
2990
|
-
avatarUrl: "",
|
|
2991
|
-
directoryUrl: "",
|
|
2992
|
-
profile: "",
|
|
2993
|
-
displayName: h.displayName,
|
|
2994
|
-
id: h.id,
|
|
2995
|
-
type: "sharebookmark"
|
|
2996
|
-
})), ...c, ...l];
|
|
2796
|
+
}
|
|
2797
|
+
class ActualitesBehaviour extends AbstractBehaviourService {
|
|
2798
|
+
constructor() {
|
|
2799
|
+
super(...arguments);
|
|
2800
|
+
u(this, "APP", "actualites");
|
|
2801
|
+
u(this, "RESOURCE", "actualites");
|
|
2997
2802
|
}
|
|
2998
|
-
async
|
|
2999
|
-
const s = await
|
|
3000
|
-
|
|
2803
|
+
async loadResources() {
|
|
2804
|
+
const [t, s] = await Promise.all([
|
|
2805
|
+
this.httpGet("/actualites/api/v1/infos/linker"),
|
|
2806
|
+
this.httpGet("/actualites/api/v1/threads")
|
|
2807
|
+
]), r = s.reduce(
|
|
2808
|
+
(i, o) => i.set(o.id, o),
|
|
2809
|
+
/* @__PURE__ */ new Map()
|
|
3001
2810
|
);
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
2811
|
+
return t.map((i) => {
|
|
2812
|
+
var a;
|
|
2813
|
+
let o;
|
|
2814
|
+
return i.threadIcon ? o = i.threadIcon + "?thumbnail=48x48" : o = "/img/icons/glyphicons_036_file.png", this.dataToResource({
|
|
2815
|
+
title: i.title + " [" + ((a = r.get(i.threadId)) == null ? void 0 : a.title) + "]",
|
|
2816
|
+
ownerName: i.owner.displayName,
|
|
2817
|
+
owner: i.owner.id,
|
|
2818
|
+
icon: o,
|
|
2819
|
+
path: "/actualites/threads/" + i.threadId + "?info=" + i.id,
|
|
2820
|
+
_id: `${i.threadId}#${i.id}`,
|
|
2821
|
+
shared: !!(i.shared && i.shared.length >= 0),
|
|
2822
|
+
modified: i.modified
|
|
2823
|
+
});
|
|
2824
|
+
});
|
|
3008
2825
|
}
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
2826
|
+
}
|
|
2827
|
+
const hexToDataUrl = (n, e = 1, t = 1) => {
|
|
2828
|
+
const s = document.createElement("canvas");
|
|
2829
|
+
s.width = e, s.height = t;
|
|
2830
|
+
const r = s.getContext("2d");
|
|
2831
|
+
return r ? (r.fillStyle = n, r.fillRect(0, 0, e, t), s.toDataURL("image/png")) : "";
|
|
2832
|
+
};
|
|
2833
|
+
class AppointmentsBehaviour extends AbstractBehaviourService {
|
|
2834
|
+
constructor() {
|
|
2835
|
+
super(...arguments);
|
|
2836
|
+
u(this, "APP", "appointments");
|
|
2837
|
+
u(this, "RESOURCE", "appointments");
|
|
2838
|
+
}
|
|
2839
|
+
async loadResources() {
|
|
2840
|
+
return (await this.httpGet("/appointments/grids/linker")).map((s) => this.dataToResource({
|
|
2841
|
+
_id: s.id.toString(),
|
|
2842
|
+
icon: hexToDataUrl(s.color, 100, 100),
|
|
2843
|
+
title: s.name,
|
|
2844
|
+
ownerName: s.ownerName,
|
|
2845
|
+
owner: s.ownerId,
|
|
2846
|
+
path: `${window.location.origin}/appointments#?gridId=${s.id}`,
|
|
2847
|
+
shared: !1,
|
|
2848
|
+
modified: s.updatingDate
|
|
2849
|
+
}));
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
class BlogBehaviour extends AbstractBehaviourService {
|
|
2853
|
+
constructor() {
|
|
2854
|
+
super(...arguments);
|
|
2855
|
+
u(this, "APP", "blog");
|
|
2856
|
+
u(this, "RESOURCE", "blog");
|
|
2857
|
+
}
|
|
2858
|
+
loadResources() {
|
|
2859
|
+
return new Promise(async (t, s) => {
|
|
2860
|
+
try {
|
|
2861
|
+
const r = await this.httpGet("/blog/linker"), i = [];
|
|
2862
|
+
r.forEach((o) => {
|
|
2863
|
+
o.thumbnail ? o.thumbnail = o.thumbnail + "?thumbnail=48x48" : o.thumbnail = "/img/illustrations/blog.svg";
|
|
2864
|
+
const a = o.fetchPosts.map((c) => this.dataToResource({
|
|
2865
|
+
owner: o.author.userId,
|
|
2866
|
+
ownerName: o.author.username,
|
|
2867
|
+
title: c.title + " [" + o.title + "]",
|
|
2868
|
+
_id: `${o._id}#${c._id}`,
|
|
2869
|
+
icon: o.thumbnail,
|
|
2870
|
+
path: `/blog/id/${o._id}/post/${c._id}`,
|
|
2871
|
+
shared: !!(o.shared && o.shared.length >= 0),
|
|
2872
|
+
modified: o.modified
|
|
2873
|
+
}));
|
|
2874
|
+
i.push(...a);
|
|
2875
|
+
}), t(i);
|
|
2876
|
+
} catch (r) {
|
|
2877
|
+
s(r);
|
|
2878
|
+
}
|
|
2879
|
+
});
|
|
3016
2880
|
}
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
);
|
|
3038
|
-
return {
|
|
3039
|
-
id: d.id,
|
|
3040
|
-
type: "user",
|
|
3041
|
-
displayName: d.username,
|
|
3042
|
-
profile: d.profile,
|
|
3043
|
-
avatarUrl: this.directory.getAvatarUrl(d.id, "user"),
|
|
3044
|
-
directoryUrl: this.directory.getDirectoryUrl(d.id, "user"),
|
|
3045
|
-
actions: g.map((f) => {
|
|
3046
|
-
const w = c[f];
|
|
3047
|
-
return {
|
|
3048
|
-
displayName: f,
|
|
3049
|
-
id: f,
|
|
3050
|
-
priority: w.priority
|
|
3051
|
-
};
|
|
3052
|
-
})
|
|
3053
|
-
};
|
|
3054
|
-
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), p = Object.keys(o.groups.checked).map((d) => o.groups.visibles.find(
|
|
3055
|
-
(A) => A.id === d
|
|
3056
|
-
)).filter((d) => d !== void 0).map((d) => {
|
|
3057
|
-
const g = this.getActionsAvailableFor(
|
|
3058
|
-
{ id: d.id, type: "group" },
|
|
3059
|
-
o,
|
|
3060
|
-
a
|
|
3061
|
-
);
|
|
3062
|
-
return {
|
|
3063
|
-
id: d.id,
|
|
3064
|
-
type: "group",
|
|
3065
|
-
displayName: d.name,
|
|
3066
|
-
profile: void 0,
|
|
3067
|
-
avatarUrl: this.directory.getAvatarUrl(d.id, "group"),
|
|
3068
|
-
directoryUrl: this.directory.getDirectoryUrl(d.id, "group"),
|
|
3069
|
-
actions: g.map((f) => {
|
|
3070
|
-
const w = c[f];
|
|
3071
|
-
return {
|
|
3072
|
-
displayName: f,
|
|
3073
|
-
id: f,
|
|
3074
|
-
priority: w.priority
|
|
3075
|
-
};
|
|
3076
|
-
})
|
|
3077
|
-
};
|
|
3078
|
-
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), E = [...l, ...p], h = o.groups.visibles.map(
|
|
3079
|
-
({ groupDisplayName: d, id: g, name: A, labels: f }) => ({
|
|
3080
|
-
labels: f,
|
|
3081
|
-
displayName: d || A,
|
|
3082
|
-
id: g
|
|
3083
|
-
})
|
|
3084
|
-
), y = o.users.visibles.map(
|
|
3085
|
-
({ id: d, profile: g, username: A, firstName: f, lastName: w, login: F }) => ({
|
|
3086
|
-
displayName: A,
|
|
3087
|
-
firstName: f,
|
|
3088
|
-
lastName: w,
|
|
3089
|
-
login: F,
|
|
3090
|
-
profile: g,
|
|
3091
|
-
id: d
|
|
2881
|
+
}
|
|
2882
|
+
class CollaborativewallBehaviour extends AbstractBehaviourService {
|
|
2883
|
+
constructor() {
|
|
2884
|
+
super(...arguments);
|
|
2885
|
+
u(this, "APP", "collaborativewall");
|
|
2886
|
+
u(this, "RESOURCE", "collaborativewall");
|
|
2887
|
+
}
|
|
2888
|
+
async loadResources() {
|
|
2889
|
+
return (await this.httpGet(
|
|
2890
|
+
"/collaborativewall/list/all"
|
|
2891
|
+
)).map(
|
|
2892
|
+
(s) => this.dataToResource({
|
|
2893
|
+
title: s.name,
|
|
2894
|
+
ownerName: s.owner.displayName,
|
|
2895
|
+
owner: s.owner.userId,
|
|
2896
|
+
icon: s.icon ? s.icon : "/img/illustrations/collaborative-wall-default.png",
|
|
2897
|
+
path: "/collaborativewall#/view/" + s._id,
|
|
2898
|
+
_id: s._id,
|
|
2899
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
2900
|
+
modified: s.modified
|
|
3092
2901
|
})
|
|
3093
2902
|
);
|
|
3094
|
-
return {
|
|
3095
|
-
rights: E,
|
|
3096
|
-
visibleBookmarks: r,
|
|
3097
|
-
visibleGroups: h,
|
|
3098
|
-
visibleUsers: y
|
|
3099
|
-
};
|
|
3100
2903
|
}
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
for (const o of t) {
|
|
3108
|
-
const a = o.actions.map((l) => i[l.id]).reduce((l, p) => Array.isArray(p) ? [...l, ...p] : l, []), c = [...new Set(a)];
|
|
3109
|
-
c.length > 0 && (o.type === "user" ? r.users[o.id] = c : o.type === "group" ? r.groups[o.id] = c : r.bookmarks[o.id] = c);
|
|
3110
|
-
}
|
|
3111
|
-
return r;
|
|
2904
|
+
}
|
|
2905
|
+
class CommunityBehaviour extends AbstractBehaviourService {
|
|
2906
|
+
constructor() {
|
|
2907
|
+
super(...arguments);
|
|
2908
|
+
u(this, "APP", "community");
|
|
2909
|
+
u(this, "RESOURCE", "community");
|
|
3112
2910
|
}
|
|
3113
|
-
async
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
2911
|
+
async loadResources() {
|
|
2912
|
+
return (await this.httpGet(
|
|
2913
|
+
"/community/listallpages"
|
|
2914
|
+
)).map((s) => {
|
|
2915
|
+
let r;
|
|
2916
|
+
return typeof s.thumbnail > "u" || s.thumbnail === "" ? r = "/img/icons/glyphicons_036_file.png" : r = s.thumbnail + "?thumbnail=48x48", this.dataToResource({
|
|
2917
|
+
title: s.name,
|
|
2918
|
+
icon: r,
|
|
2919
|
+
path: "/community#/view/" + s.id,
|
|
2920
|
+
_id: s.id,
|
|
2921
|
+
owner: "",
|
|
2922
|
+
ownerName: "",
|
|
2923
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
2924
|
+
modified: s.name
|
|
2925
|
+
// FIXME date ?
|
|
2926
|
+
});
|
|
2927
|
+
});
|
|
3125
2928
|
}
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
return
|
|
3141
|
-
|
|
2929
|
+
}
|
|
2930
|
+
class ExercizerBehaviour extends AbstractBehaviourService {
|
|
2931
|
+
constructor() {
|
|
2932
|
+
super(...arguments);
|
|
2933
|
+
u(this, "APP", "exercizer");
|
|
2934
|
+
u(this, "RESOURCE", "exercizer");
|
|
2935
|
+
}
|
|
2936
|
+
async loadResources() {
|
|
2937
|
+
return (await this.httpGet(
|
|
2938
|
+
"/exercizer/subjects-scheduled"
|
|
2939
|
+
)).map((s) => {
|
|
2940
|
+
const r = s.picture ? s.picture + "?thumbnail=48x48" : "/img/illustrations/exercizer.svg";
|
|
2941
|
+
let i, o = !1;
|
|
2942
|
+
const a = JSON.parse(s.scheduled_at);
|
|
2943
|
+
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({
|
|
2944
|
+
title: s.title,
|
|
2945
|
+
owner: s.owner,
|
|
2946
|
+
ownerName: i,
|
|
2947
|
+
icon: r,
|
|
2948
|
+
path: "/exercizer#/linker/" + s.id,
|
|
2949
|
+
_id: "" + s.id,
|
|
2950
|
+
shared: o,
|
|
2951
|
+
modified: s.modified
|
|
2952
|
+
});
|
|
2953
|
+
});
|
|
3142
2954
|
}
|
|
3143
2955
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
return MimeTypeUtils.INSTANCE.isWordLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("wordprocessing") !== -1;
|
|
3150
|
-
},
|
|
3151
|
-
xls: function({ type: n, extension: e }) {
|
|
3152
|
-
return MimeTypeUtils.INSTANCE.isExcelLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("spreadsheet") !== -1 || n.indexOf("ms-excel") !== -1;
|
|
3153
|
-
},
|
|
3154
|
-
img: function({ type: n }) {
|
|
3155
|
-
return n.indexOf("image") !== -1;
|
|
3156
|
-
},
|
|
3157
|
-
pdf: function({ type: n }) {
|
|
3158
|
-
return n.indexOf("pdf") !== -1 || n === "application/x-download";
|
|
3159
|
-
},
|
|
3160
|
-
ppt: function({ type: n, extension: e }) {
|
|
3161
|
-
return MimeTypeUtils.INSTANCE.isPowerpointLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("presentation") !== -1 || n.indexOf("powerpoint") !== -1;
|
|
3162
|
-
},
|
|
3163
|
-
txt: function({ type: n, extension: e }) {
|
|
3164
|
-
return MimeTypeUtils.INSTANCE.isTxtLike(n, e);
|
|
3165
|
-
},
|
|
3166
|
-
md: function({ type: n, extension: e }) {
|
|
3167
|
-
return MimeTypeUtils.INSTANCE.isMdLike(n, e);
|
|
3168
|
-
},
|
|
3169
|
-
video: function({ type: n }) {
|
|
3170
|
-
return n.indexOf("video") !== -1;
|
|
3171
|
-
},
|
|
3172
|
-
audio: function({ type: n }) {
|
|
3173
|
-
return n.indexOf("audio") !== -1;
|
|
3174
|
-
},
|
|
3175
|
-
zip: function({ type: n }) {
|
|
3176
|
-
return n.indexOf("zip") !== -1 || n.indexOf("rar") !== -1 || n.indexOf("tar") !== -1 || n.indexOf("7z") !== -1;
|
|
2956
|
+
class FormulaireBehaviour extends AbstractBehaviourService {
|
|
2957
|
+
constructor() {
|
|
2958
|
+
super(...arguments);
|
|
2959
|
+
u(this, "APP", "formulaire");
|
|
2960
|
+
u(this, "RESOURCE", "formulaire");
|
|
3177
2961
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
2962
|
+
async loadResources() {
|
|
2963
|
+
return (await this.httpGet(
|
|
2964
|
+
"/formulaire/forms/linker"
|
|
2965
|
+
)).map((s) => (s.picture || (s.picture = "/formulaire/public/img/logo.svg"), this.dataToResource({
|
|
2966
|
+
_id: "" + s.id,
|
|
2967
|
+
icon: s.picture,
|
|
2968
|
+
title: s.title,
|
|
2969
|
+
ownerName: s.owner_name,
|
|
2970
|
+
owner: s.owner_id,
|
|
2971
|
+
path: s.is_public ? `${window.location.origin}/formulaire-public#/form/${s.public_key}` : `${window.location.origin}/formulaire#/form/${s.id}/${s.rgpd ? "rgpd" : "new"}`,
|
|
2972
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
2973
|
+
modified: "" + s.date_modification
|
|
2974
|
+
})));
|
|
3187
2975
|
}
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
const o = i(r);
|
|
3195
|
-
if (o)
|
|
3196
|
-
return o;
|
|
3197
|
-
}
|
|
3198
|
-
return "unknown";
|
|
2976
|
+
}
|
|
2977
|
+
class ForumBehaviour extends AbstractBehaviourService {
|
|
2978
|
+
constructor() {
|
|
2979
|
+
super(...arguments);
|
|
2980
|
+
u(this, "APP", "forum");
|
|
2981
|
+
u(this, "RESOURCE", "forum");
|
|
3199
2982
|
}
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
2983
|
+
async loadResources() {
|
|
2984
|
+
return (await this.httpGet("/forum/categories")).map(
|
|
2985
|
+
(s) => this.dataToResource({
|
|
2986
|
+
_id: s._id,
|
|
2987
|
+
title: s.name,
|
|
2988
|
+
icon: s.icon || "/img/illustrations/forum.svg",
|
|
2989
|
+
path: "/forum#/view/" + s._id,
|
|
2990
|
+
ownerName: s.owner.displayName,
|
|
2991
|
+
owner: s.owner.userId,
|
|
2992
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
2993
|
+
modified: s.modified
|
|
2994
|
+
})
|
|
2995
|
+
);
|
|
3209
2996
|
}
|
|
3210
|
-
|
|
3211
|
-
|
|
2997
|
+
}
|
|
2998
|
+
class HomeworksBehaviour extends AbstractBehaviourService {
|
|
2999
|
+
constructor() {
|
|
3000
|
+
super(...arguments);
|
|
3001
|
+
u(this, "APP", "homeworks");
|
|
3002
|
+
u(this, "RESOURCE", "homeworks");
|
|
3212
3003
|
}
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3004
|
+
async loadResources() {
|
|
3005
|
+
return (await this.httpGet("/homeworks/list")).filter((t) => t.owner && t.trashed === 0).map((t) => this.dataToResource({
|
|
3006
|
+
title: t.title,
|
|
3007
|
+
ownerName: t.owner.displayName,
|
|
3008
|
+
owner: t.owner.userId,
|
|
3009
|
+
icon: t.thumbnail || "/img/illustrations/homeworks.svg",
|
|
3010
|
+
path: "/homeworks#/view-homeworks/" + t._id,
|
|
3011
|
+
_id: "" + t._id,
|
|
3012
|
+
shared: typeof t.shared < "u",
|
|
3013
|
+
modified: t.modified
|
|
3014
|
+
}));
|
|
3222
3015
|
}
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
(
|
|
3228
|
-
|
|
3229
|
-
`/workspace/document?${o.join("&")}`,
|
|
3230
|
-
i
|
|
3231
|
-
);
|
|
3232
|
-
if (this.http.isResponseError())
|
|
3233
|
-
throw this.http.latestResponse.statusText;
|
|
3234
|
-
return a;
|
|
3016
|
+
}
|
|
3017
|
+
class MagnetoBehaviour extends AbstractBehaviourService {
|
|
3018
|
+
constructor() {
|
|
3019
|
+
super(...arguments);
|
|
3020
|
+
u(this, "APP", "magneto");
|
|
3021
|
+
u(this, "RESOURCE", "magneto");
|
|
3235
3022
|
}
|
|
3236
|
-
async
|
|
3237
|
-
const {
|
|
3238
|
-
|
|
3239
|
-
const a = [];
|
|
3240
|
-
i.role === "img" && a.push("quality=1"), s != null && s.alt && a.push(`alt=${s.alt}`), s != null && s.legend && a.push(`legend=${s.legend}`), s != null && s.name && a.push(`name=${s.name}`);
|
|
3241
|
-
const c = await this.http.putFile(
|
|
3242
|
-
`/workspace/document/${e}?${a.join("&")}`,
|
|
3243
|
-
o
|
|
3023
|
+
async loadResources() {
|
|
3024
|
+
const { all: t } = await this.httpGet(
|
|
3025
|
+
"/magneto/boards/editable"
|
|
3244
3026
|
);
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
}), this.http.isResponseError())
|
|
3256
|
-
throw this.http.latestResponse.statusText;
|
|
3027
|
+
return t.map((s) => this.dataToResource({
|
|
3028
|
+
_id: s._id,
|
|
3029
|
+
title: s.title,
|
|
3030
|
+
icon: s.imageUrl,
|
|
3031
|
+
owner: s.ownerId,
|
|
3032
|
+
ownerName: s.ownerName,
|
|
3033
|
+
path: `/magneto#/board/${s._id}/view`,
|
|
3034
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
3035
|
+
modified: "" + s.modificationDate
|
|
3036
|
+
}));
|
|
3257
3037
|
}
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3038
|
+
}
|
|
3039
|
+
class MindmapBehaviour extends AbstractBehaviourService {
|
|
3040
|
+
constructor() {
|
|
3041
|
+
super(...arguments);
|
|
3042
|
+
u(this, "APP", "mindmap");
|
|
3043
|
+
u(this, "RESOURCE", "mindmap");
|
|
3261
3044
|
}
|
|
3262
|
-
async
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3045
|
+
async loadResources() {
|
|
3046
|
+
return (await this.httpGet("/mindmap/list/all")).map(
|
|
3047
|
+
(s) => this.dataToResource({
|
|
3048
|
+
title: s.name,
|
|
3049
|
+
ownerName: s.owner.displayName,
|
|
3050
|
+
owner: s.owner.userId,
|
|
3051
|
+
icon: s.thumbnail || "/img/illustrations/mindmap-default.png",
|
|
3052
|
+
path: "/mindmap#/view/" + s._id,
|
|
3053
|
+
_id: s._id,
|
|
3054
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
3055
|
+
modified: s.modified
|
|
3056
|
+
})
|
|
3057
|
+
);
|
|
3267
3058
|
}
|
|
3268
|
-
|
|
3269
|
-
|
|
3059
|
+
}
|
|
3060
|
+
class PagesBehaviour extends AbstractBehaviourService {
|
|
3061
|
+
constructor() {
|
|
3062
|
+
super(...arguments);
|
|
3063
|
+
u(this, "APP", "pages");
|
|
3064
|
+
u(this, "RESOURCE", "pages");
|
|
3270
3065
|
}
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3066
|
+
async loadResources() {
|
|
3067
|
+
const t = await this.httpGet("/pages/list/all"), s = [];
|
|
3068
|
+
return t.forEach((r) => {
|
|
3069
|
+
var o;
|
|
3070
|
+
const i = r.thumbnail ? r.thumbnail + "?thumbnail=48x48" : "/img/illustrations/pages.svg";
|
|
3071
|
+
s.push(
|
|
3072
|
+
this.dataToResource({
|
|
3073
|
+
title: r.title,
|
|
3074
|
+
owner: r.owner.userId,
|
|
3075
|
+
ownerName: r.owner.displayName,
|
|
3076
|
+
icon: i,
|
|
3077
|
+
path: "/pages#/website/" + r._id,
|
|
3078
|
+
_id: r._id,
|
|
3079
|
+
shared: typeof r.shared < "u",
|
|
3080
|
+
modified: r.modified
|
|
3081
|
+
})
|
|
3082
|
+
), (o = r.pages) == null || o.forEach((a) => {
|
|
3083
|
+
s.push(
|
|
3084
|
+
this.dataToResource({
|
|
3085
|
+
title: a.title,
|
|
3086
|
+
owner: r.owner.userId,
|
|
3087
|
+
ownerName: r.owner.displayName,
|
|
3088
|
+
icon: i,
|
|
3089
|
+
path: "/pages#/website/" + r._id + "/" + a.titleLink,
|
|
3090
|
+
_id: r._id + "/" + a.titleLink,
|
|
3091
|
+
shared: typeof r.shared < "u",
|
|
3092
|
+
modified: r.modified
|
|
3093
|
+
})
|
|
3296
3094
|
);
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
}
|
|
3300
|
-
return e;
|
|
3095
|
+
});
|
|
3096
|
+
}), s;
|
|
3301
3097
|
}
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
const r = t > 0 || s > 0 ? `${t}x${s}` : "120x120";
|
|
3309
|
-
if (typeof e == "string")
|
|
3310
|
-
return e.includes("data:image") || e.includes("thumbnail") ? e : `${e}${e.includes("?") ? "&" : "?"}thumbnail=${r}`;
|
|
3311
|
-
{
|
|
3312
|
-
const a = `/workspace/${e.public ? "pub/" : ""}document/${e._id}?thumbnail=`, c = e.thumbnails;
|
|
3313
|
-
if ((o = (i = e.metadata) == null ? void 0 : i["content-type"]) != null && o.includes("video")) {
|
|
3314
|
-
const l = c && Object.keys(c).length > 0 ? Object.keys(c)[0] : null;
|
|
3315
|
-
return l ? a + l : null;
|
|
3316
|
-
} else
|
|
3317
|
-
return a + r;
|
|
3318
|
-
}
|
|
3098
|
+
}
|
|
3099
|
+
class PollBehaviour extends AbstractBehaviourService {
|
|
3100
|
+
constructor() {
|
|
3101
|
+
super(...arguments);
|
|
3102
|
+
u(this, "APP", "poll");
|
|
3103
|
+
u(this, "RESOURCE", "poll");
|
|
3319
3104
|
}
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
parentId: s,
|
|
3334
|
-
directShared: r
|
|
3335
|
-
};
|
|
3336
|
-
return this.http.get("/workspace/folders/list", {
|
|
3337
|
-
queryParams: i
|
|
3105
|
+
async loadResources() {
|
|
3106
|
+
return (await this.httpGet("/poll/list/all")).map((s) => {
|
|
3107
|
+
const r = s.icon ? s.icon + "?thumbnail=48x48" : "/img/icons/glyphicons_036_file.png";
|
|
3108
|
+
return this.dataToResource({
|
|
3109
|
+
title: s.question,
|
|
3110
|
+
ownerName: s.owner.displayName,
|
|
3111
|
+
icon: r,
|
|
3112
|
+
path: "/poll#/view/" + s._id,
|
|
3113
|
+
_id: s._id,
|
|
3114
|
+
owner: s.owner.userId,
|
|
3115
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
3116
|
+
modified: s.modified
|
|
3117
|
+
});
|
|
3338
3118
|
});
|
|
3339
3119
|
}
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3120
|
+
}
|
|
3121
|
+
class ScrapbookBehaviour extends AbstractBehaviourService {
|
|
3122
|
+
constructor() {
|
|
3123
|
+
super(...arguments);
|
|
3124
|
+
u(this, "APP", "scrapbook");
|
|
3125
|
+
u(this, "RESOURCE", "scrapbook");
|
|
3126
|
+
}
|
|
3127
|
+
async loadResources() {
|
|
3128
|
+
return (await this.httpGet(
|
|
3129
|
+
"/scrapbook/list/all"
|
|
3130
|
+
)).map((s) => {
|
|
3131
|
+
const r = s.icon || "/img/illustrations/scrapbook.svg";
|
|
3132
|
+
return this.dataToResource({
|
|
3133
|
+
title: s.name,
|
|
3134
|
+
owner: s.owner.userId,
|
|
3135
|
+
ownerName: s.owner.displayName,
|
|
3136
|
+
icon: r,
|
|
3137
|
+
path: "/scrapbook#/view-scrapbook/" + s._id,
|
|
3138
|
+
_id: s._id,
|
|
3139
|
+
shared: !!(s.shared && s.shared.length >= 0),
|
|
3140
|
+
modified: s.modified
|
|
3141
|
+
});
|
|
3142
|
+
});
|
|
3348
3143
|
}
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
listSharedFolders(e, t) {
|
|
3356
|
-
return this.listFolder("shared", e, t, !0);
|
|
3144
|
+
}
|
|
3145
|
+
class TimelinegeneratorBehaviour extends AbstractBehaviourService {
|
|
3146
|
+
constructor() {
|
|
3147
|
+
super(...arguments);
|
|
3148
|
+
u(this, "APP", "timelinegenerator");
|
|
3149
|
+
u(this, "RESOURCE", "timelinegenerator");
|
|
3357
3150
|
}
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3151
|
+
loadResources() {
|
|
3152
|
+
return new Promise(async (t, s) => {
|
|
3153
|
+
try {
|
|
3154
|
+
const i = (await this.httpGet(
|
|
3155
|
+
"/timelinegenerator/timelines"
|
|
3156
|
+
)).map((o) => {
|
|
3157
|
+
const a = o.icon || "/img/illustrations/timeline-default.png";
|
|
3158
|
+
return this.dataToResource({
|
|
3159
|
+
title: o.headline,
|
|
3160
|
+
ownerName: o.owner.displayName,
|
|
3161
|
+
owner: o.owner.userId,
|
|
3162
|
+
icon: a,
|
|
3163
|
+
path: "/timelinegenerator#/view/" + o._id,
|
|
3164
|
+
_id: o._id,
|
|
3165
|
+
shared: typeof o.shared < "u",
|
|
3166
|
+
modified: o.modified
|
|
3167
|
+
});
|
|
3168
|
+
});
|
|
3169
|
+
t(i);
|
|
3170
|
+
} catch (r) {
|
|
3171
|
+
s(r);
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3367
3174
|
}
|
|
3368
3175
|
}
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
this
|
|
3176
|
+
class WikiBehaviour extends AbstractBehaviourService {
|
|
3177
|
+
constructor() {
|
|
3178
|
+
super(...arguments);
|
|
3179
|
+
u(this, "APP", "wiki");
|
|
3180
|
+
u(this, "RESOURCE", "wiki");
|
|
3373
3181
|
}
|
|
3374
|
-
|
|
3375
|
-
return this.
|
|
3182
|
+
async loadResources() {
|
|
3183
|
+
return (await this.httpGet(
|
|
3184
|
+
"/wiki/listallpages?visible=true"
|
|
3185
|
+
)).map((s) => s.pages.map((r) => {
|
|
3186
|
+
let i;
|
|
3187
|
+
return typeof s.thumbnail > "u" || s.thumbnail === "" ? i = "/img/icons/glyphicons_036_file.png" : i = s.thumbnail + "?thumbnail=48x48", this.dataToResource({
|
|
3188
|
+
title: r.title + " [" + s.title + "]",
|
|
3189
|
+
ownerName: s.owner.displayName,
|
|
3190
|
+
owner: s.owner.userId,
|
|
3191
|
+
icon: i,
|
|
3192
|
+
path: "/wiki#/view/" + s._id + "/" + r._id,
|
|
3193
|
+
_id: `${s._id}#${r._id}`,
|
|
3194
|
+
shared: typeof s.shared < "u",
|
|
3195
|
+
modified: r.modified
|
|
3196
|
+
});
|
|
3197
|
+
})).flat();
|
|
3376
3198
|
}
|
|
3377
|
-
|
|
3378
|
-
|
|
3199
|
+
}
|
|
3200
|
+
class WorkspaceBehaviour extends AbstractBehaviourService {
|
|
3201
|
+
constructor() {
|
|
3202
|
+
super(...arguments);
|
|
3203
|
+
u(this, "APP", "workspace");
|
|
3204
|
+
u(this, "RESOURCE", "workspace");
|
|
3379
3205
|
}
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3206
|
+
loadResources({ search: t, asset_id: s }) {
|
|
3207
|
+
return new Promise(async (r, i) => {
|
|
3208
|
+
try {
|
|
3209
|
+
let o = "/workspace/documents?filter=all&hierarchical=true";
|
|
3210
|
+
s && s.length ? o += `&search=${t}` : t && t.length && (o += `&search=${t}`);
|
|
3211
|
+
const c = (await this.httpGet(o)).filter((l) => !l.deleted).map((l) => {
|
|
3212
|
+
const h = l.metadata["content-type"] && l.metadata["content-type"].indexOf("image") !== -1 ? `/workspace/document/${l._id}?thumbnail=120x120` : "/img/icons/unknown-large.png";
|
|
3213
|
+
return this.dataToResource({
|
|
3214
|
+
title: l.name,
|
|
3215
|
+
ownerName: l.ownerName,
|
|
3216
|
+
owner: l.owner,
|
|
3217
|
+
icon: h,
|
|
3218
|
+
path: `/workspace/document/${l._id}`,
|
|
3219
|
+
_id: l._id,
|
|
3220
|
+
shared: !!(l.shared && l.shared.length >= 0),
|
|
3221
|
+
modified: l.modified
|
|
3222
|
+
});
|
|
3223
|
+
});
|
|
3224
|
+
r(c);
|
|
3225
|
+
} catch (o) {
|
|
3226
|
+
i(o);
|
|
3398
3227
|
}
|
|
3399
|
-
|
|
3400
|
-
{
|
|
3401
|
-
SERVICE: s,
|
|
3402
|
-
TYPE: t.TYPE,
|
|
3403
|
-
OUTIL: t.OUTIL,
|
|
3404
|
-
UAI: t.STRUCT_UAI,
|
|
3405
|
-
PROJET: t.PROJET,
|
|
3406
|
-
EXPLOITANT: t.EXPLOITANT,
|
|
3407
|
-
PLATEFORME: t.PLATFORME,
|
|
3408
|
-
PROFIL: t.PROFILE
|
|
3409
|
-
},
|
|
3410
|
-
!0
|
|
3411
|
-
), ATTag.identifiedVisitor.set({
|
|
3412
|
-
id: t.ID_PERSO,
|
|
3413
|
-
category: t.PROFILE
|
|
3414
|
-
}), ATTag.page.set({
|
|
3415
|
-
name: (e == null ? void 0 : e.prefix) === "userbook" ? "directory" : e == null ? void 0 : e.prefix,
|
|
3416
|
-
chapter1: "",
|
|
3417
|
-
chapter2: "",
|
|
3418
|
-
chapter3: "",
|
|
3419
|
-
level2: t.STRUCT_UAI
|
|
3420
|
-
}), ATTag.dispatch();
|
|
3421
|
-
}
|
|
3422
|
-
async getXitiConfig(n) {
|
|
3423
|
-
const [e, t] = await Promise.all([
|
|
3424
|
-
this.http.get("/analyticsConf"),
|
|
3425
|
-
//FIXME change servers config to only keep the "all-in-one" query to /analyticsConf.
|
|
3426
|
-
this.http.get("/xiti/config")
|
|
3427
|
-
]);
|
|
3428
|
-
if (!(e != null && e.type))
|
|
3429
|
-
throw ERROR_CODE.MALFORMED_DATA;
|
|
3430
|
-
return t != null && t.active && (e.xiti = await this.getXitiTrackingParams(t, n)), e.xiti;
|
|
3228
|
+
});
|
|
3431
3229
|
}
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3230
|
+
}
|
|
3231
|
+
const b = class b {
|
|
3232
|
+
static async initialize(e, t) {
|
|
3233
|
+
const s = e.http();
|
|
3234
|
+
if (!this.resourceProducingApps.length) {
|
|
3235
|
+
this.resourceProducingApps = [t, "workspace"];
|
|
3236
|
+
try {
|
|
3237
|
+
const [r, i] = await Promise.all([
|
|
3238
|
+
s.get("/resources-applications"),
|
|
3239
|
+
e.session().getUser()
|
|
3240
|
+
]);
|
|
3241
|
+
i != null && i.apps && (r != null && r.length) && (this.resourceProducingApps = r.filter(
|
|
3242
|
+
(o) => i.apps.some((a) => a.address.includes(o))
|
|
3243
|
+
));
|
|
3244
|
+
} catch (r) {
|
|
3245
|
+
console.warn("Failed to load resource-producing apps:", r);
|
|
3246
|
+
}
|
|
3440
3247
|
}
|
|
3248
|
+
return this.resourceProducingApps;
|
|
3441
3249
|
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3250
|
+
static registerCustomBehaviour(e, t, s) {
|
|
3251
|
+
this.registry.register({ application: e, resourceType: t }, s);
|
|
3252
|
+
}
|
|
3253
|
+
static async registerBehaviours(e) {
|
|
3254
|
+
this.resourceProducingApps.forEach((t) => {
|
|
3255
|
+
const s = { application: e, resourceType: t };
|
|
3256
|
+
this.registry.register(
|
|
3257
|
+
s,
|
|
3258
|
+
(r) => this.serviceFor(r, e, t)
|
|
3259
|
+
);
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
static serviceFor(e, t, s) {
|
|
3445
3263
|
let r;
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3264
|
+
switch (s) {
|
|
3265
|
+
case "timelinegenerator":
|
|
3266
|
+
r = new TimelinegeneratorBehaviour(e);
|
|
3267
|
+
break;
|
|
3268
|
+
case "workspace":
|
|
3269
|
+
r = new WorkspaceBehaviour(e);
|
|
3270
|
+
break;
|
|
3271
|
+
case "blog":
|
|
3272
|
+
r = new BlogBehaviour(e);
|
|
3273
|
+
break;
|
|
3274
|
+
case "actualites":
|
|
3275
|
+
r = new ActualitesBehaviour(e);
|
|
3276
|
+
break;
|
|
3277
|
+
case "wiki":
|
|
3278
|
+
r = new WikiBehaviour(e);
|
|
3279
|
+
break;
|
|
3280
|
+
case "pages":
|
|
3281
|
+
r = new PagesBehaviour(e);
|
|
3282
|
+
break;
|
|
3283
|
+
case "poll":
|
|
3284
|
+
r = new PollBehaviour(e);
|
|
3285
|
+
break;
|
|
3286
|
+
case "community":
|
|
3287
|
+
r = new CommunityBehaviour(e);
|
|
3288
|
+
break;
|
|
3289
|
+
case "mindmap":
|
|
3290
|
+
r = new MindmapBehaviour(e);
|
|
3291
|
+
break;
|
|
3292
|
+
case "forum":
|
|
3293
|
+
r = new ForumBehaviour(e);
|
|
3294
|
+
break;
|
|
3295
|
+
case "homeworks":
|
|
3296
|
+
r = new HomeworksBehaviour(e);
|
|
3297
|
+
break;
|
|
3298
|
+
case "scrapbook":
|
|
3299
|
+
r = new ScrapbookBehaviour(e);
|
|
3451
3300
|
break;
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3301
|
+
case "collaborativewall":
|
|
3302
|
+
r = new CollaborativewallBehaviour(e);
|
|
3303
|
+
break;
|
|
3304
|
+
case "exercizer":
|
|
3305
|
+
r = new ExercizerBehaviour(e);
|
|
3306
|
+
break;
|
|
3307
|
+
case "formulaire":
|
|
3308
|
+
r = new FormulaireBehaviour(e);
|
|
3309
|
+
break;
|
|
3310
|
+
case "magneto":
|
|
3311
|
+
r = new MagnetoBehaviour(e);
|
|
3312
|
+
break;
|
|
3313
|
+
case "appointments":
|
|
3314
|
+
r = new AppointmentsBehaviour(e);
|
|
3315
|
+
break;
|
|
3316
|
+
default:
|
|
3317
|
+
throw ERROR_CODE.NOT_SUPPORTED;
|
|
3464
3318
|
}
|
|
3465
|
-
|
|
3466
|
-
Student: "ELEVE",
|
|
3467
|
-
Teacher: "ENSEIGNANT",
|
|
3468
|
-
Relative: "PARENT",
|
|
3469
|
-
Personnel: "ADMIN_VIE_SCOL_TECH",
|
|
3470
|
-
Guest: "AUTRE"
|
|
3471
|
-
};
|
|
3472
|
-
return {
|
|
3473
|
-
LIBELLE_SERVICE: o.LIBELLE_SERVICE,
|
|
3474
|
-
// Which property of LIBELLE_SERVICE to use depends on the frontend.
|
|
3475
|
-
TYPE: o.OUTIL ? "TIERS" : "NATIF",
|
|
3476
|
-
OUTIL: o.OUTIL ? o.OUTIL : "",
|
|
3477
|
-
STRUCT_ID: r.collectiviteId,
|
|
3478
|
-
STRUCT_UAI: r.UAI,
|
|
3479
|
-
PROJET: r.projetId ? r.projetId : n.ID_PROJET,
|
|
3480
|
-
EXPLOITANT: n.ID_EXPLOITANT,
|
|
3481
|
-
PLATFORME: r.plateformeId ? r.plateformeId : n.ID_PLATEFORME,
|
|
3482
|
-
ID_PERSO: a(t.userId),
|
|
3483
|
-
PROFILE: s && s.length > 0 ? c[s[0]] ?? "" : ""
|
|
3484
|
-
};
|
|
3319
|
+
return r.APP = t, r;
|
|
3485
3320
|
}
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
|
|
3321
|
+
};
|
|
3322
|
+
//
|
|
3323
|
+
// STATIC REGISTRY
|
|
3324
|
+
//
|
|
3325
|
+
u(b, "registry", new ServiceRegistry()), // Expose some useful functions
|
|
3326
|
+
u(b, "findBehaviour", b.registry.findService.bind(b.registry)), u(b, "hasBehaviour", b.registry.isRegistered.bind(b.registry)), u(b, "resourceProducingApps", []);
|
|
3327
|
+
let SnipletsService = b;
|
|
3328
|
+
class RightService {
|
|
3489
3329
|
constructor(e) {
|
|
3490
3330
|
this.context = e;
|
|
3491
3331
|
}
|
|
3492
|
-
get
|
|
3493
|
-
return this.context.
|
|
3494
|
-
}
|
|
3495
|
-
get conf() {
|
|
3496
|
-
return this.context.conf();
|
|
3332
|
+
get session() {
|
|
3333
|
+
return this.context.session();
|
|
3497
3334
|
}
|
|
3498
3335
|
/**
|
|
3499
|
-
*
|
|
3500
|
-
*
|
|
3336
|
+
* Parse right concat as "$TYPE:$ID:$RIGHT"
|
|
3337
|
+
* $TYPE = user | group | creator
|
|
3338
|
+
* $ID: id of the resource
|
|
3339
|
+
* $RIGHT: read | contrib | manage
|
|
3340
|
+
*
|
|
3341
|
+
* @param right a concat right
|
|
3342
|
+
* @returns Right parsed
|
|
3501
3343
|
*/
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3344
|
+
parseResourceRight(e) {
|
|
3345
|
+
const t = e.split(":");
|
|
3346
|
+
if (t.length === 2) {
|
|
3347
|
+
if (t[0] === "creator")
|
|
3348
|
+
return {
|
|
3349
|
+
id: t[1],
|
|
3350
|
+
right: "creator",
|
|
3351
|
+
type: "creator"
|
|
3352
|
+
};
|
|
3353
|
+
} else return t.length === 3 ? {
|
|
3354
|
+
id: t[1],
|
|
3355
|
+
right: t[2],
|
|
3356
|
+
type: t[0]
|
|
3357
|
+
} : void 0;
|
|
3514
3358
|
}
|
|
3515
3359
|
/**
|
|
3516
|
-
*
|
|
3517
|
-
*
|
|
3518
|
-
*
|
|
3360
|
+
* Parse an array of rights concat as "$TYPE:$ID:$RIGHT"
|
|
3361
|
+
* $TYPE = user | group | creator
|
|
3362
|
+
* $ID: id of the resource
|
|
3363
|
+
* $RIGHT: read | contrib | manage
|
|
3364
|
+
*
|
|
3365
|
+
* @param rights a list of concat rights
|
|
3366
|
+
* @returns Array of Right parsed
|
|
3519
3367
|
*/
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
appCode: t,
|
|
3523
|
-
captation: s,
|
|
3524
|
-
duration: r
|
|
3525
|
-
}) {
|
|
3526
|
-
if (!e.file)
|
|
3527
|
-
throw new Error("Invalid video file.");
|
|
3528
|
-
if (!e.filename)
|
|
3529
|
-
throw new Error("Invalid video filename");
|
|
3530
|
-
const i = `${e.browser.name} ${e.browser.version}`, o = new FormData();
|
|
3531
|
-
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);
|
|
3532
|
-
let a = `/video/encode?captation=${s}`;
|
|
3533
|
-
r && (a += `&duration=${r}`);
|
|
3534
|
-
const c = await this.http.post(
|
|
3535
|
-
a,
|
|
3536
|
-
o,
|
|
3537
|
-
{ headers: { "Content-Type": "multipart/form-data" } }
|
|
3538
|
-
);
|
|
3539
|
-
if (c.state == "running") {
|
|
3540
|
-
let l = 0, p = 1;
|
|
3541
|
-
do {
|
|
3542
|
-
const E = p + l;
|
|
3543
|
-
await new Promise(
|
|
3544
|
-
(y) => setTimeout(y, E * 1e3)
|
|
3545
|
-
), l = p, p = Math.min(8, E);
|
|
3546
|
-
const h = await this.http.get(
|
|
3547
|
-
`/video/status/${c.processid}`
|
|
3548
|
-
);
|
|
3549
|
-
if (h.state == "succeed")
|
|
3550
|
-
return h.videoworkspaceid && h.videosize && this.context.data().trackVideoSave(
|
|
3551
|
-
h.videoworkspaceid,
|
|
3552
|
-
Math.round(r),
|
|
3553
|
-
h.videosize,
|
|
3554
|
-
s,
|
|
3555
|
-
e.url,
|
|
3556
|
-
i,
|
|
3557
|
-
e.device
|
|
3558
|
-
), h;
|
|
3559
|
-
if (h.state == "error")
|
|
3560
|
-
break;
|
|
3561
|
-
} while (!0);
|
|
3562
|
-
}
|
|
3563
|
-
throw new Error("Video cannot be uploaded.");
|
|
3564
|
-
}
|
|
3565
|
-
};
|
|
3566
|
-
u(R, "MAX_WEIGHT", 50), // in Mbytes. Applies to uploaded videos.
|
|
3567
|
-
u(R, "MAX_DURATION", 3);
|
|
3568
|
-
let VideoService = R;
|
|
3569
|
-
class EmbedderService {
|
|
3570
|
-
constructor(e) {
|
|
3571
|
-
this.context = e;
|
|
3572
|
-
}
|
|
3573
|
-
get http() {
|
|
3574
|
-
return this.context.http();
|
|
3368
|
+
parseResourceRights(e) {
|
|
3369
|
+
return e.map((s) => this.parseResourceRight(s)).filter((s) => s !== void 0);
|
|
3575
3370
|
}
|
|
3576
3371
|
/**
|
|
3577
|
-
*
|
|
3578
|
-
* @
|
|
3372
|
+
* Check wether a user has the expected right for a resource
|
|
3373
|
+
* @param user the userId and groupId concerned by the check
|
|
3374
|
+
* @param expect the expected right to check
|
|
3375
|
+
* @param rights array of Right for the resource
|
|
3376
|
+
* @returns true if has rights
|
|
3579
3377
|
*/
|
|
3580
|
-
|
|
3581
|
-
|
|
3378
|
+
hasResourceRight({ id: e, groupIds: t }, s, r) {
|
|
3379
|
+
const i = r.map((o) => typeof o == "string" ? this.parseResourceRight(o) : o).filter((o) => o !== void 0);
|
|
3380
|
+
for (const o of i) {
|
|
3381
|
+
if (o.id === e && o.type === "creator")
|
|
3382
|
+
return !0;
|
|
3383
|
+
if (o.id === e && o.type === "user" && o.right === s)
|
|
3384
|
+
return !0;
|
|
3385
|
+
if (t.includes(o.id) && o.type === "group" && o.right === s)
|
|
3386
|
+
return !0;
|
|
3387
|
+
}
|
|
3388
|
+
return !1;
|
|
3582
3389
|
}
|
|
3583
3390
|
/**
|
|
3584
|
-
*
|
|
3585
|
-
* @
|
|
3391
|
+
* Check wether the current user have resource right
|
|
3392
|
+
* @param expect the expected right to check
|
|
3393
|
+
* @param rights array of Right for the resource
|
|
3394
|
+
* @returns true if has rights
|
|
3586
3395
|
*/
|
|
3587
|
-
async
|
|
3588
|
-
|
|
3396
|
+
async sessionHasResourceRight(e, t) {
|
|
3397
|
+
try {
|
|
3398
|
+
const s = await this.session.getUser();
|
|
3399
|
+
return !!s && this.hasResourceRight(
|
|
3400
|
+
{ groupIds: s.groupsIds, id: s.userId },
|
|
3401
|
+
e,
|
|
3402
|
+
t
|
|
3403
|
+
);
|
|
3404
|
+
} catch (s) {
|
|
3405
|
+
return console.error(`Unexpected error ${s} in sessionHasResourceRight()`), !1;
|
|
3406
|
+
}
|
|
3589
3407
|
}
|
|
3590
3408
|
/**
|
|
3591
|
-
*
|
|
3592
|
-
* @param
|
|
3593
|
-
* @param
|
|
3594
|
-
* @returns
|
|
3409
|
+
* Check wether the current user have at least one of resource right expected
|
|
3410
|
+
* @param expects array of expected right to check
|
|
3411
|
+
* @param rights array of Right for the resource
|
|
3412
|
+
* @returns true if has rights
|
|
3595
3413
|
*/
|
|
3596
|
-
|
|
3414
|
+
async sessionHasAtLeastOneResourceRight(e, t) {
|
|
3597
3415
|
for (const s of e)
|
|
3598
|
-
if (this.
|
|
3599
|
-
return
|
|
3416
|
+
if (await this.sessionHasResourceRight(s, t))
|
|
3417
|
+
return !0;
|
|
3418
|
+
return !1;
|
|
3600
3419
|
}
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
}), i;
|
|
3420
|
+
/**
|
|
3421
|
+
* Check wether the current user has resource right for each right list
|
|
3422
|
+
* @param expect expected right to check
|
|
3423
|
+
* @param rightsArray array of array of Right for multiple resources
|
|
3424
|
+
* @returns true if has rights
|
|
3425
|
+
*/
|
|
3426
|
+
async sessionHasResourceRightForEachList(e, t) {
|
|
3427
|
+
let s = 0;
|
|
3428
|
+
for (const r of t)
|
|
3429
|
+
await this.sessionHasResourceRight(e, r) && s++;
|
|
3430
|
+
return s === t.length;
|
|
3613
3431
|
}
|
|
3614
3432
|
/**
|
|
3615
|
-
* Check
|
|
3616
|
-
* @param
|
|
3617
|
-
* @param
|
|
3618
|
-
* @returns
|
|
3433
|
+
* Check wether the current user have at least one of resource right for each right list
|
|
3434
|
+
* @param expects array of expected right to check
|
|
3435
|
+
* @param rightsArray array of array of Right for multiple resources
|
|
3436
|
+
* @returns true if has rights
|
|
3619
3437
|
*/
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3438
|
+
async sessionHasAtLeastOneResourceRightForEachList(e, t) {
|
|
3439
|
+
for (const s of e) {
|
|
3440
|
+
let r = 0;
|
|
3441
|
+
for (const i of t)
|
|
3442
|
+
await this.sessionHasResourceRight(s, i) && r++;
|
|
3443
|
+
if (r === t.length)
|
|
3624
3444
|
return !0;
|
|
3445
|
+
}
|
|
3625
3446
|
return !1;
|
|
3626
3447
|
}
|
|
3448
|
+
hasWorkflowRight(e, t) {
|
|
3449
|
+
return t.findIndex((s) => s === e) !== -1;
|
|
3450
|
+
}
|
|
3627
3451
|
/**
|
|
3628
|
-
*
|
|
3629
|
-
* @
|
|
3630
|
-
* @param {String} url - The URL for the video
|
|
3631
|
-
* @returns embed code to display the video for an URL and a provider
|
|
3452
|
+
* @param expect a workflow right
|
|
3453
|
+
* @returns true if current session has right on it
|
|
3632
3454
|
*/
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3455
|
+
async sessionHasWorkflowRight(e) {
|
|
3456
|
+
try {
|
|
3457
|
+
const t = await this.session.getUser();
|
|
3458
|
+
return !!t && this.hasWorkflowRight(
|
|
3459
|
+
e,
|
|
3460
|
+
t.authorizedActions.map(
|
|
3461
|
+
(s) => s.name
|
|
3462
|
+
)
|
|
3463
|
+
);
|
|
3464
|
+
} catch (t) {
|
|
3465
|
+
return console.error(`Unexpected error ${t} in sessionHasWorkflowRight()`), !1;
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
/**
|
|
3469
|
+
* @param expect a workflow right
|
|
3470
|
+
* @returns a record with right as key and boolean as value if current session has right on it
|
|
3471
|
+
*/
|
|
3472
|
+
async sessionHasWorkflowRights(e) {
|
|
3473
|
+
const t = {};
|
|
3474
|
+
try {
|
|
3475
|
+
const s = await this.session.getUser();
|
|
3476
|
+
for (const r of e)
|
|
3477
|
+
t[r] = !!s && this.hasWorkflowRight(
|
|
3478
|
+
r,
|
|
3479
|
+
s.authorizedActions.map(
|
|
3480
|
+
(i) => i.name
|
|
3481
|
+
)
|
|
3482
|
+
);
|
|
3483
|
+
} catch (s) {
|
|
3484
|
+
console.error(`Unexpected error ${s} in sessionHasWorkflowRights()`);
|
|
3485
|
+
for (const r of e)
|
|
3486
|
+
t[r] = !1;
|
|
3487
|
+
}
|
|
3488
|
+
return t;
|
|
3653
3489
|
}
|
|
3654
3490
|
}
|
|
3655
|
-
class
|
|
3656
|
-
//
|
|
3657
|
-
// IMPLEMENTATION
|
|
3658
|
-
//
|
|
3491
|
+
class SessionService {
|
|
3659
3492
|
constructor(e) {
|
|
3660
|
-
|
|
3661
|
-
//--- Utilities ---
|
|
3662
|
-
//-----------------
|
|
3663
|
-
u(this, "_cache");
|
|
3664
|
-
this.context = e, this._cache = new CacheService(this.context);
|
|
3493
|
+
this.context = e;
|
|
3665
3494
|
}
|
|
3666
|
-
|
|
3667
|
-
return this.
|
|
3495
|
+
get http() {
|
|
3496
|
+
return this.context.http();
|
|
3668
3497
|
}
|
|
3669
|
-
|
|
3670
|
-
return this.
|
|
3498
|
+
get cache() {
|
|
3499
|
+
return this.context.cache();
|
|
3671
3500
|
}
|
|
3672
|
-
|
|
3673
|
-
return this.
|
|
3501
|
+
get conf() {
|
|
3502
|
+
return this.context.conf();
|
|
3674
3503
|
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3504
|
+
/**
|
|
3505
|
+
* Callback to call when user logout
|
|
3506
|
+
*/
|
|
3507
|
+
onLogout() {
|
|
3508
|
+
this.cache.clearCache();
|
|
3509
|
+
}
|
|
3510
|
+
/**
|
|
3511
|
+
* Callback to call when session change
|
|
3512
|
+
*/
|
|
3513
|
+
onRefreshSession() {
|
|
3514
|
+
this.cache.clearCache();
|
|
3515
|
+
}
|
|
3516
|
+
async getSession() {
|
|
3517
|
+
const [e, t] = await Promise.all([
|
|
3518
|
+
this.getUser(),
|
|
3519
|
+
this.getPerson()
|
|
3520
|
+
]), [
|
|
3521
|
+
s,
|
|
3522
|
+
r,
|
|
3523
|
+
i,
|
|
3524
|
+
o,
|
|
3525
|
+
a
|
|
3526
|
+
] = await Promise.all([
|
|
3527
|
+
this.getCurrentLanguage(e),
|
|
3528
|
+
this.latestQuotaAndUsage(e),
|
|
3529
|
+
this.loadDescription(e),
|
|
3530
|
+
this.getUserProfile(),
|
|
3531
|
+
this.getBookmarks(e)
|
|
3532
|
+
]), { type: c, ...l } = t || {}, h = {
|
|
3533
|
+
...l,
|
|
3534
|
+
profiles: c || ["Guest"],
|
|
3535
|
+
// "type" field from /userbook/api/person becomes "profiles"
|
|
3536
|
+
...i
|
|
3537
|
+
// Inject other fields (also the correct "type")
|
|
3538
|
+
};
|
|
3681
3539
|
return {
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
modifiedAt: s,
|
|
3689
|
-
shared: t.shared,
|
|
3690
|
-
path: t.path
|
|
3540
|
+
user: e,
|
|
3541
|
+
quotaAndUsage: r,
|
|
3542
|
+
currentLanguage: s,
|
|
3543
|
+
userDescription: h,
|
|
3544
|
+
userProfile: o,
|
|
3545
|
+
bookmarkedApps: a
|
|
3691
3546
|
};
|
|
3692
3547
|
}
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3548
|
+
login(e, t, s, r) {
|
|
3549
|
+
const i = new FormData();
|
|
3550
|
+
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, {
|
|
3551
|
+
headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
3552
|
+
}).finally(() => {
|
|
3553
|
+
switch (this.http.latestResponse.status) {
|
|
3554
|
+
case 200:
|
|
3555
|
+
throw ERROR_CODE.MALFORMED_DATA;
|
|
3556
|
+
}
|
|
3557
|
+
});
|
|
3699
3558
|
}
|
|
3700
|
-
async
|
|
3701
|
-
const
|
|
3702
|
-
|
|
3703
|
-
this.httpGet("/actualites/api/v1/threads")
|
|
3704
|
-
]), r = s.reduce(
|
|
3705
|
-
(i, o) => i.set(o.id, o),
|
|
3706
|
-
/* @__PURE__ */ new Map()
|
|
3707
|
-
);
|
|
3708
|
-
return t.map((i) => {
|
|
3709
|
-
var a;
|
|
3710
|
-
let o;
|
|
3711
|
-
return i.threadIcon ? o = i.threadIcon + "?thumbnail=48x48" : o = "/img/icons/glyphicons_036_file.png", this.dataToResource({
|
|
3712
|
-
title: i.title + " [" + ((a = r.get(i.threadId)) == null ? void 0 : a.title) + "]",
|
|
3713
|
-
ownerName: i.owner.displayName,
|
|
3714
|
-
owner: i.owner.id,
|
|
3715
|
-
icon: o,
|
|
3716
|
-
path: "/actualites/threads/" + i.threadId + "?info=" + i.id,
|
|
3717
|
-
_id: `${i.threadId}#${i.id}`,
|
|
3718
|
-
shared: !!(i.shared && i.shared.length >= 0),
|
|
3719
|
-
modified: i.modified
|
|
3720
|
-
});
|
|
3559
|
+
async logout() {
|
|
3560
|
+
const e = await this.conf.getLogoutCallback();
|
|
3561
|
+
return this.http.get("/auth/logout?callback=" + e).finally(() => {
|
|
3721
3562
|
});
|
|
3722
3563
|
}
|
|
3723
|
-
|
|
3724
|
-
const
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
u(this, "APP", "appointments");
|
|
3734
|
-
u(this, "RESOURCE", "appointments");
|
|
3564
|
+
async latestQuotaAndUsage(e) {
|
|
3565
|
+
const t = { quota: 0, storage: 0 };
|
|
3566
|
+
if (!e) return t;
|
|
3567
|
+
try {
|
|
3568
|
+
return await this.http.get(
|
|
3569
|
+
`/workspace/quota/user/${e == null ? void 0 : e.userId}`
|
|
3570
|
+
);
|
|
3571
|
+
} catch (s) {
|
|
3572
|
+
return console.error(s), t;
|
|
3573
|
+
}
|
|
3735
3574
|
}
|
|
3736
|
-
async
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
shared: !1,
|
|
3745
|
-
modified: s.updatingDate
|
|
3746
|
-
}));
|
|
3575
|
+
async getCurrentLanguage(e) {
|
|
3576
|
+
const t = (e == null ? void 0 : e.sessionMetadata) && (e == null ? void 0 : e.sessionMetadata.userId);
|
|
3577
|
+
try {
|
|
3578
|
+
let s;
|
|
3579
|
+
return t ? s = await this.loadUserLanguage() : s = await this.loadDefaultLanguage(), s;
|
|
3580
|
+
} catch (s) {
|
|
3581
|
+
console.error(s);
|
|
3582
|
+
}
|
|
3747
3583
|
}
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3584
|
+
async loadUserLanguage() {
|
|
3585
|
+
try {
|
|
3586
|
+
const e = await this.http.get(
|
|
3587
|
+
"/userbook/preference/language"
|
|
3588
|
+
);
|
|
3589
|
+
return JSON.parse(e.preference)["default-domain"];
|
|
3590
|
+
} catch {
|
|
3591
|
+
return await this.loadDefaultLanguage();
|
|
3592
|
+
}
|
|
3754
3593
|
}
|
|
3755
|
-
|
|
3756
|
-
return
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3594
|
+
async loadDefaultLanguage() {
|
|
3595
|
+
return (await this.cache.httpGetJson(
|
|
3596
|
+
"/locale"
|
|
3597
|
+
)).locale;
|
|
3598
|
+
}
|
|
3599
|
+
async getUser() {
|
|
3600
|
+
const { response: e, value: t } = await this.cache.httpGet(
|
|
3601
|
+
"/auth/oauth2/userinfo"
|
|
3602
|
+
);
|
|
3603
|
+
if (!(e.status < 200 || e.status >= 300) && typeof t == "object")
|
|
3604
|
+
return t;
|
|
3605
|
+
throw ERROR_CODE.NOT_LOGGED_IN;
|
|
3606
|
+
}
|
|
3607
|
+
hasWorkflow({
|
|
3608
|
+
workflowName: e,
|
|
3609
|
+
user: t
|
|
3610
|
+
}) {
|
|
3611
|
+
return e === void 0 || (t == null ? void 0 : t.authorizedActions.findIndex((s) => s.name === e)) !== -1;
|
|
3612
|
+
}
|
|
3613
|
+
async loadDescription(e) {
|
|
3614
|
+
if (!e) return {};
|
|
3615
|
+
try {
|
|
3616
|
+
const [t, s] = await Promise.all([
|
|
3617
|
+
// FIXME The full user's description should be obtainable from a single endpoint in the backend.
|
|
3618
|
+
this.getUserProfile({
|
|
3619
|
+
options: { requestName: "refreshAvatar" }
|
|
3620
|
+
}),
|
|
3621
|
+
this.http.get("/directory/userbook/" + (e == null ? void 0 : e.userId))
|
|
3622
|
+
]);
|
|
3623
|
+
return { ...s, profiles: t };
|
|
3624
|
+
} catch (t) {
|
|
3625
|
+
return console.error(t), {};
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
async getBookmarks(e) {
|
|
3629
|
+
if (!e) return [];
|
|
3630
|
+
const t = await this.http.get("/userbook/preference/apps");
|
|
3631
|
+
t.preference || (t.preference = null);
|
|
3632
|
+
const s = JSON.parse(t.preference);
|
|
3633
|
+
let r;
|
|
3634
|
+
r = s, r || (r = {
|
|
3635
|
+
bookmarks: [],
|
|
3636
|
+
applications: []
|
|
3776
3637
|
});
|
|
3638
|
+
const i = [];
|
|
3639
|
+
return r.bookmarks.forEach((o, a) => {
|
|
3640
|
+
const c = ((e == null ? void 0 : e.apps) || []).find(
|
|
3641
|
+
(l) => l.name === o
|
|
3642
|
+
);
|
|
3643
|
+
if (c) {
|
|
3644
|
+
const l = Object.assign({}, c);
|
|
3645
|
+
i.push(l);
|
|
3646
|
+
}
|
|
3647
|
+
}), i;
|
|
3777
3648
|
}
|
|
3778
|
-
}
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
super(...arguments);
|
|
3782
|
-
u(this, "APP", "collaborativewall");
|
|
3783
|
-
u(this, "RESOURCE", "collaborativewall");
|
|
3649
|
+
async getUserProfile(e = {}) {
|
|
3650
|
+
const t = await this.getPerson(e);
|
|
3651
|
+
return (t == null ? void 0 : t.type) || ["Guest"];
|
|
3784
3652
|
}
|
|
3785
|
-
async
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
title: s.name,
|
|
3791
|
-
ownerName: s.owner.displayName,
|
|
3792
|
-
owner: s.owner.userId,
|
|
3793
|
-
icon: s.icon ? s.icon : "/img/illustrations/collaborative-wall-default.png",
|
|
3794
|
-
path: "/collaborativewall#/view/" + s._id,
|
|
3795
|
-
_id: s._id,
|
|
3796
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
3797
|
-
modified: s.modified
|
|
3798
|
-
})
|
|
3653
|
+
async getPerson(e = {}) {
|
|
3654
|
+
var c;
|
|
3655
|
+
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(
|
|
3656
|
+
i,
|
|
3657
|
+
t
|
|
3799
3658
|
);
|
|
3659
|
+
return o.status < 200 || o.status >= 300 || typeof a == "string" ? null : ((c = a == null ? void 0 : a.result) == null ? void 0 : c[0]) || null;
|
|
3800
3660
|
}
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
super(...arguments);
|
|
3805
|
-
u(this, "APP", "community");
|
|
3806
|
-
u(this, "RESOURCE", "community");
|
|
3661
|
+
async isAdml() {
|
|
3662
|
+
const e = await this.getUser();
|
|
3663
|
+
return (e == null ? void 0 : e.functions.ADMIN_LOCAL) !== void 0;
|
|
3807
3664
|
}
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
_id: s.id,
|
|
3818
|
-
owner: "",
|
|
3819
|
-
ownerName: "",
|
|
3820
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
3821
|
-
modified: s.name
|
|
3822
|
-
// FIXME date ?
|
|
3823
|
-
});
|
|
3665
|
+
/**
|
|
3666
|
+
* Get details of an application if the user can access it.
|
|
3667
|
+
* @return undefined if no access, or app not found
|
|
3668
|
+
*/
|
|
3669
|
+
async getWebApp(e) {
|
|
3670
|
+
const t = await this.getUser();
|
|
3671
|
+
return t == null ? void 0 : t.apps.find((s) => {
|
|
3672
|
+
var r;
|
|
3673
|
+
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;
|
|
3824
3674
|
});
|
|
3825
3675
|
}
|
|
3826
3676
|
}
|
|
3827
|
-
class
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
return
|
|
3835
|
-
"/exercizer/subjects-scheduled"
|
|
3836
|
-
)).map((s) => {
|
|
3837
|
-
const r = s.picture ? s.picture + "?thumbnail=48x48" : "/img/illustrations/exercizer.svg";
|
|
3838
|
-
let i, o = !1;
|
|
3839
|
-
const a = JSON.parse(s.scheduled_at);
|
|
3840
|
-
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({
|
|
3841
|
-
title: s.title,
|
|
3842
|
-
owner: s.owner,
|
|
3843
|
-
ownerName: i,
|
|
3844
|
-
icon: r,
|
|
3845
|
-
path: "/exercizer#/linker/" + s.id,
|
|
3846
|
-
_id: "" + s.id,
|
|
3847
|
-
shared: o,
|
|
3848
|
-
modified: s.modified
|
|
3849
|
-
});
|
|
3850
|
-
});
|
|
3677
|
+
class StringUtils {
|
|
3678
|
+
static removeAccents(e) {
|
|
3679
|
+
for (let t = 0; t < defaultDiacriticsRemovalMap.length; t++)
|
|
3680
|
+
e = e.replace(
|
|
3681
|
+
defaultDiacriticsRemovalMap[t].letters,
|
|
3682
|
+
defaultDiacriticsRemovalMap[t].base
|
|
3683
|
+
);
|
|
3684
|
+
return e;
|
|
3851
3685
|
}
|
|
3852
3686
|
}
|
|
3853
|
-
class
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3687
|
+
class ShareService {
|
|
3688
|
+
//
|
|
3689
|
+
// IMPLEMENTATION
|
|
3690
|
+
//
|
|
3691
|
+
constructor(e) {
|
|
3692
|
+
this.context = e;
|
|
3858
3693
|
}
|
|
3859
|
-
|
|
3860
|
-
return
|
|
3861
|
-
"/formulaire/forms/linker"
|
|
3862
|
-
)).map((s) => (s.picture || (s.picture = "/formulaire/public/img/logo.svg"), this.dataToResource({
|
|
3863
|
-
_id: "" + s.id,
|
|
3864
|
-
icon: s.picture,
|
|
3865
|
-
title: s.title,
|
|
3866
|
-
ownerName: s.owner_name,
|
|
3867
|
-
owner: s.owner_id,
|
|
3868
|
-
path: s.is_public ? `${window.location.origin}/formulaire-public#/form/${s.public_key}` : `${window.location.origin}/formulaire#/form/${s.id}/${s.rgpd ? "rgpd" : "new"}`,
|
|
3869
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
3870
|
-
modified: "" + s.date_modification
|
|
3871
|
-
})));
|
|
3694
|
+
get directory() {
|
|
3695
|
+
return this.context.directory();
|
|
3872
3696
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
constructor() {
|
|
3876
|
-
super(...arguments);
|
|
3877
|
-
u(this, "APP", "forum");
|
|
3878
|
-
u(this, "RESOURCE", "forum");
|
|
3697
|
+
get http() {
|
|
3698
|
+
return this.context.http();
|
|
3879
3699
|
}
|
|
3880
|
-
|
|
3881
|
-
return
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3700
|
+
get cache() {
|
|
3701
|
+
return this.context.cache();
|
|
3702
|
+
}
|
|
3703
|
+
getSearchUrl(e, t, s, r) {
|
|
3704
|
+
if (!r)
|
|
3705
|
+
return `/${e}/share/json/${t}?search=${s}`;
|
|
3706
|
+
if (r.includes("?search=")) {
|
|
3707
|
+
const [i] = r.split("?search=");
|
|
3708
|
+
return `${i}?search=${s}`;
|
|
3709
|
+
} else return r.includes("?") ? `${r}&search=${s}` : `${r}?search=${s}`;
|
|
3710
|
+
}
|
|
3711
|
+
async searchShareSubjects(e, t, s, r) {
|
|
3712
|
+
const i = StringUtils.removeAccents(s).toLowerCase(), o = this.getSearchUrl(
|
|
3713
|
+
e,
|
|
3714
|
+
t,
|
|
3715
|
+
s,
|
|
3716
|
+
r
|
|
3717
|
+
), a = await this.cache.httpGetJson(o), c = a.users.visibles.filter(({ username: p, firstName: y, lastName: d, login: g }) => {
|
|
3718
|
+
const A = StringUtils.removeAccents(
|
|
3719
|
+
d || ""
|
|
3720
|
+
).toLowerCase(), f = StringUtils.removeAccents(
|
|
3721
|
+
y || ""
|
|
3722
|
+
).toLowerCase(), w = StringUtils.removeAccents(
|
|
3723
|
+
p || ""
|
|
3724
|
+
).toLowerCase(), F = StringUtils.removeAccents(g || "").toLowerCase();
|
|
3725
|
+
return w.includes(i) || f.includes(i) || A.includes(i) || F.includes(i);
|
|
3726
|
+
}).map((p) => ({
|
|
3727
|
+
avatarUrl: this.directory.getAvatarUrl(p.id, "user"),
|
|
3728
|
+
directoryUrl: this.directory.getDirectoryUrl(p.id, "user"),
|
|
3729
|
+
displayName: p.username,
|
|
3730
|
+
id: p.id,
|
|
3731
|
+
profile: p.profile,
|
|
3732
|
+
type: "user"
|
|
3733
|
+
})), l = a.groups.visibles.filter(({ name: p }) => StringUtils.removeAccents(p || "").toLowerCase().includes(i)).map((p) => ({
|
|
3734
|
+
avatarUrl: this.directory.getAvatarUrl(p.id, "group"),
|
|
3735
|
+
directoryUrl: this.directory.getDirectoryUrl(p.id, "group"),
|
|
3736
|
+
displayName: p.name,
|
|
3737
|
+
id: p.id,
|
|
3738
|
+
type: "group",
|
|
3739
|
+
structureName: p.structureName
|
|
3740
|
+
}));
|
|
3741
|
+
return [...(await this.directory.getBookMarks()).filter(({ displayName: p }) => StringUtils.removeAccents(
|
|
3742
|
+
p || ""
|
|
3743
|
+
).toLowerCase().includes(i)).map((p) => ({
|
|
3744
|
+
avatarUrl: "",
|
|
3745
|
+
directoryUrl: "",
|
|
3746
|
+
profile: "",
|
|
3747
|
+
displayName: p.displayName,
|
|
3748
|
+
id: p.id,
|
|
3749
|
+
type: "sharebookmark"
|
|
3750
|
+
})), ...c, ...l];
|
|
3751
|
+
}
|
|
3752
|
+
async getShareMapping(e, t) {
|
|
3753
|
+
const s = await this.cache.httpGetJson(
|
|
3754
|
+
t || `/${e}/rights/sharing`
|
|
3755
|
+
);
|
|
3756
|
+
for (const r of Object.keys(s))
|
|
3757
|
+
if (r.includes(".")) {
|
|
3758
|
+
const i = r.split(".")[1], o = s[r];
|
|
3759
|
+
delete s[r], s[i] = o;
|
|
3760
|
+
}
|
|
3761
|
+
return s;
|
|
3762
|
+
}
|
|
3763
|
+
getActionsAvailableFor({ id: e, type: t }, s, r) {
|
|
3764
|
+
const o = (t === "user" ? s.users.checked[e] : s.groups.checked[e]) || [], a = Object.keys(r), c = [];
|
|
3765
|
+
for (const l of a)
|
|
3766
|
+
r[l].filter(
|
|
3767
|
+
(p) => o.includes(p)
|
|
3768
|
+
).length > 0 && c.push(l);
|
|
3769
|
+
return c;
|
|
3770
|
+
}
|
|
3771
|
+
async getRightsForResource(e, t, s) {
|
|
3772
|
+
const r = await this.directory.getBookMarks(), i = this.getSearchUrl(
|
|
3773
|
+
e,
|
|
3774
|
+
t,
|
|
3775
|
+
"",
|
|
3776
|
+
s == null ? void 0 : s.getResourceRights
|
|
3777
|
+
), o = await this.cache.httpGetJson(
|
|
3778
|
+
i
|
|
3779
|
+
), a = await this.getShareMapping(
|
|
3780
|
+
e,
|
|
3781
|
+
s == null ? void 0 : s.getShareMapping
|
|
3782
|
+
), c = await this.cache.httpGetJson(
|
|
3783
|
+
"/infra/public/json/sharing-rights.json"
|
|
3784
|
+
), l = Object.keys(o.users.checked).map((d) => o.users.visibles.find(
|
|
3785
|
+
(A) => A.id === d
|
|
3786
|
+
)).filter((d) => d !== void 0).map((d) => {
|
|
3787
|
+
const g = this.getActionsAvailableFor(
|
|
3788
|
+
{ id: d.id, type: "user" },
|
|
3789
|
+
o,
|
|
3790
|
+
a
|
|
3791
|
+
);
|
|
3792
|
+
return {
|
|
3793
|
+
id: d.id,
|
|
3794
|
+
type: "user",
|
|
3795
|
+
displayName: d.username,
|
|
3796
|
+
profile: d.profile,
|
|
3797
|
+
avatarUrl: this.directory.getAvatarUrl(d.id, "user"),
|
|
3798
|
+
directoryUrl: this.directory.getDirectoryUrl(d.id, "user"),
|
|
3799
|
+
actions: g.map((f) => {
|
|
3800
|
+
const w = c[f];
|
|
3801
|
+
return {
|
|
3802
|
+
displayName: f,
|
|
3803
|
+
id: f,
|
|
3804
|
+
priority: w.priority
|
|
3805
|
+
};
|
|
3806
|
+
})
|
|
3807
|
+
};
|
|
3808
|
+
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), h = Object.keys(o.groups.checked).map((d) => o.groups.visibles.find(
|
|
3809
|
+
(A) => A.id === d
|
|
3810
|
+
)).filter((d) => d !== void 0).map((d) => {
|
|
3811
|
+
const g = this.getActionsAvailableFor(
|
|
3812
|
+
{ id: d.id, type: "group" },
|
|
3813
|
+
o,
|
|
3814
|
+
a
|
|
3815
|
+
);
|
|
3816
|
+
return {
|
|
3817
|
+
id: d.id,
|
|
3818
|
+
type: "group",
|
|
3819
|
+
displayName: d.name,
|
|
3820
|
+
profile: void 0,
|
|
3821
|
+
avatarUrl: this.directory.getAvatarUrl(d.id, "group"),
|
|
3822
|
+
directoryUrl: this.directory.getDirectoryUrl(d.id, "group"),
|
|
3823
|
+
actions: g.map((f) => {
|
|
3824
|
+
const w = c[f];
|
|
3825
|
+
return {
|
|
3826
|
+
displayName: f,
|
|
3827
|
+
id: f,
|
|
3828
|
+
priority: w.priority
|
|
3829
|
+
};
|
|
3830
|
+
})
|
|
3831
|
+
};
|
|
3832
|
+
}).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), E = [...l, ...h], p = o.groups.visibles.map(
|
|
3833
|
+
({ groupDisplayName: d, id: g, name: A, labels: f }) => ({
|
|
3834
|
+
labels: f,
|
|
3835
|
+
displayName: d || A,
|
|
3836
|
+
id: g
|
|
3837
|
+
})
|
|
3838
|
+
), y = o.users.visibles.map(
|
|
3839
|
+
({ id: d, profile: g, username: A, firstName: f, lastName: w, login: F }) => ({
|
|
3840
|
+
displayName: A,
|
|
3841
|
+
firstName: f,
|
|
3842
|
+
lastName: w,
|
|
3843
|
+
login: F,
|
|
3844
|
+
profile: g,
|
|
3845
|
+
id: d
|
|
3891
3846
|
})
|
|
3892
3847
|
);
|
|
3848
|
+
return {
|
|
3849
|
+
rights: E,
|
|
3850
|
+
visibleBookmarks: r,
|
|
3851
|
+
visibleGroups: p,
|
|
3852
|
+
visibleUsers: y
|
|
3853
|
+
};
|
|
3893
3854
|
}
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
owner: t.owner.userId,
|
|
3906
|
-
icon: t.thumbnail || "/img/illustrations/homeworks.svg",
|
|
3907
|
-
path: "/homeworks#/view-homeworks/" + t._id,
|
|
3908
|
-
_id: "" + t._id,
|
|
3909
|
-
shared: typeof t.shared < "u",
|
|
3910
|
-
modified: t.modified
|
|
3911
|
-
}));
|
|
3912
|
-
}
|
|
3913
|
-
}
|
|
3914
|
-
class MagnetoBehaviour extends AbstractBehaviourService {
|
|
3915
|
-
constructor() {
|
|
3916
|
-
super(...arguments);
|
|
3917
|
-
u(this, "APP", "magneto");
|
|
3918
|
-
u(this, "RESOURCE", "magneto");
|
|
3855
|
+
async getPutSharePayload(e, t, s) {
|
|
3856
|
+
const r = {
|
|
3857
|
+
users: {},
|
|
3858
|
+
groups: {},
|
|
3859
|
+
bookmarks: {}
|
|
3860
|
+
}, i = await this.getShareMapping(e, s);
|
|
3861
|
+
for (const o of t) {
|
|
3862
|
+
const a = o.actions.map((l) => i[l.id]).reduce((l, h) => Array.isArray(h) ? [...l, ...h] : l, []), c = [...new Set(a)];
|
|
3863
|
+
c.length > 0 && (o.type === "user" ? r.users[o.id] = c : o.type === "group" ? r.groups[o.id] = c : r.bookmarks[o.id] = c);
|
|
3864
|
+
}
|
|
3865
|
+
return r;
|
|
3919
3866
|
}
|
|
3920
|
-
async
|
|
3921
|
-
const
|
|
3922
|
-
|
|
3867
|
+
async saveRights(e, t, s, r) {
|
|
3868
|
+
const i = await this.getPutSharePayload(
|
|
3869
|
+
e,
|
|
3870
|
+
s,
|
|
3871
|
+
r == null ? void 0 : r.getShareMapping
|
|
3872
|
+
), o = (r == null ? void 0 : r.saveResourceRights) || `/${e}/share/resource/${t}`, a = this.getSearchUrl(
|
|
3873
|
+
e,
|
|
3874
|
+
t,
|
|
3875
|
+
"",
|
|
3876
|
+
r == null ? void 0 : r.getResourceRights
|
|
3923
3877
|
);
|
|
3924
|
-
return
|
|
3925
|
-
_id: s._id,
|
|
3926
|
-
title: s.title,
|
|
3927
|
-
icon: s.imageUrl,
|
|
3928
|
-
owner: s.ownerId,
|
|
3929
|
-
ownerName: s.ownerName,
|
|
3930
|
-
path: `/magneto#/board/${s._id}/view`,
|
|
3931
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
3932
|
-
modified: "" + s.modificationDate
|
|
3933
|
-
}));
|
|
3934
|
-
}
|
|
3935
|
-
}
|
|
3936
|
-
class MindmapBehaviour extends AbstractBehaviourService {
|
|
3937
|
-
constructor() {
|
|
3938
|
-
super(...arguments);
|
|
3939
|
-
u(this, "APP", "mindmap");
|
|
3940
|
-
u(this, "RESOURCE", "mindmap");
|
|
3878
|
+
return this.cache.clearCache(a), await this.http.putJson(o, i);
|
|
3941
3879
|
}
|
|
3942
|
-
async
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
}
|
|
3954
|
-
)
|
|
3880
|
+
async getActionsForApp(e, t) {
|
|
3881
|
+
const s = await this.cache.httpGetJson(
|
|
3882
|
+
"/infra/public/json/sharing-rights.json"
|
|
3883
|
+
), r = await this.getShareMapping(e, t);
|
|
3884
|
+
return Object.keys(s).map((o) => {
|
|
3885
|
+
const a = s[o];
|
|
3886
|
+
return {
|
|
3887
|
+
displayName: o,
|
|
3888
|
+
id: o,
|
|
3889
|
+
priority: a.priority,
|
|
3890
|
+
requires: a.requires
|
|
3891
|
+
};
|
|
3892
|
+
}).filter((o) => {
|
|
3893
|
+
var a;
|
|
3894
|
+
return ((a = r[o.id]) == null ? void 0 : a.length) > 0;
|
|
3895
|
+
}).sort((o, a) => o.priority - a.priority);
|
|
3955
3896
|
}
|
|
3956
3897
|
}
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
u(this, "
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
var o;
|
|
3967
|
-
const i = r.thumbnail ? r.thumbnail + "?thumbnail=48x48" : "/img/illustrations/pages.svg";
|
|
3968
|
-
s.push(
|
|
3969
|
-
this.dataToResource({
|
|
3970
|
-
title: r.title,
|
|
3971
|
-
owner: r.owner.userId,
|
|
3972
|
-
ownerName: r.owner.displayName,
|
|
3973
|
-
icon: i,
|
|
3974
|
-
path: "/pages#/website/" + r._id,
|
|
3975
|
-
_id: r._id,
|
|
3976
|
-
shared: typeof r.shared < "u",
|
|
3977
|
-
modified: r.modified
|
|
3978
|
-
})
|
|
3979
|
-
), (o = r.pages) == null || o.forEach((a) => {
|
|
3980
|
-
s.push(
|
|
3981
|
-
this.dataToResource({
|
|
3982
|
-
title: a.title,
|
|
3983
|
-
owner: r.owner.userId,
|
|
3984
|
-
ownerName: r.owner.displayName,
|
|
3985
|
-
icon: i,
|
|
3986
|
-
path: "/pages#/website/" + r._id + "/" + a.titleLink,
|
|
3987
|
-
_id: r._id + "/" + a.titleLink,
|
|
3988
|
-
shared: typeof r.shared < "u",
|
|
3989
|
-
modified: r.modified
|
|
3990
|
-
})
|
|
3991
|
-
);
|
|
3992
|
-
});
|
|
3993
|
-
}), s;
|
|
3898
|
+
const loadedScripts = {};
|
|
3899
|
+
class HttpService {
|
|
3900
|
+
constructor(e, t) {
|
|
3901
|
+
// Axios automatically manages the XSRF-TOKEN cookie and the X-XSRF-TOKEN HTTP header.
|
|
3902
|
+
u(this, "axios");
|
|
3903
|
+
u(this, "baseUrl");
|
|
3904
|
+
u(this, "headers", {});
|
|
3905
|
+
u(this, "_latestResponse");
|
|
3906
|
+
this.context = e, this.axios = axios.create(t);
|
|
3994
3907
|
}
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
constructor() {
|
|
3998
|
-
super(...arguments);
|
|
3999
|
-
u(this, "APP", "poll");
|
|
4000
|
-
u(this, "RESOURCE", "poll");
|
|
3908
|
+
fixBaseUrl(e) {
|
|
3909
|
+
return e.startsWith("http://") || e.startsWith("https://") ? e : this.baseUrl ? this.baseUrl.endsWith("/") || e.startsWith("/") ? `${this.baseUrl}${e}` : `${this.baseUrl}/${e}` : e;
|
|
4001
3910
|
}
|
|
4002
|
-
|
|
4003
|
-
return
|
|
4004
|
-
const r = s.icon ? s.icon + "?thumbnail=48x48" : "/img/icons/glyphicons_036_file.png";
|
|
4005
|
-
return this.dataToResource({
|
|
4006
|
-
title: s.question,
|
|
4007
|
-
ownerName: s.owner.displayName,
|
|
4008
|
-
icon: r,
|
|
4009
|
-
path: "/poll#/view/" + s._id,
|
|
4010
|
-
_id: s._id,
|
|
4011
|
-
owner: s.owner.userId,
|
|
4012
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
4013
|
-
modified: s.modified
|
|
4014
|
-
});
|
|
4015
|
-
});
|
|
3911
|
+
useBaseUrl(e) {
|
|
3912
|
+
return this.baseUrl = e, this;
|
|
4016
3913
|
}
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
constructor() {
|
|
4020
|
-
super(...arguments);
|
|
4021
|
-
u(this, "APP", "scrapbook");
|
|
4022
|
-
u(this, "RESOURCE", "scrapbook");
|
|
3914
|
+
useHeaders(e) {
|
|
3915
|
+
return this.headers = e, this;
|
|
4023
3916
|
}
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
const r = s.icon || "/img/illustrations/scrapbook.svg";
|
|
4029
|
-
return this.dataToResource({
|
|
4030
|
-
title: s.name,
|
|
4031
|
-
owner: s.owner.userId,
|
|
4032
|
-
ownerName: s.owner.displayName,
|
|
4033
|
-
icon: r,
|
|
4034
|
-
path: "/scrapbook#/view-scrapbook/" + s._id,
|
|
4035
|
-
_id: s._id,
|
|
4036
|
-
shared: !!(s.shared && s.shared.length >= 0),
|
|
4037
|
-
modified: s.modified
|
|
4038
|
-
});
|
|
3917
|
+
setCdn(e) {
|
|
3918
|
+
e && XMLHttpRequest && !XMLHttpRequest.prototype.cdnUrl && (XMLHttpRequest.prototype.cdnUrl = e, XMLHttpRequest.prototype.baseOpen = XMLHttpRequest.prototype.open, XMLHttpRequest.prototype.open = function() {
|
|
3919
|
+
const t = arguments[1];
|
|
3920
|
+
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);
|
|
4039
3921
|
});
|
|
4040
3922
|
}
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
3923
|
+
// private toAxiosConfig(params?: IHttpParams): AxiosRequestConfig {
|
|
3924
|
+
toAxiosConfig(e) {
|
|
3925
|
+
if (e) {
|
|
3926
|
+
const t = Object.assign({}, this.axios.defaults);
|
|
3927
|
+
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));
|
|
3928
|
+
const s = t.headers ?? {};
|
|
3929
|
+
return t.headers = { ...s, ...this.headers }, t;
|
|
3930
|
+
} else
|
|
3931
|
+
return this.axios.defaults;
|
|
3932
|
+
}
|
|
3933
|
+
toCdnUrl(e) {
|
|
3934
|
+
e = this.fixBaseUrl(e);
|
|
3935
|
+
const t = this.context.conf().getCdnUrl() || "";
|
|
3936
|
+
if (t.length > 0 && e !== "/conf/public") {
|
|
3937
|
+
const s = "" + e;
|
|
3938
|
+
(s.startsWith("/infra/public") || s.startsWith("/assets") || /^\/([^\/]*)\/public/.test(s)) && (e = t + s);
|
|
3939
|
+
}
|
|
3940
|
+
return e;
|
|
4047
3941
|
}
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
modified: o.modified
|
|
4064
|
-
});
|
|
4065
|
-
});
|
|
4066
|
-
t(i);
|
|
4067
|
-
} catch (r) {
|
|
4068
|
-
s(r);
|
|
3942
|
+
mapAxiosError(e, t) {
|
|
3943
|
+
e.response ? this._latestResponse = e.response : e.request ? this._latestResponse = {
|
|
3944
|
+
status: 408,
|
|
3945
|
+
statusText: ERROR_CODE.TIME_OUT
|
|
3946
|
+
} : this._latestResponse = {
|
|
3947
|
+
status: 500,
|
|
3948
|
+
statusText: ERROR_CODE.UNKNOWN
|
|
3949
|
+
};
|
|
3950
|
+
const { status: s, statusText: r, headers: i, data: o } = this._latestResponse;
|
|
3951
|
+
return t != null && t.disableNotifications || notify.events().publish(LAYER_NAME.TRANSPORT, {
|
|
3952
|
+
name: EVENT_NAME.ERROR_OCCURED,
|
|
3953
|
+
data: {
|
|
3954
|
+
params: t,
|
|
3955
|
+
response: { status: s, statusText: r, headers: i },
|
|
3956
|
+
payload: o
|
|
4069
3957
|
}
|
|
4070
|
-
});
|
|
3958
|
+
}), o;
|
|
4071
3959
|
}
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
constructor() {
|
|
4075
|
-
super(...arguments);
|
|
4076
|
-
u(this, "APP", "wiki");
|
|
4077
|
-
u(this, "RESOURCE", "wiki");
|
|
3960
|
+
mapAxiosResponse(e, t) {
|
|
3961
|
+
return this._latestResponse = e, e.data;
|
|
4078
3962
|
}
|
|
4079
|
-
|
|
4080
|
-
return
|
|
4081
|
-
"/wiki/listallpages?visible=true"
|
|
4082
|
-
)).map((s) => s.pages.map((r) => {
|
|
4083
|
-
let i;
|
|
4084
|
-
return typeof s.thumbnail > "u" || s.thumbnail === "" ? i = "/img/icons/glyphicons_036_file.png" : i = s.thumbnail + "?thumbnail=48x48", this.dataToResource({
|
|
4085
|
-
title: r.title + " [" + s.title + "]",
|
|
4086
|
-
ownerName: s.owner.displayName,
|
|
4087
|
-
owner: s.owner.userId,
|
|
4088
|
-
icon: i,
|
|
4089
|
-
path: "/wiki#/view/" + s._id + "/" + r._id,
|
|
4090
|
-
_id: `${s._id}#${r._id}`,
|
|
4091
|
-
shared: typeof s.shared < "u",
|
|
4092
|
-
modified: r.modified
|
|
4093
|
-
});
|
|
4094
|
-
})).flat();
|
|
3963
|
+
get latestResponse() {
|
|
3964
|
+
return this._latestResponse;
|
|
4095
3965
|
}
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
constructor() {
|
|
4099
|
-
super(...arguments);
|
|
4100
|
-
u(this, "APP", "workspace");
|
|
4101
|
-
u(this, "RESOURCE", "workspace");
|
|
3966
|
+
isResponseError() {
|
|
3967
|
+
return this.latestResponse.status < 200 || this.latestResponse.status >= 300;
|
|
4102
3968
|
}
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
owner: l.owner,
|
|
4114
|
-
icon: p,
|
|
4115
|
-
path: `/workspace/document/${l._id}`,
|
|
4116
|
-
_id: l._id,
|
|
4117
|
-
shared: !!(l.shared && l.shared.length >= 0),
|
|
4118
|
-
modified: l.modified
|
|
4119
|
-
});
|
|
4120
|
-
});
|
|
4121
|
-
r(c);
|
|
4122
|
-
} catch (o) {
|
|
4123
|
-
i(o);
|
|
4124
|
-
}
|
|
4125
|
-
});
|
|
3969
|
+
async get(e, t) {
|
|
3970
|
+
try {
|
|
3971
|
+
const s = await this.axios.get(
|
|
3972
|
+
this.toCdnUrl(e),
|
|
3973
|
+
this.toAxiosConfig(t)
|
|
3974
|
+
);
|
|
3975
|
+
return this.mapAxiosResponse(s, t);
|
|
3976
|
+
} catch (s) {
|
|
3977
|
+
throw this.mapAxiosError(s, t);
|
|
3978
|
+
}
|
|
4126
3979
|
}
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
]);
|
|
4138
|
-
i != null && i.apps && (r != null && r.length) && (this.resourceProducingApps = r.filter(
|
|
4139
|
-
(o) => i.apps.some((a) => a.address.includes(o))
|
|
4140
|
-
));
|
|
4141
|
-
} catch (r) {
|
|
4142
|
-
console.warn("Failed to load resource-producing apps:", r);
|
|
4143
|
-
}
|
|
3980
|
+
async post(e, t, s) {
|
|
3981
|
+
try {
|
|
3982
|
+
const r = await this.axios.post(
|
|
3983
|
+
this.fixBaseUrl(e),
|
|
3984
|
+
t,
|
|
3985
|
+
this.toAxiosConfig(s)
|
|
3986
|
+
);
|
|
3987
|
+
return this.mapAxiosResponse(r, s);
|
|
3988
|
+
} catch (r) {
|
|
3989
|
+
throw this.mapAxiosError(r, s);
|
|
4144
3990
|
}
|
|
4145
|
-
return this.resourceProducingApps;
|
|
4146
3991
|
}
|
|
4147
|
-
|
|
4148
|
-
this.
|
|
3992
|
+
async postFile(e, t, s) {
|
|
3993
|
+
const r = this.toAxiosConfig(s);
|
|
3994
|
+
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
3995
|
+
try {
|
|
3996
|
+
const i = await this.axios.post(this.fixBaseUrl(e), t, {
|
|
3997
|
+
...r,
|
|
3998
|
+
headers: {
|
|
3999
|
+
"Content-Type": "multipart/form-data"
|
|
4000
|
+
}
|
|
4001
|
+
});
|
|
4002
|
+
return this.mapAxiosResponse(i, s);
|
|
4003
|
+
} catch (i) {
|
|
4004
|
+
throw this.mapAxiosError(i, s);
|
|
4005
|
+
}
|
|
4149
4006
|
}
|
|
4150
|
-
|
|
4151
|
-
this.
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4007
|
+
async postJson(e, t, s) {
|
|
4008
|
+
const r = this.toAxiosConfig();
|
|
4009
|
+
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
4010
|
+
try {
|
|
4011
|
+
const i = await this.axios.post(
|
|
4012
|
+
this.fixBaseUrl(e),
|
|
4013
|
+
t,
|
|
4014
|
+
this.toAxiosConfig(s)
|
|
4156
4015
|
);
|
|
4157
|
-
|
|
4016
|
+
return this.mapAxiosResponse(i, s);
|
|
4017
|
+
} catch (i) {
|
|
4018
|
+
throw this.mapAxiosError(i, s);
|
|
4019
|
+
}
|
|
4158
4020
|
}
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
break;
|
|
4195
|
-
case "scrapbook":
|
|
4196
|
-
r = new ScrapbookBehaviour(e);
|
|
4197
|
-
break;
|
|
4198
|
-
case "collaborativewall":
|
|
4199
|
-
r = new CollaborativewallBehaviour(e);
|
|
4200
|
-
break;
|
|
4201
|
-
case "exercizer":
|
|
4202
|
-
r = new ExercizerBehaviour(e);
|
|
4203
|
-
break;
|
|
4204
|
-
case "formulaire":
|
|
4205
|
-
r = new FormulaireBehaviour(e);
|
|
4206
|
-
break;
|
|
4207
|
-
case "magneto":
|
|
4208
|
-
r = new MagnetoBehaviour(e);
|
|
4209
|
-
break;
|
|
4210
|
-
case "appointments":
|
|
4211
|
-
r = new AppointmentsBehaviour(e);
|
|
4212
|
-
break;
|
|
4213
|
-
default:
|
|
4214
|
-
throw ERROR_CODE.NOT_SUPPORTED;
|
|
4021
|
+
async put(e, t, s) {
|
|
4022
|
+
try {
|
|
4023
|
+
const r = await this.axios.put(
|
|
4024
|
+
this.fixBaseUrl(e),
|
|
4025
|
+
t,
|
|
4026
|
+
this.toAxiosConfig(s)
|
|
4027
|
+
);
|
|
4028
|
+
return this.mapAxiosResponse(r, s);
|
|
4029
|
+
} catch (r) {
|
|
4030
|
+
throw this.mapAxiosError(r, s);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
async putFile(e, t, s) {
|
|
4034
|
+
try {
|
|
4035
|
+
const r = this.toAxiosConfig(s);
|
|
4036
|
+
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
4037
|
+
const i = await this.axios.put(this.fixBaseUrl(e), t, {
|
|
4038
|
+
...r,
|
|
4039
|
+
headers: {
|
|
4040
|
+
"Content-Type": "multipart/form-data"
|
|
4041
|
+
}
|
|
4042
|
+
});
|
|
4043
|
+
return this.mapAxiosResponse(i, s);
|
|
4044
|
+
} catch (r) {
|
|
4045
|
+
throw this.mapAxiosError(r, s);
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
async putJson(e, t, s) {
|
|
4049
|
+
const r = this.toAxiosConfig(s);
|
|
4050
|
+
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
4051
|
+
try {
|
|
4052
|
+
const i = await this.axios.put(this.fixBaseUrl(e), t, r);
|
|
4053
|
+
return this.mapAxiosResponse(i, s);
|
|
4054
|
+
} catch (i) {
|
|
4055
|
+
throw this.mapAxiosError(i, s);
|
|
4215
4056
|
}
|
|
4216
|
-
return r.APP = t, r;
|
|
4217
|
-
}
|
|
4218
|
-
};
|
|
4219
|
-
//
|
|
4220
|
-
// STATIC REGISTRY
|
|
4221
|
-
//
|
|
4222
|
-
u(b, "registry", new ServiceRegistry()), // Expose some useful functions
|
|
4223
|
-
u(b, "findBehaviour", b.registry.findService.bind(b.registry)), u(b, "hasBehaviour", b.registry.isRegistered.bind(b.registry)), u(b, "resourceProducingApps", []);
|
|
4224
|
-
let SnipletsService = b;
|
|
4225
|
-
const SEND_ALL = "*";
|
|
4226
|
-
class WebBroker {
|
|
4227
|
-
constructor(e) {
|
|
4228
|
-
u(this, "subscription");
|
|
4229
|
-
this.odeServices = e;
|
|
4230
4057
|
}
|
|
4231
|
-
|
|
4232
|
-
|
|
4058
|
+
async patch(e, t, s) {
|
|
4059
|
+
try {
|
|
4060
|
+
const r = await this.axios.patch(
|
|
4061
|
+
this.fixBaseUrl(e),
|
|
4062
|
+
t,
|
|
4063
|
+
this.toAxiosConfig(s)
|
|
4064
|
+
);
|
|
4065
|
+
return this.mapAxiosResponse(r, s);
|
|
4066
|
+
} catch (r) {
|
|
4067
|
+
throw this.mapAxiosError(r, s);
|
|
4068
|
+
}
|
|
4233
4069
|
}
|
|
4234
|
-
|
|
4235
|
-
|
|
4070
|
+
async patchFile(e, t, s) {
|
|
4071
|
+
try {
|
|
4072
|
+
const r = this.toAxiosConfig(s);
|
|
4073
|
+
r.headers && r.headers["Content-Type"] && delete r.headers["Content-Type"];
|
|
4074
|
+
const i = await this.axios.patch(this.fixBaseUrl(e), t, {
|
|
4075
|
+
...r,
|
|
4076
|
+
headers: {
|
|
4077
|
+
"Content-Type": "multipart/form-data"
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4080
|
+
return this.mapAxiosResponse(i, s);
|
|
4081
|
+
} catch (r) {
|
|
4082
|
+
throw this.mapAxiosError(r, s);
|
|
4083
|
+
}
|
|
4236
4084
|
}
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4085
|
+
async patchJson(e, t, s) {
|
|
4086
|
+
const r = this.toAxiosConfig(s);
|
|
4087
|
+
r.headers && (r.headers["Content-Type"] = "application/json");
|
|
4088
|
+
try {
|
|
4089
|
+
const i = await this.axios.patch(this.fixBaseUrl(e), t, r);
|
|
4090
|
+
return this.mapAxiosResponse(i, s);
|
|
4091
|
+
} catch (i) {
|
|
4092
|
+
throw this.mapAxiosError(i, s);
|
|
4093
|
+
}
|
|
4243
4094
|
}
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
const
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
(s) => this.dispatchEvent(s, t)
|
|
4095
|
+
async delete(e, t) {
|
|
4096
|
+
try {
|
|
4097
|
+
const s = await this.axios.delete(
|
|
4098
|
+
this.fixBaseUrl(e),
|
|
4099
|
+
this.toAxiosConfig(t)
|
|
4250
4100
|
);
|
|
4101
|
+
return this.mapAxiosResponse(s, t);
|
|
4102
|
+
} catch (s) {
|
|
4103
|
+
throw this.mapAxiosError(s, t);
|
|
4251
4104
|
}
|
|
4252
|
-
return this;
|
|
4253
4105
|
}
|
|
4254
|
-
|
|
4255
|
-
|
|
4106
|
+
async deleteJson(e, t) {
|
|
4107
|
+
try {
|
|
4108
|
+
const s = await this.axios.delete(this.fixBaseUrl(e), {
|
|
4109
|
+
data: t
|
|
4110
|
+
});
|
|
4111
|
+
return this.mapAxiosResponse(s);
|
|
4112
|
+
} catch (s) {
|
|
4113
|
+
throw this.mapAxiosError(s);
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
getScript(e, t, s) {
|
|
4117
|
+
const r = s ?? "exports", i = this.toAxiosConfig(t);
|
|
4118
|
+
return i.headers && (i.headers.Accept = "application/javascript"), this.axios.get(this.toCdnUrl(e), i).then((o) => this.mapAxiosResponse(o, t)).then((o) => {
|
|
4119
|
+
try {
|
|
4120
|
+
const a = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
|
|
4121
|
+
return Function(a)();
|
|
4122
|
+
} catch {
|
|
4123
|
+
return o;
|
|
4124
|
+
}
|
|
4125
|
+
}).catch((o) => {
|
|
4126
|
+
throw this.mapAxiosError(o, t), o;
|
|
4127
|
+
});
|
|
4128
|
+
}
|
|
4129
|
+
loadScript(e, t) {
|
|
4130
|
+
return loadedScripts[e] ? Promise.resolve() : this.getScript(e, t).then((s) => {
|
|
4131
|
+
loadedScripts[e] = !0;
|
|
4132
|
+
});
|
|
4256
4133
|
}
|
|
4257
4134
|
}
|
|
4258
|
-
class
|
|
4135
|
+
const R = class R {
|
|
4136
|
+
// in minutes. Applies to recorded videos.
|
|
4259
4137
|
constructor(e) {
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
this.odeServices = e;
|
|
4138
|
+
this.context = e;
|
|
4139
|
+
}
|
|
4140
|
+
get http() {
|
|
4141
|
+
return this.context.http();
|
|
4265
4142
|
}
|
|
4266
4143
|
get conf() {
|
|
4267
|
-
return this.
|
|
4144
|
+
return this.context.conf();
|
|
4268
4145
|
}
|
|
4269
|
-
|
|
4270
|
-
|
|
4146
|
+
/**
|
|
4147
|
+
* Returns the video app public conf (maxWeight, maxDuration and accepted extensions)
|
|
4148
|
+
* @returns the Video app public conf
|
|
4149
|
+
*/
|
|
4150
|
+
async getVideoConf() {
|
|
4151
|
+
var t;
|
|
4152
|
+
const e = await this.conf.getPublicConf(
|
|
4153
|
+
APP$4.VIDEO
|
|
4154
|
+
);
|
|
4155
|
+
return {
|
|
4156
|
+
maxWeight: (e == null ? void 0 : e["max-videosize-mbytes"]) ?? R.MAX_WEIGHT,
|
|
4157
|
+
maxDuration: (e == null ? void 0 : e["max-videoduration-minutes"]) ?? R.MAX_DURATION,
|
|
4158
|
+
acceptVideoUploadExtensions: ((t = e == null ? void 0 : e["accept-videoupload-extensions"]) == null ? void 0 : t.map(
|
|
4159
|
+
(s) => s.toUpperCase()
|
|
4160
|
+
)) ?? []
|
|
4161
|
+
};
|
|
4271
4162
|
}
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4163
|
+
/**
|
|
4164
|
+
* Starts the encoding process and check when video is fully processed.
|
|
4165
|
+
* @param params cf VideoUploadParams
|
|
4166
|
+
* @returns a VideoCheckResponse
|
|
4167
|
+
*/
|
|
4168
|
+
async upload({
|
|
4169
|
+
data: e,
|
|
4170
|
+
appCode: t,
|
|
4171
|
+
captation: s,
|
|
4172
|
+
duration: r
|
|
4173
|
+
}) {
|
|
4174
|
+
if (!e.file)
|
|
4175
|
+
throw new Error("Invalid video file.");
|
|
4176
|
+
if (!e.filename)
|
|
4177
|
+
throw new Error("Invalid video filename");
|
|
4178
|
+
const i = `${e.browser.name} ${e.browser.version}`, o = new FormData();
|
|
4179
|
+
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);
|
|
4180
|
+
let a = `/video/encode?captation=${s}`;
|
|
4181
|
+
r && (a += `&duration=${r}`);
|
|
4182
|
+
const c = await this.http.post(
|
|
4183
|
+
a,
|
|
4184
|
+
o,
|
|
4185
|
+
{ headers: { "Content-Type": "multipart/form-data" } }
|
|
4186
|
+
);
|
|
4187
|
+
if (c.state == "running") {
|
|
4188
|
+
let l = 0, h = 1;
|
|
4189
|
+
do {
|
|
4190
|
+
const E = h + l;
|
|
4191
|
+
await new Promise(
|
|
4192
|
+
(y) => setTimeout(y, E * 1e3)
|
|
4193
|
+
), l = h, h = Math.min(8, E);
|
|
4194
|
+
const p = await this.http.get(
|
|
4195
|
+
`/video/status/${c.processid}`
|
|
4196
|
+
);
|
|
4197
|
+
if (p.state == "succeed")
|
|
4198
|
+
return p.videoworkspaceid && p.videosize && this.context.data().trackVideoSave(
|
|
4199
|
+
p.videoworkspaceid,
|
|
4200
|
+
Math.round(r),
|
|
4201
|
+
p.videosize,
|
|
4202
|
+
s,
|
|
4203
|
+
e.url,
|
|
4204
|
+
i,
|
|
4205
|
+
e.device
|
|
4206
|
+
), p;
|
|
4207
|
+
if (p.state == "error")
|
|
4208
|
+
break;
|
|
4209
|
+
} while (!0);
|
|
4281
4210
|
}
|
|
4211
|
+
throw new Error("Video cannot be uploaded.");
|
|
4282
4212
|
}
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4213
|
+
};
|
|
4214
|
+
u(R, "MAX_WEIGHT", 50), // in Mbytes. Applies to uploaded videos.
|
|
4215
|
+
u(R, "MAX_DURATION", 3);
|
|
4216
|
+
let VideoService = R;
|
|
4217
|
+
class WidgetService {
|
|
4218
|
+
constructor(e) {
|
|
4219
|
+
this.context = e;
|
|
4286
4220
|
}
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
this.notify.events().publish(LAYER_NAME.WEB_DATA, {
|
|
4290
|
-
name: EVENT_NAME.DATA_TRACKED,
|
|
4291
|
-
data: e
|
|
4292
|
-
});
|
|
4221
|
+
get session() {
|
|
4222
|
+
return this.context.session();
|
|
4293
4223
|
}
|
|
4294
|
-
|
|
4295
|
-
|
|
4224
|
+
async getSystemWidgets() {
|
|
4225
|
+
try {
|
|
4226
|
+
const e = await this.session.getUser();
|
|
4227
|
+
return e == null ? void 0 : e.widgets;
|
|
4228
|
+
} catch (e) {
|
|
4229
|
+
throw console.error("[WidgetService] getSystemWidgets failed", e), e;
|
|
4230
|
+
}
|
|
4296
4231
|
}
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
"event-type": "VIDEO_SAVE",
|
|
4300
|
-
module: this.app || "video",
|
|
4301
|
-
video_id: e,
|
|
4302
|
-
browser: o,
|
|
4303
|
-
duration: Math.round(t),
|
|
4304
|
-
weight: s,
|
|
4305
|
-
source: r ? "CAPTURED" : "UPLOADED",
|
|
4306
|
-
url: i
|
|
4307
|
-
});
|
|
4308
|
-
a && (c.device_type = a), this.trackWebEvent(c);
|
|
4232
|
+
async getPreferences() {
|
|
4233
|
+
return await this.context.conf().getPreference("widgets");
|
|
4309
4234
|
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4235
|
+
async setPreferences(e) {
|
|
4236
|
+
await this.context.conf().savePreference("widgets", e);
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
const defaultMappers = {
|
|
4240
|
+
csv: function({ type: n, extension: e }) {
|
|
4241
|
+
return MimeTypeUtils.INSTANCE.isCsvLike(n, e);
|
|
4242
|
+
},
|
|
4243
|
+
doc: function({ type: n, extension: e }) {
|
|
4244
|
+
return MimeTypeUtils.INSTANCE.isWordLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("wordprocessing") !== -1;
|
|
4245
|
+
},
|
|
4246
|
+
xls: function({ type: n, extension: e }) {
|
|
4247
|
+
return MimeTypeUtils.INSTANCE.isExcelLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("spreadsheet") !== -1 || n.indexOf("ms-excel") !== -1;
|
|
4248
|
+
},
|
|
4249
|
+
img: function({ type: n }) {
|
|
4250
|
+
return n.indexOf("image") !== -1;
|
|
4251
|
+
},
|
|
4252
|
+
pdf: function({ type: n }) {
|
|
4253
|
+
return n.indexOf("pdf") !== -1 || n === "application/x-download";
|
|
4254
|
+
},
|
|
4255
|
+
ppt: function({ type: n, extension: e }) {
|
|
4256
|
+
return MimeTypeUtils.INSTANCE.isPowerpointLike(n, e) ? !0 : n.indexOf("document") !== -1 && n.indexOf("presentation") !== -1 || n.indexOf("powerpoint") !== -1;
|
|
4257
|
+
},
|
|
4258
|
+
txt: function({ type: n, extension: e }) {
|
|
4259
|
+
return MimeTypeUtils.INSTANCE.isTxtLike(n, e);
|
|
4260
|
+
},
|
|
4261
|
+
md: function({ type: n, extension: e }) {
|
|
4262
|
+
return MimeTypeUtils.INSTANCE.isMdLike(n, e);
|
|
4263
|
+
},
|
|
4264
|
+
video: function({ type: n }) {
|
|
4265
|
+
return n.indexOf("video") !== -1;
|
|
4266
|
+
},
|
|
4267
|
+
audio: function({ type: n }) {
|
|
4268
|
+
return n.indexOf("audio") !== -1;
|
|
4269
|
+
},
|
|
4270
|
+
zip: function({ type: n }) {
|
|
4271
|
+
return n.indexOf("zip") !== -1 || n.indexOf("rar") !== -1 || n.indexOf("tar") !== -1 || n.indexOf("7z") !== -1;
|
|
4320
4272
|
}
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4273
|
+
}, v = class v {
|
|
4274
|
+
/* Similar role notion as in infra-front > workspace > Model.ts */
|
|
4275
|
+
static getRole(e) {
|
|
4276
|
+
var t, s;
|
|
4277
|
+
return v.role(
|
|
4278
|
+
(t = e.metadata) == null ? void 0 : t["content-type"],
|
|
4279
|
+
!1,
|
|
4280
|
+
(s = e.metadata) == null ? void 0 : s.extension
|
|
4281
|
+
);
|
|
4327
4282
|
}
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4283
|
+
/* Similar role notion as in infra-front > workspace > Model.ts */
|
|
4284
|
+
static role(e, t = !1, s) {
|
|
4285
|
+
if (s && (s = s.trim()), !e) return "unknown";
|
|
4286
|
+
this.roleMappers || console.warn("[DocumentHelper.role] should not have empty roles", this);
|
|
4287
|
+
const r = { type: e, previewRole: t, extension: s };
|
|
4288
|
+
for (const i of this.roleMappers) {
|
|
4289
|
+
const o = i(r);
|
|
4290
|
+
if (o)
|
|
4291
|
+
return o;
|
|
4292
|
+
}
|
|
4293
|
+
return "unknown";
|
|
4333
4294
|
}
|
|
4334
|
-
}
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4295
|
+
};
|
|
4296
|
+
// FIXME add edumedia support
|
|
4297
|
+
u(v, "roleMappers", [
|
|
4298
|
+
(e) => Object.keys(defaultMappers).find((s) => defaultMappers[s](e))
|
|
4299
|
+
]);
|
|
4300
|
+
let DocumentHelper = v;
|
|
4301
|
+
class WorkspaceService {
|
|
4302
|
+
constructor(e) {
|
|
4303
|
+
this.context = e;
|
|
4338
4304
|
}
|
|
4339
4305
|
get http() {
|
|
4340
4306
|
return this.context.http();
|
|
4341
4307
|
}
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4351
|
-
async loadReactionSummaries(e) {
|
|
4352
|
-
const t = await this.http.get(
|
|
4353
|
-
`/audience/reactions/${this.module}/${this.resourceType}?resourceIds=${e.join(",")}`
|
|
4354
|
-
);
|
|
4355
|
-
return this.http.isResponseError() ? {} : t.reactionsByResource;
|
|
4308
|
+
extractMetadata(e) {
|
|
4309
|
+
const t = e.name || "", s = t.split("."), r = e.type || "application/octet-stream", i = s.length > 1 ? s[s.length - 1] : "", o = {
|
|
4310
|
+
"content-type": r,
|
|
4311
|
+
filename: t,
|
|
4312
|
+
size: e.size,
|
|
4313
|
+
extension: i,
|
|
4314
|
+
role: DocumentHelper.role(r, !1, i)
|
|
4315
|
+
}, a = t.replace("." + o.extension, ""), c = o.extension ? a + "." + o.extension : a;
|
|
4316
|
+
return { basename: a, fullname: c, metadata: o };
|
|
4356
4317
|
}
|
|
4357
|
-
async
|
|
4358
|
-
const r =
|
|
4359
|
-
|
|
4318
|
+
async saveFile(e, t) {
|
|
4319
|
+
const { fullname: s, metadata: r } = this.extractMetadata(e), i = new FormData();
|
|
4320
|
+
i.append("file", e, s);
|
|
4321
|
+
const o = [];
|
|
4322
|
+
((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}`);
|
|
4323
|
+
const a = await this.http.postFile(
|
|
4324
|
+
`/workspace/document?${o.join("&")}`,
|
|
4325
|
+
i
|
|
4360
4326
|
);
|
|
4361
|
-
|
|
4327
|
+
if (this.http.isResponseError())
|
|
4328
|
+
throw this.http.latestResponse.statusText;
|
|
4329
|
+
return a;
|
|
4362
4330
|
}
|
|
4363
|
-
async
|
|
4364
|
-
|
|
4365
|
-
|
|
4331
|
+
async updateFile(e, t, s) {
|
|
4332
|
+
const { fullname: r, metadata: i } = this.extractMetadata(t), o = new FormData();
|
|
4333
|
+
o.append("file", t, r);
|
|
4334
|
+
const a = [];
|
|
4335
|
+
i.role === "img" && a.push("quality=1"), s != null && s.alt && a.push(`alt=${s.alt}`), s != null && s.legend && a.push(`legend=${s.legend}`), s != null && s.name && a.push(`name=${s.name}`);
|
|
4336
|
+
const c = await this.http.putFile(
|
|
4337
|
+
`/workspace/document/${e}?${a.join("&")}`,
|
|
4338
|
+
o
|
|
4366
4339
|
);
|
|
4340
|
+
if (this.http.isResponseError())
|
|
4341
|
+
throw this.http.latestResponse.statusText;
|
|
4342
|
+
return c;
|
|
4367
4343
|
}
|
|
4368
|
-
async
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4344
|
+
async deleteFile(e) {
|
|
4345
|
+
const t = e.map((s) => s._id);
|
|
4346
|
+
if (t.length == 0)
|
|
4347
|
+
Promise.resolve(null);
|
|
4348
|
+
else if (await this.http.deleteJson("/workspace/documents", {
|
|
4349
|
+
ids: t
|
|
4350
|
+
}), this.http.isResponseError())
|
|
4351
|
+
throw this.http.latestResponse.statusText;
|
|
4376
4352
|
}
|
|
4377
|
-
async
|
|
4378
|
-
await this.
|
|
4379
|
-
|
|
4380
|
-
{
|
|
4381
|
-
resourceId: e,
|
|
4382
|
-
reactionType: t
|
|
4383
|
-
}
|
|
4384
|
-
);
|
|
4353
|
+
async acceptDocuments(e) {
|
|
4354
|
+
const t = await this.context.session().getUser();
|
|
4355
|
+
return (s) => s.deleted && s.trasher ? (t == null ? void 0 : t.userId) == s.trasher : !0;
|
|
4385
4356
|
}
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4357
|
+
async searchDocuments(e) {
|
|
4358
|
+
const t = e.filter !== "external" || e.parentId ? await this.http.get("/workspace/documents", {
|
|
4359
|
+
queryParams: { ...e, _: (/* @__PURE__ */ new Date()).getTime() }
|
|
4360
|
+
}) : [], s = await this.acceptDocuments(e);
|
|
4361
|
+
return t.filter(s);
|
|
4390
4362
|
}
|
|
4391
|
-
|
|
4392
|
-
return this.
|
|
4363
|
+
async listDocuments(e, t) {
|
|
4364
|
+
return this.searchDocuments({ filter: e, parentId: t, includeall: !0 });
|
|
4393
4365
|
}
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4366
|
+
/**
|
|
4367
|
+
* Duplicate and transfers documents if needed to a different folder with the specified application and visibility.
|
|
4368
|
+
* @param documents - The array of documents to transfer.
|
|
4369
|
+
* @param application - The application to associate with the transferred documents.
|
|
4370
|
+
* @param visibility - The visibility of the transferred documents. Defaults to "protected".
|
|
4371
|
+
* @returns A Promise that resolves to an array of transferred WorkspaceElements.
|
|
4372
|
+
*/
|
|
4373
|
+
async transferDocuments(e, t, s = "protected") {
|
|
4374
|
+
const r = [];
|
|
4375
|
+
if (e.forEach((i) => {
|
|
4376
|
+
(s === "public" && !i.public || !i.public && !i.protected) && r.push(i);
|
|
4377
|
+
}), r.length > 0) {
|
|
4378
|
+
const i = await this.http.post(
|
|
4379
|
+
"/workspace/documents/transfer",
|
|
4380
|
+
{
|
|
4381
|
+
application: t,
|
|
4382
|
+
visibility: s,
|
|
4383
|
+
ids: r.map((o) => o._id)
|
|
4384
|
+
}
|
|
4385
|
+
);
|
|
4386
|
+
if (this.http.isResponseError())
|
|
4387
|
+
throw this.http.latestResponse.statusText;
|
|
4388
|
+
return r.forEach((o, a) => {
|
|
4389
|
+
const c = e.findIndex(
|
|
4390
|
+
(l) => l._id === o._id
|
|
4391
|
+
);
|
|
4392
|
+
0 <= c && c < e.length && (e[c] = i[a]);
|
|
4393
|
+
}), e.filter((o) => !!o);
|
|
4394
|
+
}
|
|
4395
|
+
return e;
|
|
4399
4396
|
}
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4397
|
+
/**
|
|
4398
|
+
* Get the URL of the thumbnail of a workspace element (or its URL),
|
|
4399
|
+
* or `null` if none exists or can be created.
|
|
4400
|
+
*/
|
|
4401
|
+
getThumbnailUrl(e, t = 0, s = 0) {
|
|
4402
|
+
var i, o;
|
|
4403
|
+
const r = t > 0 || s > 0 ? `${t}x${s}` : "120x120";
|
|
4404
|
+
if (typeof e == "string")
|
|
4405
|
+
return e.includes("data:image") || e.includes("thumbnail") ? e : `${e}${e.includes("?") ? "&" : "?"}thumbnail=${r}`;
|
|
4406
|
+
{
|
|
4407
|
+
const a = `/workspace/${e.public ? "pub/" : ""}document/${e._id}?thumbnail=`, c = e.thumbnails;
|
|
4408
|
+
if ((o = (i = e.metadata) == null ? void 0 : i["content-type"]) != null && o.includes("video")) {
|
|
4409
|
+
const l = c && Object.keys(c).length > 0 ? Object.keys(c)[0] : null;
|
|
4410
|
+
return l ? a + l : null;
|
|
4411
|
+
} else
|
|
4412
|
+
return a + r;
|
|
4413
|
+
}
|
|
4405
4414
|
}
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4415
|
+
/**
|
|
4416
|
+
* Get the URL of the file of a workspace element (or its URL),
|
|
4417
|
+
* or `null` if none exists or can be created.
|
|
4418
|
+
* @param filter - The filter to apply to the workspace element.
|
|
4419
|
+
* @param withChildren - If true, include all children folders.
|
|
4420
|
+
* @param parentId - The ID of the parent folder to list.
|
|
4421
|
+
* @param directShared - If true, include only elements directly shared with the user.
|
|
4422
|
+
*
|
|
4423
|
+
*/
|
|
4424
|
+
listFolder(e, t = !1, s, r) {
|
|
4425
|
+
const i = {
|
|
4426
|
+
filter: e,
|
|
4427
|
+
hierarchical: t,
|
|
4428
|
+
parentId: s,
|
|
4429
|
+
directShared: r
|
|
4430
|
+
};
|
|
4431
|
+
return this.http.get("/workspace/folders/list", {
|
|
4432
|
+
queryParams: i
|
|
4433
|
+
});
|
|
4410
4434
|
}
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4435
|
+
/**
|
|
4436
|
+
* List all folders in the workspace.
|
|
4437
|
+
* @param withChildren - If true, include all children folders.
|
|
4438
|
+
* @param parentId - The ID of the parent folder to list.
|
|
4439
|
+
* @returns A promise that resolves to an array of WorkspaceElement objects.
|
|
4440
|
+
*/
|
|
4441
|
+
listOwnerFolders(e, t) {
|
|
4442
|
+
return this.listFolder("owner", e, t);
|
|
4415
4443
|
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4444
|
+
/**
|
|
4445
|
+
* List all shared folders in the workspace.
|
|
4446
|
+
* @param withChildren - If true, include all children folders.
|
|
4447
|
+
* @param parentId - The ID of the parent folder to list.
|
|
4448
|
+
* @returns A promise that resolves to an array of WorkspaceElement objects.
|
|
4449
|
+
*/
|
|
4450
|
+
listSharedFolders(e, t) {
|
|
4451
|
+
return this.listFolder("shared", e, t, !0);
|
|
4418
4452
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4453
|
+
/**
|
|
4454
|
+
* Create a new folder in the workspace.
|
|
4455
|
+
* @param name - The name of the new folder.
|
|
4456
|
+
* @param parentId - The ID of the parent folder where the new folder will be created.
|
|
4457
|
+
* @returns void
|
|
4458
|
+
*/
|
|
4459
|
+
createFolder(e, t) {
|
|
4460
|
+
const s = new FormData();
|
|
4461
|
+
return s.append("name", e), t && s.append("parentFolderId", t), this.http.postFile("/workspace/folder", s);
|
|
4421
4462
|
}
|
|
4422
4463
|
}
|
|
4423
4464
|
class OdeServices {
|
|
@@ -4434,9 +4475,10 @@ class OdeServices {
|
|
|
4434
4475
|
u(this, "_session");
|
|
4435
4476
|
u(this, "_share");
|
|
4436
4477
|
u(this, "_video");
|
|
4478
|
+
u(this, "_widget");
|
|
4437
4479
|
u(this, "_workspace");
|
|
4438
4480
|
u(this, "_embedder");
|
|
4439
|
-
this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this._data = new DataService(this), this._directory = new DirectoryService(this), this._http = new HttpService(this), this._idiom = new IdiomService(this), this._notify = NotifyFrameworkFactory.instance(), 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);
|
|
4481
|
+
this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this._data = new DataService(this), this._directory = new DirectoryService(this), this._http = new HttpService(this), this._idiom = new IdiomService(this), this._notify = NotifyFrameworkFactory.instance(), this._rights = new RightService(this), this._session = new SessionService(this), this._share = new ShareService(this), this._video = new VideoService(this), this._widget = new WidgetService(this), this._workspace = new WorkspaceService(this), this._embedder = new EmbedderService(this);
|
|
4440
4482
|
}
|
|
4441
4483
|
initialize() {
|
|
4442
4484
|
return this._data.initialize(), this;
|
|
@@ -4486,6 +4528,9 @@ class OdeServices {
|
|
|
4486
4528
|
video() {
|
|
4487
4529
|
return this._video;
|
|
4488
4530
|
}
|
|
4531
|
+
widget() {
|
|
4532
|
+
return this._widget;
|
|
4533
|
+
}
|
|
4489
4534
|
workspace() {
|
|
4490
4535
|
return this._workspace;
|
|
4491
4536
|
}
|
|
@@ -4686,17 +4731,17 @@ class WidgetFramework {
|
|
|
4686
4731
|
var a;
|
|
4687
4732
|
const i = ((a = r.find((c) => c.child === t.skin)) == null ? void 0 : a.parent) === "panda" ? secondLevelWidgets : firstLevelWidgets;
|
|
4688
4733
|
this._widgets = this._widgets.filter((c, l) => {
|
|
4689
|
-
const
|
|
4690
|
-
return i.indexOf(
|
|
4691
|
-
index: defaultWidgetOrder[
|
|
4734
|
+
const h = c.platformConf.name;
|
|
4735
|
+
return i.indexOf(h) !== -1 ? !1 : (this._userPrefs[h] || (this._userPrefs[h] = {
|
|
4736
|
+
index: defaultWidgetOrder[h] ?? 999,
|
|
4692
4737
|
show: !0,
|
|
4693
4738
|
position: c.platformConf.position
|
|
4694
|
-
}), c.platformConf.mandatory && (this._userPrefs[
|
|
4739
|
+
}), c.platformConf.mandatory && (this._userPrefs[h].show = !0, this._userPrefs[h].index = defaultWidgetOrder[h] ?? 999), c.platformConf.i18n && s.push(c.platformConf.i18n), c.applyUserPref(this._userPrefs[h]), !0);
|
|
4695
4740
|
});
|
|
4696
4741
|
const o = new Idiom();
|
|
4697
4742
|
this._widgets = this._widgets.sort((c, l) => {
|
|
4698
|
-
const
|
|
4699
|
-
return
|
|
4743
|
+
const h = o.translate(`timeline.settings.${c.platformConf.name}`).toLowerCase(), E = o.translate(`timeline.settings.${l.platformConf.name}`).toLowerCase();
|
|
4744
|
+
return h < E ? -1 : h > E ? 1 : 0;
|
|
4700
4745
|
});
|
|
4701
4746
|
});
|
|
4702
4747
|
}
|
|
@@ -4721,22 +4766,7 @@ class Widget {
|
|
|
4721
4766
|
this._userPref = e, this._userPref.position = this._userPref.position ?? widgets.lookupDefaultPosition(this._platformConf.name) ?? "left";
|
|
4722
4767
|
}
|
|
4723
4768
|
}
|
|
4724
|
-
const widgets = new WidgetFramework()
|
|
4725
|
-
class LastInfosWidget {
|
|
4726
|
-
loadInfos(e) {
|
|
4727
|
-
return transport.http.get("/actualites/infos/last/" + e);
|
|
4728
|
-
}
|
|
4729
|
-
getMaxResults() {
|
|
4730
|
-
return transport.http.get("/userbook/preference/maxInfos").then((e) => e.preference ? parseInt(e.preference) : 4);
|
|
4731
|
-
}
|
|
4732
|
-
setMaxResults(e) {
|
|
4733
|
-
return transport.http.putJson(
|
|
4734
|
-
"/userbook/preference/maxInfos",
|
|
4735
|
-
`"${e}"`
|
|
4736
|
-
);
|
|
4737
|
-
}
|
|
4738
|
-
}
|
|
4739
|
-
const WIDGET_NAME = {
|
|
4769
|
+
const widgets = new WidgetFramework(), WIDGET_NAME = {
|
|
4740
4770
|
LAST_INFOS: "last-infos-widget",
|
|
4741
4771
|
BIRTHDAY: "birthday",
|
|
4742
4772
|
CALENDAR: "calendar-widget",
|
|
@@ -4773,7 +4803,6 @@ export {
|
|
|
4773
4803
|
FOLDER,
|
|
4774
4804
|
ITimelineFactory,
|
|
4775
4805
|
LAYER_NAME,
|
|
4776
|
-
LastInfosWidget,
|
|
4777
4806
|
NotifyFrameworkFactory,
|
|
4778
4807
|
ReactionTypes,
|
|
4779
4808
|
ResourceService,
|