@cocreate/organizations 1.3.2 → 1.5.1
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [1.5.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.5.0...v1.5.1) (2022-06-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update padding of datables td element ([4adf0fe](https://github.com/CoCreate-app/CoCreate-organizations/commit/4adf0fe02212df759b333da837c616e473b1d9b1))
|
|
7
|
+
|
|
8
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.4.0...v1.5.0) (2022-05-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* deleteDocument broadcasted after orgDeleted ([be1ecee](https://github.com/CoCreate-app/CoCreate-organizations/commit/be1ecee732ce71a3877dfbb06df9b19c0148eb16))
|
|
14
|
+
* deleteOrgs action to select and delete many organizations ([0abaa20](https://github.com/CoCreate-app/CoCreate-organizations/commit/0abaa2061ac7575c51314f5011aa6031022b6d7f))
|
|
15
|
+
|
|
16
|
+
# [1.4.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.3.2...v1.4.0) (2022-05-28)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* deleteOrg will delete db and org from from platformDB ([0fcb1bc](https://github.com/CoCreate-app/CoCreate-organizations/commit/0fcb1bc2ecdbb1948733c240ce7adfaceaa2b5e6))
|
|
22
|
+
|
|
1
23
|
## [1.3.2](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.3.1...v1.3.2) (2022-05-23)
|
|
2
24
|
|
|
3
25
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div content_id="content" class="padding:5px">
|
|
13
13
|
<table class="width:100% border-collapse:collapse">
|
|
14
14
|
<tr class="border-bottom:1px_solid_darkgray">
|
|
15
|
-
<td class="position:sticky top:0 background:white padding
|
|
15
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
16
16
|
<input type="text" class="floating-label"
|
|
17
17
|
filter-name="name"
|
|
18
18
|
template_id="datatable"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</a>
|
|
25
25
|
</span>
|
|
26
26
|
</td>
|
|
27
|
-
<td class="position:sticky top:0 background:white padding:
|
|
27
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
28
28
|
<input type="text" class="floating-label"
|
|
29
29
|
filter-name="_id"
|
|
30
30
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div content_id="content" class="padding:5px">
|
|
13
13
|
<table class="width:100% border-collapse:collapse">
|
|
14
14
|
<tr class="border-bottom:1px_solid_darkgray">
|
|
15
|
-
<td class="position:sticky top:0 background:white padding
|
|
15
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
16
16
|
<input type="text" class="floating-label"
|
|
17
17
|
filter-name="name"
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</a>
|
|
27
27
|
</span>
|
|
28
28
|
</td>
|
|
29
|
-
<td class="position:sticky top:0 background:white padding:
|
|
29
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
30
30
|
<input type="text" class="floating-label"
|
|
31
31
|
filter-name="_id"
|
|
32
32
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -30,14 +30,11 @@ const CoCreateOrganization = {
|
|
|
30
30
|
}
|
|
31
31
|
data[name] = value;
|
|
32
32
|
});
|
|
33
|
-
const room = config.organization_id;
|
|
34
33
|
|
|
35
34
|
crud.send('createOrg', {
|
|
36
|
-
apiKey: config.apiKey,
|
|
37
|
-
organization_id: config.organization_id,
|
|
38
35
|
collection: 'organizations',
|
|
39
36
|
data: data
|
|
40
|
-
}
|
|
37
|
+
});
|
|
41
38
|
},
|
|
42
39
|
|
|
43
40
|
setDocumentId: function(collection, id) {
|
|
@@ -53,9 +50,63 @@ const CoCreateOrganization = {
|
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
},
|
|
53
|
+
|
|
54
|
+
deleteOrg: async function(btn) {
|
|
55
|
+
const { collection, document_id } = crud.getAttr(btn);
|
|
56
|
+
const organization_id = document_id;
|
|
57
|
+
|
|
58
|
+
if(crud.checkAttrValue(collection) && crud.checkAttrValue(document_id)) {
|
|
59
|
+
|
|
60
|
+
crud.send('deleteOrg', {
|
|
61
|
+
collection,
|
|
62
|
+
document_id,
|
|
63
|
+
data: {
|
|
64
|
+
organization_id,
|
|
65
|
+
},
|
|
66
|
+
'metadata': 'deleteOrg-action'
|
|
67
|
+
}).then(response => {
|
|
68
|
+
|
|
69
|
+
// ToDo: replace with custom event
|
|
70
|
+
document.dispatchEvent(new CustomEvent('deletedOrg', {
|
|
71
|
+
detail: {}
|
|
72
|
+
}));
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
deleteOrgs: async function(btn) {
|
|
78
|
+
const collection = btn.getAttribute('collection');
|
|
79
|
+
if(crud.checkAttrValue(collection)) {
|
|
80
|
+
const dataTemplateid = btn.getAttribute('template_id');
|
|
81
|
+
if(!dataTemplateid) return;
|
|
82
|
+
|
|
83
|
+
const selectedEls = document.querySelectorAll(`.selected[templateid="${dataTemplateid}"]`);
|
|
84
|
+
|
|
85
|
+
selectedEls.forEach((el) => {
|
|
86
|
+
const document_id = el.getAttribute('document_id');
|
|
87
|
+
const organization_id = document_id;
|
|
88
|
+
|
|
89
|
+
if(crud.checkAttrValue(document_id)) {
|
|
90
|
+
crud.send('deleteOrg', {
|
|
91
|
+
collection,
|
|
92
|
+
document_id,
|
|
93
|
+
data: {
|
|
94
|
+
organization_id,
|
|
95
|
+
},
|
|
96
|
+
'metadata': 'deleteOrgs-action'
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
document.dispatchEvent(new CustomEvent('deletedOrgs', {
|
|
102
|
+
detail: {}
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
56
106
|
|
|
57
107
|
};
|
|
58
108
|
|
|
109
|
+
|
|
59
110
|
action.init({
|
|
60
111
|
name: "createOrg",
|
|
61
112
|
endEvent: "createdOrg",
|
|
@@ -64,6 +115,22 @@ action.init({
|
|
|
64
115
|
},
|
|
65
116
|
});
|
|
66
117
|
|
|
118
|
+
action.init({
|
|
119
|
+
name: "deleteOrg",
|
|
120
|
+
endEvent: "deletedOrg",
|
|
121
|
+
callback: (btn, data) => {
|
|
122
|
+
CoCreateOrganization.deleteOrg(btn);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
action.init({
|
|
127
|
+
name: "deleteOrgs",
|
|
128
|
+
endEvent: "deletedOrgs",
|
|
129
|
+
callback: (btn, data) => {
|
|
130
|
+
CoCreateOrganization.deleteOrgs(btn);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
67
134
|
CoCreateOrganization.init();
|
|
68
135
|
|
|
69
136
|
export default CoCreateOrganization;
|
package/src/server.js
CHANGED
|
@@ -9,8 +9,12 @@ class CoCreateOrganization {
|
|
|
9
9
|
|
|
10
10
|
init() {
|
|
11
11
|
if (this.wsManager) {
|
|
12
|
-
this.wsManager.on('createOrg',
|
|
13
|
-
|
|
12
|
+
this.wsManager.on('createOrg', (socket, data, socketInfo) =>
|
|
13
|
+
this.createOrg(socket, data, socketInfo)
|
|
14
|
+
);
|
|
15
|
+
this.wsManager.on('deleteOrg', (socket, data, socketInfo) =>
|
|
16
|
+
this.deleteOrg(socket, data, socketInfo)
|
|
17
|
+
);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -52,8 +56,32 @@ class CoCreateOrganization {
|
|
|
52
56
|
async deleteOrg(socket, data, socketInfo) {
|
|
53
57
|
const self = this;
|
|
54
58
|
if(!data.data) return;
|
|
59
|
+
const organization_id = data.data.organization_id
|
|
60
|
+
if(!organization_id || organization_id == process.env.organization_id) return;
|
|
61
|
+
if(data.organization_id != process.env.organization_id) return;
|
|
55
62
|
try{
|
|
56
|
-
|
|
63
|
+
const db = this.dbClient.db(organization_id);
|
|
64
|
+
db.dropDatabase().then(response => {
|
|
65
|
+
if (response === true){
|
|
66
|
+
process.emit('deleteOrg', organization_id)
|
|
67
|
+
|
|
68
|
+
// delete org from platformDB
|
|
69
|
+
const platformDB = self.dbClient.db(process.env.organization_id).collection(data['collection']);
|
|
70
|
+
const query = {
|
|
71
|
+
"_id": new ObjectId(organization_id)
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
platformDB.deleteOne(query, function(error, result) {
|
|
75
|
+
if (!error) {
|
|
76
|
+
let response = { ...data }
|
|
77
|
+
self.wsManager.send(socket, 'deleteOrg', response, socketInfo);
|
|
78
|
+
self.wsManager.broadcast(socket, response.namespace || response['organization_id'], response.room, 'deleteDocument', response, socketInfo);
|
|
79
|
+
} else {
|
|
80
|
+
self.wsManager.send(socket, 'ServerError', error, socketInfo);
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
})
|
|
57
85
|
}catch(error){
|
|
58
86
|
console.log('deleteOrg error', error);
|
|
59
87
|
}
|