@hed-hog/core 0.0.279 → 0.0.286
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/dist/auth/auth.controller.d.ts +3 -3
- package/dist/auth/auth.service.d.ts +8 -8
- package/dist/file/file.controller.d.ts +2 -2
- package/dist/file/file.service.d.ts +4 -4
- package/dist/role/guards/role.guard.d.ts.map +1 -1
- package/dist/role/guards/role.guard.js +1 -1
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/session/session.controller.d.ts +1 -1
- package/dist/session/session.service.d.ts +3 -3
- package/dist/setting/setting.controller.d.ts +3 -0
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +10 -0
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +2 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +51 -12
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +2 -2
- package/dist/user/user.service.d.ts +6 -6
- package/hedhog/data/route.yaml +8 -0
- package/hedhog/frontend/app/ai_agent/page.tsx.ejs +72 -65
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +1 -92
- package/hedhog/frontend/app/dashboard/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/mail/log/page.tsx.ejs +37 -42
- package/hedhog/frontend/app/mail/template/page.tsx.ejs +176 -126
- package/hedhog/frontend/app/menu/page.tsx.ejs +45 -39
- package/hedhog/frontend/app/preferences/page.tsx.ejs +34 -121
- package/hedhog/frontend/app/roles/page.tsx.ejs +45 -46
- package/hedhog/frontend/app/users/page.tsx.ejs +71 -68
- package/hedhog/frontend/messages/en.json +7 -0
- package/hedhog/frontend/messages/pt.json +7 -0
- package/package.json +2 -2
- package/src/role/guards/role.guard.ts +9 -8
- package/src/setting/setting.controller.ts +21 -16
- package/src/setting/setting.service.ts +63 -17
|
@@ -2,22 +2,22 @@ import { Public, Role, User } from '@hed-hog/api';
|
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
3
|
import { Pagination } from '@hed-hog/api-pagination';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
Body,
|
|
6
|
+
Controller,
|
|
7
|
+
Delete,
|
|
8
|
+
forwardRef,
|
|
9
|
+
Get,
|
|
10
|
+
Header,
|
|
11
|
+
Inject,
|
|
12
|
+
Param,
|
|
13
|
+
ParseIntPipe,
|
|
14
|
+
Patch,
|
|
15
|
+
Post,
|
|
16
|
+
Put,
|
|
17
|
+
Query,
|
|
18
|
+
Res,
|
|
19
|
+
UploadedFile,
|
|
20
|
+
UseInterceptors
|
|
21
21
|
} from '@nestjs/common';
|
|
22
22
|
import { FileInterceptor } from '@nestjs/platform-express';
|
|
23
23
|
import { Response } from 'express';
|
|
@@ -78,6 +78,11 @@ export class SettingsController {
|
|
|
78
78
|
return this.settingService.getUserSettings(id);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
@Get('/effective')
|
|
82
|
+
async getEffectiveSettings(@User() { id }) {
|
|
83
|
+
return this.settingService.getEffectiveSettings(id);
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
@Get()
|
|
82
87
|
async listSettings(@Pagination() paginationParams, @Locale() locale) {
|
|
83
88
|
return this.settingService.listSettings(locale, paginationParams);
|
|
@@ -3,12 +3,12 @@ import { getLocaleText, LocaleService } from '@hed-hog/api-locale';
|
|
|
3
3
|
import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
|
|
4
4
|
import { PrismaService, setting_type_enum } from '@hed-hog/api-prisma';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
BadRequestException,
|
|
7
|
+
forwardRef,
|
|
8
|
+
Inject,
|
|
9
|
+
Injectable,
|
|
10
|
+
Logger,
|
|
11
|
+
NotFoundException
|
|
12
12
|
} from '@nestjs/common';
|
|
13
13
|
import * as pako from 'pako';
|
|
14
14
|
import { CreateDTO } from './dto/create.dto';
|
|
@@ -190,6 +190,46 @@ export class SettingService {
|
|
|
190
190
|
return { locales, setting };
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
async getEffectiveSettings(userId: number): Promise<any> {
|
|
194
|
+
const { locales, setting } = await this.getSystemSettings();
|
|
195
|
+
const userSettings = await this.getUserSettings(userId);
|
|
196
|
+
|
|
197
|
+
for (const userSetting of userSettings) {
|
|
198
|
+
const slug = userSetting.setting?.slug;
|
|
199
|
+
if (!slug) continue;
|
|
200
|
+
|
|
201
|
+
const value = userSetting.value;
|
|
202
|
+
if (value === undefined || value === null) continue;
|
|
203
|
+
|
|
204
|
+
const globalValue = setting?.[slug];
|
|
205
|
+
const globalType = typeof globalValue;
|
|
206
|
+
|
|
207
|
+
if (globalType === 'boolean') {
|
|
208
|
+
setting[slug] = value === 'true';
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (globalType === 'number') {
|
|
213
|
+
const parsed = Number(value);
|
|
214
|
+
setting[slug] = Number.isNaN(parsed) ? value : parsed;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (Array.isArray(globalValue) || globalType === 'object') {
|
|
219
|
+
try {
|
|
220
|
+
setting[slug] = JSON.parse(value);
|
|
221
|
+
} catch {
|
|
222
|
+
setting[slug] = value;
|
|
223
|
+
}
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
setting[slug] = value;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return { locales, setting };
|
|
231
|
+
}
|
|
232
|
+
|
|
193
233
|
async setManySettings(data: SettingDTO) {
|
|
194
234
|
this.clearCache();
|
|
195
235
|
const transaction = [];
|
|
@@ -621,10 +661,12 @@ export class SettingService {
|
|
|
621
661
|
|
|
622
662
|
async getSettingValues(
|
|
623
663
|
slug: string | string[],
|
|
664
|
+
userId?: number,
|
|
624
665
|
): Promise<Record<string, any>> {
|
|
625
666
|
|
|
626
667
|
const slugs = Array.isArray(slug) ? slug : [slug];
|
|
627
668
|
if (
|
|
669
|
+
userId === undefined &&
|
|
628
670
|
this.cachedSettings &&
|
|
629
671
|
slugs.every(s => Object.prototype.hasOwnProperty.call(this.cachedSettings, s))
|
|
630
672
|
) {
|
|
@@ -659,17 +701,21 @@ export class SettingService {
|
|
|
659
701
|
|
|
660
702
|
const slugUserOverride = setting.filter((s) => s.user_override);
|
|
661
703
|
|
|
662
|
-
const settingUser =
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
704
|
+
const settingUser =
|
|
705
|
+
userId === undefined
|
|
706
|
+
? []
|
|
707
|
+
: await this.prismaService.setting_user.findMany({
|
|
708
|
+
where: {
|
|
709
|
+
user_id: userId,
|
|
710
|
+
setting_id: {
|
|
711
|
+
in: slugUserOverride.map((setting) => setting?.id),
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
select: {
|
|
715
|
+
value: true,
|
|
716
|
+
setting_id: true,
|
|
717
|
+
},
|
|
718
|
+
});
|
|
673
719
|
|
|
674
720
|
const data: Record<string, any> = {};
|
|
675
721
|
const cacheData: Record<string, any> = {};
|