11-- Settings page for managing master data - UI matching entries.sql design system
2+
3+ SET _scn_id_format = COALESCE((SELECT value FROM app_settings WHERE key = ' scn_id_format' ), ' SCN-{NUM}' );
4+ SET _req_id_format = COALESCE((SELECT value FROM app_settings WHERE key = ' req_id_format' ), ' RQ-{NUM}' );
5+ SET _openai_key = COALESCE((SELECT value FROM app_settings WHERE key = ' openai_api_key' ), ' ' );
6+ SET _gemini_key = COALESCE((SELECT value FROM app_settings WHERE key = ' gemini_api_key' ), ' ' );
7+ SET _groq_key = COALESCE((SELECT value FROM app_settings WHERE key = ' groq_api_key' ), ' ' );
8+ SET _anthropic_key = COALESCE((SELECT value FROM app_settings WHERE key = ' anthropic_api_key' ), ' ' );
9+
210SELECT ' shell' AS component,
311 ' Qualityfolio AI' AS title,
412 ' logo.png' AS image,
@@ -213,6 +221,12 @@ SELECT 'html' AS component, '
213221 <a href="settings.sql?tab=markdown_paths" class="cfg-tab-btn ' || CASE WHEN $tab = ' markdown_paths' THEN ' active' ELSE ' ' END || ' ">
214222 Markdown Folder
215223 </a>
224+ <a href="settings.sql?tab=database_path" class="cfg-tab-btn ' || CASE WHEN $tab = ' database_path' THEN ' active' ELSE ' ' END || ' ">
225+ Database Path
226+ </a>
227+ <a href="settings.sql?tab=llm_keys" class="cfg-tab-btn ' || CASE WHEN $tab = ' llm_keys' THEN ' active' ELSE ' ' END || ' ">
228+ LLM API Keys
229+ </a>
216230 </div>
217231</div>
218232' AS html;
@@ -675,29 +689,85 @@ SELECT 'html' AS component, '
675689' AS html
676690WHERE $tab = ' id_formats' ;
677691
678- SELECT ' html' AS component,'
679- <div class="cfg-wrap" style="padding-top:0">
680- <div class="cfg-card">
681- <div class="cfg-card-title"> Markdown Destination Folder</div>
682- <div class="cfg-card-desc">Set the folder where generated markdown files will be saved.</div>
683- <form method="POST" action="/pages/settings/save_path_settings.sql" class="cfg-format-form">
684- <div class="cfg-format-field">
685- <label>Destination Path</label>
686- <input type="text"
687- name="artifact_destination"
688- placeholder="e.g. /home/user/markdown or ./docs/output"
689- value="' || COALESCE(destination_path, ' ' ) || ' "
690- autocomplete="off" />
691- <span class="hint">Enter the foldername (e.g. outputs)</span>
692- </div>
693- <div class="cfg-footer-btns">
694- <button type="submit" class="btn btn-primary qfg-tc-btn">💾 Save Folder Name</button>
695- </div>
696- </form>
697- </div>
698- </div>
699- '
700- AS html
701- FROM path_settings
702- WHERE setting_key = ' markdown_destination'
703- AND $tab = ' markdown_paths' ;
692+ -- ============================================
693+ -- PATH SETTINGS TABS (Markdown / Database)
694+ -- ============================================
695+ SELECT ' html' AS component,
696+ CASE
697+ WHEN $tab = ' markdown_paths' THEN '
698+ <div class="cfg-wrap" style="padding-top:0">
699+ <div class="cfg-card">
700+ <div class="cfg-card-title"> Markdown Destination Folder</div>
701+ <div class="cfg-card-desc">Set the folder where generated markdown files will be saved.</div>
702+ <form method="POST" action="/pages/settings/save_path_settings.sql" class="cfg-format-form">
703+ <div class="cfg-format-field">
704+ <label>Destination Path</label>
705+ <input type="text"
706+ name="artifact_destination"
707+ placeholder="e.g. /home/user/markdown or ./docs/output"
708+ value="' || COALESCE((SELECT destination_path FROM path_settings WHERE setting_key = ' markdown_destination' ), ' ' ) || ' "
709+ autocomplete="off" />
710+ <span class="hint">Enter the foldername (e.g. outputs)</span>
711+ </div>
712+ <div class="cfg-footer-btns">
713+ <button type="submit" class="btn btn-primary qfg-tc-btn">💾 Save Folder Name</button>
714+ </div>
715+ </form>
716+ </div>
717+ </div>'
718+ WHEN $tab = ' database_path' THEN '
719+ <div class="cfg-wrap" style="padding-top:0">
720+ <div class="cfg-card">
721+ <div class="cfg-card-title"> Database Path (RSSD)</div>
722+ <div class="cfg-card-desc">Set the path to the Resource Surveillance SQLite database file. This is used by the AI Chat.</div>
723+ <form method="POST" action="/pages/settings/save_database_path.sql" class="cfg-format-form">
724+ <div class="cfg-format-field">
725+ <label>Database Path</label>
726+ <input type="text"
727+ name="database_path"
728+ placeholder="e.g. ../resource-surveillance.sqlite.db"
729+ value="' || COALESCE((SELECT destination_path FROM path_settings WHERE setting_key = ' database_path' ), ' ' ) || ' "
730+ autocomplete="off" />
731+ <span class="hint">Enter the path to the .db file (e.g. ../resource-surveillance.sqlite.db)</span>
732+ </div>
733+ <div class="cfg-footer-btns">
734+ <button type="submit" class="btn btn-primary qfg-tc-btn">💾 Save Database Path</button>
735+ </div>
736+ </form>
737+ </div>
738+ </div>'
739+ WHEN $tab = ' llm_keys' THEN '
740+ <div class="cfg-wrap" style="padding-top:0">
741+ <div class="cfg-card">
742+ <div class="cfg-card-title"> LLM API Keys</div>
743+ <div class="cfg-card-desc">Set your API keys for various LLM providers. These are saved to the root .env file.</div>
744+ <form method="POST" action="/pages/settings/save_llm_keys.sql" class="cfg-format-form">
745+ <div class="cfg-format-group">
746+ <div class="cfg-format-field">
747+ <label>OpenAI API Key</label>
748+ <input type="password" name="openai_api_key" placeholder="sk-..." value="' || $_openai_key || ' " autocomplete="off" />
749+ </div>
750+ <div class="cfg-format-field">
751+ <label>Gemini API Key</label>
752+ <input type="password" name="gemini_api_key" placeholder="AIza..." value="' || $_gemini_key || ' " autocomplete="off" />
753+ </div>
754+ </div>
755+ <div class="cfg-format-group">
756+ <div class="cfg-format-field">
757+ <label>Groq API Key</label>
758+ <input type="password" name="groq_api_key" placeholder="gsk_..." value="' || $_groq_key || ' " autocomplete="off" />
759+ </div>
760+ <div class="cfg-format-field">
761+ <label>Anthropic API Key</label>
762+ <input type="password" name="anthropic_api_key" placeholder="sk-ant-..." value="' || $_anthropic_key || ' " autocomplete="off" />
763+ </div>
764+ </div>
765+ <div class="cfg-footer-btns">
766+ <button type="submit" class="btn btn-primary qfg-tc-btn">💾 Save API Keys</button>
767+ </div>
768+ </form>
769+ </div>
770+ </div>'
771+ ELSE ' '
772+ END AS html
773+ WHERE $tab IN (' markdown_paths' , ' database_path' , ' llm_keys' );
0 commit comments