Skip to content

Commit 0621e00

Browse files
committed
add more translations
1 parent 260773b commit 0621e00

File tree

14 files changed

+64
-23
lines changed

14 files changed

+64
-23
lines changed

adminforth/documentation/docs/tutorial/03-Customization/15-websocket.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ const admin = new AdminForth({
162162

163163
```
164164

165+
> 👆 Please not that `adminUser` might be undefined in `websocketSubscribed` callback if unauthorized client subscribes to `/opentopic/` (see authorization section below)
166+
165167
### Subscribing authorization
166168

167169
Currently, any user can subscribe to the any topic and receive published messages.
@@ -210,6 +212,7 @@ const admin = new AdminForth({
210212
```
211213

212214
There is still method to bypass this websocketTopicAuth check by using special topic `/opentopic/`. In other words if topic starts with `/opentopic/` it will be allowed to subscribe by any user bypassing `websocketTopicAuth` call at all.
215+
Internally AdminForth uses `/opentopic/` for menu badges and possibly for other internal purposes.
213216

214217
### Publish authorization
215218

adminforth/modules/restApi.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,31 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
477477
}
478478
})
479479
);
480-
480+
}
481+
let enumItems = undefined;
482+
if (col.enum) {
483+
enumItems = await Promise.all(
484+
col.enum.map(async (item) => {
485+
return {
486+
...item,
487+
label: await tr(item.label, `resource.${resource.resourceId}.enum.${col.name}`),
488+
}
489+
})
490+
);
491+
}
492+
// TODO: better to move all coroutines to translationRoutines
493+
if (col.editingNote?.create) {
494+
col.editingNote.create = await tr(col.editingNote.create, `resource.${resource.resourceId}.editingNote.create`);
495+
}
496+
if (col.editingNote?.edit) {
497+
col.editingNote.edit = await tr(col.editingNote.edit, `resource.${resource.resourceId}.editingNote.edit`);
481498
}
482499

483500
return {
484501
...col,
485502
validation,
486503
label: translated[`resCol${i}`],
504+
enum: enumItems,
487505
}
488506
}
489507
),

adminforth/modules/socketBroker.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ export default class SocketBroker implements IWebSocketBroker {
8989
this.topics[data.topic].push(client);
9090
client.topics.add(data.topic);
9191
if (this.adminforth.config.auth.websocketSubscribed) {
92-
this.adminforth.config.auth.websocketSubscribed(data.topic, client.adminUser);
92+
(async () => {
93+
try {
94+
await this.adminforth.config.auth.websocketSubscribed(data.topic, client.adminUser);
95+
} catch (e) {
96+
console.error(`Error in websocketSubscribed for topic ${data.topic}`, e);
97+
}
98+
})(); // run in background
9399
}
94100
} else if (data.type === 'unsubscribe') {
95101
if (!data.topic) {

adminforth/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adminforth",
3-
"version": "1.5.8-next.15",
3+
"version": "1.5.8-next.17",
44
"description": "OpenSource Vue3 powered forth-generation admin panel",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

adminforth/plugins/i18n/custom/LanguageUnderLogin.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<p class="text-gray-500 dark:text-gray-400 font-sm text-left mt-3 flex items-center justify-center">
33
<Select
4+
class="w-full"
45
v-model="selectedLanguage"
56
:options="options"
67
:placeholder="$t('Select language')"

adminforth/plugins/i18n/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/plugins/i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adminforth/i18n",
3-
"version": "1.0.18-next.12",
3+
"version": "1.0.18",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"type": "module",

adminforth/plugins/upload/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/plugins/upload/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adminforth/upload",
3-
"version": "1.0.27",
3+
"version": "1.0.28",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)