Skip to content

Commit 750d5b0

Browse files
Merge pull request #5677 from Countly/journey+content
Merge common components from journey+content, Update EcmaVersion to 2023 [node 20 compat]
2 parents 35acbb4 + 431d4ec commit 750d5b0

File tree

17 files changed

+1031
-9
lines changed

17 files changed

+1031
-9
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
"node": true
213213
},
214214
"parserOptions": {
215-
"ecmaVersion": 2020
215+
"ecmaVersion": 2023
216216
},
217217
"rules": {
218218
"no-console": "off",

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ module.exports = function(grunt) {
144144
'frontend/express/public/javascripts/countly/vue/components/date.js',
145145
'frontend/express/public/javascripts/countly/vue/components/dropdown.js',
146146
'frontend/express/public/javascripts/countly/vue/components/input.js',
147+
'frontend/express/public/javascripts/countly/vue/components/content.js',
147148
'frontend/express/public/javascripts/countly/vue/datatable-legacy.js',
148149
'frontend/express/public/javascripts/countly/vue/components/datatable.js',
149150
'frontend/express/public/javascripts/countly/vue/components/dialog.js',

api/utils/countlyFs.js

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,60 @@ countlyFs.gridfs = {};
316316
}
317317
};
318318

319+
/**
320+
* Update file fields by ID
321+
* @param {string} category - collection where the file is stored
322+
* @param {string} id - file id
323+
* @param {object} updateFields - fields to update
324+
* @param {function} callback - function called when updating was completed or errored, providing error object as first param
325+
* @example
326+
* countlyFs.gridfs.updateFileById("test", "66d6c2d770434130c03b7dae", { filename: "newname.png", "metadata.tags": "newtag" }, function(err){
327+
* console.log("Update finished", err);
328+
* });
329+
*/
330+
ob.updateFileById = function(category, id, updateFields, callback) {
331+
if (!db) {
332+
if (callback) {
333+
callback(new Error("Database connection not available"));
334+
}
335+
return;
336+
}
337+
338+
const collection = db.collection(category + ".files");
339+
const setOps = {};
340+
341+
for (const [key, value] of Object.entries(updateFields)) {
342+
setOps[key] = value;
343+
}
344+
345+
collection.findOneAndUpdate(
346+
{ _id: new db.ObjectID(id) },
347+
{ $set: setOps },
348+
{ returnOriginal: true },
349+
function(err, result) {
350+
if (err) {
351+
log.e("Error updating file:", err);
352+
if (callback) {
353+
callback(err);
354+
}
355+
return;
356+
}
357+
358+
if (!result.value) {
359+
if (callback) {
360+
callback(new Error("File not found"));
361+
}
362+
return;
363+
}
364+
365+
log.d("File updated successfully");
366+
if (callback) {
367+
callback(null, result.value);
368+
}
369+
}
370+
);
371+
};
372+
319373
/**
320374
* Delete file from shared system
321375
* @param {string} category - collection where to store data
@@ -647,10 +701,12 @@ countlyFs.gridfs = {};
647701
bucket.find().toArray()
648702
.then((records) => callback(
649703
null,
650-
records.map(({ filename, uploadDate, length }) => ({
704+
records.map(({ _id, filename, uploadDate, length, metadata }) => ({
705+
_id,
651706
filename,
652707
createdOn: uploadDate,
653-
size: length
708+
size: length,
709+
metadata
654710
}))
655711
))
656712
.catch((error) => callback(error, null));

frontend/express/public/core/date-presets/templates/preset-management.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<cly-main>
1212
<cly-datatable-n
13+
:display-mode="'list'"
1314
:rows="rows"
1415
:resizable="true"
1516
:force-loading="isLoading"

0 commit comments

Comments
 (0)