@ozdao/prometheus-framework 0.0.91 → 0.0.93
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Feed-530e40ab.mjs +428 -0
- package/dist/Feed-a0df5d24.js +1 -0
- package/dist/Feed-bf575b72.mjs +428 -0
- package/dist/Feed-c25dc839.js +1 -0
- package/dist/Product-2459e9da.mjs +838 -0
- package/dist/Product-7f86f9d4.js +7 -0
- package/dist/Product-a23f852f.js +7 -0
- package/dist/Product-c085f00f.mjs +838 -0
- package/dist/ProductEdit-171c9923.js +1 -0
- package/dist/ProductEdit-23d35d67.mjs +350 -0
- package/dist/ProductEdit-cdc3415a.mjs +350 -0
- package/dist/ProductEdit-d2666662.js +1 -0
- package/dist/ProfileBlogposts-5382274b.mjs +64 -0
- package/dist/ProfileBlogposts-8b66ae1b.js +1 -0
- package/dist/ProfileBlogposts-a2d04221.js +1 -0
- package/dist/ProfileBlogposts-f90f947b.mjs +64 -0
- package/dist/ProfileComments-061ea40b.mjs +44 -0
- package/dist/ProfileComments-06985576.mjs +44 -0
- package/dist/ProfileComments-db4b6fbc.js +1 -0
- package/dist/ProfileComments-e0116e5f.js +1 -0
- package/dist/ProfileLikes-11ca8c11.js +1 -0
- package/dist/ProfileLikes-3c5c02be.mjs +44 -0
- package/dist/ProfileLikes-553c52df.js +1 -0
- package/dist/ProfileLikes-e88dae8f.mjs +44 -0
- package/dist/auth.client.cjs +1 -1
- package/dist/auth.client.js +86 -91
- package/dist/community.client.cjs +1 -1
- package/dist/community.client.js +2 -2
- package/dist/organizations.client-1eb0b49c.js +3 -0
- package/dist/organizations.client-21cfcf36.mjs +3038 -0
- package/dist/organizations.client-6947e530.js +3 -0
- package/dist/organizations.client-c7844bc2.mjs +3038 -0
- package/dist/organizations.client.cjs +1 -1
- package/dist/organizations.client.js +2 -2
- package/dist/users.client.cjs +1 -1
- package/dist/users.client.js +20 -20
- package/package.json +1 -1
- package/src/modules/auth/components/pages/SignIn.vue +3 -3
- package/src/modules/community/components/sections/Feed.vue +1 -1
- package/src/modules/users/components/pages/Profile.vue +1 -1
@@ -0,0 +1,428 @@
|
|
1
|
+
import { reactive as L, watch as I, openBlock as o, createElementBlock as l, toDisplayString as u, createCommentVNode as i, createElementVNode as b, ref as g, createTextVNode as z, computed as B, createVNode as w, normalizeClass as O, unref as d, renderSlot as A, createBlock as x, onMounted as T, Transition as $, withCtx as j, Fragment as U, renderList as E } from "vue";
|
2
|
+
import { _ as M } from "./EmptyState-34d85f10.mjs";
|
3
|
+
import { _ as F } from "./_plugin-vue_export-helper-dad06003.mjs";
|
4
|
+
import { _ as V, a as q } from "./Chips-f0b7ce36.mjs";
|
5
|
+
import { useRouter as D } from "vue-router";
|
6
|
+
import { a as N } from "./auth-5217f6a5.mjs";
|
7
|
+
import { s as p } from "./globals-96ba60e4.mjs";
|
8
|
+
const k = N.create({ baseURL: process.env.API_URL, withCredentials: !0 });
|
9
|
+
k.defaults.withCredentials = !0;
|
10
|
+
const f = L({
|
11
|
+
all: [],
|
12
|
+
filter: {
|
13
|
+
// query
|
14
|
+
tags: [],
|
15
|
+
period: ""
|
16
|
+
// pagination
|
17
|
+
},
|
18
|
+
pagination: {
|
19
|
+
page: 1,
|
20
|
+
perPage: 18
|
21
|
+
},
|
22
|
+
// Sort
|
23
|
+
sort: {
|
24
|
+
current: "popularity",
|
25
|
+
ascending: !1
|
26
|
+
},
|
27
|
+
current: {
|
28
|
+
_id: "",
|
29
|
+
url: "",
|
30
|
+
status: "",
|
31
|
+
name: "",
|
32
|
+
tags: [],
|
33
|
+
owner: {},
|
34
|
+
date: "",
|
35
|
+
views: 0,
|
36
|
+
content: []
|
37
|
+
}
|
38
|
+
});
|
39
|
+
async function S(e = {}) {
|
40
|
+
e.params = e.params || {}, e.params.skip = e.skip || 0, e.params.limit = e.limit || 9, e.params.tags = e.tags || [], e.period && (e.params.period = e.period), e.url && (e.params = { url: e.url }), e.category && (e.params.category = e.category), e.organization && (e.params.organization = e.organization), e.owner && (e.params.owner = e.owner), e.creator && (e.params.creator = e.creator), e.status && (e.params.status = e.status), e.user && (e.params.user = e.user), e.params.skip = e.skip || 0, e.params.limit = e.limit || 10;
|
41
|
+
try {
|
42
|
+
console.log("Request params:" + e.params);
|
43
|
+
const t = await k.get("/api/blog/read", { params: e.params });
|
44
|
+
return e.url ? _(t.data, "current") : _(t.data, "all"), Promise.resolve(t.data);
|
45
|
+
} catch (t) {
|
46
|
+
return p(t), Promise.reject(t);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
async function G(e) {
|
50
|
+
return k.post("/api/blog/create", e).then(
|
51
|
+
(t) => (_(t.data, "current"), Promise.resolve(t.data)),
|
52
|
+
(t) => (p(t), Promise.reject(t))
|
53
|
+
);
|
54
|
+
}
|
55
|
+
async function H(e) {
|
56
|
+
return k.post("/api/blog/update", e).then(
|
57
|
+
(t) => (_(t.data, "current"), Promise.resolve(t.data)),
|
58
|
+
(t) => (p(t), Promise.reject(t))
|
59
|
+
);
|
60
|
+
}
|
61
|
+
async function J(e) {
|
62
|
+
return await k.delete(`/api/blog/delete/${e}`).then(
|
63
|
+
(t) => {
|
64
|
+
const a = f.all.findIndex((r) => r._id === e);
|
65
|
+
return a !== -1 && f.all.splice(a, 1), Promise.resolve(t.data);
|
66
|
+
},
|
67
|
+
(t) => (p(t), Promise.reject(t))
|
68
|
+
);
|
69
|
+
}
|
70
|
+
function _(e, t) {
|
71
|
+
f[t] = e;
|
72
|
+
}
|
73
|
+
function K() {
|
74
|
+
f.current = {
|
75
|
+
_id: "",
|
76
|
+
url: "",
|
77
|
+
status: "",
|
78
|
+
name: "",
|
79
|
+
tags: [],
|
80
|
+
author: "",
|
81
|
+
owner: "",
|
82
|
+
date: "",
|
83
|
+
views: 0,
|
84
|
+
content: []
|
85
|
+
};
|
86
|
+
}
|
87
|
+
function Q(e) {
|
88
|
+
const t = {
|
89
|
+
order: f.project.content.length + 1,
|
90
|
+
type: e.type,
|
91
|
+
data: e.data,
|
92
|
+
class: e.class,
|
93
|
+
content: e.content
|
94
|
+
};
|
95
|
+
f.project.content.push(t);
|
96
|
+
}
|
97
|
+
I(f, (e, t) => {
|
98
|
+
});
|
99
|
+
const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
100
|
+
__proto__: null,
|
101
|
+
blockAdd: Q,
|
102
|
+
clean: K,
|
103
|
+
create: G,
|
104
|
+
read: S,
|
105
|
+
remove: J,
|
106
|
+
set: _,
|
107
|
+
state: f,
|
108
|
+
update: H
|
109
|
+
}, Symbol.toStringTag, { value: "Module" })), W = {
|
110
|
+
props: {
|
111
|
+
progress: {
|
112
|
+
type: Number,
|
113
|
+
default: null
|
114
|
+
},
|
115
|
+
status: {
|
116
|
+
type: String,
|
117
|
+
default: null
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}, X = { class: "circular-loader" }, Y = /* @__PURE__ */ b("svg", { viewBox: "25 25 50 50" }, [
|
121
|
+
/* @__PURE__ */ b("circle", {
|
122
|
+
cx: "50",
|
123
|
+
cy: "50",
|
124
|
+
r: "20",
|
125
|
+
fill: "none",
|
126
|
+
"stroke-width": "4",
|
127
|
+
"stroke-miterlimit": "10"
|
128
|
+
})
|
129
|
+
], -1), Z = {
|
130
|
+
key: 0,
|
131
|
+
class: "progress-text"
|
132
|
+
}, ee = {
|
133
|
+
key: 1,
|
134
|
+
class: "uppercase t-semi w-m-10r status-text"
|
135
|
+
};
|
136
|
+
function te(e, t, a, r, s, c) {
|
137
|
+
return o(), l("div", X, [
|
138
|
+
Y,
|
139
|
+
a.progress ? (o(), l("div", Z, u(a.progress), 1)) : i("", !0),
|
140
|
+
a.status ? (o(), l("div", ee, u(a.status), 1)) : i("", !0)
|
141
|
+
]);
|
142
|
+
}
|
143
|
+
const re = /* @__PURE__ */ F(W, [["render", te]]), P = N.create({
|
144
|
+
baseURL: process.env.API_URL,
|
145
|
+
withCredentials: !0
|
146
|
+
}), y = L({
|
147
|
+
reactions: [],
|
148
|
+
error: null
|
149
|
+
}), C = {
|
150
|
+
async read({ user: e, type: t, target: a, role: r }) {
|
151
|
+
try {
|
152
|
+
const s = await P.get("/api/reactions", { params: { user: e, type: t, target: a, role: r } });
|
153
|
+
return y.error = null, y.reactions = s.data, Promise.resolve(s.data);
|
154
|
+
} catch (s) {
|
155
|
+
return p(s), Promise.reject(s);
|
156
|
+
}
|
157
|
+
},
|
158
|
+
async create(e) {
|
159
|
+
try {
|
160
|
+
const t = await P.post("/api/reactions/create", e);
|
161
|
+
return y.error = null, Promise.resolve(t.data);
|
162
|
+
} catch (t) {
|
163
|
+
return console.log(t), p(t), Promise.reject(t);
|
164
|
+
}
|
165
|
+
},
|
166
|
+
async update(e) {
|
167
|
+
try {
|
168
|
+
const t = await P.post("/api/reactions/update", e);
|
169
|
+
return y.error = null, Promise.resolve(t.data);
|
170
|
+
} catch (t) {
|
171
|
+
return p(t), Promise.reject(t);
|
172
|
+
}
|
173
|
+
},
|
174
|
+
async delete(e) {
|
175
|
+
try {
|
176
|
+
const t = await P.post("/api/reactions/delete", e);
|
177
|
+
return y.error = null, Promise.resolve(t.data);
|
178
|
+
} catch (t) {
|
179
|
+
return p(t), Promise.reject(t);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}, ae = {
|
183
|
+
handleReactionUpdate(e, t, a) {
|
184
|
+
let r;
|
185
|
+
if (Array.isArray(e) ? r = e.find((s) => s._id === t.target) : typeof e == "object" && e._id === t.target && (r = e), r)
|
186
|
+
if (r.hasReaction = a, a)
|
187
|
+
r.reactions.push(t), r.numberOfReactions += 1;
|
188
|
+
else {
|
189
|
+
const s = r.reactions.findIndex((c) => c._id === t._id);
|
190
|
+
s !== -1 && (r.reactions.splice(s, 1), r.numberOfReactions -= 1);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
};
|
194
|
+
I(y, (e) => {
|
195
|
+
});
|
196
|
+
const Se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
197
|
+
__proto__: null,
|
198
|
+
actions: C,
|
199
|
+
mutations: ae,
|
200
|
+
state: y
|
201
|
+
}, Symbol.toStringTag, { value: "Module" })), se = { class: "t-semi br-top-dark flex-nowrap flex-nojustify flex" }, oe = /* @__PURE__ */ b("span", { class: "mn-r-small mn-l-small d-block" }, "·", -1), ne = { class: "cursor-pointer" }, le = /* @__PURE__ */ b("span", { class: "mn-r-small mn-l-small d-block" }, "·", -1), ce = {
|
202
|
+
__name: "FooterBlogpost",
|
203
|
+
props: ["blogpost", "owner", "user"],
|
204
|
+
setup(e) {
|
205
|
+
const t = e, a = g(t.blogpost.numberOfReactions), r = g(t.blogpost.isReacted), s = g(t.blogpost.reactionId);
|
206
|
+
async function c(h) {
|
207
|
+
if (!t.user) {
|
208
|
+
alert("Please login to add a reaction");
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
try {
|
212
|
+
const n = {
|
213
|
+
target: t.blogpost._id,
|
214
|
+
type: "blogpost",
|
215
|
+
user: t.user,
|
216
|
+
class: "like"
|
217
|
+
}, v = await C.create(n);
|
218
|
+
v.reaction.class === "like" && (a.value += 1, r.value = !0, s.value = v.reaction._id);
|
219
|
+
} catch (n) {
|
220
|
+
console.error(n), alert("Error adding reaction. Please try again later.");
|
221
|
+
}
|
222
|
+
}
|
223
|
+
async function m(h) {
|
224
|
+
if (!t.user) {
|
225
|
+
alert("Please login to add a reaction");
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
try {
|
229
|
+
const n = { _id: s.value };
|
230
|
+
await C.delete(n), a.value -= 1, r.value = !1, s.value = null;
|
231
|
+
} catch {
|
232
|
+
alert("Error adding reaction. Please try again later.");
|
233
|
+
}
|
234
|
+
}
|
235
|
+
return (h, n) => (o(), l("footer", se, [
|
236
|
+
z(" 👁️ " + u(e.blogpost.views) + " ", 1),
|
237
|
+
oe,
|
238
|
+
b("div", ne, [
|
239
|
+
r.value ? i("", !0) : (o(), l("div", {
|
240
|
+
key: 0,
|
241
|
+
class: "cursor-pointer",
|
242
|
+
onClick: n[0] || (n[0] = (v) => c())
|
243
|
+
}, " 👍 " + u(a.value), 1)),
|
244
|
+
r.value ? (o(), l("div", {
|
245
|
+
key: 1,
|
246
|
+
class: "cursor-pointer",
|
247
|
+
onClick: n[1] || (n[1] = (v) => m())
|
248
|
+
}, " 👍 " + u(a.value), 1)) : i("", !0)
|
249
|
+
]),
|
250
|
+
le,
|
251
|
+
z(" 💬 " + u(e.blogpost.numberOfComments), 1)
|
252
|
+
]));
|
253
|
+
}
|
254
|
+
}, ie = { class: "bg-grey radius-big" }, ue = ["src"], de = { class: "pd-t-zero pd-medium" }, me = {
|
255
|
+
key: 0,
|
256
|
+
class: "cursor-pointer mn-thin flex-nowrap flex w-100"
|
257
|
+
}, ge = {
|
258
|
+
key: 0,
|
259
|
+
class: "pd-micro t-white uppercase t-semi p-small flex-center flex pd-r-small pd-l-small mn-l-thin w-min bg-second radius-extra"
|
260
|
+
}, pe = {
|
261
|
+
key: 1,
|
262
|
+
class: "mn-small t-transp p-big"
|
263
|
+
}, fe = {
|
264
|
+
key: 2,
|
265
|
+
class: "mn-small h2"
|
266
|
+
}, ye = {
|
267
|
+
__name: "CardBlogpost",
|
268
|
+
props: ["blogpost", "user", "type"],
|
269
|
+
setup(e) {
|
270
|
+
const t = e, a = D(), r = B(() => t.blogpost.content.find((c) => c.type === "ImageUpload")), s = B(() => t.blogpost.content.find((c) => c.type === "Textarea"));
|
271
|
+
return (c, m) => (o(), l("article", ie, [
|
272
|
+
w(V, {
|
273
|
+
class: O({
|
274
|
+
"mn-small pd-medium": e.type !== "short",
|
275
|
+
"flex-child-order-last flex-child mn-l-small": e.type === "short"
|
276
|
+
}),
|
277
|
+
owner: e.blogpost.owner,
|
278
|
+
creator: e.blogpost.creator,
|
279
|
+
date: e.blogpost.createdAt
|
280
|
+
}, null, 8, ["class", "owner", "creator", "date"]),
|
281
|
+
d(r) && d(r).content && e.type !== "blogpostPage" ? (o(), l("img", {
|
282
|
+
key: 0,
|
283
|
+
src: d(r).content,
|
284
|
+
alt: "Blog post image",
|
285
|
+
class: "mn-medium object-fit-cover w-100 h-20r"
|
286
|
+
}, null, 8, ue)) : i("", !0),
|
287
|
+
b("section", de, [
|
288
|
+
e.type !== "blogpostPage" ? (o(), l("div", me, [
|
289
|
+
b("h3", {
|
290
|
+
onClick: m[0] || (m[0] = (h) => d(a).push({
|
291
|
+
name: "BlogPost",
|
292
|
+
params: {
|
293
|
+
url: e.blogpost.url
|
294
|
+
}
|
295
|
+
})),
|
296
|
+
class: ""
|
297
|
+
}, u(e.blogpost.name), 1),
|
298
|
+
e.blogpost.status === "draft" ? (o(), l("div", ge, u(e.blogpost.status), 1)) : i("", !0)
|
299
|
+
])) : i("", !0),
|
300
|
+
d(s) && d(s).content && e.type !== "blogpostPage" ? (o(), l("p", pe, u(d(s).content.slice(0, 120)) + "... ", 1)) : i("", !0),
|
301
|
+
e.type === "blogpostPage" ? (o(), l("h3", fe, u(e.blogpost.name), 1)) : i("", !0),
|
302
|
+
A(c.$slots, "default"),
|
303
|
+
e.type !== "short" && e.blogpost.tags.length > 0 ? (o(), x(q, {
|
304
|
+
key: 3,
|
305
|
+
chips: e.blogpost.tags
|
306
|
+
}, null, 8, ["chips"])) : i("", !0)
|
307
|
+
]),
|
308
|
+
w(ce, {
|
309
|
+
class: "pd-t-zero pd-medium",
|
310
|
+
blogpost: e.blogpost,
|
311
|
+
user: e.user
|
312
|
+
}, null, 8, ["blogpost", "user"])
|
313
|
+
]));
|
314
|
+
}
|
315
|
+
}, be = { class: "feed" }, he = { key: 1 }, Ce = {
|
316
|
+
__name: "Feed",
|
317
|
+
props: {
|
318
|
+
category: {
|
319
|
+
type: String,
|
320
|
+
default: null
|
321
|
+
},
|
322
|
+
owner: {
|
323
|
+
type: String,
|
324
|
+
default: null
|
325
|
+
},
|
326
|
+
creator: {
|
327
|
+
type: String,
|
328
|
+
default: null
|
329
|
+
},
|
330
|
+
status: {
|
331
|
+
type: String,
|
332
|
+
default: "published"
|
333
|
+
},
|
334
|
+
user: {
|
335
|
+
type: [String, Number],
|
336
|
+
default: null
|
337
|
+
},
|
338
|
+
period: {
|
339
|
+
type: String,
|
340
|
+
default: null
|
341
|
+
}
|
342
|
+
},
|
343
|
+
setup(e) {
|
344
|
+
const t = e, a = g([]), r = g(!0);
|
345
|
+
let s = g(!0), c = g(0), m = g(7);
|
346
|
+
const h = async () => {
|
347
|
+
if (r.value) {
|
348
|
+
c.value += m.value;
|
349
|
+
const n = await S({
|
350
|
+
skip: c.value,
|
351
|
+
limit: m.value,
|
352
|
+
category: t.category,
|
353
|
+
user: t.user,
|
354
|
+
owner: t.owner,
|
355
|
+
status: t.status,
|
356
|
+
creator: t.creator,
|
357
|
+
period: t.period
|
358
|
+
});
|
359
|
+
n.length === 0 && (r.value = !1), a.value = [...a.value, ...n];
|
360
|
+
}
|
361
|
+
};
|
362
|
+
return T(async () => {
|
363
|
+
const n = await S({
|
364
|
+
skip: c.value,
|
365
|
+
limit: m.value,
|
366
|
+
category: t.category,
|
367
|
+
user: t.user,
|
368
|
+
owner: t.owner,
|
369
|
+
status: t.status,
|
370
|
+
creator: t.creator,
|
371
|
+
period: t.period
|
372
|
+
});
|
373
|
+
n.length === 0 ? r.value = !1 : r.value = !0, a.value = n, s.value = !1;
|
374
|
+
}), (n, v) => (o(), l("section", be, [
|
375
|
+
w($, { name: "fade" }, {
|
376
|
+
default: j(() => [
|
377
|
+
d(s) ? (o(), x(re, {
|
378
|
+
key: 0,
|
379
|
+
class: "z-index-5 pos-t-50 left-t-50 pos-absolute"
|
380
|
+
})) : i("", !0)
|
381
|
+
]),
|
382
|
+
_: 1
|
383
|
+
}),
|
384
|
+
w($, { name: "fade" }, {
|
385
|
+
default: j(() => [
|
386
|
+
!d(s) && a.value.length < 1 ? (o(), x(M, {
|
387
|
+
key: 0,
|
388
|
+
title: "No Blog Posts Found",
|
389
|
+
description: "Currently, there are no posts available in this blog. Please check back later.",
|
390
|
+
class: "pd-medium mn-thin bg-grey radius-big"
|
391
|
+
})) : (o(), l("div", he, [
|
392
|
+
(o(!0), l(U, null, E(a.value, (R) => (o(), x(ye, {
|
393
|
+
key: R._id,
|
394
|
+
blogpost: R,
|
395
|
+
user: e.user,
|
396
|
+
class: "mn-medium"
|
397
|
+
}, null, 8, ["blogpost", "user"]))), 128)),
|
398
|
+
w($, { name: "fade" }, {
|
399
|
+
default: j(() => [
|
400
|
+
r.value && a.value.length > 0 ? (o(), l("button", {
|
401
|
+
key: 0,
|
402
|
+
onClick: h,
|
403
|
+
class: "w-100 bg-main button"
|
404
|
+
}, " Load more ")) : i("", !0)
|
405
|
+
]),
|
406
|
+
_: 1
|
407
|
+
})
|
408
|
+
]))
|
409
|
+
]),
|
410
|
+
_: 1
|
411
|
+
})
|
412
|
+
]));
|
413
|
+
}
|
414
|
+
};
|
415
|
+
export {
|
416
|
+
re as L,
|
417
|
+
Ce as _,
|
418
|
+
G as a,
|
419
|
+
J as b,
|
420
|
+
K as c,
|
421
|
+
ye as d,
|
422
|
+
ce as e,
|
423
|
+
je as f,
|
424
|
+
Se as g,
|
425
|
+
S as r,
|
426
|
+
f as s,
|
427
|
+
H as u
|
428
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const e=require("vue"),V=require("./EmptyState-7658d7d6.js"),S=require("./_plugin-vue_export-helper-f246444f.js"),v=require("./Chips-2a0d9bfe.js"),$=require("vue-router"),w=require("./auth-5a58f8cb.js"),u=require("./globals-928eb13c.js"),f=w.axios.create({baseURL:process.env.API_URL,withCredentials:!0});f.defaults.withCredentials=!0;const c=e.reactive({all:[],filter:{tags:[],period:""},pagination:{page:1,perPage:18},sort:{current:"popularity",ascending:!1},current:{_id:"",url:"",status:"",name:"",tags:[],owner:{},date:"",views:0,content:[]}});async function k(t={}){t.params=t.params||{},t.params.skip=t.skip||0,t.params.limit=t.limit||9,t.params.tags=t.tags||[],t.period&&(t.params.period=t.period),t.url&&(t.params={url:t.url}),t.category&&(t.params.category=t.category),t.organization&&(t.params.organization=t.organization),t.owner&&(t.params.owner=t.owner),t.creator&&(t.params.creator=t.creator),t.status&&(t.params.status=t.status),t.user&&(t.params.user=t.user),t.params.skip=t.skip||0,t.params.limit=t.limit||10;try{console.log("Request params:"+t.params);const r=await f.get("/api/blog/read",{params:t.params});return t.url?g(r.data,"current"):g(r.data,"all"),Promise.resolve(r.data)}catch(r){return u.setError(r),Promise.reject(r)}}async function B(t){return f.post("/api/blog/create",t).then(r=>(g(r.data,"current"),Promise.resolve(r.data)),r=>(u.setError(r),Promise.reject(r)))}async function _(t){return f.post("/api/blog/update",t).then(r=>(g(r.data,"current"),Promise.resolve(r.data)),r=>(u.setError(r),Promise.reject(r)))}async function x(t){return await f.delete(`/api/blog/delete/${t}`).then(r=>{const o=c.all.findIndex(a=>a._id===t);return o!==-1&&c.all.splice(o,1),Promise.resolve(r.data)},r=>(u.setError(r),Promise.reject(r)))}function g(t,r){c[r]=t}function E(){c.current={_id:"",url:"",status:"",name:"",tags:[],author:"",owner:"",date:"",views:0,content:[]}}function j(t){const r={order:c.project.content.length+1,type:t.type,data:t.data,class:t.class,content:t.content};c.project.content.push(r)}e.watch(c,(t,r)=>{});const R=Object.freeze(Object.defineProperty({__proto__:null,blockAdd:j,clean:E,create:B,read:k,remove:x,set:g,state:c,update:_},Symbol.toStringTag,{value:"Module"})),D={props:{progress:{type:Number,default:null},status:{type:String,default:null}}},z={class:"circular-loader"},L=e.createElementVNode("svg",{viewBox:"25 25 50 50"},[e.createElementVNode("circle",{cx:"50",cy:"50",r:"20",fill:"none","stroke-width":"4","stroke-miterlimit":"10"})],-1),T={key:0,class:"progress-text"},q={key:1,class:"uppercase t-semi w-m-10r status-text"};function I(t,r,o,a,s,l){return e.openBlock(),e.createElementBlock("div",z,[L,o.progress?(e.openBlock(),e.createElementBlock("div",T,e.toDisplayString(o.progress),1)):e.createCommentVNode("",!0),o.status?(e.openBlock(),e.createElementBlock("div",q,e.toDisplayString(o.status),1)):e.createCommentVNode("",!0)])}const P=S._export_sfc(D,[["render",I]]),y=w.axios.create({baseURL:process.env.API_URL,withCredentials:!0}),d=e.reactive({reactions:[],error:null}),b={async read({user:t,type:r,target:o,role:a}){try{const s=await y.get("/api/reactions",{params:{user:t,type:r,target:o,role:a}});return d.error=null,d.reactions=s.data,Promise.resolve(s.data)}catch(s){return u.setError(s),Promise.reject(s)}},async create(t){try{const r=await y.post("/api/reactions/create",t);return d.error=null,Promise.resolve(r.data)}catch(r){return console.log(r),u.setError(r),Promise.reject(r)}},async update(t){try{const r=await y.post("/api/reactions/update",t);return d.error=null,Promise.resolve(r.data)}catch(r){return u.setError(r),Promise.reject(r)}},async delete(t){try{const r=await y.post("/api/reactions/delete",t);return d.error=null,Promise.resolve(r.data)}catch(r){return u.setError(r),Promise.reject(r)}}},O={handleReactionUpdate(t,r,o){let a;if(Array.isArray(t)?a=t.find(s=>s._id===r.target):typeof t=="object"&&t._id===r.target&&(a=t),a)if(a.hasReaction=o,o)a.reactions.push(r),a.numberOfReactions+=1;else{const s=a.reactions.findIndex(l=>l._id===r._id);s!==-1&&(a.reactions.splice(s,1),a.numberOfReactions-=1)}}};e.watch(d,t=>{});const A=Object.freeze(Object.defineProperty({__proto__:null,actions:b,mutations:O,state:d},Symbol.toStringTag,{value:"Module"})),U={class:"t-semi br-top-dark flex-nowrap flex-nojustify flex"},M=e.createElementVNode("span",{class:"mn-r-small mn-l-small d-block"},"·",-1),F={class:"cursor-pointer"},H=e.createElementVNode("span",{class:"mn-r-small mn-l-small d-block"},"·",-1),N={__name:"FooterBlogpost",props:["blogpost","owner","user"],setup(t){const r=t,o=e.ref(r.blogpost.numberOfReactions),a=e.ref(r.blogpost.isReacted),s=e.ref(r.blogpost.reactionId);async function l(m){if(!r.user){alert("Please login to add a reaction");return}try{const n={target:r.blogpost._id,type:"blogpost",user:r.user,class:"like"},p=await b.create(n);p.reaction.class==="like"&&(o.value+=1,a.value=!0,s.value=p.reaction._id)}catch(n){console.error(n),alert("Error adding reaction. Please try again later.")}}async function i(m){if(!r.user){alert("Please login to add a reaction");return}try{const n={_id:s.value};await b.delete(n),o.value-=1,a.value=!1,s.value=null}catch{alert("Error adding reaction. Please try again later.")}}return(m,n)=>(e.openBlock(),e.createElementBlock("footer",U,[e.createTextVNode(" 👁️ "+e.toDisplayString(t.blogpost.views)+" ",1),M,e.createElementVNode("div",F,[a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"cursor-pointer",onClick:n[0]||(n[0]=p=>l())}," 👍 "+e.toDisplayString(o.value),1)),a.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"cursor-pointer",onClick:n[1]||(n[1]=p=>i())}," 👍 "+e.toDisplayString(o.value),1)):e.createCommentVNode("",!0)]),H,e.createTextVNode(" 💬 "+e.toDisplayString(t.blogpost.numberOfComments),1)]))}},G={class:"bg-grey radius-big"},J=["src"],K={class:"pd-t-zero pd-medium"},Q={key:0,class:"cursor-pointer mn-thin flex-nowrap flex w-100"},W={key:0,class:"pd-micro t-white uppercase t-semi p-small flex-center flex pd-r-small pd-l-small mn-l-thin w-min bg-second radius-extra"},X={key:1,class:"mn-small t-transp p-big"},Y={key:2,class:"mn-small h2"},C={__name:"CardBlogpost",props:["blogpost","user","type"],setup(t){const r=t,o=$.useRouter(),a=e.computed(()=>r.blogpost.content.find(l=>l.type==="ImageUpload")),s=e.computed(()=>r.blogpost.content.find(l=>l.type==="Textarea"));return(l,i)=>(e.openBlock(),e.createElementBlock("article",G,[e.createVNode(v._sfc_main,{class:e.normalizeClass({"mn-small pd-medium":t.type!=="short","flex-child-order-last flex-child mn-l-small":t.type==="short"}),owner:t.blogpost.owner,creator:t.blogpost.creator,date:t.blogpost.createdAt},null,8,["class","owner","creator","date"]),e.unref(a)&&e.unref(a).content&&t.type!=="blogpostPage"?(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(a).content,alt:"Blog post image",class:"mn-medium object-fit-cover w-100 h-20r"},null,8,J)):e.createCommentVNode("",!0),e.createElementVNode("section",K,[t.type!=="blogpostPage"?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("h3",{onClick:i[0]||(i[0]=m=>e.unref(o).push({name:"BlogPost",params:{url:t.blogpost.url}})),class:""},e.toDisplayString(t.blogpost.name),1),t.blogpost.status==="draft"?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.blogpost.status),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref(s)&&e.unref(s).content&&t.type!=="blogpostPage"?(e.openBlock(),e.createElementBlock("p",X,e.toDisplayString(e.unref(s).content.slice(0,120))+"... ",1)):e.createCommentVNode("",!0),t.type==="blogpostPage"?(e.openBlock(),e.createElementBlock("h3",Y,e.toDisplayString(t.blogpost.name),1)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"default"),t.type!=="short"&&t.blogpost.tags.length>0?(e.openBlock(),e.createBlock(v._sfc_main$1,{key:3,chips:t.blogpost.tags},null,8,["chips"])):e.createCommentVNode("",!0)]),e.createVNode(N,{class:"pd-t-zero pd-medium",blogpost:t.blogpost,user:t.user},null,8,["blogpost","user"])]))}},Z={class:"feed"},ee={key:1},te={__name:"Feed",props:{category:{type:String,default:null},owner:{type:String,default:null},creator:{type:String,default:null},status:{type:String,default:"published"},user:{type:[String,Number],default:null},period:{type:String,default:null}},setup(t){const r=t,o=e.ref([]),a=e.ref(!0);let s=e.ref(!0),l=e.ref(0),i=e.ref(10);const m=async()=>{if(a.value){l.value+=i.value;const n=await k({skip:l.value,limit:i.value,category:r.category,user:r.user,owner:r.owner,status:r.status,creator:r.creator,period:r.period});n.length===0&&(a.value=!1),o.value=[...o.value,...n]}};return e.onMounted(async()=>{const n=await k({skip:l.value,limit:i.value,category:r.category,user:r.user,owner:r.owner,status:r.status,creator:r.creator,period:r.period});n.length===0?a.value=!1:a.value=!0,o.value=n,s.value=!1}),(n,p)=>(e.openBlock(),e.createElementBlock("section",Z,[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.unref(s)?(e.openBlock(),e.createBlock(P,{key:0,class:"z-index-5 pos-t-50 left-t-50 pos-absolute"})):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[!e.unref(s)&&o.value.length<1?(e.openBlock(),e.createBlock(V._sfc_main,{key:0,title:"No Blog Posts Found",description:"Currently, there are no posts available in this blog. Please check back later.",class:"pd-medium mn-thin bg-grey radius-big"})):(e.openBlock(),e.createElementBlock("div",ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,h=>(e.openBlock(),e.createBlock(C,{key:h._id,blogpost:h,user:t.user,class:"mn-medium"},null,8,["blogpost","user"]))),128)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[a.value&&o.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:m,class:"w-100 bg-main button"}," Load more ")):e.createCommentVNode("",!0)]),_:1})]))]),_:1})]))}};exports.Loader=P;exports._sfc_main=te;exports._sfc_main$1=C;exports._sfc_main$2=N;exports.blogposts=R;exports.clean=E;exports.create=B;exports.reactions=A;exports.read=k;exports.remove=x;exports.state=c;exports.update=_;
|