Add enable/disable management for book tools (characters, worlds, and locations)
- Introduced toggling functionality for managing `characters`, `worlds`, and `locations` tool availability per book. - Updated `CharacterComponent`, `WorldSetting`, and `LocationComponent` with toggle switches for tool enablement. - Added `book_tools` database table and related schema migration for storing tool settings. - Extended API calls, models, and IPC handlers to support tool enablement states. - Localized new strings for English with supporting descriptions and messages. - Adjusted conditional rendering logic across components to respect tool enablement.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import {Dispatch, forwardRef, SetStateAction, useContext, useEffect, useImperativeHandle, useState} from 'react';
|
import {Dispatch, forwardRef, SetStateAction, useContext, useEffect, useImperativeHandle, useState} from 'react';
|
||||||
import {Attribute, CharacterProps} from "@/lib/models/Character";
|
import {Attribute, CharacterProps, CharacterListResponse} from "@/lib/models/Character";
|
||||||
import {SessionContext} from "@/context/SessionContext";
|
import {SessionContext} from "@/context/SessionContext";
|
||||||
import CharacterList from './CharacterList';
|
import CharacterList from './CharacterList';
|
||||||
import System from '@/lib/models/System';
|
import System from '@/lib/models/System';
|
||||||
@@ -13,6 +13,7 @@ import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
|
|||||||
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
||||||
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
||||||
import {SyncedBook} from "@/lib/models/SyncedBook";
|
import {SyncedBook} from "@/lib/models/SyncedBook";
|
||||||
|
import ToggleSwitch from "@/components/form/ToggleSwitch";
|
||||||
|
|
||||||
interface CharacterDetailProps {
|
interface CharacterDetailProps {
|
||||||
selectedCharacter: CharacterProps | null;
|
selectedCharacter: CharacterProps | null;
|
||||||
@@ -47,17 +48,18 @@ const initialCharacterState: CharacterProps = {
|
|||||||
motivations: [],
|
motivations: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export function CharacterComponent(props: any, ref: any) {
|
export function CharacterComponent({showToggle = true}: {showToggle?: boolean}, ref: any) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const {lang} = useContext<LangContextProps>(LangContext)
|
const {lang} = useContext<LangContextProps>(LangContext)
|
||||||
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
||||||
const {addToQueue} = useContext<LocalSyncQueueContextProps>(LocalSyncQueueContext);
|
const {addToQueue} = useContext<LocalSyncQueueContextProps>(LocalSyncQueueContext);
|
||||||
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
||||||
const {session} = useContext(SessionContext);
|
const {session} = useContext(SessionContext);
|
||||||
const {book} = useContext(BookContext);
|
const {book, setBook} = useContext(BookContext);
|
||||||
const {errorMessage, successMessage} = useContext(AlertContext);
|
const {errorMessage, successMessage} = useContext(AlertContext);
|
||||||
const [characters, setCharacters] = useState<CharacterProps[]>([]);
|
const [characters, setCharacters] = useState<CharacterProps[]>([]);
|
||||||
const [selectedCharacter, setSelectedCharacter] = useState<CharacterProps | null>(null);
|
const [selectedCharacter, setSelectedCharacter] = useState<CharacterProps | null>(null);
|
||||||
|
const [toolEnabled, setToolEnabled] = useState<boolean>(book?.tools?.characters ?? false);
|
||||||
|
|
||||||
useImperativeHandle(ref, function () {
|
useImperativeHandle(ref, function () {
|
||||||
return {
|
return {
|
||||||
@@ -69,22 +71,60 @@ export function CharacterComponent(props: any, ref: any) {
|
|||||||
getCharacters().then();
|
getCharacters().then();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
async function handleToggleTool(enabled: boolean): Promise<void> {
|
||||||
|
try {
|
||||||
|
let response: boolean;
|
||||||
|
if (isCurrentlyOffline() || book?.localBook) {
|
||||||
|
response = await window.electron.invoke<boolean>('db:book:tool:update', {
|
||||||
|
bookId: book?.bookId,
|
||||||
|
toolName: 'characters',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response = await System.authPatchToServer<boolean>('book/tool-setting', {
|
||||||
|
bookId: book?.bookId,
|
||||||
|
toolName: 'characters',
|
||||||
|
enabled: enabled
|
||||||
|
}, session.accessToken, lang);
|
||||||
|
if (localSyncedBooks.find((syncedBook: SyncedBook): boolean => syncedBook.id === book?.bookId)) {
|
||||||
|
addToQueue('db:book:tool:update', {
|
||||||
|
bookId: book?.bookId,
|
||||||
|
toolName: 'characters',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (response && setBook && book) {
|
||||||
|
setToolEnabled(enabled);
|
||||||
|
setBook({...book, tools: {...book.tools, characters: enabled}});
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
errorMessage(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getCharacters(): Promise<void> {
|
async function getCharacters(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
let response: CharacterProps[];
|
let response: CharacterListResponse;
|
||||||
if (isCurrentlyOffline()) {
|
if (isCurrentlyOffline()) {
|
||||||
response = await window.electron.invoke<CharacterProps[]>('db:character:list', {bookid: book?.bookId});
|
response = await window.electron.invoke<CharacterListResponse>('db:character:list', {bookid: book?.bookId});
|
||||||
} else {
|
} else {
|
||||||
if (book?.localBook) {
|
if (book?.localBook) {
|
||||||
response = await window.electron.invoke<CharacterProps[]>('db:character:list', {bookid: book?.bookId});
|
response = await window.electron.invoke<CharacterListResponse>('db:character:list', {bookid: book?.bookId});
|
||||||
} else {
|
} else {
|
||||||
response = await System.authGetQueryToServer<CharacterProps[]>(`character/list`, session.accessToken, lang, {
|
response = await System.authGetQueryToServer<CharacterListResponse>(`character/list`, session.accessToken, lang, {
|
||||||
bookid: book?.bookId,
|
bookid: book?.bookId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setCharacters(response);
|
setCharacters(response.characters);
|
||||||
|
setToolEnabled(response.enabled);
|
||||||
|
if (setBook && book) {
|
||||||
|
setBook({...book, tools: {...book.tools, characters: response.enabled}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@@ -317,6 +357,18 @@ export function CharacterComponent(props: any, ref: any) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
|
{showToggle && (
|
||||||
|
<div className="bg-secondary/20 rounded-xl p-4 shadow-inner border border-secondary/30">
|
||||||
|
<ToggleSwitch
|
||||||
|
enabled={toolEnabled}
|
||||||
|
setEnabled={handleToggleTool}
|
||||||
|
label={t('characterComponent.enableTool')}
|
||||||
|
description={t('characterComponent.enableToolDescription')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{toolEnabled && (
|
||||||
|
<>
|
||||||
{selectedCharacter ? (
|
{selectedCharacter ? (
|
||||||
<CharacterDetail
|
<CharacterDetail
|
||||||
selectedCharacter={selectedCharacter}
|
selectedCharacter={selectedCharacter}
|
||||||
@@ -333,6 +385,8 @@ export function CharacterComponent(props: any, ref: any) {
|
|||||||
handleCharacterClick={handleCharacterClick}
|
handleCharacterClick={handleCharacterClick}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
|
|||||||
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
||||||
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
||||||
import {SyncedBook} from "@/lib/models/SyncedBook";
|
import {SyncedBook} from "@/lib/models/SyncedBook";
|
||||||
|
import ToggleSwitch from "@/components/form/ToggleSwitch";
|
||||||
|
|
||||||
interface SubElement {
|
interface SubElement {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -35,7 +36,12 @@ interface LocationProps {
|
|||||||
elements: Element[];
|
elements: Element[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LocationComponent(props: any, ref: any) {
|
interface LocationListResponse {
|
||||||
|
locations: LocationProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LocationComponent({showToggle = true}: {showToggle?: boolean}, ref: any) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const {lang} = useContext<LangContextProps>(LangContext);
|
const {lang} = useContext<LangContextProps>(LangContext);
|
||||||
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
||||||
@@ -43,7 +49,7 @@ export function LocationComponent(props: any, ref: any) {
|
|||||||
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
||||||
const {session} = useContext(SessionContext);
|
const {session} = useContext(SessionContext);
|
||||||
const {successMessage, errorMessage} = useContext(AlertContext);
|
const {successMessage, errorMessage} = useContext(AlertContext);
|
||||||
const {book} = useContext(BookContext);
|
const {book, setBook} = useContext(BookContext);
|
||||||
|
|
||||||
const bookId: string | undefined = book?.bookId;
|
const bookId: string | undefined = book?.bookId;
|
||||||
const token: string = session.accessToken;
|
const token: string = session.accessToken;
|
||||||
@@ -52,6 +58,7 @@ export function LocationComponent(props: any, ref: any) {
|
|||||||
const [newSectionName, setNewSectionName] = useState<string>('');
|
const [newSectionName, setNewSectionName] = useState<string>('');
|
||||||
const [newElementNames, setNewElementNames] = useState<{ [key: string]: string }>({});
|
const [newElementNames, setNewElementNames] = useState<{ [key: string]: string }>({});
|
||||||
const [newSubElementNames, setNewSubElementNames] = useState<{ [key: string]: string }>({});
|
const [newSubElementNames, setNewSubElementNames] = useState<{ [key: string]: string }>({});
|
||||||
|
const [toolEnabled, setToolEnabled] = useState<boolean>(book?.tools?.locations ?? false);
|
||||||
|
|
||||||
useImperativeHandle(ref, function () {
|
useImperativeHandle(ref, function () {
|
||||||
return {
|
return {
|
||||||
@@ -63,22 +70,60 @@ export function LocationComponent(props: any, ref: any) {
|
|||||||
getAllLocations().then();
|
getAllLocations().then();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
async function handleToggleTool(enabled: boolean): Promise<void> {
|
||||||
|
try {
|
||||||
|
let response: boolean;
|
||||||
|
if (isCurrentlyOffline() || book?.localBook) {
|
||||||
|
response = await window.electron.invoke<boolean>('db:book:tool:update', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'locations',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response = await System.authPatchToServer<boolean>('book/tool-setting', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'locations',
|
||||||
|
enabled: enabled
|
||||||
|
}, token, lang);
|
||||||
|
if (localSyncedBooks.find((syncedBook: SyncedBook): boolean => syncedBook.id === bookId)) {
|
||||||
|
addToQueue('db:book:tool:update', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'locations',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (response && setBook && book) {
|
||||||
|
setToolEnabled(enabled);
|
||||||
|
setBook({...book, tools: {...book.tools, locations: enabled}});
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
errorMessage(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getAllLocations(): Promise<void> {
|
async function getAllLocations(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
let response: LocationProps[];
|
let response: LocationListResponse;
|
||||||
if (isCurrentlyOffline()) {
|
if (isCurrentlyOffline()) {
|
||||||
response = await window.electron.invoke<LocationProps[]>('db:location:all', {bookid: bookId});
|
response = await window.electron.invoke<LocationListResponse>('db:location:all', {bookid: bookId});
|
||||||
} else {
|
} else {
|
||||||
if (book?.localBook) {
|
if (book?.localBook) {
|
||||||
response = await window.electron.invoke<LocationProps[]>('db:location:all', {bookid: bookId});
|
response = await window.electron.invoke<LocationListResponse>('db:location:all', {bookid: bookId});
|
||||||
} else {
|
} else {
|
||||||
response = await System.authGetQueryToServer<LocationProps[]>(`location/all`, token, lang, {
|
response = await System.authGetQueryToServer<LocationListResponse>(`location/all`, token, lang, {
|
||||||
bookid: bookId,
|
bookid: bookId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response && response.length > 0) {
|
if (response) {
|
||||||
setSections(response);
|
setSections(response.locations);
|
||||||
|
setToolEnabled(response.enabled);
|
||||||
|
if (setBook && book) {
|
||||||
|
setBook({...book, tools: {...book.tools, locations: response.enabled}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@@ -423,6 +468,18 @@ export function LocationComponent(props: any, ref: any) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
|
{showToggle && (
|
||||||
|
<div className="bg-secondary/20 rounded-xl p-4 shadow-inner border border-secondary/30">
|
||||||
|
<ToggleSwitch
|
||||||
|
enabled={toolEnabled}
|
||||||
|
setEnabled={handleToggleTool}
|
||||||
|
label={t('locationComponent.enableTool')}
|
||||||
|
description={t('locationComponent.enableToolDescription')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{toolEnabled && (
|
||||||
|
<>
|
||||||
<div className="bg-tertiary/90 backdrop-blur-sm rounded-xl shadow-lg p-4 border border-secondary/50">
|
<div className="bg-tertiary/90 backdrop-blur-sm rounded-xl shadow-lg p-4 border border-secondary/50">
|
||||||
<div className="grid grid-cols-1 gap-4 mb-4">
|
<div className="grid grid-cols-1 gap-4 mb-4">
|
||||||
<InputField
|
<InputField
|
||||||
@@ -558,6 +615,8 @@ export function LocationComponent(props: any, ref: any) {
|
|||||||
<p className="text-text-secondary mb-4">{t("locationComponent.noSectionAvailable")}</p>
|
<p className="text-text-secondary mb-4">{t("locationComponent.noSectionAvailable")}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {BookContext} from "@/context/BookContext";
|
|||||||
import {AlertContext} from "@/context/AlertContext";
|
import {AlertContext} from "@/context/AlertContext";
|
||||||
import {SelectBoxProps} from "@/shared/interface";
|
import {SelectBoxProps} from "@/shared/interface";
|
||||||
import System from "@/lib/models/System";
|
import System from "@/lib/models/System";
|
||||||
import {elementSections, WorldProps} from "@/lib/models/World";
|
import {elementSections, WorldProps, WorldListResponse} from "@/lib/models/World";
|
||||||
import {SessionContext} from "@/context/SessionContext";
|
import {SessionContext} from "@/context/SessionContext";
|
||||||
import InputField from "@/components/form/InputField";
|
import InputField from "@/components/form/InputField";
|
||||||
import TextInput from '@/components/form/TextInput';
|
import TextInput from '@/components/form/TextInput';
|
||||||
@@ -20,6 +20,7 @@ import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
|
|||||||
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
import {LocalSyncQueueContext, LocalSyncQueueContextProps} from "@/context/SyncQueueContext";
|
||||||
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
import {BooksSyncContext, BooksSyncContextProps} from "@/context/BooksSyncContext";
|
||||||
import {SyncedBook} from "@/lib/models/SyncedBook";
|
import {SyncedBook} from "@/lib/models/SyncedBook";
|
||||||
|
import ToggleSwitch from "@/components/form/ToggleSwitch";
|
||||||
|
|
||||||
export interface ElementSection {
|
export interface ElementSection {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -27,7 +28,7 @@ export interface ElementSection {
|
|||||||
icon: IconDefinition;
|
icon: IconDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WorldSetting(props: any, ref: any) {
|
export function WorldSetting({showToggle = true}: {showToggle?: boolean}, ref: any) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const {lang} = useContext<LangContextProps>(LangContext);
|
const {lang} = useContext<LangContextProps>(LangContext);
|
||||||
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext);
|
||||||
@@ -35,7 +36,7 @@ export function WorldSetting(props: any, ref: any) {
|
|||||||
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
const {localSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
||||||
const {errorMessage, successMessage} = useContext(AlertContext);
|
const {errorMessage, successMessage} = useContext(AlertContext);
|
||||||
const {session} = useContext(SessionContext);
|
const {session} = useContext(SessionContext);
|
||||||
const {book} = useContext(BookContext);
|
const {book, setBook} = useContext(BookContext);
|
||||||
const bookId: string = book?.bookId ? book.bookId.toString() : '';
|
const bookId: string = book?.bookId ? book.bookId.toString() : '';
|
||||||
|
|
||||||
const [worlds, setWorlds] = useState<WorldProps[]>([]);
|
const [worlds, setWorlds] = useState<WorldProps[]>([]);
|
||||||
@@ -43,6 +44,7 @@ export function WorldSetting(props: any, ref: any) {
|
|||||||
const [selectedWorldIndex, setSelectedWorldIndex] = useState<number>(0);
|
const [selectedWorldIndex, setSelectedWorldIndex] = useState<number>(0);
|
||||||
const [worldsSelector, setWorldsSelector] = useState<SelectBoxProps[]>([]);
|
const [worldsSelector, setWorldsSelector] = useState<SelectBoxProps[]>([]);
|
||||||
const [showAddNewWorld, setShowAddNewWorld] = useState<boolean>(false);
|
const [showAddNewWorld, setShowAddNewWorld] = useState<boolean>(false);
|
||||||
|
const [toolEnabled, setToolEnabled] = useState<boolean>(book?.tools?.worlds ?? false);
|
||||||
|
|
||||||
useImperativeHandle(ref, function () {
|
useImperativeHandle(ref, function () {
|
||||||
return {
|
return {
|
||||||
@@ -54,23 +56,61 @@ export function WorldSetting(props: any, ref: any) {
|
|||||||
getWorlds().then();
|
getWorlds().then();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
async function handleToggleTool(enabled: boolean): Promise<void> {
|
||||||
|
try {
|
||||||
|
let response: boolean;
|
||||||
|
if (isCurrentlyOffline() || book?.localBook) {
|
||||||
|
response = await window.electron.invoke<boolean>('db:book:tool:update', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'worlds',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response = await System.authPatchToServer<boolean>('book/tool-setting', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'worlds',
|
||||||
|
enabled: enabled
|
||||||
|
}, session.accessToken, lang);
|
||||||
|
if (localSyncedBooks.find((syncedBook: SyncedBook): boolean => syncedBook.id === bookId)) {
|
||||||
|
addToQueue('db:book:tool:update', {
|
||||||
|
bookId: bookId,
|
||||||
|
toolName: 'worlds',
|
||||||
|
enabled: enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (response && setBook && book) {
|
||||||
|
setToolEnabled(enabled);
|
||||||
|
setBook({...book, tools: {...book.tools, worlds: enabled}});
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
errorMessage(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getWorlds() {
|
async function getWorlds() {
|
||||||
try {
|
try {
|
||||||
let response: WorldProps[];
|
let response: WorldListResponse;
|
||||||
if (isCurrentlyOffline()) {
|
if (isCurrentlyOffline()) {
|
||||||
response = await window.electron.invoke<WorldProps[]>('db:book:worlds:get', {bookid: bookId});
|
response = await window.electron.invoke<WorldListResponse>('db:book:worlds:get', {bookid: bookId});
|
||||||
} else {
|
} else {
|
||||||
if (book?.localBook) {
|
if (book?.localBook) {
|
||||||
response = await window.electron.invoke<WorldProps[]>('db:book:worlds:get', {bookid: bookId});
|
response = await window.electron.invoke<WorldListResponse>('db:book:worlds:get', {bookid: bookId});
|
||||||
} else {
|
} else {
|
||||||
response = await System.authGetQueryToServer<WorldProps[]>(`book/worlds`, session.accessToken, lang, {
|
response = await System.authGetQueryToServer<WorldListResponse>(`book/worlds`, session.accessToken, lang, {
|
||||||
bookid: bookId,
|
bookid: bookId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setWorlds(response);
|
setWorlds(response.worlds);
|
||||||
const formattedWorlds: SelectBoxProps[] = response.map(
|
setToolEnabled(response.enabled);
|
||||||
|
if (setBook && book) {
|
||||||
|
setBook({...book, tools: {...book.tools, worlds: response.enabled}});
|
||||||
|
}
|
||||||
|
const formattedWorlds: SelectBoxProps[] = response.worlds.map(
|
||||||
(world: WorldProps): SelectBoxProps => ({
|
(world: WorldProps): SelectBoxProps => ({
|
||||||
label: world.name,
|
label: world.name,
|
||||||
value: world.id.toString(),
|
value: world.id.toString(),
|
||||||
@@ -193,6 +233,18 @@ export function WorldSetting(props: any, ref: any) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
|
{showToggle && (
|
||||||
|
<div className="bg-secondary/20 rounded-xl p-4 shadow-inner border border-secondary/30">
|
||||||
|
<ToggleSwitch
|
||||||
|
enabled={toolEnabled}
|
||||||
|
setEnabled={handleToggleTool}
|
||||||
|
label={t('worldSetting.enableTool')}
|
||||||
|
description={t('worldSetting.enableToolDescription')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{toolEnabled && (
|
||||||
|
<>
|
||||||
<div className="bg-tertiary/90 backdrop-blur-sm rounded-xl p-5 border border-secondary/50 shadow-lg">
|
<div className="bg-tertiary/90 backdrop-blur-sm rounded-xl p-5 border border-secondary/50 shadow-lg">
|
||||||
<div className="grid grid-cols-1 gap-4 mb-4">
|
<div className="grid grid-cols-1 gap-4 mb-4">
|
||||||
<InputField
|
<InputField
|
||||||
@@ -344,6 +396,8 @@ export function WorldSetting(props: any, ref: any) {
|
|||||||
<p className="text-text-secondary mb-4">{t("worldSetting.noWorldAvailable")}</p>
|
<p className="text-text-secondary mb-4">{t("worldSetting.noWorldAvailable")}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,13 +156,13 @@ export default function ComposerRightBar() {
|
|||||||
<QuillSense/>
|
<QuillSense/>
|
||||||
)}
|
)}
|
||||||
{currentPanel?.id === 2 && (
|
{currentPanel?.id === 2 && (
|
||||||
<WorldSetting ref={worldRef}/>
|
<WorldSetting ref={worldRef} showToggle={false}/>
|
||||||
)}
|
)}
|
||||||
{currentPanel?.id === 3 && (
|
{currentPanel?.id === 3 && (
|
||||||
<LocationComponent ref={locationRef}/>
|
<LocationComponent ref={locationRef} showToggle={false}/>
|
||||||
)}
|
)}
|
||||||
{currentPanel?.id === 4 && (
|
{currentPanel?.id === 4 && (
|
||||||
<CharacterComponent ref={characterRef}/>
|
<CharacterComponent ref={characterRef} showToggle={false}/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -180,6 +180,18 @@ export default function ComposerRightBar() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Filter Worlds if tools.worlds is disabled
|
||||||
|
if (component.id === 2 && !book?.tools?.worlds) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Filter Locations if tools.locations is disabled
|
||||||
|
if (component.id === 3 && !book?.tools?.locations) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Filter Characters if tools.characters is disabled
|
||||||
|
if (component.id === 4 && !book?.tools?.characters) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.map((component: PanelComponent) => (
|
.map((component: PanelComponent) => (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import System from '../System.js';
|
import System from '../System.js';
|
||||||
import { getUserEncryptionKey } from '../keyManager.js';
|
import { getUserEncryptionKey } from '../keyManager.js';
|
||||||
import BookRepo, { BookQuery, EritBooksTable } from "../repositories/book.repository.js";
|
import BookRepo, { BookQuery, BookToolsTable, BookToolsSettings, EritBooksTable } from "../repositories/book.repository.js";
|
||||||
import { BookActSummariesTable } from "../repositories/act.repository.js";
|
import { BookActSummariesTable } from "../repositories/act.repository.js";
|
||||||
import { BookAIGuideLineTable, BookGuideLineTable } from "../repositories/guideline.repository.js";
|
import { BookAIGuideLineTable, BookGuideLineTable } from "../repositories/guideline.repository.js";
|
||||||
import ChapterRepo, {
|
import ChapterRepo, {
|
||||||
@@ -34,6 +34,12 @@ import { SyncedAIGuideLine, SyncedGuideLine } from "./GuideLine.js";
|
|||||||
import Cover from "./Cover.js";
|
import Cover from "./Cover.js";
|
||||||
import UserRepo from "../repositories/user.repository.js";
|
import UserRepo from "../repositories/user.repository.js";
|
||||||
|
|
||||||
|
export interface SyncedBookTools {
|
||||||
|
charactersEnabled: boolean;
|
||||||
|
worldsEnabled: boolean;
|
||||||
|
locationsEnabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface BookProps {
|
export interface BookProps {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -47,6 +53,7 @@ export interface BookProps {
|
|||||||
wordCount?: number;
|
wordCount?: number;
|
||||||
coverImage?: string;
|
coverImage?: string;
|
||||||
bookMeta?: string;
|
bookMeta?: string;
|
||||||
|
tools?: BookToolsSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompleteBook {
|
export interface CompleteBook {
|
||||||
@@ -67,6 +74,7 @@ export interface CompleteBook {
|
|||||||
worldElements: BookWorldElementsTable[];
|
worldElements: BookWorldElementsTable[];
|
||||||
locationElements: LocationElementTable[];
|
locationElements: LocationElementTable[];
|
||||||
locationSubElements: LocationSubElementTable[];
|
locationSubElements: LocationSubElementTable[];
|
||||||
|
bookTools: BookToolsTable[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SyncedBook {
|
export interface SyncedBook {
|
||||||
@@ -85,6 +93,7 @@ export interface SyncedBook {
|
|||||||
actSummaries: SyncedActSummary[];
|
actSummaries: SyncedActSummary[];
|
||||||
guideLine: SyncedGuideLine | null;
|
guideLine: SyncedGuideLine | null;
|
||||||
aiGuideLine: SyncedAIGuideLine | null;
|
aiGuideLine: SyncedAIGuideLine | null;
|
||||||
|
bookTools: SyncedBookTools | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BookSyncCompare {
|
export interface BookSyncCompare {
|
||||||
@@ -105,6 +114,7 @@ export interface BookSyncCompare {
|
|||||||
actSummaries: string[];
|
actSummaries: string[];
|
||||||
guideLine: boolean;
|
guideLine: boolean;
|
||||||
aiGuideLine: boolean;
|
aiGuideLine: boolean;
|
||||||
|
bookTools: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompleteBookData {
|
export interface CompleteBookData {
|
||||||
@@ -242,6 +252,7 @@ export default class Book {
|
|||||||
public static async getBook(userId: string, bookId: string, lang: 'fr' | 'en'): Promise<BookProps> {
|
public static async getBook(userId: string, bookId: string, lang: 'fr' | 'en'): Promise<BookProps> {
|
||||||
const book: Book = new Book(bookId);
|
const book: Book = new Book(bookId);
|
||||||
book.getBookInfos(userId);
|
book.getBookInfos(userId);
|
||||||
|
const bookTools: BookToolsTable | null = BookRepo.fetchBookTools(userId, bookId, lang);
|
||||||
return {
|
return {
|
||||||
id: book.getId(),
|
id: book.getId(),
|
||||||
type: book.getType(),
|
type: book.getType(),
|
||||||
@@ -253,7 +264,12 @@ export default class Book {
|
|||||||
desiredReleaseDate: book.getDesiredReleaseDate(),
|
desiredReleaseDate: book.getDesiredReleaseDate(),
|
||||||
desiredWordCount: book.getDesiredWordCount(),
|
desiredWordCount: book.getDesiredWordCount(),
|
||||||
wordCount: book.getWordCount(),
|
wordCount: book.getWordCount(),
|
||||||
coverImage: book.getCover()
|
coverImage: book.getCover(),
|
||||||
|
tools: {
|
||||||
|
characters: bookTools ? bookTools.characters_enabled === 1 : false,
|
||||||
|
worlds: bookTools ? bookTools.worlds_enabled === 1 : false,
|
||||||
|
locations: bookTools ? bookTools.locations_enabled === 1 : false
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +306,11 @@ export default class Book {
|
|||||||
return BookRepo.deleteBook(userId, bookId, lang);
|
return BookRepo.deleteBook(userId, bookId, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static updateBookToolSetting(userId: string, bookId: string, toolName: 'characters' | 'worlds' | 'locations', enabled: boolean, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||||
|
const columnName: 'characters_enabled' | 'worlds_enabled' | 'locations_enabled' = `${toolName}_enabled` as 'characters_enabled' | 'worlds_enabled' | 'locations_enabled';
|
||||||
|
return BookRepo.updateBookToolSetting(userId, bookId, columnName, enabled, lang);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the book ID.
|
* Gets the book ID.
|
||||||
* @returns The book's unique identifier
|
* @returns The book's unique identifier
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import CharacterRepo, {
|
|||||||
CharacterResult,
|
CharacterResult,
|
||||||
CompleteCharacterResult
|
CompleteCharacterResult
|
||||||
} from "../repositories/character.repository.js";
|
} from "../repositories/character.repository.js";
|
||||||
|
import BookRepo, {BookToolsTable} from "../repositories/book.repository.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import {getUserEncryptionKey} from "../keyManager.js";
|
import {getUserEncryptionKey} from "../keyManager.js";
|
||||||
|
|
||||||
@@ -41,6 +42,11 @@ export interface CharacterProps {
|
|||||||
history: string;
|
history: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CharacterListResponse {
|
||||||
|
characters: CharacterProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CompleteCharacterProps {
|
export interface CompleteCharacterProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -87,11 +93,15 @@ export default class Character {
|
|||||||
* @param lang - The language code for localization (defaults to 'fr')
|
* @param lang - The language code for localization (defaults to 'fr')
|
||||||
* @returns An array of decrypted character properties
|
* @returns An array of decrypted character properties
|
||||||
*/
|
*/
|
||||||
public static getCharacterList(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): CharacterProps[] {
|
public static getCharacterList(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): CharacterListResponse {
|
||||||
|
const bookTools: BookToolsTable | null = BookRepo.fetchBookTools(userId, bookId, lang);
|
||||||
|
const enabled: boolean = bookTools ? bookTools.characters_enabled === 1 : false;
|
||||||
|
|
||||||
const userEncryptionKey: string = getUserEncryptionKey(userId);
|
const userEncryptionKey: string = getUserEncryptionKey(userId);
|
||||||
const encryptedCharacters: CharacterResult[] = CharacterRepo.fetchCharacters(userId, bookId, lang);
|
const encryptedCharacters: CharacterResult[] = CharacterRepo.fetchCharacters(userId, bookId, lang);
|
||||||
if (!encryptedCharacters) return [];
|
if (!encryptedCharacters || encryptedCharacters.length === 0) {
|
||||||
if (encryptedCharacters.length === 0) return [];
|
return { characters: [], enabled };
|
||||||
|
}
|
||||||
const decryptedCharacterList: CharacterProps[] = [];
|
const decryptedCharacterList: CharacterProps[] = [];
|
||||||
for (const encryptedCharacter of encryptedCharacters) {
|
for (const encryptedCharacter of encryptedCharacters) {
|
||||||
decryptedCharacterList.push({
|
decryptedCharacterList.push({
|
||||||
@@ -106,7 +116,7 @@ export default class Character {
|
|||||||
history: encryptedCharacter.history ? System.decryptDataWithUserKey(encryptedCharacter.history, userEncryptionKey) : '',
|
history: encryptedCharacter.history ? System.decryptDataWithUserKey(encryptedCharacter.history, userEncryptionKey) : '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return decryptedCharacterList;
|
return { characters: decryptedCharacterList, enabled };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,4 +368,5 @@ export default class Character {
|
|||||||
}).join('\n\n');
|
}).join('\n\n');
|
||||||
return formattedCharactersDescription;
|
return formattedCharactersDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {getUserEncryptionKey} from "../keyManager.js";
|
import {getUserEncryptionKey} from "../keyManager.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import {CompleteBook} from "./Book.js";
|
import {CompleteBook} from "./Book.js";
|
||||||
import BookRepo, {EritBooksTable} from "../repositories/book.repository.js";
|
import BookRepo, {EritBooksTable, BookToolsTable} from "../repositories/book.repository.js";
|
||||||
import ChapterRepo, {
|
import ChapterRepo, {
|
||||||
BookChapterInfosTable,
|
BookChapterInfosTable,
|
||||||
BookChaptersTable
|
BookChaptersTable
|
||||||
@@ -192,9 +192,14 @@ export default class Download {
|
|||||||
});
|
});
|
||||||
if (!guidelinesInserted) return false;
|
if (!guidelinesInserted) return false;
|
||||||
|
|
||||||
return data.issues.every((issue: BookIssuesTable): boolean => {
|
const issuesInserted: boolean = data.issues.every((issue: BookIssuesTable): boolean => {
|
||||||
const encryptedIssueName: string = System.encryptDataWithUserKey(issue.name, userEncryptionKey);
|
const encryptedIssueName: string = System.encryptDataWithUserKey(issue.name, userEncryptionKey);
|
||||||
return IssueRepository.insertSyncIssue(issue.issue_id, userId, issue.book_id, encryptedIssueName, issue.hashed_issue_name, issue.last_update, lang);
|
return IssueRepository.insertSyncIssue(issue.issue_id, userId, issue.book_id, encryptedIssueName, issue.hashed_issue_name, issue.last_update, lang);
|
||||||
});
|
});
|
||||||
|
if (!issuesInserted) return false;
|
||||||
|
|
||||||
|
return data.bookTools.every((bookTool: BookToolsTable): boolean => {
|
||||||
|
return BookRepo.insertSyncBookTools(bookTool.book_id, userId, bookTool.characters_enabled, bookTool.worlds_enabled, bookTool.locations_enabled, lang);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import LocationRepo, {
|
|||||||
} from "../repositories/location.repository.js";
|
} from "../repositories/location.repository.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import {getUserEncryptionKey} from "../keyManager.js";
|
import {getUserEncryptionKey} from "../keyManager.js";
|
||||||
|
import BookRepo, {BookToolsTable} from "../repositories/book.repository.js";
|
||||||
|
|
||||||
export interface SubElement {
|
export interface SubElement {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -25,6 +26,11 @@ export interface LocationProps {
|
|||||||
elements: Element[];
|
elements: Element[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LocationListResponse {
|
||||||
|
locations: LocationProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface SyncedLocation {
|
export interface SyncedLocation {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -51,11 +57,16 @@ export default class Location {
|
|||||||
* @param userId - The user's unique identifier.
|
* @param userId - The user's unique identifier.
|
||||||
* @param bookId - The book's unique identifier.
|
* @param bookId - The book's unique identifier.
|
||||||
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
||||||
* @returns An array of location properties with their elements and sub-elements.
|
* @returns LocationListResponse containing an array of locations and enabled flag.
|
||||||
*/
|
*/
|
||||||
static getAllLocations(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): LocationProps[] {
|
static getAllLocations(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): LocationListResponse {
|
||||||
|
const bookTools: BookToolsTable | null = BookRepo.fetchBookTools(userId, bookId, lang);
|
||||||
|
const enabled: boolean = bookTools ? bookTools.locations_enabled === 1 : false;
|
||||||
|
|
||||||
const locationRecords: LocationQueryResult[] = LocationRepo.getLocation(userId, bookId, lang);
|
const locationRecords: LocationQueryResult[] = LocationRepo.getLocation(userId, bookId, lang);
|
||||||
if (!locationRecords || locationRecords.length === 0) return [];
|
if (!locationRecords || locationRecords.length === 0) {
|
||||||
|
return { locations: [], enabled };
|
||||||
|
}
|
||||||
const userKey: string = getUserEncryptionKey(userId);
|
const userKey: string = getUserEncryptionKey(userId);
|
||||||
|
|
||||||
const locationArray: LocationProps[] = [];
|
const locationArray: LocationProps[] = [];
|
||||||
@@ -104,7 +115,7 @@ export default class Location {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return locationArray;
|
return { locations: locationArray, enabled };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,4 +336,5 @@ export default class Location {
|
|||||||
return descriptionFields.join('\n');
|
return descriptionFields.join('\n');
|
||||||
}).join('\n\n');
|
}).join('\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getUserEncryptionKey } from "../keyManager.js";
|
import { getUserEncryptionKey } from "../keyManager.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import { BookSyncCompare, CompleteBook, SyncedBook } from "./Book.js";
|
import { BookSyncCompare, CompleteBook, SyncedBook, SyncedBookTools } from "./Book.js";
|
||||||
import BookRepo, { EritBooksTable, SyncedBookResult } from "../repositories/book.repository.js";
|
import BookRepo, { EritBooksTable, SyncedBookResult, BookToolsTable } from "../repositories/book.repository.js";
|
||||||
import ChapterRepo, {
|
import ChapterRepo, {
|
||||||
BookChapterInfosTable,
|
BookChapterInfosTable,
|
||||||
BookChaptersTable,
|
BookChaptersTable,
|
||||||
@@ -350,6 +350,9 @@ export default class Sync {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bookToolsResult: BookToolsTable | null = BookRepo.fetchBookTools(userId, syncCompareData.id, lang);
|
||||||
|
const bookTools: BookToolsTable[] = bookToolsResult ? [bookToolsResult] : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
eritBooks: decryptedBooks,
|
eritBooks: decryptedBooks,
|
||||||
chapters: decryptedChapters,
|
chapters: decryptedChapters,
|
||||||
@@ -367,7 +370,8 @@ export default class Sync {
|
|||||||
actSummaries: decryptedActSummaries,
|
actSummaries: decryptedActSummaries,
|
||||||
guideLine: decryptedGuideLines,
|
guideLine: decryptedGuideLines,
|
||||||
aiGuideLine: decryptedAIGuideLines,
|
aiGuideLine: decryptedAIGuideLines,
|
||||||
issues: decryptedIssues
|
issues: decryptedIssues,
|
||||||
|
bookTools: bookTools
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,6 +728,23 @@ export default class Sync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const serverBookTools: BookToolsTable[] = completeBook.bookTools;
|
||||||
|
if (serverBookTools && serverBookTools.length > 0) {
|
||||||
|
for (const serverBookTool of serverBookTools) {
|
||||||
|
const bookToolsExists: BookToolsTable | null = BookRepo.fetchBookTools(userId, bookId, lang);
|
||||||
|
if (bookToolsExists) {
|
||||||
|
BookRepo.updateBookToolSetting(userId, bookId, 'characters_enabled', serverBookTool.characters_enabled === 1, lang);
|
||||||
|
BookRepo.updateBookToolSetting(userId, bookId, 'worlds_enabled', serverBookTool.worlds_enabled === 1, lang);
|
||||||
|
BookRepo.updateBookToolSetting(userId, bookId, 'locations_enabled', serverBookTool.locations_enabled === 1, lang);
|
||||||
|
} else {
|
||||||
|
const insertSuccessful: boolean = BookRepo.insertSyncBookTools(bookId, userId, serverBookTool.characters_enabled, serverBookTool.worlds_enabled, serverBookTool.locations_enabled, lang);
|
||||||
|
if (!insertSuccessful) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,6 +961,13 @@ export default class Sync {
|
|||||||
lastUpdate: aiGuidelineRecord.last_update
|
lastUpdate: aiGuidelineRecord.last_update
|
||||||
} : null;
|
} : null;
|
||||||
|
|
||||||
|
const bookToolsRecord: BookToolsTable | null = BookRepo.fetchBookTools(userId, currentBookId, lang);
|
||||||
|
const bookTools: SyncedBookTools | null = bookToolsRecord ? {
|
||||||
|
charactersEnabled: bookToolsRecord.characters_enabled === 1,
|
||||||
|
worldsEnabled: bookToolsRecord.worlds_enabled === 1,
|
||||||
|
locationsEnabled: bookToolsRecord.locations_enabled === 1
|
||||||
|
} : null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: currentBookId,
|
id: currentBookId,
|
||||||
type: bookRecord.type,
|
type: bookRecord.type,
|
||||||
@@ -955,7 +983,8 @@ export default class Sync {
|
|||||||
issues: bookIssues,
|
issues: bookIssues,
|
||||||
actSummaries: bookActSummaries,
|
actSummaries: bookActSummaries,
|
||||||
guideLine: bookGuideLine,
|
guideLine: bookGuideLine,
|
||||||
aiGuideLine: bookAIGuideLine
|
aiGuideLine: bookAIGuideLine,
|
||||||
|
bookTools: bookTools
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getUserEncryptionKey } from "../keyManager.js";
|
import { getUserEncryptionKey } from "../keyManager.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import { CompleteBook } from "./Book.js";
|
import { CompleteBook } from "./Book.js";
|
||||||
import BookRepo, { EritBooksTable } from "../repositories/book.repository.js";
|
import BookRepo, { EritBooksTable, BookToolsTable } from "../repositories/book.repository.js";
|
||||||
import ActRepository, { BookActSummariesTable } from "../repositories/act.repository.js";
|
import ActRepository, { BookActSummariesTable } from "../repositories/act.repository.js";
|
||||||
import GuidelineRepo, { BookAIGuideLineTable, BookGuideLineTable } from "../repositories/guideline.repository.js";
|
import GuidelineRepo, { BookAIGuideLineTable, BookGuideLineTable } from "../repositories/guideline.repository.js";
|
||||||
import ChapterRepo, {
|
import ChapterRepo, {
|
||||||
@@ -51,7 +51,8 @@ export default class Upload {
|
|||||||
encryptedIssues,
|
encryptedIssues,
|
||||||
encryptedLocations,
|
encryptedLocations,
|
||||||
encryptedPlotPoints,
|
encryptedPlotPoints,
|
||||||
encryptedWorlds
|
encryptedWorlds,
|
||||||
|
bookToolsData
|
||||||
]: [
|
]: [
|
||||||
EritBooksTable[],
|
EritBooksTable[],
|
||||||
BookActSummariesTable[],
|
BookActSummariesTable[],
|
||||||
@@ -63,7 +64,8 @@ export default class Upload {
|
|||||||
BookIssuesTable[],
|
BookIssuesTable[],
|
||||||
BookLocationTable[],
|
BookLocationTable[],
|
||||||
BookPlotPointsTable[],
|
BookPlotPointsTable[],
|
||||||
BookWorldTable[]
|
BookWorldTable[],
|
||||||
|
BookToolsTable | null
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
BookRepo.fetchEritBooksTable(userId, bookId, lang),
|
BookRepo.fetchEritBooksTable(userId, bookId, lang),
|
||||||
ActRepository.fetchBookActSummaries(userId, bookId, lang),
|
ActRepository.fetchBookActSummaries(userId, bookId, lang),
|
||||||
@@ -75,7 +77,8 @@ export default class Upload {
|
|||||||
IssueRepository.fetchBookIssues(userId, bookId, lang),
|
IssueRepository.fetchBookIssues(userId, bookId, lang),
|
||||||
LocationRepo.fetchBookLocations(userId, bookId, lang),
|
LocationRepo.fetchBookLocations(userId, bookId, lang),
|
||||||
PlotPointRepository.fetchBookPlotPoints(userId, bookId, lang),
|
PlotPointRepository.fetchBookPlotPoints(userId, bookId, lang),
|
||||||
WorldRepository.fetchBookWorlds(userId, bookId, lang)
|
WorldRepository.fetchBookWorlds(userId, bookId, lang),
|
||||||
|
BookRepo.fetchBookTools(userId, bookId, lang)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
@@ -234,6 +237,8 @@ export default class Upload {
|
|||||||
sub_elem_description: locationSubElement.sub_elem_description ? System.decryptDataWithUserKey(locationSubElement.sub_elem_description, userEncryptionKey) : null
|
sub_elem_description: locationSubElement.sub_elem_description ? System.decryptDataWithUserKey(locationSubElement.sub_elem_description, userEncryptionKey) : null
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const bookTools: BookToolsTable[] = bookToolsData ? [bookToolsData] : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
eritBooks,
|
eritBooks,
|
||||||
actSummaries,
|
actSummaries,
|
||||||
@@ -251,7 +256,8 @@ export default class Upload {
|
|||||||
worlds,
|
worlds,
|
||||||
worldElements,
|
worldElements,
|
||||||
locationElements,
|
locationElements,
|
||||||
locationSubElements
|
locationSubElements,
|
||||||
|
bookTools
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { getUserEncryptionKey } from "../keyManager.js";
|
import { getUserEncryptionKey } from "../keyManager.js";
|
||||||
import System from "../System.js";
|
import System from "../System.js";
|
||||||
import WorldRepository, { WorldElementValue, WorldQuery } from "../repositories/world.repository.js";
|
import WorldRepository, { WorldElementValue, WorldQuery } from "../repositories/world.repository.js";
|
||||||
|
import BookRepo, {BookToolsTable} from "../repositories/book.repository.js";
|
||||||
|
|
||||||
export interface SyncedWorld {
|
export interface SyncedWorld {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -44,6 +45,11 @@ export interface WorldProps {
|
|||||||
importantCharacters: WorldElement[];
|
importantCharacters: WorldElement[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WorldListResponse {
|
||||||
|
worlds: WorldProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of element type keys to their corresponding numeric type identifiers.
|
* Mapping of element type keys to their corresponding numeric type identifiers.
|
||||||
*/
|
*/
|
||||||
@@ -107,9 +113,12 @@ export default class World {
|
|||||||
* @param userId - The unique identifier of the user
|
* @param userId - The unique identifier of the user
|
||||||
* @param bookId - The unique identifier of the book
|
* @param bookId - The unique identifier of the book
|
||||||
* @param lang - The language for error messages ('fr' or 'en'), defaults to 'fr'
|
* @param lang - The language for error messages ('fr' or 'en'), defaults to 'fr'
|
||||||
* @returns An array of WorldProps objects containing all world data and their elements
|
* @returns WorldListResponse containing an array of WorldProps and enabled flag
|
||||||
*/
|
*/
|
||||||
public static getWorlds(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): WorldProps[] {
|
public static getWorlds(userId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): WorldListResponse {
|
||||||
|
const bookTools: BookToolsTable | null = BookRepo.fetchBookTools(userId, bookId, lang);
|
||||||
|
const enabled: boolean = bookTools ? bookTools.worlds_enabled === 1 : false;
|
||||||
|
|
||||||
const worldQueryResults: WorldQuery[] = WorldRepository.fetchWorlds(userId, bookId, lang);
|
const worldQueryResults: WorldQuery[] = WorldRepository.fetchWorlds(userId, bookId, lang);
|
||||||
const userEncryptionKey: string = getUserEncryptionKey(userId);
|
const userEncryptionKey: string = getUserEncryptionKey(userId);
|
||||||
const worlds: WorldProps[] = [];
|
const worlds: WorldProps[] = [];
|
||||||
@@ -167,7 +176,7 @@ export default class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return worlds;
|
return { worlds, enabled };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,4 +274,5 @@ export default class World {
|
|||||||
public static removeElementFromWorld(userId: string, elementId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
public static removeElementFromWorld(userId: string, elementId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||||
return WorldRepository.deleteElement(userId, elementId, lang);
|
return WorldRepository.deleteElement(userId, elementId, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,20 @@ export interface BookCoverQuery extends Record<string, SQLiteValue> {
|
|||||||
cover_image: string;
|
cover_image: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BookToolsTable extends Record<string, SQLiteValue> {
|
||||||
|
book_id: string;
|
||||||
|
user_id: string;
|
||||||
|
characters_enabled: number;
|
||||||
|
worlds_enabled: number;
|
||||||
|
locations_enabled: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BookToolsSettings {
|
||||||
|
characters: boolean;
|
||||||
|
worlds: boolean;
|
||||||
|
locations: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export default class BookRepo {
|
export default class BookRepo {
|
||||||
/**
|
/**
|
||||||
* Retrieves all books for a user.
|
* Retrieves all books for a user.
|
||||||
@@ -361,4 +375,70 @@ export default class BookRepo {
|
|||||||
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fetchBookTools(userId: string, bookId: string, lang: 'fr' | 'en'): BookToolsTable | null {
|
||||||
|
try {
|
||||||
|
const db: Database = System.getDb();
|
||||||
|
const query: string = 'SELECT book_id, user_id, characters_enabled, worlds_enabled, locations_enabled FROM book_tools WHERE user_id=? AND book_id=?';
|
||||||
|
const params: SQLiteValue[] = [userId, bookId];
|
||||||
|
const result = db.get(query, params) as BookToolsTable | undefined;
|
||||||
|
return result ?? null;
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
console.error(`DB Error: ${error.message}`);
|
||||||
|
throw new Error(lang === 'fr' ? 'Impossible de récupérer les paramètres des outils.' : 'Unable to fetch tools settings.');
|
||||||
|
}
|
||||||
|
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static updateBookToolSetting(userId: string, bookId: string, toolName: 'characters_enabled' | 'worlds_enabled' | 'locations_enabled', enabled: boolean, lang: 'fr' | 'en'): boolean {
|
||||||
|
const enabledValue: number = enabled ? 1 : 0;
|
||||||
|
try {
|
||||||
|
const db: Database = System.getDb();
|
||||||
|
const updateQuery: string = `UPDATE book_tools SET ${toolName}=? WHERE user_id=? AND book_id=?`;
|
||||||
|
const updateResult: RunResult = db.run(updateQuery, [enabledValue, userId, bookId]);
|
||||||
|
if (updateResult.changes > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const charactersValue: number = toolName === 'characters_enabled' ? enabledValue : 0;
|
||||||
|
const worldsValue: number = toolName === 'worlds_enabled' ? enabledValue : 0;
|
||||||
|
const locationsValue: number = toolName === 'locations_enabled' ? enabledValue : 0;
|
||||||
|
const insertQuery: string = 'INSERT INTO book_tools (book_id, user_id, characters_enabled, worlds_enabled, locations_enabled) VALUES (?, ?, ?, ?, ?)';
|
||||||
|
const insertResult: RunResult = db.run(insertQuery, [bookId, userId, charactersValue, worldsValue, locationsValue]);
|
||||||
|
return insertResult.changes > 0;
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
console.error(`DB Error: ${error.message}`);
|
||||||
|
throw new Error(lang === 'fr' ? 'Impossible de mettre à jour les paramètres des outils.' : 'Unable to update tools settings.');
|
||||||
|
}
|
||||||
|
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts book tools settings during sync.
|
||||||
|
* @param bookId - The book identifier
|
||||||
|
* @param userId - The user identifier
|
||||||
|
* @param charactersEnabled - Whether characters tool is enabled
|
||||||
|
* @param worldsEnabled - Whether worlds tool is enabled
|
||||||
|
* @param locationsEnabled - Whether locations tool is enabled
|
||||||
|
* @param lang - The language for error messages
|
||||||
|
* @returns true if the insertion was successful
|
||||||
|
*/
|
||||||
|
static insertSyncBookTools(bookId: string, userId: string, charactersEnabled: number, worldsEnabled: number, locationsEnabled: number, lang: 'fr' | 'en'): boolean {
|
||||||
|
try {
|
||||||
|
const db: Database = System.getDb();
|
||||||
|
const query: string = 'INSERT INTO book_tools (book_id, user_id, characters_enabled, worlds_enabled, locations_enabled) VALUES (?, ?, ?, ?, ?)';
|
||||||
|
const params: SQLiteValue[] = [bookId, userId, charactersEnabled, worldsEnabled, locationsEnabled];
|
||||||
|
const insertResult: RunResult = db.run(query, params);
|
||||||
|
return insertResult.changes > 0;
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
console.error(`DB Error: ${error.message}`);
|
||||||
|
throw new Error(lang === 'fr' ? "Impossible d'insérer les paramètres des outils." : 'Unable to insert tools settings.');
|
||||||
|
}
|
||||||
|
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ type Database = sqlite3.Database;
|
|||||||
* Data is encrypted before storage and decrypted on retrieval
|
* Data is encrypted before storage and decrypted on retrieval
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const SCHEMA_VERSION = 2;
|
export const SCHEMA_VERSION = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the local SQLite database with all required tables
|
* Initialize the local SQLite database with all required tables
|
||||||
@@ -412,6 +412,19 @@ export function initializeSchema(db: Database): void {
|
|||||||
);
|
);
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
// Book Tools
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS book_tools (
|
||||||
|
book_id TEXT NOT NULL,
|
||||||
|
user_id TEXT NOT NULL,
|
||||||
|
characters_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
worlds_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
locations_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (book_id, user_id),
|
||||||
|
FOREIGN KEY (book_id) REFERENCES erit_books(book_id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
|
||||||
// Create indexes for better performance
|
// Create indexes for better performance
|
||||||
createIndexes(db);
|
createIndexes(db);
|
||||||
|
|
||||||
@@ -574,6 +587,20 @@ export function runMigrations(db: Database): void {
|
|||||||
`, 'chapter_info_id, chapter_id, act_id, incident_id, plot_point_id, book_id, author_id, summary, goal, last_update');
|
`, 'chapter_info_id, chapter_id, act_id, incident_id, plot_point_id, book_id, author_id, summary, goal, last_update');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentVersion < 3) {
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS book_tools (
|
||||||
|
book_id TEXT NOT NULL,
|
||||||
|
user_id TEXT NOT NULL,
|
||||||
|
characters_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
worlds_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
locations_enabled INTEGER NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (book_id, user_id),
|
||||||
|
FOREIGN KEY (book_id) REFERENCES erit_books(book_id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
// Update schema version
|
// Update schema version
|
||||||
setDbSchemaVersion(db, SCHEMA_VERSION);
|
setDbSchemaVersion(db, SCHEMA_VERSION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ interface UpdateWorldData {
|
|||||||
world: WorldProps;
|
world: WorldProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface UpdateBookToolData {
|
||||||
|
bookId: string;
|
||||||
|
toolName: 'characters' | 'worlds' | 'locations';
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// GET /books - Get all books
|
// GET /books - Get all books
|
||||||
ipcMain.handle('db:book:books', createHandler<void, BookProps[]>(
|
ipcMain.handle('db:book:books', createHandler<void, BookProps[]>(
|
||||||
async function(userId: string, _body: void, lang: 'fr' | 'en'):Promise<BookProps[]> {
|
async function(userId: string, _body: void, lang: 'fr' | 'en'):Promise<BookProps[]> {
|
||||||
@@ -412,3 +418,11 @@ ipcMain.handle('db:book:world:update', createHandler<UpdateWorldData, boolean>(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// PATCH /book/tool-setting - Update book tool setting
|
||||||
|
ipcMain.handle('db:book:tool:update', createHandler<UpdateBookToolData, boolean>(
|
||||||
|
function(userId: string, data: UpdateBookToolData, lang: 'fr' | 'en') {
|
||||||
|
return Book.updateBookToolSetting(userId, data.bookId, data.toolName, data.enabled, lang);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|||||||
@@ -354,7 +354,11 @@
|
|||||||
"languagesPlaceholder": "Create your own language or simply mention those available.",
|
"languagesPlaceholder": "Create your own language or simply mention those available.",
|
||||||
"updateWorldError": "Failed to update:",
|
"updateWorldError": "Failed to update:",
|
||||||
"addWorldError": "Error adding world.",
|
"addWorldError": "Error adding world.",
|
||||||
"updateWorldSuccess": "World updated successfully."
|
"updateWorldSuccess": "World updated successfully.",
|
||||||
|
"enableTool": "Enable worlds",
|
||||||
|
"enableToolDescription": "Enable world management for this book.",
|
||||||
|
"toolEnabled": "World management enabled.",
|
||||||
|
"toolDisabled": "World management disabled."
|
||||||
},
|
},
|
||||||
"locationComponent": {
|
"locationComponent": {
|
||||||
"newSectionPlaceholder": "New section name",
|
"newSectionPlaceholder": "New section name",
|
||||||
@@ -387,7 +391,11 @@
|
|||||||
"errorSave": "An error occurred while saving the locations.",
|
"errorSave": "An error occurred while saving the locations.",
|
||||||
"errorUnknownSave": "Unable to save changes. Please try again later.",
|
"errorUnknownSave": "Unable to save changes. Please try again later.",
|
||||||
"errorUnknownFetchLocations": "Unknown error fetching locations.",
|
"errorUnknownFetchLocations": "Unknown error fetching locations.",
|
||||||
"successSave": "Locations saved successfully."
|
"successSave": "Locations saved successfully.",
|
||||||
|
"enableTool": "Enable locations",
|
||||||
|
"enableToolDescription": "Enable location management for this book.",
|
||||||
|
"toolEnabled": "Location management enabled.",
|
||||||
|
"toolDisabled": "Location management disabled."
|
||||||
},
|
},
|
||||||
"characterComponent": {
|
"characterComponent": {
|
||||||
"errorNameRequired": "Character name is required.",
|
"errorNameRequired": "Character name is required.",
|
||||||
@@ -397,7 +405,11 @@
|
|||||||
"errorAddCharacter": "Error adding character.",
|
"errorAddCharacter": "Error adding character.",
|
||||||
"errorUpdateCharacter": "Error updating character.",
|
"errorUpdateCharacter": "Error updating character.",
|
||||||
"errorAddAttribute": "Error adding attribute.",
|
"errorAddAttribute": "Error adding attribute.",
|
||||||
"errorRemoveAttribute": "Error removing attribute."
|
"errorRemoveAttribute": "Error removing attribute.",
|
||||||
|
"enableTool": "Enable characters",
|
||||||
|
"enableToolDescription": "Enable character management for this book.",
|
||||||
|
"toolEnabled": "Character management enabled.",
|
||||||
|
"toolDisabled": "Character management disabled."
|
||||||
},
|
},
|
||||||
"characterDetail": {
|
"characterDetail": {
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
@@ -1013,6 +1025,9 @@
|
|||||||
"errorSave": "Error saving settings.",
|
"errorSave": "Error saving settings.",
|
||||||
"errorUnknown": "An unknown error occurred.",
|
"errorUnknown": "An unknown error occurred.",
|
||||||
"successSave": "QuillSense settings saved successfully.",
|
"successSave": "QuillSense settings saved successfully.",
|
||||||
"noBookSelected": "No book selected."
|
"noBookSelected": "No book selected.",
|
||||||
|
"enable_characters": "Enable character management for this book",
|
||||||
|
"enable_worlds": "Enable world management for this book",
|
||||||
|
"enable_locations": "Enable location management for this book"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,11 @@
|
|||||||
"languagesPlaceholder": "Créez votre propre langue ou mentionnez simplement celles disponibles.",
|
"languagesPlaceholder": "Créez votre propre langue ou mentionnez simplement celles disponibles.",
|
||||||
"updateWorldError": "Échec de la mise à jour :",
|
"updateWorldError": "Échec de la mise à jour :",
|
||||||
"addWorldError": "Erreur lors de l'ajout du monde.",
|
"addWorldError": "Erreur lors de l'ajout du monde.",
|
||||||
"updateWorldSuccess": "Monde mis à jour avec succès."
|
"updateWorldSuccess": "Monde mis à jour avec succès.",
|
||||||
|
"enableTool": "Activer les mondes",
|
||||||
|
"enableToolDescription": "Activer la gestion des mondes pour ce livre.",
|
||||||
|
"toolEnabled": "Gestion des mondes activée.",
|
||||||
|
"toolDisabled": "Gestion des mondes désactivée."
|
||||||
},
|
},
|
||||||
"locationComponent": {
|
"locationComponent": {
|
||||||
"newSectionPlaceholder": "Nom de la nouvelle section",
|
"newSectionPlaceholder": "Nom de la nouvelle section",
|
||||||
@@ -387,7 +391,11 @@
|
|||||||
"errorSave": "Une erreur est survenue lors de la sauvegarde des emplacements.",
|
"errorSave": "Une erreur est survenue lors de la sauvegarde des emplacements.",
|
||||||
"errorUnknownSave": "Impossible de sauvegarder les modifications. Veuillez réessayer ultérieurement.",
|
"errorUnknownSave": "Impossible de sauvegarder les modifications. Veuillez réessayer ultérieurement.",
|
||||||
"errorUnknownFetchLocations": "Erreur inconnue lors de la récupération des emplacements.",
|
"errorUnknownFetchLocations": "Erreur inconnue lors de la récupération des emplacements.",
|
||||||
"successSave": "Emplacements sauvegardés avec succès."
|
"successSave": "Emplacements sauvegardés avec succès.",
|
||||||
|
"enableTool": "Activer les lieux",
|
||||||
|
"enableToolDescription": "Activer la gestion des lieux pour ce livre.",
|
||||||
|
"toolEnabled": "Gestion des lieux activée.",
|
||||||
|
"toolDisabled": "Gestion des lieux désactivée."
|
||||||
},
|
},
|
||||||
"characterComponent": {
|
"characterComponent": {
|
||||||
"errorNameRequired": "Le nom du personnage est requis.",
|
"errorNameRequired": "Le nom du personnage est requis.",
|
||||||
@@ -397,7 +405,11 @@
|
|||||||
"errorAddCharacter": "Erreur lors de l'ajout du personnage.",
|
"errorAddCharacter": "Erreur lors de l'ajout du personnage.",
|
||||||
"errorUpdateCharacter": "Erreur lors de la mise à jour du personnage.",
|
"errorUpdateCharacter": "Erreur lors de la mise à jour du personnage.",
|
||||||
"errorAddAttribute": "Erreur lors de l'ajout de l'attribut.",
|
"errorAddAttribute": "Erreur lors de l'ajout de l'attribut.",
|
||||||
"errorRemoveAttribute": "Erreur lors de la suppression de l'attribut."
|
"errorRemoveAttribute": "Erreur lors de la suppression de l'attribut.",
|
||||||
|
"enableTool": "Activer les personnages",
|
||||||
|
"enableToolDescription": "Activer la gestion des personnages pour ce livre.",
|
||||||
|
"toolEnabled": "Gestion des personnages activée.",
|
||||||
|
"toolDisabled": "Gestion des personnages désactivée."
|
||||||
},
|
},
|
||||||
"characterDetail": {
|
"characterDetail": {
|
||||||
"back": "Retour",
|
"back": "Retour",
|
||||||
@@ -1014,6 +1026,9 @@
|
|||||||
"errorSave": "Erreur lors de la sauvegarde des paramètres.",
|
"errorSave": "Erreur lors de la sauvegarde des paramètres.",
|
||||||
"errorUnknown": "Une erreur inconnue est survenue.",
|
"errorUnknown": "Une erreur inconnue est survenue.",
|
||||||
"successSave": "Paramètres QuillSense sauvegardés avec succès.",
|
"successSave": "Paramètres QuillSense sauvegardés avec succès.",
|
||||||
"noBookSelected": "Aucun livre sélectionné."
|
"noBookSelected": "Aucun livre sélectionné.",
|
||||||
|
"enable_characters": "Activer la gestion des personnages pour ce livre",
|
||||||
|
"enable_worlds": "Activer la gestion des mondes pour ce livre",
|
||||||
|
"enable_locations": "Activer la gestion des lieux pour ce livre"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,12 @@ export interface SyncedBook {
|
|||||||
aiGuideLine: SyncedAIGuideLine | null;
|
aiGuideLine: SyncedAIGuideLine | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BookToolsSettings {
|
||||||
|
characters: boolean;
|
||||||
|
worlds: boolean;
|
||||||
|
locations: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface BookProps {
|
export interface BookProps {
|
||||||
bookId: string;
|
bookId: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -72,6 +78,7 @@ export interface BookProps {
|
|||||||
localBook?: boolean;
|
localBook?: boolean;
|
||||||
chapters?: ChapterProps[];
|
chapters?: ChapterProps[];
|
||||||
quillsenseEnabled?: boolean;
|
quillsenseEnabled?: boolean;
|
||||||
|
tools?: BookToolsSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BookListProps {
|
export interface BookListProps {
|
||||||
|
|||||||
@@ -163,6 +163,11 @@ export interface CharacterProps {
|
|||||||
history?: string;
|
history?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CharacterListResponse {
|
||||||
|
characters: CharacterProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CharacterElement {
|
export interface CharacterElement {
|
||||||
title: string;
|
title: string;
|
||||||
section: keyof CharacterProps;
|
section: keyof CharacterProps;
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ export interface WorldProps {
|
|||||||
importantCharacters: WorldElement[];
|
importantCharacters: WorldElement[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WorldListResponse {
|
||||||
|
worlds: WorldProps[];
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export const elementSections: ElementSection[] = [
|
export const elementSections: ElementSection[] = [
|
||||||
{
|
{
|
||||||
title: 'Lois',
|
title: 'Lois',
|
||||||
|
|||||||
Reference in New Issue
Block a user