@steedos/service-core-objects 3.0.0-beta.40 → 3.0.0-beta.42
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.
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 连接到服务器
|
|
2
|
+
const socket = window.io("http://192.168.3.59:6900", {
|
|
3
|
+
path: "/socket.io"
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
// 监听连接事件
|
|
7
|
+
socket.on("connect", () => {
|
|
8
|
+
console.log("Connected to server!");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// 监听自定义事件(根据服务器提供的接口)
|
|
12
|
+
socket.on("metadata:change", (data) => {
|
|
13
|
+
console.log("Received:", data);
|
|
14
|
+
if(data.type === 'apps'){
|
|
15
|
+
window.$(`.btn-reload-global-header-${data.name}`).trigger('click');
|
|
16
|
+
window.$(`.btn-reload-app-menu-${data.name}`).trigger('click');
|
|
17
|
+
setTimeout(function(){
|
|
18
|
+
window.$(".btn-reload-app-dashboard").trigger('click');
|
|
19
|
+
}, 1000 * 1)
|
|
20
|
+
}else if(data.type === 'objects'){
|
|
21
|
+
window.getUISchema(data.name, true).then(()=>{
|
|
22
|
+
if(window.location.pathname.includes(`/${data.name}/view`)){
|
|
23
|
+
window.navigate(window.location.pathname, {state: {reloadKey: new Date().getTime()}})
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}else if(data.type === 'object_listviews'){
|
|
27
|
+
window.getUISchema(data.objectName, true).then(()=>{
|
|
28
|
+
if(window.location.pathname.endsWith(`/${data.objectName}`)){
|
|
29
|
+
window.navigate(window.location.pathname, {state: {reloadKey: new Date().getTime()}})
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// 发送消息
|
|
36
|
+
socket.emit("event", { key: "value" });
|
|
37
|
+
|
|
38
|
+
// 断开连接时
|
|
39
|
+
socket.on("disconnect", () => {
|
|
40
|
+
console.log("Disconnected from server");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
window.socket = socket;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
3
|
+
* @Date: 2025-05-27 14:51:49
|
|
4
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
5
|
+
* @LastEditTime: 2025-05-27 15:48:42
|
|
6
|
+
*/
|
|
7
|
+
const { requireAuthentication } = require("@steedos/auth");
|
|
8
|
+
const { getSteedosSchema, getObject } = require("@steedos/objectql");
|
|
9
|
+
const express = require("express");
|
|
10
|
+
const router = express.Router();
|
|
11
|
+
const _ = require("lodash");
|
|
12
|
+
|
|
13
|
+
const util = {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the object record Relative url
|
|
16
|
+
*/
|
|
17
|
+
getObjectRecordRelativeUrl: (objectName, recordId, spaceId = null, options = {}) => {
|
|
18
|
+
let appId = '-';
|
|
19
|
+
if (options.appId) {
|
|
20
|
+
appId = options.appId;
|
|
21
|
+
}
|
|
22
|
+
let url = `/app/${appId}/${objectName}/view/${recordId}`;
|
|
23
|
+
if (objectName === "instances") {
|
|
24
|
+
url = `/workflow/space/${spaceId}/inbox/${recordId}`;
|
|
25
|
+
}
|
|
26
|
+
return url;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
router.get(
|
|
31
|
+
"/api/v4/notifications/:_id/read",
|
|
32
|
+
requireAuthentication,
|
|
33
|
+
async function (req, res) {
|
|
34
|
+
let { _id: record_id } = req.params;
|
|
35
|
+
let { rootUrl, appId } = req.query;
|
|
36
|
+
const userSession = req.user;
|
|
37
|
+
let req_async = _.has(req.query, 'async');
|
|
38
|
+
if (userSession.userId) {
|
|
39
|
+
let record = await getSteedosSchema().getObject("notifications").findOne(record_id, { fields: ['owner', 'is_read', 'related_to', 'space', 'url'] });
|
|
40
|
+
if (!record) {
|
|
41
|
+
// 跳转到通知记录界面会显示为404效果
|
|
42
|
+
let redirectUrl = util.getObjectRecordRelativeUrl("notifications", record_id);
|
|
43
|
+
if (req.get("X-Requested-With") === 'XMLHttpRequest') {
|
|
44
|
+
return res.status(200).send({
|
|
45
|
+
"status": 404,
|
|
46
|
+
"redirect": redirectUrl
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
return res.redirect(redirectUrl);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!record.related_to && !record.url) {
|
|
53
|
+
return res.status(401).send({
|
|
54
|
+
"error": "Validate Request -- Missing related_to or url",
|
|
55
|
+
"success": false
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (!record.is_read && record.owner === userSession.userId) {
|
|
59
|
+
// 没有权限时,只是不修改is_read值,但是允许跳转到相关记录查看
|
|
60
|
+
await getSteedosSchema().getObject('notifications').update(record_id, { 'is_read': true, modified: new Date() })
|
|
61
|
+
}
|
|
62
|
+
let redirectUrl = record.url ? record.url : util.getObjectRecordRelativeUrl(record.related_to.o, record.related_to.ids[0], record.space, {
|
|
63
|
+
rootUrl, appId
|
|
64
|
+
});
|
|
65
|
+
if (req_async) { // || req.get("X-Requested-With") === 'XMLHttpRequest'
|
|
66
|
+
return res.status(200).send({
|
|
67
|
+
"status": 200,
|
|
68
|
+
"redirect": redirectUrl
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
return res.redirect(redirectUrl);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return res.status(401).send({
|
|
75
|
+
"error": "Validate Request -- Missing X-Auth-Token",
|
|
76
|
+
"success": false
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
router.post(
|
|
82
|
+
"/api/v4/notifications/all/markReadAll",
|
|
83
|
+
requireAuthentication,
|
|
84
|
+
async function (req, res) {
|
|
85
|
+
let userSession = req.user;
|
|
86
|
+
let error;
|
|
87
|
+
let updatedCount = await getObject("notifications").directUpdateMany([
|
|
88
|
+
["space", "=", userSession.spaceId],
|
|
89
|
+
["owner", "=", userSession.userId],
|
|
90
|
+
[["is_read", "=", null], 'or', ["is_read", "=", false]]
|
|
91
|
+
], {
|
|
92
|
+
is_read: true
|
|
93
|
+
}).catch((ex) => {
|
|
94
|
+
console.error(ex);
|
|
95
|
+
error = ex;
|
|
96
|
+
return 0;
|
|
97
|
+
});
|
|
98
|
+
if (error) {
|
|
99
|
+
res.status(500).send({
|
|
100
|
+
"error": error,
|
|
101
|
+
"success": false
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return res.send({
|
|
106
|
+
markedCount: updatedCount,
|
|
107
|
+
"success": true
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
exports.default = router;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-core-objects",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.42",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"steedos"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/service-package-loader": "3.0.0-beta.
|
|
13
|
+
"@steedos/service-package-loader": "3.0.0-beta.42",
|
|
14
14
|
"json2xls": "^0.1.2",
|
|
15
15
|
"lodash": "^4.17.21"
|
|
16
16
|
},
|
|
17
17
|
"description": "steedos package",
|
|
18
18
|
"repository": {},
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "5f8aace8aca89b3e250b51d1728ad764a2338202"
|
|
21
21
|
}
|