@hedhog/setting 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/setting/dto/create.dto.d.ts +8 -0
- package/dist/setting/dto/create.dto.d.ts.map +1 -0
- package/dist/setting/dto/create.dto.js +36 -0
- package/dist/setting/dto/create.dto.js.map +1 -0
- package/dist/setting/dto/delete.dto.d.ts.map +1 -0
- package/dist/setting/dto/delete.dto.js.map +1 -0
- package/dist/setting/dto/setting-user.dto.d.ts +4 -0
- package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
- package/dist/{dto/create.dto.js → setting/dto/setting-user.dto.js} +6 -7
- package/dist/setting/dto/setting-user.dto.js.map +1 -0
- package/dist/setting/dto/setting.dto.d.ts +9 -0
- package/dist/setting/dto/setting.dto.d.ts.map +1 -0
- package/dist/setting/dto/setting.dto.js +34 -0
- package/dist/setting/dto/setting.dto.js.map +1 -0
- package/dist/setting/dto/update.dto.d.ts +6 -0
- package/dist/setting/dto/update.dto.d.ts.map +1 -0
- package/dist/{dto → setting/dto}/update.dto.js +2 -1
- package/dist/setting/dto/update.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +26 -0
- package/dist/setting/setting.controller.d.ts.map +1 -0
- package/dist/setting/setting.controller.js +160 -0
- package/dist/setting/setting.controller.js.map +1 -0
- package/dist/setting/setting.service.d.ts +33 -0
- package/dist/setting/setting.service.d.ts.map +1 -0
- package/dist/setting/setting.service.js +377 -0
- package/dist/setting/setting.service.js.map +1 -0
- package/dist/setting.module.d.ts +3 -0
- package/dist/setting.module.d.ts.map +1 -0
- package/dist/{settings.module.js → setting.module.js} +8 -8
- package/dist/setting.module.js.map +1 -0
- package/frontend/setting/components/create-panel.tsx +83 -0
- package/frontend/setting/components/setting.screen.tsx +105 -0
- package/frontend/setting/components/update-panel.tsx +96 -0
- package/frontend/setting/locales/en/setting.setting.json +11 -0
- package/frontend/setting/locales/pt/setting.setting.json +11 -0
- package/frontend/setting/react-query/handlers.ts +28 -0
- package/frontend/setting/react-query/requests.ts +55 -0
- package/frontend/setting-group/components/create-panel.tsx +62 -0
- package/frontend/setting-group/components/setting-group.screen.tsx +107 -0
- package/frontend/setting-group/components/update-panel.tsx +76 -0
- package/frontend/setting-group/locales/en/setting.setting-group.json +11 -0
- package/frontend/setting-group/locales/pt/setting.setting-group.json +11 -0
- package/frontend/setting-group/react-query/handlers.ts +28 -0
- package/frontend/setting-group/react-query/requests.ts +58 -0
- package/frontend/setting-user/components/create-panel.tsx +71 -0
- package/frontend/setting-user/components/setting-user.screen.tsx +107 -0
- package/frontend/setting-user/components/update-panel.tsx +85 -0
- package/frontend/setting-user/locales/en/setting.setting-user.json +11 -0
- package/frontend/setting-user/locales/pt/setting.setting-user.json +11 -0
- package/frontend/setting-user/react-query/handlers.ts +28 -0
- package/frontend/setting-user/react-query/requests.ts +57 -0
- package/hedhog.yaml +380 -0
- package/package.json +39 -27
- package/dist/dto/create.dto.d.ts +0 -4
- package/dist/dto/create.dto.d.ts.map +0 -1
- package/dist/dto/create.dto.js.map +0 -1
- package/dist/dto/delete.dto.d.ts.map +0 -1
- package/dist/dto/delete.dto.js.map +0 -1
- package/dist/dto/update.dto.d.ts +0 -4
- package/dist/dto/update.dto.d.ts.map +0 -1
- package/dist/dto/update.dto.js.map +0 -1
- package/dist/migrations/index.d.ts +0 -6
- package/dist/migrations/index.d.ts.map +0 -1
- package/dist/migrations/index.js +0 -67
- package/dist/migrations/index.js.map +0 -1
- package/dist/settings.controller.d.ts +0 -14
- package/dist/settings.controller.d.ts.map +0 -1
- package/dist/settings.controller.js +0 -93
- package/dist/settings.controller.js.map +0 -1
- package/dist/settings.module.d.ts +0 -3
- package/dist/settings.module.d.ts.map +0 -1
- package/dist/settings.module.js.map +0 -1
- package/dist/settings.service.d.ts +0 -19
- package/dist/settings.service.d.ts.map +0 -1
- package/dist/settings.service.js +0 -83
- package/dist/settings.service.js.map +0 -1
- package/src/dto/create.dto.ts +0 -7
- package/src/dto/delete.dto.ts +0 -8
- package/src/dto/update.dto.ts +0 -3
- package/src/index.ts +0 -2
- package/src/migrations/index.ts +0 -78
- package/src/settings.controller.ts +0 -63
- package/src/settings.module.ts +0 -18
- package/src/settings.service.ts +0 -86
- package/tsconfig.lib.json +0 -9
- package/tsconfig.production.json +0 -20
- /package/dist/{dto → setting/dto}/delete.dto.d.ts +0 -0
- /package/dist/{dto → setting/dto}/delete.dto.js +0 -0
@@ -0,0 +1,377 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.SettingService = void 0;
|
16
|
+
const file_1 = require("@hedhog/file");
|
17
|
+
const pagination_1 = require("@hedhog/pagination");
|
18
|
+
const prisma_1 = require("@hedhog/prisma");
|
19
|
+
const utils_1 = require("@hedhog/utils");
|
20
|
+
const common_1 = require("@nestjs/common");
|
21
|
+
let SettingService = class SettingService {
|
22
|
+
constructor(prismaService, paginationService, fileService) {
|
23
|
+
this.prismaService = prismaService;
|
24
|
+
this.paginationService = paginationService;
|
25
|
+
this.fileService = fileService;
|
26
|
+
}
|
27
|
+
async getAppearanceCSS(res) {
|
28
|
+
const fileCSS = await this.fileService.readStream(`appearance/theme.css`);
|
29
|
+
res.setHeader('Content-Type', 'text/css');
|
30
|
+
return fileCSS.pipe(res);
|
31
|
+
}
|
32
|
+
async updateAppearanceSettings() {
|
33
|
+
console.log({ updateAppearanceSettings: 'updateAppearanceSettings' });
|
34
|
+
const settings = await this.prismaService.setting.findMany({
|
35
|
+
where: {
|
36
|
+
setting_group: {
|
37
|
+
slug: 'appearance',
|
38
|
+
},
|
39
|
+
},
|
40
|
+
});
|
41
|
+
await this.fileService.uploadFromString('appearance', 'theme.css', `
|
42
|
+
@layer base {
|
43
|
+
:root {
|
44
|
+
--background: 0 0% 100%;
|
45
|
+
--foreground: 20 14.3% 4.1%;
|
46
|
+
--card: 0 0% 100%;
|
47
|
+
--card-foreground: 20 14.3% 4.1%;
|
48
|
+
--popover: 0 0% 100%;
|
49
|
+
--popover-foreground: 20 14.3% 4.1%;
|
50
|
+
--primary: 24.6 95% 53.1%;
|
51
|
+
--primary-foreground: 60 9.1% 97.8%;
|
52
|
+
--secondary: 60 4.8% 95.9%;
|
53
|
+
--secondary-foreground: 24 9.8% 10%;
|
54
|
+
--muted: 60 4.8% 95.9%;
|
55
|
+
--muted-foreground: 25 5.3% 44.7%;
|
56
|
+
--accent: 60 4.8% 95.9%;
|
57
|
+
--accent-foreground: 24 9.8% 10%;
|
58
|
+
--destructive: 0 84.2% 60.2%;
|
59
|
+
--destructive-foreground: 60 9.1% 97.8%;
|
60
|
+
--border: 20 5.9% 90%;
|
61
|
+
--input: 20 5.9% 90%;
|
62
|
+
--ring: 24.6 95% 53.1%;
|
63
|
+
--radius: 0.5rem;
|
64
|
+
--chart-1: 12 76% 61%;
|
65
|
+
--chart-2: 173 58% 39%;
|
66
|
+
--chart-3: 197 37% 24%;
|
67
|
+
--chart-4: 43 74% 66%;
|
68
|
+
--chart-5: 27 87% 67%;
|
69
|
+
}
|
70
|
+
|
71
|
+
.dark {
|
72
|
+
--background: 20 14.3% 4.1%;
|
73
|
+
--foreground: 60 9.1% 97.8%;
|
74
|
+
--card: 20 14.3% 4.1%;
|
75
|
+
--card-foreground: 60 9.1% 97.8%;
|
76
|
+
--popover: 20 14.3% 4.1%;
|
77
|
+
--popover-foreground: 60 9.1% 97.8%;
|
78
|
+
--primary: 20.5 90.2% 48.2%;
|
79
|
+
--primary-foreground: 60 9.1% 97.8%;
|
80
|
+
--secondary: 12 6.5% 15.1%;
|
81
|
+
--secondary-foreground: 60 9.1% 97.8%;
|
82
|
+
--muted: 12 6.5% 15.1%;
|
83
|
+
--muted-foreground: 24 5.4% 63.9%;
|
84
|
+
--accent: 12 6.5% 15.1%;
|
85
|
+
--accent-foreground: 60 9.1% 97.8%;
|
86
|
+
--destructive: 0 72.2% 50.6%;
|
87
|
+
--destructive-foreground: 60 9.1% 97.8%;
|
88
|
+
--border: 12 6.5% 15.1%;
|
89
|
+
--input: 12 6.5% 15.1%;
|
90
|
+
--ring: 20.5 90.2% 48.2%;
|
91
|
+
--chart-1: 220 70% 50%;
|
92
|
+
--chart-2: 160 60% 45%;
|
93
|
+
--chart-3: 30 80% 55%;
|
94
|
+
--chart-4: 280 65% 60%;
|
95
|
+
--chart-5: 340 75% 55%;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
`, 'text/css');
|
99
|
+
console.log({ settings });
|
100
|
+
}
|
101
|
+
async setManySettings(data) {
|
102
|
+
const transaction = [];
|
103
|
+
for (const { slug, value } of data.setting) {
|
104
|
+
transaction.push(this.prismaService.setting.updateMany({
|
105
|
+
where: {
|
106
|
+
slug,
|
107
|
+
},
|
108
|
+
data: {
|
109
|
+
value,
|
110
|
+
},
|
111
|
+
}));
|
112
|
+
}
|
113
|
+
await this.prismaService.$transaction(transaction);
|
114
|
+
const hasAppearance = await this.prismaService.setting.count({
|
115
|
+
where: {
|
116
|
+
slug: {
|
117
|
+
in: data.setting.map((setting) => setting.slug),
|
118
|
+
},
|
119
|
+
setting_group: {
|
120
|
+
slug: 'appearance',
|
121
|
+
},
|
122
|
+
},
|
123
|
+
});
|
124
|
+
if (hasAppearance) {
|
125
|
+
await this.updateAppearanceSettings();
|
126
|
+
}
|
127
|
+
return { success: true };
|
128
|
+
}
|
129
|
+
async getSettingFromGroup(locale, paginationParams, slug) {
|
130
|
+
const fields = ['slug', 'value'];
|
131
|
+
paginationParams.pageSize = 100;
|
132
|
+
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
133
|
+
const result = await this.paginationService.paginate(this.prismaService.setting, paginationParams, {
|
134
|
+
where: {
|
135
|
+
AND: {
|
136
|
+
setting_group: {
|
137
|
+
slug,
|
138
|
+
},
|
139
|
+
OR,
|
140
|
+
},
|
141
|
+
},
|
142
|
+
include: {
|
143
|
+
setting_group: {
|
144
|
+
include: {
|
145
|
+
setting_group_locale: {
|
146
|
+
where: {
|
147
|
+
locale: {
|
148
|
+
code: locale,
|
149
|
+
},
|
150
|
+
},
|
151
|
+
select: {
|
152
|
+
name: true,
|
153
|
+
description: true,
|
154
|
+
},
|
155
|
+
},
|
156
|
+
},
|
157
|
+
},
|
158
|
+
setting_locale: {
|
159
|
+
where: {
|
160
|
+
locale: {
|
161
|
+
code: locale,
|
162
|
+
},
|
163
|
+
},
|
164
|
+
select: {
|
165
|
+
name: true,
|
166
|
+
description: true,
|
167
|
+
},
|
168
|
+
},
|
169
|
+
},
|
170
|
+
}, 'setting_locale');
|
171
|
+
result.data = result.data.map((setting) => {
|
172
|
+
setting.setting_group = (0, utils_1.itemTranslations)('setting_group_locale', setting.setting_group);
|
173
|
+
return setting;
|
174
|
+
});
|
175
|
+
return result;
|
176
|
+
}
|
177
|
+
async listSettingGroups(locale, paginationParams) {
|
178
|
+
const fields = ['slug', 'icon'];
|
179
|
+
paginationParams.pageSize = 100;
|
180
|
+
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
181
|
+
const result = await this.paginationService.paginate(this.prismaService.setting_group, paginationParams, {
|
182
|
+
where: {
|
183
|
+
OR,
|
184
|
+
},
|
185
|
+
include: {
|
186
|
+
setting_group_locale: {
|
187
|
+
where: {
|
188
|
+
locale: {
|
189
|
+
code: locale,
|
190
|
+
},
|
191
|
+
},
|
192
|
+
select: {
|
193
|
+
name: true,
|
194
|
+
description: true,
|
195
|
+
},
|
196
|
+
},
|
197
|
+
},
|
198
|
+
}, 'setting_group_locale');
|
199
|
+
return result;
|
200
|
+
}
|
201
|
+
async listSettings(locale, paginationParams) {
|
202
|
+
const fields = ['slug', 'value'];
|
203
|
+
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
204
|
+
const result = await this.paginationService.paginate(this.prismaService.setting, paginationParams, {
|
205
|
+
where: {
|
206
|
+
OR,
|
207
|
+
},
|
208
|
+
include: {
|
209
|
+
setting_group: {
|
210
|
+
include: {
|
211
|
+
setting_group_locale: {
|
212
|
+
where: {
|
213
|
+
locale: {
|
214
|
+
code: locale,
|
215
|
+
},
|
216
|
+
},
|
217
|
+
select: {
|
218
|
+
name: true,
|
219
|
+
description: true,
|
220
|
+
},
|
221
|
+
},
|
222
|
+
},
|
223
|
+
},
|
224
|
+
setting_locale: {
|
225
|
+
where: {
|
226
|
+
locale: {
|
227
|
+
code: locale,
|
228
|
+
},
|
229
|
+
},
|
230
|
+
select: {
|
231
|
+
name: true,
|
232
|
+
description: true,
|
233
|
+
},
|
234
|
+
},
|
235
|
+
},
|
236
|
+
}, 'setting_locale');
|
237
|
+
result.data = result.data.map((setting) => {
|
238
|
+
setting.setting_group = (0, utils_1.itemTranslations)('setting_group_locale', setting.setting_group);
|
239
|
+
return setting;
|
240
|
+
});
|
241
|
+
return result;
|
242
|
+
}
|
243
|
+
async get(settingId) {
|
244
|
+
return this.prismaService.setting.findUnique({
|
245
|
+
where: { id: settingId },
|
246
|
+
});
|
247
|
+
}
|
248
|
+
async create({}) {
|
249
|
+
return this.prismaService.setting.create({
|
250
|
+
data: {},
|
251
|
+
});
|
252
|
+
}
|
253
|
+
async update({ id, data }) {
|
254
|
+
return this.prismaService.setting.update({
|
255
|
+
where: { id },
|
256
|
+
data,
|
257
|
+
});
|
258
|
+
}
|
259
|
+
async updateFromSlug(slug, data) {
|
260
|
+
const { id } = await this.prismaService.setting.findFirst({
|
261
|
+
where: {
|
262
|
+
slug,
|
263
|
+
},
|
264
|
+
});
|
265
|
+
if (!id) {
|
266
|
+
throw new common_1.BadRequestException(`Setting with slug ${slug} not found.`);
|
267
|
+
}
|
268
|
+
return this.update({
|
269
|
+
id,
|
270
|
+
data,
|
271
|
+
});
|
272
|
+
}
|
273
|
+
async delete({ ids }) {
|
274
|
+
if (ids == undefined || ids == null) {
|
275
|
+
throw new common_1.BadRequestException(`You must select at least one setting to delete.`);
|
276
|
+
}
|
277
|
+
return this.prismaService.setting.deleteMany({
|
278
|
+
where: {
|
279
|
+
id: {
|
280
|
+
in: ids,
|
281
|
+
},
|
282
|
+
},
|
283
|
+
});
|
284
|
+
}
|
285
|
+
async setSettingUserValue(user_id, slug, value) {
|
286
|
+
const user = await this.prismaService.user.findUnique({
|
287
|
+
where: {
|
288
|
+
id: user_id,
|
289
|
+
},
|
290
|
+
select: {
|
291
|
+
id: true,
|
292
|
+
},
|
293
|
+
});
|
294
|
+
if (!user) {
|
295
|
+
throw new common_1.BadRequestException(`User with id ${user_id} not found.`);
|
296
|
+
}
|
297
|
+
const setting = await this.prismaService.setting.findFirst({
|
298
|
+
where: {
|
299
|
+
slug,
|
300
|
+
user_override: true,
|
301
|
+
},
|
302
|
+
});
|
303
|
+
if (!setting) {
|
304
|
+
throw new common_1.BadRequestException(`Setting with slug ${slug} not found or user can not override.`);
|
305
|
+
}
|
306
|
+
return await this.prismaService.setting_user.upsert({
|
307
|
+
where: {
|
308
|
+
user_id_setting_id: {
|
309
|
+
setting_id: setting.id,
|
310
|
+
user_id: user.id,
|
311
|
+
},
|
312
|
+
},
|
313
|
+
create: {
|
314
|
+
setting_id: setting.id,
|
315
|
+
value,
|
316
|
+
user_id: user.id,
|
317
|
+
},
|
318
|
+
update: {
|
319
|
+
value,
|
320
|
+
},
|
321
|
+
select: {
|
322
|
+
setting_id: true,
|
323
|
+
user_id: true,
|
324
|
+
value: true,
|
325
|
+
},
|
326
|
+
});
|
327
|
+
}
|
328
|
+
async getSettingValues(slug) {
|
329
|
+
slug = Array.isArray(slug) ? slug : [slug];
|
330
|
+
let setting = await this.prismaService.setting.findMany({
|
331
|
+
where: {
|
332
|
+
slug: {
|
333
|
+
in: slug,
|
334
|
+
},
|
335
|
+
},
|
336
|
+
select: {
|
337
|
+
id: true,
|
338
|
+
value: true,
|
339
|
+
slug: true,
|
340
|
+
type: true,
|
341
|
+
user_override: true,
|
342
|
+
},
|
343
|
+
});
|
344
|
+
const slugUserOverride = setting.filter((setting) => setting.userOverride);
|
345
|
+
const settingUser = await this.prismaService.setting_user.findMany({
|
346
|
+
where: {
|
347
|
+
setting_id: {
|
348
|
+
in: slugUserOverride.map((setting) => setting.id),
|
349
|
+
},
|
350
|
+
},
|
351
|
+
select: {
|
352
|
+
value: true,
|
353
|
+
setting_id: true,
|
354
|
+
},
|
355
|
+
});
|
356
|
+
const data = {};
|
357
|
+
setting.forEach((setting) => {
|
358
|
+
data[setting.slug] = setting.value;
|
359
|
+
});
|
360
|
+
settingUser.forEach((setting) => {
|
361
|
+
data[slugUserOverride.find((s) => s.id === setting.setting_id).slug] =
|
362
|
+
setting.value;
|
363
|
+
});
|
364
|
+
return data;
|
365
|
+
}
|
366
|
+
};
|
367
|
+
exports.SettingService = SettingService;
|
368
|
+
exports.SettingService = SettingService = __decorate([
|
369
|
+
(0, common_1.Injectable)(),
|
370
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
|
371
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => pagination_1.PaginationService))),
|
372
|
+
__param(2, (0, common_1.Inject)((0, common_1.forwardRef)(() => file_1.FileService))),
|
373
|
+
__metadata("design:paramtypes", [prisma_1.PrismaService,
|
374
|
+
pagination_1.PaginationService,
|
375
|
+
file_1.FileService])
|
376
|
+
], SettingService);
|
377
|
+
//# sourceMappingURL=setting.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.service.js","sourceRoot":"","sources":["../../src/setting/setting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA2C;AAC3C,mDAAsE;AACtE,2CAA+C;AAC/C,yCAAiD;AACjD,2CAKwB;AAQjB,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAEmB,aAA4B,EAE5B,iBAAoC,EAEpC,WAAwB;QAJxB,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpC,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ,KAAK,CAAC,gBAAgB,CAAC,GAAa;QAClC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;QAE1E,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAE1C,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,wBAAwB;QAC5B,OAAO,CAAC,GAAG,CAAC,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,CAAC,CAAC;QAEtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;YACzD,KAAK,EAAE;gBACL,aAAa,EAAE;oBACb,IAAI,EAAE,YAAY;iBACnB;aACF;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CACrC,YAAY,EACZ,WAAW,EACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDC,EACD,UAAU,CACX,CA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C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;gBAClE,OAAO,CAAC,KAAK,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAvbY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;IAE3C,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kBAAW,CAAC,CAAC,CAAA;qCAHN,sBAAa;QAET,8BAAiB;QAEvB,kBAAW;GAPhC,cAAc,CAub1B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.module.d.ts","sourceRoot":"","sources":["../src/setting.module.ts"],"names":[],"mappings":"AAOA,qBAUa,aAAa;CAAG"}
|
@@ -7,25 +7,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
7
7
|
};
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
9
|
exports.SettingModule = void 0;
|
10
|
-
const
|
10
|
+
const file_1 = require("@hedhog/file");
|
11
11
|
const pagination_1 = require("@hedhog/pagination");
|
12
12
|
const prisma_1 = require("@hedhog/prisma");
|
13
13
|
const common_1 = require("@nestjs/common");
|
14
|
-
const
|
15
|
-
const
|
14
|
+
const setting_controller_1 = require("./setting/setting.controller");
|
15
|
+
const setting_service_1 = require("./setting/setting.service");
|
16
16
|
let SettingModule = class SettingModule {
|
17
17
|
};
|
18
18
|
exports.SettingModule = SettingModule;
|
19
19
|
exports.SettingModule = SettingModule = __decorate([
|
20
20
|
(0, common_1.Module)({
|
21
|
-
providers: [
|
22
|
-
exports: [
|
23
|
-
controllers: [
|
21
|
+
providers: [setting_service_1.SettingService],
|
22
|
+
exports: [setting_service_1.SettingService],
|
23
|
+
controllers: [setting_controller_1.SettingsController],
|
24
24
|
imports: [
|
25
|
-
(0, common_1.forwardRef)(() => auth_1.AuthModule),
|
26
25
|
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
27
26
|
(0, common_1.forwardRef)(() => pagination_1.PaginationModule),
|
27
|
+
(0, common_1.forwardRef)(() => file_1.FileModule),
|
28
28
|
],
|
29
29
|
})
|
30
30
|
], SettingModule);
|
31
|
-
//# sourceMappingURL=
|
31
|
+
//# sourceMappingURL=setting.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.module.js","sourceRoot":"","sources":["../src/setting.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAA0C;AAC1C,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAoD;AACpD,qEAAkE;AAClE,+DAA2D;AAYpD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAVzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;QACzB,WAAW,EAAE,CAAC,uCAAkB,CAAC;QACjC,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;YAClC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,iBAAU,CAAC;SAC7B;KACF,CAAC;GACW,aAAa,CAAG"}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import FormPanel, {
|
2
|
+
FormPanelRef,
|
3
|
+
getFieldsLocale,
|
4
|
+
} from "@/components/panels/form-panel";
|
5
|
+
import { EnumFieldType } from "@/enums/EnumFieldType";
|
6
|
+
import { useSettingCreate } from "@/features/blog/setting";
|
7
|
+
import { Setting } from "@/types/models";
|
8
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
9
|
+
import { useTranslation } from "react-i18next";
|
10
|
+
|
11
|
+
export type SettingCreatePanelRef = {
|
12
|
+
submit: () => void;
|
13
|
+
};
|
14
|
+
|
15
|
+
export type SettingCreatePanelProps = {
|
16
|
+
onCreated?: (data: Setting) => void;
|
17
|
+
};
|
18
|
+
|
19
|
+
const SettingCreatePanel = forwardRef(
|
20
|
+
({ onCreated }: SettingCreatePanelProps, ref) => {
|
21
|
+
const formRef = useRef<FormPanelRef>(null);
|
22
|
+
const { t } = useTranslation(["actions"]);
|
23
|
+
const { mutateAsync: createSetting } = useSettingCreate();
|
24
|
+
|
25
|
+
useImperativeHandle(
|
26
|
+
ref,
|
27
|
+
() => ({
|
28
|
+
submit: () => {
|
29
|
+
formRef.current?.submit();
|
30
|
+
},
|
31
|
+
}),
|
32
|
+
[formRef],
|
33
|
+
);
|
34
|
+
|
35
|
+
return (
|
36
|
+
<FormPanel
|
37
|
+
ref={formRef}
|
38
|
+
fields={[
|
39
|
+
{
|
40
|
+
name: "group_id",
|
41
|
+
label: { text: t("group_id", { ns: "translation" }) },
|
42
|
+
type: EnumFieldType.TEXT,
|
43
|
+
required: true,
|
44
|
+
},
|
45
|
+
|
46
|
+
{
|
47
|
+
name: "type",
|
48
|
+
label: { text: t("type", { ns: "translation" }) },
|
49
|
+
type: EnumFieldType.TEXT,
|
50
|
+
required: true,
|
51
|
+
},
|
52
|
+
|
53
|
+
{
|
54
|
+
name: "value",
|
55
|
+
label: { text: t("value", { ns: "translation" }) },
|
56
|
+
type: EnumFieldType.TEXT,
|
57
|
+
required: true,
|
58
|
+
},
|
59
|
+
|
60
|
+
{
|
61
|
+
name: "user_override",
|
62
|
+
label: { text: t("user_override", { ns: "translation" }) },
|
63
|
+
type: EnumFieldType.TEXT,
|
64
|
+
required: true,
|
65
|
+
},
|
66
|
+
|
67
|
+
...getFieldsLocale([{ name: "name" }]),
|
68
|
+
]}
|
69
|
+
button={{ text: t("create", { ns: "actions" }) }}
|
70
|
+
onSubmit={async (data) => {
|
71
|
+
const createdData = await createSetting(data);
|
72
|
+
if (typeof onCreated === "function") {
|
73
|
+
onCreated(createdData);
|
74
|
+
}
|
75
|
+
}}
|
76
|
+
/>
|
77
|
+
);
|
78
|
+
},
|
79
|
+
);
|
80
|
+
|
81
|
+
SettingCreatePanel.displayName = "SettingCreatePanel";
|
82
|
+
|
83
|
+
export default SettingCreatePanel;
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { PageTitle } from "@/components/custom/page-title";
|
2
|
+
import DataPanel from "@/components/panels/data-panel";
|
3
|
+
import { useSettingDelete } from "@/features/blog/setting";
|
4
|
+
import { useApp } from "@/hooks/use-app";
|
5
|
+
import { isPlural } from "@/lib/utils";
|
6
|
+
import { Setting } from "@/types/models";
|
7
|
+
import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
|
8
|
+
import { useState } from "react";
|
9
|
+
import { useTranslation } from "react-i18next";
|
10
|
+
import SettingCreatePanel from "./components/setting-create-panel";
|
11
|
+
import SettingUpdatePanel from "./components/setting-update-panel";
|
12
|
+
|
13
|
+
export default function Page() {
|
14
|
+
const [selectedItems, setSelectedItems] = useState<Setting[]>([]);
|
15
|
+
const { mutate: deleteSetting } = useSettingDelete();
|
16
|
+
const { openSheet, confirm, closeSheet } = useApp();
|
17
|
+
const { t } = useTranslation(["setting", "modules", "actions"]);
|
18
|
+
|
19
|
+
const openCreate = () => {
|
20
|
+
const id = openSheet({
|
21
|
+
title: t("create", { ns: "actions" }),
|
22
|
+
description: t("createText", { ns: "setting" }),
|
23
|
+
children: () => <SettingCreatePanel onCreated={() => closeSheet(id)} />,
|
24
|
+
});
|
25
|
+
|
26
|
+
return id;
|
27
|
+
};
|
28
|
+
|
29
|
+
const openDelete = (items: Setting[]) => {
|
30
|
+
return confirm({
|
31
|
+
title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
|
32
|
+
description: t("deleteText", { ns: "setting" }),
|
33
|
+
})
|
34
|
+
.then(() =>
|
35
|
+
deleteSetting(
|
36
|
+
items.map((item) => item.id).filter((id) => id !== undefined),
|
37
|
+
),
|
38
|
+
)
|
39
|
+
.catch(() => setSelectedItems(items));
|
40
|
+
};
|
41
|
+
|
42
|
+
const openUpdate = (item: Setting) => {
|
43
|
+
const id = openSheet({
|
44
|
+
children: () => (
|
45
|
+
<SettingUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
46
|
+
),
|
47
|
+
title: t("edit", { ns: "setting" }),
|
48
|
+
description: t("editText", { ns: "setting" }),
|
49
|
+
});
|
50
|
+
|
51
|
+
return id;
|
52
|
+
};
|
53
|
+
|
54
|
+
return (
|
55
|
+
<>
|
56
|
+
<PageTitle title={t("setting", { ns: "modules" })} />
|
57
|
+
<DataPanel
|
58
|
+
url="/setting"
|
59
|
+
layout="table"
|
60
|
+
id="setting"
|
61
|
+
selectable
|
62
|
+
columns={[
|
63
|
+
{ key: "id", header: "ID", width: 64 },
|
64
|
+
{ key: "name", header: t("name", { ns: "setting" }) },
|
65
|
+
]}
|
66
|
+
selected={selectedItems as Setting[]}
|
67
|
+
multiple
|
68
|
+
hasSearch
|
69
|
+
sortable
|
70
|
+
onItemDoubleClick={(item) => openUpdate(item)}
|
71
|
+
menuActions={[
|
72
|
+
{
|
73
|
+
icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
|
74
|
+
label: t("edit", { ns: "actions" }),
|
75
|
+
tooltip: t("editTooltip", { ns: "setting" }),
|
76
|
+
handler: (items: Setting[]) => {
|
77
|
+
if (items.length === 1) openUpdate(items[0]);
|
78
|
+
},
|
79
|
+
show: "once",
|
80
|
+
},
|
81
|
+
{
|
82
|
+
icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
|
83
|
+
label: t("delete", { ns: "actions" }),
|
84
|
+
tooltip: t("deleteTooltip", { ns: "setting" }),
|
85
|
+
variant: "destructive",
|
86
|
+
handler: (items: Setting[]) => {
|
87
|
+
openDelete(items);
|
88
|
+
},
|
89
|
+
show: "some",
|
90
|
+
},
|
91
|
+
{
|
92
|
+
icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
|
93
|
+
label: t("create", { ns: "actions" }),
|
94
|
+
tooltip: t("createTooltip", { ns: "setting" }),
|
95
|
+
variant: "default",
|
96
|
+
handler: () => {
|
97
|
+
openCreate();
|
98
|
+
},
|
99
|
+
show: "none",
|
100
|
+
},
|
101
|
+
]}
|
102
|
+
/>
|
103
|
+
</>
|
104
|
+
);
|
105
|
+
}
|