2
This commit is contained in:
parent
70b32b34db
commit
f1be1e14ea
@ -37,14 +37,6 @@ const menuAside: MenuAsideItem[] = [
|
||||
icon: icon.mdiShieldAccountOutline ?? icon.mdiTable,
|
||||
permissions: 'READ_PERMISSIONS'
|
||||
},
|
||||
{
|
||||
href: '/admin_access_keys/admin_access_keys-list',
|
||||
label: 'Admin access keys',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiKey' in icon ? icon['mdiKey' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_ADMIN_ACCESS_KEYS'
|
||||
},
|
||||
{
|
||||
href: '/languages/languages-list',
|
||||
label: 'Languages',
|
||||
|
||||
@ -28,7 +28,6 @@ const Dashboard = () => {
|
||||
const [users, setUsers] = React.useState(loadingMessage);
|
||||
const [roles, setRoles] = React.useState(loadingMessage);
|
||||
const [permissions, setPermissions] = React.useState(loadingMessage);
|
||||
const [admin_access_keys, setAdmin_access_keys] = React.useState(loadingMessage);
|
||||
const [languages, setLanguages] = React.useState(loadingMessage);
|
||||
const [music_styles, setMusic_styles] = React.useState(loadingMessage);
|
||||
const [eras, setEras] = React.useState(loadingMessage);
|
||||
@ -53,8 +52,8 @@ const Dashboard = () => {
|
||||
|
||||
|
||||
async function loadData() {
|
||||
const entities = ['users','roles','permissions','admin_access_keys','languages','music_styles','eras','ai_voices','lyric_templates','songs','song_voice_tracks','lyric_sync_segments','generation_jobs','media_assets','playback_sessions','system_settings',];
|
||||
const fns = [setUsers,setRoles,setPermissions,setAdmin_access_keys,setLanguages,setMusic_styles,setEras,setAi_voices,setLyric_templates,setSongs,setSong_voice_tracks,setLyric_sync_segments,setGeneration_jobs,setMedia_assets,setPlayback_sessions,setSystem_settings,];
|
||||
const entities = ['users','roles','permissions','languages','music_styles','eras','ai_voices','lyric_templates','songs','song_voice_tracks','lyric_sync_segments','generation_jobs','media_assets','playback_sessions','system_settings',];
|
||||
const fns = [setUsers,setRoles,setPermissions,setLanguages,setMusic_styles,setEras,setAi_voices,setLyric_templates,setSongs,setSong_voice_tracks,setLyric_sync_segments,setGeneration_jobs,setMedia_assets,setPlayback_sessions,setSystem_settings,];
|
||||
|
||||
const requests = entities.map((entity, index) => {
|
||||
|
||||
@ -235,34 +234,6 @@ const Dashboard = () => {
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_ADMIN_ACCESS_KEYS') && <Link href={'/admin_access_keys/admin_access_keys-list'}>
|
||||
<div
|
||||
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
|
||||
>
|
||||
<div className="flex justify-between align-center">
|
||||
<div>
|
||||
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
|
||||
Admin access keys
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{admin_access_keys}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<BaseIcon
|
||||
className={`${iconsColor}`}
|
||||
w="w-16"
|
||||
h="h-16"
|
||||
size={48}
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
path={'mdiKey' in icon ? icon['mdiKey' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_LANGUAGES') && <Link href={'/languages/languages-list'}>
|
||||
<div
|
||||
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
|
||||
@ -610,4 +581,4 @@ Dashboard.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>
|
||||
}
|
||||
|
||||
export default Dashboard
|
||||
export default Dashboard
|
||||
@ -1,8 +1,7 @@
|
||||
|
||||
import React, { ReactElement, useEffect, useState, useRef } from 'react';
|
||||
import HeadInstance from 'next/head';
|
||||
import { Formik, Form, Field } from 'formik';
|
||||
import { mdiMusic, mdiMicrophone, mdiAutoFix, mdiHistory, mdiPlay, mdiDownload, mdiAlertCircle, mdiCheckCircle, mdiLock, mdiPause } from '@mdi/js';
|
||||
import { mdiMusic, mdiMicrophone, mdiAutoFix, mdiHistory, mdiPlay, mdiDownload, mdiAlertCircle, mdiCheckCircle, mdiPause } from '@mdi/js';
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||
import SectionMain from '../../components/SectionMain';
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||
@ -18,14 +17,9 @@ import BaseIcon from '../../components/BaseIcon';
|
||||
import FormField from '../../components/FormField';
|
||||
import NotificationBar from '../../components/NotificationBar';
|
||||
|
||||
const STUDIO_KEY = 'STUDIO-2026-PRO';
|
||||
|
||||
const StudioPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { songs, loading: songsLoading } = useAppSelector((state) => state.songs);
|
||||
const [hasKey, setHasKey] = useState(false);
|
||||
const [keyInput, setKeyInput] = useState('');
|
||||
const [showKeyError, setShowKeyError] = useState(false);
|
||||
const [isGenerating, setIsGenerating] = useState(false);
|
||||
const [generationSuccess, setGenerationSuccess] = useState(false);
|
||||
|
||||
@ -34,24 +28,9 @@ const StudioPage = () => {
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const storedKey = localStorage.getItem('studio_key');
|
||||
if (storedKey === STUDIO_KEY) {
|
||||
setHasKey(true);
|
||||
}
|
||||
dispatch(fetchSongs({ query: '?limit=10&offset=0&sort=createdAt_DESC' }));
|
||||
}, [dispatch]);
|
||||
|
||||
const handleKeySubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (keyInput === STUDIO_KEY) {
|
||||
localStorage.setItem('studio_key', STUDIO_KEY);
|
||||
setHasKey(true);
|
||||
setShowKeyError(false);
|
||||
} else {
|
||||
setShowKeyError(true);
|
||||
}
|
||||
};
|
||||
|
||||
const initialValues = {
|
||||
song_title: '',
|
||||
generation_mode: 'manual_lyrics',
|
||||
@ -131,41 +110,6 @@ const StudioPage = () => {
|
||||
window.open(`/api/file/download?id=${fileId}`, '_blank');
|
||||
};
|
||||
|
||||
if (!hasKey) {
|
||||
return (
|
||||
<SectionMain className="flex items-center justify-center min-h-[70vh]">
|
||||
<CardBox className="w-full max-w-md shadow-2xl border-emerald-500/20">
|
||||
<div className="text-center mb-8">
|
||||
<div className="w-16 h-16 bg-emerald-500/10 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<BaseIcon path={mdiLock} size={32} className="text-emerald-500" />
|
||||
</div>
|
||||
<h2 className="text-2xl font-bold text-white">Private Studio Access</h2>
|
||||
<p className="text-slate-400 mt-2">Enter your unique administrator key to continue.</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleKeySubmit} className="space-y-4">
|
||||
<FormField label="Access Key" help={showKeyError ? 'Invalid access key. Please check again.' : ''}>
|
||||
<input
|
||||
type="password"
|
||||
className={`w-full bg-slate-800 border-slate-700 text-white rounded-lg p-3 focus:ring-emerald-500 focus:border-emerald-500 ${showKeyError ? 'border-red-500' : ''}`}
|
||||
placeholder="STUDIO-XXXX-XXXX"
|
||||
value={keyInput}
|
||||
onChange={(e) => setKeyInput(e.target.value)}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseButton
|
||||
type="submit"
|
||||
color="info"
|
||||
label="Unlock Studio"
|
||||
className="w-full py-3 bg-emerald-500 hover:bg-emerald-600 border-none text-slate-950 font-bold"
|
||||
/>
|
||||
</form>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeadInstance>
|
||||
@ -394,4 +338,4 @@ StudioPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>;
|
||||
};
|
||||
|
||||
export default StudioPage;
|
||||
export default StudioPage;
|
||||
@ -430,96 +430,8 @@ const UsersView = () => {
|
||||
|
||||
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Admin_access_keys IssuedToUser</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
>
|
||||
<div className='overflow-x-auto'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
|
||||
<th>KeyName</th>
|
||||
|
||||
|
||||
|
||||
<th>KeyHash</th>
|
||||
|
||||
|
||||
|
||||
<th>IsActive</th>
|
||||
|
||||
|
||||
|
||||
<th>IssuedAt</th>
|
||||
|
||||
|
||||
|
||||
<th>LastUsedAt</th>
|
||||
|
||||
|
||||
|
||||
<th>UsageCount</th>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{users.admin_access_keys_issued_to_user && Array.isArray(users.admin_access_keys_issued_to_user) &&
|
||||
users.admin_access_keys_issued_to_user.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/admin_access_keys/admin_access_keys-view/?id=${item.id}`)}>
|
||||
|
||||
|
||||
<td data-label="key_name">
|
||||
{ item.key_name }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="key_hash">
|
||||
{ item.key_hash }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="is_active">
|
||||
{ dataFormatter.booleanFormatter(item.is_active) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="issued_at">
|
||||
{ dataFormatter.dateTimeFormatter(item.issued_at) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="last_used_at">
|
||||
{ dataFormatter.dateTimeFormatter(item.last_used_at) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="usage_count">
|
||||
{ item.usage_count }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!users?.admin_access_keys_issued_to_user?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -560,4 +472,4 @@ UsersView.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default UsersView;
|
||||
export default UsersView;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user