2026-02-24 20:44:16 +00:00
|
|
|
import { Notification, toast } from '@/components/ui'
|
|
|
|
|
import { generateBackgroundWorkers } from '@/services/background-worker.service'
|
|
|
|
|
import { getLocalization } from '@/services/localization.service'
|
|
|
|
|
import { store } from '@/store'
|
|
|
|
|
import { clearRedisCache } from './languageText.service'
|
2026-04-28 12:43:19 +00:00
|
|
|
import { kickUser } from './identity.service'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
|
|
|
export abstract class UiEvalService {
|
|
|
|
|
static Init = () => {
|
|
|
|
|
//console.log('init')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ApiGenerateBackgroundWorkers = () => {
|
|
|
|
|
// Get store state directly instead of using hook
|
|
|
|
|
const state = store.getState()
|
|
|
|
|
const { texts, config } = state.abpConfig
|
|
|
|
|
|
|
|
|
|
// Create translate function similar to useLocalization hook
|
|
|
|
|
const translate = (
|
|
|
|
|
localizationKey: string,
|
|
|
|
|
params?: Record<string, string | number>,
|
|
|
|
|
defaultResourceName?: string,
|
|
|
|
|
): string => {
|
|
|
|
|
if (!texts) {
|
|
|
|
|
return localizationKey
|
|
|
|
|
}
|
|
|
|
|
return getLocalization(
|
|
|
|
|
texts,
|
|
|
|
|
defaultResourceName ?? config?.localization?.defaultResourceName,
|
|
|
|
|
localizationKey,
|
|
|
|
|
params,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const asyncCall = async () => {
|
|
|
|
|
await generateBackgroundWorkers()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asyncCall()
|
|
|
|
|
|
|
|
|
|
toast.push(
|
|
|
|
|
<Notification type="success" duration={2000}>
|
|
|
|
|
{translate('::App.BackgroundWorkers.Message')}
|
|
|
|
|
</Notification>,
|
|
|
|
|
{
|
|
|
|
|
placement: 'top-end',
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ApiClearRedisCache = () => {
|
|
|
|
|
// Get store state directly instead of using hook
|
|
|
|
|
const state = store.getState()
|
|
|
|
|
const { texts, config } = state.abpConfig
|
|
|
|
|
|
|
|
|
|
// Create translate function similar to useLocalization hook
|
|
|
|
|
const translate = (
|
|
|
|
|
localizationKey: string,
|
|
|
|
|
params?: Record<string, string | number>,
|
|
|
|
|
defaultResourceName?: string,
|
|
|
|
|
): string => {
|
|
|
|
|
if (!texts) {
|
|
|
|
|
return localizationKey
|
|
|
|
|
}
|
|
|
|
|
return getLocalization(
|
|
|
|
|
texts,
|
|
|
|
|
defaultResourceName ?? config?.localization?.defaultResourceName,
|
|
|
|
|
localizationKey,
|
|
|
|
|
params,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const asyncCall = async () => {
|
|
|
|
|
await clearRedisCache()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asyncCall()
|
|
|
|
|
|
|
|
|
|
toast.push(
|
|
|
|
|
<Notification type="success" duration={2000}>
|
|
|
|
|
{translate('::App.ClearRedisCache.Message')}
|
|
|
|
|
</Notification>,
|
|
|
|
|
{
|
|
|
|
|
placement: 'top-end',
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-04-28 12:43:19 +00:00
|
|
|
|
|
|
|
|
static ApiKickUser = (userId: string, gridRef?: any) => {
|
|
|
|
|
// Get store state directly instead of using hook
|
|
|
|
|
const state = store.getState()
|
|
|
|
|
const { texts, config } = state.abpConfig
|
|
|
|
|
|
|
|
|
|
// Create translate function similar to useLocalization hook
|
|
|
|
|
const translate = (
|
|
|
|
|
localizationKey: string,
|
|
|
|
|
params?: Record<string, string | number>,
|
|
|
|
|
defaultResourceName?: string,
|
|
|
|
|
): string => {
|
|
|
|
|
if (!texts) {
|
|
|
|
|
return localizationKey
|
|
|
|
|
}
|
|
|
|
|
return getLocalization(
|
|
|
|
|
texts,
|
|
|
|
|
defaultResourceName ?? config?.localization?.defaultResourceName,
|
|
|
|
|
localizationKey,
|
|
|
|
|
params,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const asyncCall = async () => {
|
|
|
|
|
await kickUser(userId)
|
|
|
|
|
if (gridRef?.current) {
|
|
|
|
|
gridRef.current.instance().refresh()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asyncCall()
|
|
|
|
|
|
|
|
|
|
toast.push(
|
|
|
|
|
<Notification type="success" duration={2000}>
|
|
|
|
|
{translate('::App.KickUser.Message')}
|
|
|
|
|
</Notification>,
|
|
|
|
|
{
|
|
|
|
|
placement: 'top-end',
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-02-24 20:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const _global = (window || global) as any
|
|
|
|
|
_global.UiEvalService = UiEvalService
|