@pristy/pristy-libvue 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +40 -6
- package/.gitlab-ci.yml +0 -51
- package/src/AlfrescoApi.js +0 -68
- package/src/AlfrescoFileService.js +0 -62
- package/src/AlfrescoNodeService.js +0 -176
- package/src/AlfrescoPermissionService.js +0 -23
- package/src/ErrorService.js +0 -191
- package/src/WorkspaceService.js +0 -338
- package/src/index.js +0 -30
- package/src/stores/user.js +0 -169
package/README.md
CHANGED
|
@@ -39,3 +39,5 @@ The pristy-libvue package of the package.json will be overloaded by the local li
|
|
|
39
39
|
| 0.2.3 | Add workspaceService |
|
|
40
40
|
| 0.2.4 | Adding the publication of an act |
|
|
41
41
|
| 0.2.5 | Update Readme and licence in package.json |
|
|
42
|
+
| 0.2.6 | Update wording and fix import of TrashCanApi |
|
|
43
|
+
|
package/package.json
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristy/pristy-libvue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Library for Pristy application",
|
|
5
5
|
"homepage": "https://pristy.fr/en/",
|
|
6
|
-
"main": "src/index.js",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"@alfresco/js-api": "^4.11.0",
|
|
9
|
-
"pinia": "^2.0.15"
|
|
10
|
-
},
|
|
11
6
|
"author": "JECI SARL",
|
|
12
7
|
"license": "AGPL-3.0",
|
|
13
8
|
"keywords": [
|
|
14
9
|
"alfresco",
|
|
15
10
|
"vue"
|
|
16
11
|
],
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/pristy-libvue.umd.js",
|
|
16
|
+
"module": "./dist/pristy-libvue.mjs",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/pristy-libvue.mjs",
|
|
20
|
+
"require": "./dist/pristy-libvue.umd.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"unpkg": "./dist/pristy-libvue.umd.js",
|
|
24
|
+
"jsdelivr": "./dist/pristy-libvye.umd.js",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build:library": "vite build",
|
|
27
|
+
"analyze": "vite build --config analyze.config.js",
|
|
28
|
+
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
|
|
29
|
+
"format": "prettier . --write"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": "^3.2.5"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
36
|
+
"eslint": "^8.1.0",
|
|
37
|
+
"eslint-config-prettier": "^8.5.0",
|
|
38
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
39
|
+
"eslint-plugin-vue": "^9.5.0",
|
|
40
|
+
"prettier": "^2.3.2",
|
|
41
|
+
"rollup-plugin-visualizer": "^5.5.2",
|
|
42
|
+
"tslib": "^2.4.0",
|
|
43
|
+
"vite": "^3.1.2",
|
|
44
|
+
"vite-plugin-eslint": "^1.8.1"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@alfresco/js-api": "^5.0.0",
|
|
48
|
+
"pinia": "^2.0.15",
|
|
49
|
+
"primevue": "^3.17.0"
|
|
50
|
+
},
|
|
17
51
|
"repository": {
|
|
18
52
|
"type": "git",
|
|
19
53
|
"url": "git+https://gitlab.com/pristy-oss/pristy-libvue.git"
|
package/.gitlab-ci.yml
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
stages:
|
|
3
|
-
- prepare
|
|
4
|
-
- build
|
|
5
|
-
- publish
|
|
6
|
-
|
|
7
|
-
default:
|
|
8
|
-
tags:
|
|
9
|
-
- docker
|
|
10
|
-
- jeci
|
|
11
|
-
|
|
12
|
-
variables:
|
|
13
|
-
DOCKER_HOST: tcp://docker:2375
|
|
14
|
-
DOCKER_TLS_CERTDIR: ""
|
|
15
|
-
DOCKER_DRIVER: overlay2
|
|
16
|
-
|
|
17
|
-
## NODE BUILD ##
|
|
18
|
-
|
|
19
|
-
.npm-build:
|
|
20
|
-
image: docker.io/node:16.15-alpine
|
|
21
|
-
interruptible: true
|
|
22
|
-
retry: 1
|
|
23
|
-
only:
|
|
24
|
-
- tags
|
|
25
|
-
- merge_requests
|
|
26
|
-
- develop
|
|
27
|
-
|
|
28
|
-
npm-install:
|
|
29
|
-
stage: prepare
|
|
30
|
-
extends: .npm-build
|
|
31
|
-
script:
|
|
32
|
-
- npm install --no-progress --no-audit --no-fund --verbose
|
|
33
|
-
artifacts:
|
|
34
|
-
name: 'deps_$CI_COMMIT_REF_SLUG'
|
|
35
|
-
paths:
|
|
36
|
-
- node_modules/
|
|
37
|
-
when: on_success
|
|
38
|
-
expire_in: 36h
|
|
39
|
-
|
|
40
|
-
# Publishes the package to nexus.
|
|
41
|
-
publish:
|
|
42
|
-
stage: publish
|
|
43
|
-
extends: .npm-build
|
|
44
|
-
dependencies:
|
|
45
|
-
- npm-install
|
|
46
|
-
script:
|
|
47
|
-
- npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
|
|
48
|
-
- npm publish --access public
|
|
49
|
-
resource_group: 'deployment-$CI_COMMIT_REF_SLUG'
|
|
50
|
-
only:
|
|
51
|
-
- stable
|
package/src/AlfrescoApi.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AlfrescoApi,
|
|
3
|
-
ContentApi,
|
|
4
|
-
NodesApi,
|
|
5
|
-
PeopleApi,
|
|
6
|
-
RenditionsApi,
|
|
7
|
-
SearchApi,
|
|
8
|
-
SitesApi,
|
|
9
|
-
UploadApi,
|
|
10
|
-
FavoritesApi
|
|
11
|
-
} from "@alfresco/js-api";
|
|
12
|
-
|
|
13
|
-
var _alfrescoApi = null;
|
|
14
|
-
export function alfrescoApi() {
|
|
15
|
-
return (
|
|
16
|
-
_alfrescoApi ??
|
|
17
|
-
new AlfrescoApi({
|
|
18
|
-
hostEcm: window.config["ALFRESCO_HOST"],
|
|
19
|
-
authType: window.config["ALFRESCO_AUTH"],
|
|
20
|
-
contextRoot: window.config["ALFRESCO_ROOT"],
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var _contentApi = null;
|
|
26
|
-
export function contentApi() {
|
|
27
|
-
return _contentApi ?? new ContentApi(alfrescoApi());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _uploadApi = null;
|
|
31
|
-
export function uploadApi() {
|
|
32
|
-
return _uploadApi ?? new UploadApi(alfrescoApi());
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var _renditionsApi = null;
|
|
36
|
-
export function renditionsApi() {
|
|
37
|
-
return _renditionsApi ?? new RenditionsApi(alfrescoApi());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var _nodesApi = null;
|
|
41
|
-
export function nodesApi() {
|
|
42
|
-
return _nodesApi ?? new NodesApi(alfrescoApi());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var _sitesApi = null;
|
|
46
|
-
export function sitesApi() {
|
|
47
|
-
return _sitesApi ?? new SitesApi(alfrescoApi());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var _searchApi = null;
|
|
51
|
-
export function searchApi() {
|
|
52
|
-
return _searchApi ?? new SearchApi(alfrescoApi());
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var _peopleApi = null;
|
|
56
|
-
export function peopleApi() {
|
|
57
|
-
return _peopleApi ?? new PeopleApi(alfrescoApi());
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var _favoritesApi = null;
|
|
61
|
-
export function favoritesApi() {
|
|
62
|
-
return _favoritesApi ?? new FavoritesApi(alfrescoApi());
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var _trashcanApi = null;
|
|
66
|
-
export function trashcanApi() {
|
|
67
|
-
return _trashcanApi ?? new TrashcanApi(alfrescoApi());
|
|
68
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { contentApi, uploadApi, renditionsApi } from "./AlfrescoApi";
|
|
2
|
-
import ErrorService from "./ErrorService";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _errorService = null;
|
|
6
|
-
export function errorService() {
|
|
7
|
-
return (
|
|
8
|
-
_errorService ??
|
|
9
|
-
new ErrorService()
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default class AlfrescoFileService {
|
|
14
|
-
getThumbnailUrl(nodeId) {
|
|
15
|
-
return contentApi().getDocumentThumbnailUrl(nodeId);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
getPreviewUrl(nodeId) {
|
|
19
|
-
return contentApi().getDocumentPreviewUrl(nodeId);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getContentUrl(nodeId) {
|
|
23
|
-
return contentApi().getContentUrl(nodeId);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
uploadFile(nodeId, opts, file) {
|
|
27
|
-
return uploadApi()
|
|
28
|
-
.uploadFile(file, null, nodeId, null, opts)
|
|
29
|
-
.on("progress", (progress) => {
|
|
30
|
-
// console.log("Total :" + progress.total);
|
|
31
|
-
// console.log("Loaded :" + progress.loaded);
|
|
32
|
-
console.log("Percent :" + progress.percent);
|
|
33
|
-
})
|
|
34
|
-
.then(
|
|
35
|
-
(data) => {
|
|
36
|
-
// async call
|
|
37
|
-
this.createAllRendition(data.entry.id);
|
|
38
|
-
return data;
|
|
39
|
-
},
|
|
40
|
-
(error) => {
|
|
41
|
-
errorService().uploadFileError(error);
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
createRendition(nodeId, rendition) {
|
|
47
|
-
return renditionsApi().createRendition(nodeId, {
|
|
48
|
-
id: rendition,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
createAllRendition(nodeId) {
|
|
53
|
-
return renditionsApi().createRendition(nodeId, [
|
|
54
|
-
{
|
|
55
|
-
id: "doclib",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: "imgpreview",
|
|
59
|
-
},
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { nodesApi } from "./AlfrescoApi";
|
|
2
|
-
import ErrorService from "./ErrorService";
|
|
3
|
-
|
|
4
|
-
var _errorService = null;
|
|
5
|
-
export function errorService() {
|
|
6
|
-
return (
|
|
7
|
-
_errorService ??
|
|
8
|
-
new ErrorService()
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default class AlfrescoNodeService {
|
|
13
|
-
getNode(id) {
|
|
14
|
-
const opts = {
|
|
15
|
-
include: ["isFavorite", "properties", "allowableOperations", "permissions"],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return nodesApi()
|
|
19
|
-
.getNode(id, opts)
|
|
20
|
-
.then((data) => {
|
|
21
|
-
return data.entry;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
createNode(id, opts) {
|
|
26
|
-
return nodesApi()
|
|
27
|
-
.createNode(id, opts)
|
|
28
|
-
.then(
|
|
29
|
-
(data) => {
|
|
30
|
-
return data;
|
|
31
|
-
},
|
|
32
|
-
(error) => {
|
|
33
|
-
errorService().createNodeError(error);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getChildren(id) {
|
|
39
|
-
const opts = {
|
|
40
|
-
include: ["isFavorite", "properties", "allowableOperations", "permissions"],
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return nodesApi()
|
|
44
|
-
.listNodeChildren(id, opts)
|
|
45
|
-
.then((data) => {
|
|
46
|
-
let children = data.list.entries.map((data) => data.entry);
|
|
47
|
-
let documentLibrary = children.filter(
|
|
48
|
-
(child) => child.name == "documentLibrary"
|
|
49
|
-
)[0];
|
|
50
|
-
if (documentLibrary) {
|
|
51
|
-
return this.getChildren(documentLibrary.id).then((subChildren) => {
|
|
52
|
-
return {
|
|
53
|
-
documentLibrary: documentLibrary,
|
|
54
|
-
subChildren: subChildren,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
return children;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
updateNode(id, opts) {
|
|
64
|
-
return nodesApi()
|
|
65
|
-
.updateNode(id, opts)
|
|
66
|
-
.then(
|
|
67
|
-
(data) => {
|
|
68
|
-
return data;
|
|
69
|
-
},
|
|
70
|
-
function (error) {
|
|
71
|
-
console.log("coucou");
|
|
72
|
-
errorService().updateNodeError(error);
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
deleteNode(id, type) {
|
|
78
|
-
const opts = {};
|
|
79
|
-
|
|
80
|
-
return nodesApi()
|
|
81
|
-
.deleteNode(id, opts)
|
|
82
|
-
.then(
|
|
83
|
-
(data) => {
|
|
84
|
-
return data;
|
|
85
|
-
},
|
|
86
|
-
function (error) {
|
|
87
|
-
errorService().deleteNodeError(error);
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getParents(id) {
|
|
93
|
-
const opts = {
|
|
94
|
-
include: ["isFavorite", "properties"],
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return nodesApi()
|
|
98
|
-
.listParents(id, opts)
|
|
99
|
-
.then((data) => {
|
|
100
|
-
let parents = data.list.entries.map((data) => data.entry);
|
|
101
|
-
let documentLibrary = parents[0];
|
|
102
|
-
if (documentLibrary && documentLibrary.name == "documentLibrary") {
|
|
103
|
-
return this.getParents(documentLibrary.id).then((supParent) => {
|
|
104
|
-
return {
|
|
105
|
-
documentLibrary: documentLibrary,
|
|
106
|
-
supParent: supParent,
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
return parents[0];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
updateContentNode(id, file) {
|
|
116
|
-
return nodesApi()
|
|
117
|
-
.updateNodeContent(id, file)
|
|
118
|
-
.then(
|
|
119
|
-
(data) => {
|
|
120
|
-
return data;
|
|
121
|
-
},
|
|
122
|
-
function (error) {
|
|
123
|
-
errorService().updateContentNodeError(error);
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
copyNode(id, destination, name){
|
|
129
|
-
const nodeBody = name != null ? {
|
|
130
|
-
targetParentId: destination,
|
|
131
|
-
name: name,
|
|
132
|
-
} : {
|
|
133
|
-
targetParentId: destination,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const opts = {
|
|
137
|
-
include: ["path"],
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
return nodesApi()
|
|
141
|
-
.copyNode(id, nodeBody, opts)
|
|
142
|
-
.then(
|
|
143
|
-
(data) => {
|
|
144
|
-
return data;
|
|
145
|
-
},
|
|
146
|
-
function (error) {
|
|
147
|
-
errorService().copyNodeError(error);
|
|
148
|
-
}
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
moveNode(id, destination, name){
|
|
153
|
-
const nodeBody = name != null ? {
|
|
154
|
-
targetParentId: destination,
|
|
155
|
-
name: name,
|
|
156
|
-
} : {
|
|
157
|
-
targetParentId: destination,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const opts = {
|
|
161
|
-
include: ["path"],
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return nodesApi()
|
|
165
|
-
.moveNode(id, nodeBody, opts)
|
|
166
|
-
.then(
|
|
167
|
-
(data) => {
|
|
168
|
-
return data;
|
|
169
|
-
},
|
|
170
|
-
function (error) {
|
|
171
|
-
errorService().moveNodeError(error);
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// import { ContentApi, UploadApi, RenditionsApi } from "@alfresco/js-api";
|
|
2
|
-
// import { useUserStore } from "../stores/user";
|
|
3
|
-
|
|
4
|
-
/* Service permettant la gestion des invitations et des liens de partage.
|
|
5
|
-
*
|
|
6
|
-
* Liens de partage
|
|
7
|
-
*/
|
|
8
|
-
export default class AlfrescoPermissionService {
|
|
9
|
-
getPublicLink() {
|
|
10
|
-
// Recupère le liens publique de l'espace de travaille
|
|
11
|
-
// Voir métadonnées avec Cindy
|
|
12
|
-
// <serveur>:<port>/<app>/p/<key>
|
|
13
|
-
// Il faut récupérer la
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
createPublicLink() {
|
|
17
|
-
// Créer le liens publique de l'espace de travaille
|
|
18
|
-
// 1. Créer un utilisateur caché username="_public_<rand 16c>" avec mdp password="<rand 16c>"
|
|
19
|
-
// 2. Création d'un hash similaire au hashmac : base64(<format>|<username>|<password>)
|
|
20
|
-
// Format=1
|
|
21
|
-
// <serveur>:<port>/<app>/p/<key>
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/ErrorService.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
export default class ErrorService {
|
|
2
|
-
|
|
3
|
-
uploadFileError(error){
|
|
4
|
-
let message;
|
|
5
|
-
switch (error.status) {
|
|
6
|
-
case 400:
|
|
7
|
-
message = "Les paramètres de la requête sont invalides.";
|
|
8
|
-
break;
|
|
9
|
-
case 403:
|
|
10
|
-
message = "Vous n'avez pas les droits pour créer un fichier.";
|
|
11
|
-
break;
|
|
12
|
-
case 404:
|
|
13
|
-
message = "Impossible de trouver le dossier parent.";
|
|
14
|
-
break;
|
|
15
|
-
case 409:
|
|
16
|
-
message = "Le fichier " + file.name + " existe déjà.";
|
|
17
|
-
break;
|
|
18
|
-
case 413:
|
|
19
|
-
message =
|
|
20
|
-
"Le contenu dépasse la limite de taille de fichier individuelle configurée pour le réseau ou le système";
|
|
21
|
-
break;
|
|
22
|
-
case 415:
|
|
23
|
-
message = "Le type du contenu du noeud n'est pas supporté.";
|
|
24
|
-
break;
|
|
25
|
-
case 422:
|
|
26
|
-
message =
|
|
27
|
-
"Exception d'intégrité du modèle incluant un nom de fichier contenant des caractères non valides.";
|
|
28
|
-
break;
|
|
29
|
-
case 507:
|
|
30
|
-
message =
|
|
31
|
-
"Le contenu dépasse la limite de quota de stockage globale configurée pour le réseau ou le système.";
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
34
|
-
message = error.message;
|
|
35
|
-
}
|
|
36
|
-
throw new Error(message);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
createNodeError(error){
|
|
40
|
-
let message;
|
|
41
|
-
switch (error.status) {
|
|
42
|
-
case 400:
|
|
43
|
-
message = "Le nom choisi est invalide.";
|
|
44
|
-
break;
|
|
45
|
-
case 409:
|
|
46
|
-
message = "Le nom choisi est déjà existant.";
|
|
47
|
-
break;
|
|
48
|
-
case 422:
|
|
49
|
-
message = "Le nom choisi ne respecte pas le format requis.";
|
|
50
|
-
break;
|
|
51
|
-
default:
|
|
52
|
-
message = error.message;
|
|
53
|
-
}
|
|
54
|
-
throw new Error(message);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
updateNodeError(error){
|
|
58
|
-
let message;
|
|
59
|
-
switch (error.status) {
|
|
60
|
-
case 400:
|
|
61
|
-
message = "Le nom choisi est invalide.";
|
|
62
|
-
break;
|
|
63
|
-
case 409:
|
|
64
|
-
message = "Le nom choisi est déjà existant.";
|
|
65
|
-
break;
|
|
66
|
-
case 422:
|
|
67
|
-
message = "Le nom choisi ne respecte pas le format requis.";
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
message = error.message;
|
|
71
|
-
}
|
|
72
|
-
throw new Error(message);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
deleteNodeError(error){
|
|
76
|
-
let message;
|
|
77
|
-
switch (error.status) {
|
|
78
|
-
case 403:
|
|
79
|
-
message =
|
|
80
|
-
"Vous n'avez pas la permission de supprimer ce " + type + ".";
|
|
81
|
-
break;
|
|
82
|
-
case 404:
|
|
83
|
-
message = "Le " + type + " à supprimer n'existe pas.";
|
|
84
|
-
break;
|
|
85
|
-
case 409:
|
|
86
|
-
message =
|
|
87
|
-
"Vous ne pouvez pas supprimer ce " +
|
|
88
|
-
type +
|
|
89
|
-
", ce dernier est verrouillé.";
|
|
90
|
-
break;
|
|
91
|
-
default:
|
|
92
|
-
message = error.message;
|
|
93
|
-
}
|
|
94
|
-
throw new Error(message);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
updateContentNodeError(error) {
|
|
98
|
-
let message;
|
|
99
|
-
switch (error.status) {
|
|
100
|
-
case 400:
|
|
101
|
-
message = "Le type du contenu du noeud n'est pas supporté.";
|
|
102
|
-
break;
|
|
103
|
-
case 403:
|
|
104
|
-
message = "Vous n'avez pas la permission pour mettre à jour.";
|
|
105
|
-
break;
|
|
106
|
-
case 404:
|
|
107
|
-
message = "Impossible de mettre à jour un fichier inexistant.";
|
|
108
|
-
break;
|
|
109
|
-
case 409:
|
|
110
|
-
message = "Le nom du fichier est déjà existant.";
|
|
111
|
-
break;
|
|
112
|
-
case 413:
|
|
113
|
-
message =
|
|
114
|
-
"Le contenu dépasse la taille limite individuelle de fichier configurée pour le réseau ou le système.";
|
|
115
|
-
break;
|
|
116
|
-
case 422:
|
|
117
|
-
message =
|
|
118
|
-
"Exception d'intégrité du modèle incluant un nom de fichier contenant des caractères non valides.";
|
|
119
|
-
break;
|
|
120
|
-
case 507:
|
|
121
|
-
message =
|
|
122
|
-
"Le contenu dépasse la limite de quota de stockage globale configurée pour le réseau ou le système.";
|
|
123
|
-
break;
|
|
124
|
-
default:
|
|
125
|
-
message = error.message;
|
|
126
|
-
}
|
|
127
|
-
throw new Error(message);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
copyNodeError(error){
|
|
131
|
-
let message;
|
|
132
|
-
switch (error.status) {
|
|
133
|
-
case 403:
|
|
134
|
-
message = "Vous n'avez pas la permission pour copier cet élément";
|
|
135
|
-
break;
|
|
136
|
-
case 404:
|
|
137
|
-
message = "Impossible de copier un élément inexistant.";
|
|
138
|
-
break;
|
|
139
|
-
case 409:
|
|
140
|
-
message = "Le nom de l'élément entre en conflit avec un élément existant au même endroit.";
|
|
141
|
-
break;
|
|
142
|
-
case 422:
|
|
143
|
-
message =
|
|
144
|
-
"Exception d'intégrité du modèle incluant un nom d'élément contenant des caractères non valides.";
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
message = error.message;
|
|
148
|
-
}
|
|
149
|
-
throw new Error(message);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
moveNodeError(error){
|
|
153
|
-
let message;
|
|
154
|
-
switch (error.status) {
|
|
155
|
-
case 400 :
|
|
156
|
-
message = "Vous ne pouvez pas déplacer l'élément à l'endroit ou il se trouve.";
|
|
157
|
-
case 403:
|
|
158
|
-
message = "Vous n'avez pas la permission pour déplacer cet élément";
|
|
159
|
-
break;
|
|
160
|
-
case 404:
|
|
161
|
-
message = "Impossible de déplacer un élément inexistant.";
|
|
162
|
-
break;
|
|
163
|
-
case 409:
|
|
164
|
-
message = "Le nom de l'élément entre en conflit avec un élément existant au même endroit.";
|
|
165
|
-
break;
|
|
166
|
-
case 422:
|
|
167
|
-
message =
|
|
168
|
-
"Exception d'intégrité du modèle incluant un nom d'élément contenant des caractères non valides.";
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
message = error.message;
|
|
172
|
-
}
|
|
173
|
-
throw new Error(message);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function loginError(data){
|
|
178
|
-
let message;
|
|
179
|
-
let error = JSON.parse(data.message).error;
|
|
180
|
-
switch (error.statusCode) {
|
|
181
|
-
case 401:
|
|
182
|
-
message = "L'authentification a échoué";
|
|
183
|
-
break;
|
|
184
|
-
case 403:
|
|
185
|
-
message = "Nom d'utilisateur ou mot de passe incorrect.";
|
|
186
|
-
break;
|
|
187
|
-
default:
|
|
188
|
-
message = error.message;
|
|
189
|
-
}
|
|
190
|
-
throw new Error(message);
|
|
191
|
-
}
|
package/src/WorkspaceService.js
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2022 - Jeci SARL - https://jeci.fr
|
|
3
|
-
*
|
|
4
|
-
* This program is free software: you can redistribute it and/or modify
|
|
5
|
-
* it under the terms of the GNU Affero General Public License as
|
|
6
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
7
|
-
* License, or (at your option) any later version.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU Affero General Public License for more details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
-
* along with this program. If not, see https://www.gnu.org/licenses/agpl-3.0.html.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
sitesApi,
|
|
20
|
-
peopleApi,
|
|
21
|
-
searchApi,
|
|
22
|
-
nodesApi,
|
|
23
|
-
} from "./AlfrescoApi";
|
|
24
|
-
|
|
25
|
-
export default class WorkspaceService {
|
|
26
|
-
|
|
27
|
-
getWorkspaces() {
|
|
28
|
-
const opts = {
|
|
29
|
-
skipCount: 0,
|
|
30
|
-
maxItems: 100,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return sitesApi()
|
|
34
|
-
.listSites(opts)
|
|
35
|
-
.then((data) => {
|
|
36
|
-
return data.list.entries.map((data) => data.entry);
|
|
37
|
-
})
|
|
38
|
-
.catch((err) => {
|
|
39
|
-
throw new Error(err.message);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
searchAllWorkspaces(extraQuery = "") {
|
|
44
|
-
const query = {
|
|
45
|
-
query: {
|
|
46
|
-
//language: "afts",
|
|
47
|
-
query: "TYPE: 'st:site' " + extraQuery,
|
|
48
|
-
},
|
|
49
|
-
include: ["properties"],
|
|
50
|
-
paging: {
|
|
51
|
-
maxItems: 100,
|
|
52
|
-
skipCount: 0,
|
|
53
|
-
},
|
|
54
|
-
localization: { locales: ["fr_FR"] },
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return searchApi()
|
|
58
|
-
.search(query)
|
|
59
|
-
.then((data) => {
|
|
60
|
-
return data.list.entries.map((data) => {
|
|
61
|
-
let obj = data.entry;
|
|
62
|
-
// add some basic properties to match sitesApi.listSites output
|
|
63
|
-
obj.title = data.entry.properties["cm:title"];
|
|
64
|
-
obj.visibility = data.entry.properties["st:siteVisibility"];
|
|
65
|
-
obj.typeEspace = data.entry.properties["pm:typeEspace"];
|
|
66
|
-
return obj;
|
|
67
|
-
});
|
|
68
|
-
})
|
|
69
|
-
.catch((err) => {
|
|
70
|
-
throw new Error(err.message);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getWorkspace(id) {
|
|
75
|
-
const opts = {};
|
|
76
|
-
|
|
77
|
-
return sitesApi()
|
|
78
|
-
.getSite(id, opts)
|
|
79
|
-
.then((data) => {
|
|
80
|
-
return data.entry;
|
|
81
|
-
})
|
|
82
|
-
.catch((err) => {
|
|
83
|
-
throw new Error(err.message);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getWorkspaceMemberships(id) {
|
|
88
|
-
const opts = {};
|
|
89
|
-
|
|
90
|
-
return sitesApi()
|
|
91
|
-
.listSiteMemberships(id, opts)
|
|
92
|
-
.then((data) => {
|
|
93
|
-
return data.list.entries.map((data) => data.entry);
|
|
94
|
-
})
|
|
95
|
-
.catch((err) => {
|
|
96
|
-
throw new Error(err.message);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
createWorkspace(id, title, descr, visibility) {
|
|
101
|
-
const opts = {
|
|
102
|
-
id: id,
|
|
103
|
-
title: title,
|
|
104
|
-
description: descr,
|
|
105
|
-
visibility: visibility,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
return sitesApi()
|
|
109
|
-
.createSite(opts)
|
|
110
|
-
.then((siteMemberEntry) => {
|
|
111
|
-
return siteMemberEntry;
|
|
112
|
-
})
|
|
113
|
-
.catch((err) => {
|
|
114
|
-
let message;
|
|
115
|
-
switch (err.status) {
|
|
116
|
-
case 400:
|
|
117
|
-
message = "L'identifiant choisi ne respecte pas le format requis.";
|
|
118
|
-
break;
|
|
119
|
-
case 409:
|
|
120
|
-
message = "L'identifiant choisi est déjà existant.";
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
message = err.message;
|
|
124
|
-
}
|
|
125
|
-
throw new Error(message);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async getWorskpaceUuid(id) {
|
|
130
|
-
const opts = {
|
|
131
|
-
skipCount: 0,
|
|
132
|
-
maxItems: 100,
|
|
133
|
-
};
|
|
134
|
-
var uuid = null;
|
|
135
|
-
const list = (await sitesApi.listSiteContainers(id, opts)).list.entries;
|
|
136
|
-
for (let element in list) {
|
|
137
|
-
if (list[element].entry.folderId == "documentLibrary") {
|
|
138
|
-
uuid = list[element].entry.id;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return uuid;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
updateWorkspaceMemberRole(siteId, memberId, newRole) {
|
|
145
|
-
const siteMembershipBody = {
|
|
146
|
-
role: newRole,
|
|
147
|
-
};
|
|
148
|
-
const opts = {};
|
|
149
|
-
|
|
150
|
-
return sitesApi()
|
|
151
|
-
.updateSiteMembership(siteId, memberId, siteMembershipBody, opts)
|
|
152
|
-
.then((siteMemberShip) => {
|
|
153
|
-
return siteMemberShip;
|
|
154
|
-
})
|
|
155
|
-
.catch((err) => {
|
|
156
|
-
let message;
|
|
157
|
-
switch (err.status) {
|
|
158
|
-
case 404:
|
|
159
|
-
message = "L'identifiant entré ne correspond à aucun utilisateur.";
|
|
160
|
-
break;
|
|
161
|
-
case 422:
|
|
162
|
-
message =
|
|
163
|
-
"Au moins un utilisateur doit être Gestionnaire. Si ce n'est pas le cas, vous n'avez pas la permission de modifier le rôle de cet utilisateur.";
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
message = err.message;
|
|
167
|
-
}
|
|
168
|
-
throw new Error(message);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
deleteWorkspaceMember(siteId, memberId) {
|
|
173
|
-
const opts = {};
|
|
174
|
-
|
|
175
|
-
return sitesApi()
|
|
176
|
-
.deleteSiteMembership(siteId, memberId, opts)
|
|
177
|
-
.then(() => {
|
|
178
|
-
return memberId;
|
|
179
|
-
})
|
|
180
|
-
.catch((err) => {
|
|
181
|
-
let message;
|
|
182
|
-
switch (err.status) {
|
|
183
|
-
case 400:
|
|
184
|
-
message =
|
|
185
|
-
"Impossible de supprimer le seul Gestionnaire de l'espace.";
|
|
186
|
-
break;
|
|
187
|
-
case 404:
|
|
188
|
-
message = "Vous ne pouvez pas supprimer un utilisateur inexistant.";
|
|
189
|
-
break;
|
|
190
|
-
case 422:
|
|
191
|
-
message =
|
|
192
|
-
"Vous n'avez pas la permission de supprimer l'accès à cet utilisateur.";
|
|
193
|
-
break;
|
|
194
|
-
default:
|
|
195
|
-
message = err.message;
|
|
196
|
-
}
|
|
197
|
-
throw new Error(message);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
addWorkspaceMember(siteId, memberId, role) {
|
|
202
|
-
const memberShipBody = {
|
|
203
|
-
role: role,
|
|
204
|
-
id: memberId,
|
|
205
|
-
};
|
|
206
|
-
const opts = {};
|
|
207
|
-
|
|
208
|
-
return sitesApi()
|
|
209
|
-
.createSiteMembership(siteId, memberShipBody, opts)
|
|
210
|
-
.then((siteMemberShip) => {
|
|
211
|
-
return siteMemberShip;
|
|
212
|
-
})
|
|
213
|
-
.catch((err) => {
|
|
214
|
-
let message;
|
|
215
|
-
switch (err.status) {
|
|
216
|
-
case 403:
|
|
217
|
-
message = "Vous ne pouvez pas inviter sur ce site.";
|
|
218
|
-
break;
|
|
219
|
-
case 404:
|
|
220
|
-
message = "Vous ne pouvez pas ajouter un utilisateur inexistant.";
|
|
221
|
-
break;
|
|
222
|
-
case 409:
|
|
223
|
-
message = "L'utilisateur a déjà accès à cet espace.";
|
|
224
|
-
break;
|
|
225
|
-
default:
|
|
226
|
-
message = err.message;
|
|
227
|
-
}
|
|
228
|
-
throw new Error(message);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
updateWorkspaceType(id, typeEspace) {
|
|
233
|
-
const opts = {
|
|
234
|
-
properties: {
|
|
235
|
-
"pm:typeEspace": typeEspace,
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
return nodesApi()
|
|
240
|
-
.updateNode(id, opts)
|
|
241
|
-
.then((data) => {
|
|
242
|
-
return data;
|
|
243
|
-
})
|
|
244
|
-
.catch((err) => {
|
|
245
|
-
let message;
|
|
246
|
-
switch (err.status) {
|
|
247
|
-
case 404:
|
|
248
|
-
message = "Vous ne pouvez pas mettre à jour un espace inexistant.";
|
|
249
|
-
break;
|
|
250
|
-
default:
|
|
251
|
-
message = err.message;
|
|
252
|
-
}
|
|
253
|
-
throw new Error(message);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
async getAllUsers() {
|
|
258
|
-
let userObj = "[";
|
|
259
|
-
let response = await peopleApi().listPeople();
|
|
260
|
-
let usersObject = response.list.entries;
|
|
261
|
-
usersObject.forEach((item) => {
|
|
262
|
-
let firstname = item.entry.firstName;
|
|
263
|
-
let lastname = item.entry.lastName;
|
|
264
|
-
let email = item.entry.email;
|
|
265
|
-
if (email == null) {
|
|
266
|
-
email = "";
|
|
267
|
-
}
|
|
268
|
-
if (firstname == null) {
|
|
269
|
-
if (email == null) {
|
|
270
|
-
firstname = "";
|
|
271
|
-
}
|
|
272
|
-
firstname = email;
|
|
273
|
-
}
|
|
274
|
-
if (lastname == null) {
|
|
275
|
-
if (email == null) {
|
|
276
|
-
lastname = "";
|
|
277
|
-
}
|
|
278
|
-
lastname = email;
|
|
279
|
-
}
|
|
280
|
-
let user =
|
|
281
|
-
'{ "firstname":' +
|
|
282
|
-
'"' +
|
|
283
|
-
firstname +
|
|
284
|
-
'"' +
|
|
285
|
-
', "lastname":' +
|
|
286
|
-
'"' +
|
|
287
|
-
lastname +
|
|
288
|
-
'"' +
|
|
289
|
-
', "email":' +
|
|
290
|
-
'"' +
|
|
291
|
-
email +
|
|
292
|
-
'"' +
|
|
293
|
-
', "id":' +
|
|
294
|
-
'"' +
|
|
295
|
-
item.entry.id +
|
|
296
|
-
'"' +
|
|
297
|
-
', "label":"' +
|
|
298
|
-
firstname +
|
|
299
|
-
" " +
|
|
300
|
-
lastname +
|
|
301
|
-
'"' +
|
|
302
|
-
', "label2":"' +
|
|
303
|
-
lastname +
|
|
304
|
-
" " +
|
|
305
|
-
firstname +
|
|
306
|
-
'"},';
|
|
307
|
-
userObj += user;
|
|
308
|
-
});
|
|
309
|
-
userObj = userObj.slice(0, -1);
|
|
310
|
-
userObj += "]";
|
|
311
|
-
let users = JSON.parse(userObj);
|
|
312
|
-
return users;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
deleteWorkspace(siteId) {
|
|
316
|
-
const opts = {};
|
|
317
|
-
|
|
318
|
-
return sitesApi()
|
|
319
|
-
.deleteSite(siteId, opts)
|
|
320
|
-
.then(() => {
|
|
321
|
-
console.log("Site deletion successful.");
|
|
322
|
-
})
|
|
323
|
-
.catch((err) => {
|
|
324
|
-
throw new Error(err.message);
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
updateWorkspace(id, opts) {
|
|
329
|
-
return sitesApi()
|
|
330
|
-
.updateSite(id, opts)
|
|
331
|
-
.then((data) => {
|
|
332
|
-
return data;
|
|
333
|
-
})
|
|
334
|
-
.catch((err) => {
|
|
335
|
-
throw new Error(err.message);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import AlfrescoFileService from "./AlfrescoFileService";
|
|
2
|
-
import AlfrescoNodeService from "./AlfrescoNodeService";
|
|
3
|
-
import AlfrescoPermissionService from "./AlfrescoPermissionService";
|
|
4
|
-
import ErrorService from "./ErrorService";
|
|
5
|
-
import WorkspaceService from "./WorkspaceService"
|
|
6
|
-
import { alfrescoApi, uploadApi, renditionsApi, nodesApi, sitesApi, searchApi, peopleApi, favoritesApi, trashcanApi } from "./AlfrescoApi";
|
|
7
|
-
import { useUserStore } from "./stores/user";
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
AlfrescoFileService,
|
|
11
|
-
AlfrescoNodeService,
|
|
12
|
-
AlfrescoPermissionService,
|
|
13
|
-
ErrorService,
|
|
14
|
-
uploadApi,
|
|
15
|
-
renditionsApi,
|
|
16
|
-
nodesApi,
|
|
17
|
-
sitesApi,
|
|
18
|
-
searchApi,
|
|
19
|
-
peopleApi,
|
|
20
|
-
alfrescoApi,
|
|
21
|
-
favoritesApi,
|
|
22
|
-
trashcanApi,
|
|
23
|
-
useUserStore,
|
|
24
|
-
WorkspaceService
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default class Index {
|
|
28
|
-
constructor() {
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/stores/user.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2022 - Jeci SARL - https://jeci.fr
|
|
3
|
-
*
|
|
4
|
-
* This program is free software: you can redistribute it and/or modify
|
|
5
|
-
* it under the terms of the GNU Affero General Public License as
|
|
6
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
7
|
-
* License, or (at your option) any later version.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU Affero General Public License for more details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
-
* along with this program. If not, see https://www.gnu.org/licenses/agpl-3.0.html.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// @ts-check
|
|
19
|
-
import { defineStore, acceptHMRUpdate } from "pinia";
|
|
20
|
-
import { alfrescoApi, peopleApi } from "../AlfrescoApi";
|
|
21
|
-
import { loginError } from "../ErrorService";
|
|
22
|
-
|
|
23
|
-
export const useUserStore = defineStore({
|
|
24
|
-
id: "user",
|
|
25
|
-
state: () => ({
|
|
26
|
-
displayName: "",
|
|
27
|
-
token: "",
|
|
28
|
-
isAdmin: false,
|
|
29
|
-
person: null,
|
|
30
|
-
apiAlfresco: null,
|
|
31
|
-
}),
|
|
32
|
-
getters: {
|
|
33
|
-
displayName(state) {
|
|
34
|
-
return state.person == null ? "" : state.person.displayName;
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
actions: {
|
|
38
|
-
logout() {
|
|
39
|
-
console.log("logout with " + this.email);
|
|
40
|
-
|
|
41
|
-
if (this.apiAlfresco) {
|
|
42
|
-
this.apiAlfresco.logout();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.$patch({
|
|
46
|
-
token: "",
|
|
47
|
-
isAdmin: false,
|
|
48
|
-
person: null,
|
|
49
|
-
apiAlfresco: null,
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
isLoggedIn() {
|
|
54
|
-
|
|
55
|
-
var alfresco;
|
|
56
|
-
|
|
57
|
-
if (!this.apiAlfresco) {
|
|
58
|
-
alfresco = alfrescoApi();
|
|
59
|
-
} else {
|
|
60
|
-
alfresco = this.apiAlfresco;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return peopleApi()
|
|
64
|
-
.getPerson("-me-")
|
|
65
|
-
.then((personEntry) => {
|
|
66
|
-
this.$patch({
|
|
67
|
-
person: personEntry.entry,
|
|
68
|
-
apiAlfresco: alfresco,
|
|
69
|
-
});
|
|
70
|
-
return true;
|
|
71
|
-
})
|
|
72
|
-
.catch((data) => {
|
|
73
|
-
return catchLogin(data);
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
/**
|
|
77
|
-
* Attempt to login a user
|
|
78
|
-
* @param {string} user
|
|
79
|
-
* @param {string} password
|
|
80
|
-
*/
|
|
81
|
-
async login(user, password) {
|
|
82
|
-
if (!user || !password) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
await this.apiLogin(user, password)
|
|
87
|
-
.then((personEntry) => {
|
|
88
|
-
this.$patch({
|
|
89
|
-
person: personEntry.entry,
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
.catch((error) => {
|
|
93
|
-
loginError(error);
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
/**
|
|
97
|
-
* Simulate a login
|
|
98
|
-
* @param {string} a
|
|
99
|
-
* @param {string} p
|
|
100
|
-
*/
|
|
101
|
-
apiLogin(a, p) {
|
|
102
|
-
|
|
103
|
-
return alfrescoApi()
|
|
104
|
-
.login(a, p)
|
|
105
|
-
.then(() => {
|
|
106
|
-
this.$patch({
|
|
107
|
-
apiAlfresco: alfrescoApi(),
|
|
108
|
-
});
|
|
109
|
-
return peopleApi().getPerson("-me-");
|
|
110
|
-
})
|
|
111
|
-
.catch((err) => {
|
|
112
|
-
return Promise.reject(err);
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
async publiclogoff() {
|
|
116
|
-
var userProfile = localStorage.getItem("ACS_USERNAME");
|
|
117
|
-
if (userProfile && userProfile.startsWith("user_publication_")) {
|
|
118
|
-
localStorage.removeItem("ticket-ECM");
|
|
119
|
-
localStorage.removeItem("ACS_USERNAME");
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
async publiclogin(espace_id) {
|
|
123
|
-
let ticketECM = window.localStorage.getItem("ticket-ECM");
|
|
124
|
-
|
|
125
|
-
if (typeof ticketECM !== "undefined" && ticketECM != null) {
|
|
126
|
-
// TODO check ticket validity
|
|
127
|
-
} else {
|
|
128
|
-
await fetch(
|
|
129
|
-
window.config["ALFRESCO_HOST"] +
|
|
130
|
-
"/alfresco/s/fr/jeci/pristy/authentication/ticket/publication/site/" +
|
|
131
|
-
espace_id,
|
|
132
|
-
{
|
|
133
|
-
method: "GET",
|
|
134
|
-
headers: {
|
|
135
|
-
"Content-Type": "application/json",
|
|
136
|
-
Accept: "application/json",
|
|
137
|
-
},
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
.then((response) => response.json())
|
|
141
|
-
.then((specs) => {
|
|
142
|
-
window.localStorage.setItem("ticket-ECM", specs.ticket);
|
|
143
|
-
window.localStorage.setItem("ACS_USERNAME", specs.login);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
alfrescoApi() {
|
|
148
|
-
return this.apiAlfresco;
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
if (import.meta.hot) {
|
|
154
|
-
import.meta.hot.accept(acceptHMRUpdate(useUserStore, import.meta.hot));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Traitement de l'erreur de connexion
|
|
159
|
-
*/
|
|
160
|
-
function catchLogin(data) {
|
|
161
|
-
let error = JSON.parse(data.message).error;
|
|
162
|
-
if (error.statusCode == 401) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
if (error.statusCode == 403) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
throw new Error(data);
|
|
169
|
-
}
|