@@ -5,15 +5,27 @@ import { DatabaseView } from "DatabaseView";
55import { LOGGER } from "services/Logger" ;
66import { developer_settings_section } from "settings/DeveloperSection" ;
77
8+ interface GlobalSettings {
9+ enable_debug_mode : boolean ;
10+ logger_level_info : string ;
11+ }
812
13+ export interface LocalSettings {
14+ enable_show_state : boolean ;
15+ }
916export interface DatabaseSettings {
10- enable_debug_mode : boolean ;
11- logger_level_info : string ;
17+ global_settings : GlobalSettings ;
18+ local_settings : LocalSettings ;
1219}
1320
1421export const DEFAULT_SETTINGS : DatabaseSettings = {
22+ global_settings :{
1523 enable_debug_mode : false ,
16- logger_level_info : "error"
24+ logger_level_info : 'error'
25+ } ,
26+ local_settings :{
27+ enable_show_state : false
28+ }
1729} ;
1830
1931export type SettingRetriever = < K extends keyof DatabaseSettings > (
@@ -49,19 +61,27 @@ export interface SettingsManagerConfig {
4961 this . config = config ;
5062 this . settings = settings ;
5163 }
52- constructUI ( containerEl : HTMLElement , heading : string , local : boolean ) {
64+
65+ /**
66+ * Render settings window
67+ * @param containerEl
68+ * @param heading
69+ * @param local
70+ * @param view optional. Used only for local settings
71+ */
72+ constructUI ( containerEl : HTMLElement , heading : string , local : boolean , view ?: DatabaseView ) {
5373 /** Common modal headings */
5474 containerEl . empty ( ) ;
5575 containerEl . addClass ( 'database-settings-modal' ) ;
5676 add_setting_header ( containerEl , heading , 'h2' ) ;
5777 const settingsBody :HTMLDivElement = containerEl . createDiv ( 'database-settings-body' ) ;
58- this . constructSettingBody ( settingsBody , local ) ;
78+ this . constructSettingBody ( settingsBody , local , view ) ;
5979 }
6080
61- constructSettingBody ( containerEl : HTMLElement , local : boolean ) {
81+ constructSettingBody ( containerEl : HTMLElement , local : boolean , view ?: DatabaseView ) {
6282 containerEl . empty ( ) ;
6383 /** Developer section */
64- developer_settings_section ( this , containerEl , local ) ;
84+ developer_settings_section ( this , containerEl , local , view ) ;
6585 }
6686 cleanUp ( ) {
6787 this . cleanupFns . forEach ( ( fn ) => fn ( ) ) ;
@@ -89,7 +109,7 @@ export class SettingsModal extends Modal {
89109
90110 modalEl . addClass ( 'database-settings-modal' ) ;
91111
92- this . settingsManager . constructUI ( contentEl , this . view . file . basename , true ) ;
112+ this . settingsManager . constructUI ( contentEl , this . view . file . basename , true , this . view ) ;
93113 }
94114
95115 onClose ( ) {
@@ -117,6 +137,6 @@ export class DBFolderSettingTab extends PluginSettingTab {
117137
118138export function loadServicesThatRequireSettings ( settings : DatabaseSettings ) {
119139 /** Init logger */
120- LOGGER . setDebugMode ( settings . enable_debug_mode ) ;
121- LOGGER . setLevelInfo ( settings . logger_level_info ) ;
140+ LOGGER . setDebugMode ( settings . global_settings . enable_debug_mode ) ;
141+ LOGGER . setLevelInfo ( settings . global_settings . logger_level_info ) ;
122142}
0 commit comments