sumba 2.2.3 → 2.3.0
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/extend/bajo/hook/waibu-mpa.sumba@after-build-locals.js +1 -0
- package/extend/bajo/hook/waibu-mpa@pre-parsing.js +0 -20
- package/extend/bajo/hook/waibu@on-request.js +2 -2
- package/extend/bajoTemplate/partial/signout.html +1 -1
- package/extend/dobo/model/site-setting.json +4 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/site-setting/@action.js +11 -0
- package/index.js +14 -5
- package/lib/check-iconset.js +1 -1
- package/lib/check-theme.js +1 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +10 -0
|
@@ -10,6 +10,7 @@ async function afterBuildLocals (locals, req) {
|
|
|
10
10
|
items.push({ icon: 'key', 't:tooltip': 'forgotPassword', href: routePath('sumba:/user/forgot-password') })
|
|
11
11
|
items.push({ icon: 'personAdd', 't:tooltip': 'newUserSignup', href: routePath('sumba:/user/signup') })
|
|
12
12
|
}
|
|
13
|
+
items.push({ divider: true })
|
|
13
14
|
items.push({ icon: 'envelope', 't:tooltip': 'contactForm', href: routePath('sumba:/help/contact-form') })
|
|
14
15
|
items.push({ icon: 'chat', 't:tooltip': 'troubleTickets', href: routePath('sumba:/help/trouble-tickets') })
|
|
15
16
|
locals.sidebar = items
|
|
@@ -6,30 +6,10 @@ import checkTeam from '../../../lib/check-team.js'
|
|
|
6
6
|
const preParsing = {
|
|
7
7
|
level: 10,
|
|
8
8
|
handler: async function (req, reply) {
|
|
9
|
-
// const { routePath } = this.app.waibu
|
|
10
|
-
|
|
11
9
|
await checkTheme.call(this, req, reply)
|
|
12
10
|
await checkIconset.call(this, req, reply)
|
|
13
11
|
await checkUserId.call(this, req, reply, 'waibuMpa')
|
|
14
12
|
await checkTeam.call(this, req, reply, 'waibuMpa')
|
|
15
|
-
/*
|
|
16
|
-
req.menu = req.menu ?? {}
|
|
17
|
-
if (req.user) {
|
|
18
|
-
req.menu.user = [
|
|
19
|
-
{ value: routePath('sumba:/your-stuff/change-password', req), text: req.t('Change Password') },
|
|
20
|
-
{ value: routePath('sumba:/your-stuff/profile', req), text: req.t('yourProfile') },
|
|
21
|
-
'-',
|
|
22
|
-
{ value: routePath('sumba:/signout', req), text: req.t('signout') }
|
|
23
|
-
]
|
|
24
|
-
} else {
|
|
25
|
-
req.menu.user = [
|
|
26
|
-
{ value: routePath('sumba:/signin', req), text: req.t('signin') },
|
|
27
|
-
'-',
|
|
28
|
-
{ value: routePath('sumba:/user/signup', req), text: req.t('signup') },
|
|
29
|
-
{ value: routePath('sumba:/user/forgot-password', req), text: req.t('forgotPassword') }
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
*/
|
|
33
13
|
}
|
|
34
14
|
}
|
|
35
15
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const onRequest = {
|
|
2
2
|
level: 10,
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
|
-
const
|
|
5
|
-
req.site = await this.getSite(
|
|
4
|
+
const { getHostname } = this.app.waibu
|
|
5
|
+
req.site = await this.getSite(getHostname(req))
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const action = {
|
|
2
|
+
method: ['GET', 'POST'],
|
|
3
|
+
title: 'siteSetting',
|
|
4
|
+
handler: async function (req, reply) {
|
|
5
|
+
const { importModule } = this.app.bajo
|
|
6
|
+
const crudSkel = await importModule('waibuAdmin:/lib/crud-skel.js')
|
|
7
|
+
return await crudSkel.call(this, 'SumbaSiteSetting', req, reply)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default action
|
package/index.js
CHANGED
|
@@ -182,6 +182,8 @@ async function factory (pkgName) {
|
|
|
182
182
|
{ title: 'manageTeam', href: `waibuAdmin:/${prefix}/team/list` },
|
|
183
183
|
{ title: 'manageTeamUser', href: `waibuAdmin:/${prefix}/team-user/list` },
|
|
184
184
|
{ title: 'manageDownload', href: `waibuAdmin:/${prefix}/download/list` },
|
|
185
|
+
{ title: '-' },
|
|
186
|
+
{ title: 'siteSetting', href: `waibuAdmin:/${prefix}/site-setting/list` },
|
|
185
187
|
{ title: 'resetUserPassword', href: `waibuAdmin:/${prefix}/reset-user-password` }
|
|
186
188
|
]
|
|
187
189
|
}, {
|
|
@@ -403,7 +405,7 @@ async function factory (pkgName) {
|
|
|
403
405
|
|
|
404
406
|
const mergeSetting = async (site) => {
|
|
405
407
|
const { defaultsDeep } = this.app.lib.aneka
|
|
406
|
-
const { parseObject } = this.app.lib
|
|
408
|
+
const { parseObject, dayjs } = this.app.lib
|
|
407
409
|
const { trim, get, filter } = this.app.lib._
|
|
408
410
|
const defSetting = {}
|
|
409
411
|
const nsSetting = {}
|
|
@@ -412,20 +414,27 @@ async function factory (pkgName) {
|
|
|
412
414
|
ns: { $in: names },
|
|
413
415
|
siteId: site.id
|
|
414
416
|
}
|
|
415
|
-
const all = await this.app.dobo.getModel('SumbaSiteSetting').
|
|
417
|
+
const all = await this.app.dobo.getModel('SumbaSiteSetting').findAllRecord({ query })
|
|
416
418
|
for (const ns of names) {
|
|
417
419
|
nsSetting[ns] = {}
|
|
418
420
|
defSetting[ns] = get(this, `app.${ns}.config.siteSetting`, {})
|
|
419
421
|
const items = filter(all, { ns })
|
|
420
422
|
for (const item of items) {
|
|
421
423
|
let value = trim([item.value] ?? '')
|
|
422
|
-
if (['[', '{'].includes(value[0]))
|
|
423
|
-
|
|
424
|
+
if (['[', '{'].includes(value[0])) {
|
|
425
|
+
try {
|
|
426
|
+
value = parseObject(JSON.parse(value))
|
|
427
|
+
} catch (err) {}
|
|
428
|
+
} else if (Number(value)) value = Number(value)
|
|
424
429
|
else if (['true', 'false'].includes(value)) value = value === 'true'
|
|
430
|
+
else {
|
|
431
|
+
const dt = dayjs(value)
|
|
432
|
+
if (dt.isValid()) value = dt.toDate()
|
|
433
|
+
}
|
|
425
434
|
nsSetting[ns][item.key] = value
|
|
426
435
|
}
|
|
427
436
|
}
|
|
428
|
-
site.setting =
|
|
437
|
+
site.setting = defaultsDeep({}, nsSetting, defSetting)
|
|
429
438
|
// additional fields
|
|
430
439
|
const country = await this.app.dobo.getModel('CdbCountry').getRecord(site.country, { noHook: true })
|
|
431
440
|
site.countryName = (country ?? {}).name ?? site.country
|
package/lib/check-iconset.js
CHANGED
|
@@ -4,7 +4,7 @@ async function checkIconset (req, reply) {
|
|
|
4
4
|
|
|
5
5
|
if (!req.site) return
|
|
6
6
|
const siteIconset = get(req, 'site.setting.waibuMpa.iconset')
|
|
7
|
-
req.iconset = get(mpa, 'config.iconset.set',
|
|
7
|
+
req.iconset = siteIconset ?? get(mpa, 'config.iconset.set', 'default')
|
|
8
8
|
const hiconset = req.headers['x-iconset']
|
|
9
9
|
if (isString(hiconset) && mpa.getIconset(hiconset)) req.iconset = hiconset
|
|
10
10
|
req.iconset = req.iconset ?? 'default'
|
package/lib/check-theme.js
CHANGED
|
@@ -4,7 +4,7 @@ async function checkTheme (req, reply) {
|
|
|
4
4
|
|
|
5
5
|
if (!req.site) return
|
|
6
6
|
const siteTheme = get(req, 'site.setting.waibuMpa.theme')
|
|
7
|
-
req.theme = get(mpa, 'config.theme.set',
|
|
7
|
+
req.theme = siteTheme ?? get(mpa, 'config.theme.set', 'default')
|
|
8
8
|
const htheme = req.headers['x-theme']
|
|
9
9
|
if (isString(htheme) && mpa.getTheme(htheme)) req.theme = htheme
|
|
10
10
|
req.theme = req.theme ?? 'default'
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-02-17
|
|
4
|
+
|
|
5
|
+
- [2.3.0] Add admin menu links to ```siteSetting```
|
|
6
|
+
- [2.3.0] Bug fix on ```getSite()```
|
|
7
|
+
- [2.3.0] Add unique index on model ```SumbaSiteSetting```
|
|
8
|
+
- [2.3.0] Add admin subroute to manage site setting
|
|
9
|
+
- [2.3.0] Bug fix on ```req.theme``` and ```req.iconset``` resolver
|
|
10
|
+
|
|
3
11
|
## 2026-02-09
|
|
4
12
|
|
|
5
13
|
- [2.2.3] Bug fix on sidebar menu
|
|
14
|
+
- [2.2.4] Bug fix on signout template
|
|
15
|
+
- [2.2.4] Bug fix on sidebar buttons
|
|
6
16
|
|
|
7
17
|
## 2026-02-08
|
|
8
18
|
|