Skip to content

Commit 178b744

Browse files
authored
Merge pull request #1 from aaronba/BT_Banner
Bt banner
2 parents 3e872b8 + c6d0182 commit 178b744

File tree

8 files changed

+102
-3
lines changed

8 files changed

+102
-3
lines changed

1deploysimplechat_banner.zip

3.08 MB
Binary file not shown.

2deploysimplechat_banner.zip

3.08 MB
Binary file not shown.

application/single_app/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def before_first_request():
4343
def inject_settings():
4444
settings = get_settings()
4545
public_settings = sanitize_settings_for_user(settings)
46+
# No change needed if you already return app_settings=public_settings
4647
return dict(app_settings=public_settings)
4748

4849
@app.template_filter('to_datetime')

application/single_app/route_frontend_admin_settings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ def admin_settings():
4848
# --- End Refined Default Checks ---
4949

5050

51+
# --- Add defaults for classification banner ---
52+
if 'classification_banner_enabled' not in settings:
53+
settings['classification_banner_enabled'] = False
54+
if 'classification_banner_text' not in settings:
55+
settings['classification_banner_text'] = ''
56+
if 'classification_banner_color' not in settings:
57+
settings['classification_banner_color'] = '#ffc107' # Bootstrap warning color
58+
5159
if request.method == 'GET':
5260
# --- Model fetching logic remains the same ---
5361
gpt_deployments = []
@@ -151,6 +159,11 @@ def admin_settings():
151159
flash('Error parsing Image Gen model data. Changes may not be saved.', 'warning')
152160
image_gen_model_obj = settings.get('image_gen_model', {'selected': [], 'all': []}) # Fallback
153161

162+
# --- Extract banner fields from form_data ---
163+
classification_banner_enabled = form_data.get('classification_banner_enabled') == 'on'
164+
classification_banner_text = form_data.get('classification_banner_text', '').strip()
165+
classification_banner_color = form_data.get('classification_banner_color', '#ffc107').strip()
166+
154167
# --- Construct new_settings Dictionary ---
155168
new_settings = {
156169
# General
@@ -296,6 +309,11 @@ def admin_settings():
296309
'speech_service_key': form_data.get('speech_service_key', '').strip(),
297310

298311
'metadata_extraction_model': form_data.get('metadata_extraction_model', '').strip(),
312+
313+
# --- Banner fields ---
314+
'classification_banner_enabled': classification_banner_enabled,
315+
'classification_banner_text': classification_banner_text,
316+
'classification_banner_color': classification_banner_color,
299317
}
300318

301319
logo_file = request.files.get('logo_file')

application/single_app/static/css/chats.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,9 @@ ol {
811811
border-radius: var(--bs-border-radius);
812812
margin-bottom: 0;
813813
}
814+
815+
#classification-banner {
816+
border-bottom: 1px solid #e0e0e0;
817+
box-shadow: 0 2px 4px rgba(0,0,0,0.02);
818+
z-index: 1050;
819+
}

application/single_app/templates/admin_settings.html

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,34 @@ <h5>Page Text (Markdown)</h5>
188188
style="white-space: pre-wrap; display: none;"
189189
></div>
190190
</div>
191+
192+
<!-- New Classification Banner Section -->
193+
<div class="card p-3 mb-3">
194+
<h5>Classification Banner</h5>
195+
<div class="form-check form-switch mb-2">
196+
<input class="form-check-input" type="checkbox" id="classification_banner_enabled" name="classification_banner_enabled"
197+
{% if settings.classification_banner_enabled %}checked{% endif %}>
198+
<label class="form-check-label ms-2" for="classification_banner_enabled">
199+
Enable Classification Banner
200+
</label>
201+
</div>
202+
<div class="mb-2">
203+
<label for="classification_banner_text" class="form-label">Banner Text</label>
204+
<input type="text" class="form-control" id="classification_banner_text" name="classification_banner_text"
205+
value="{{ settings.classification_banner_text }}">
206+
</div>
207+
<div class="mb-2">
208+
<label for="classification_banner_color" class="form-label">Banner Color</label>
209+
<input type="color" class="form-control form-control-color" id="classification_banner_color" name="classification_banner_color"
210+
value="{{ settings.classification_banner_color or '#ffc107' }}" style="width: 3rem; height: 2rem;">
211+
</div>
212+
<div class="mb-2">
213+
<span id="classification-banner-preview"
214+
style="display:inline-block; padding:0.5em 1em; border-radius:0.3em; font-weight:bold; color:#212529; background:{{ settings.classification_banner_color or '#ffc107' }};">
215+
{{ settings.classification_banner_text or 'Banner Preview' }}
216+
</span>
217+
</div>
218+
</div>
191219
</div>
192220

193221

@@ -746,7 +774,7 @@ <h5>Video Indexer Settings</h5>
746774
value="{{ settings.video_indexer_api_key or '' }}">
747775
<button type="button" class="btn btn-outline-secondary"
748776
id="toggle_video_indexer_api_key">Show</button>
749-
</div>
777+
</div>
750778
</div>
751779

752780
<div class="mb-3">
@@ -1685,6 +1713,22 @@ <h5>File Processing Logs</h5>
16851713
</form>
16861714
</div>
16871715
{% endblock %}
1716+
<script>
1717+
// Live preview for banner in admin
1718+
document.addEventListener('DOMContentLoaded', function() {
1719+
const textInput = document.getElementById('classification_banner_text');
1720+
const colorInput = document.getElementById('classification_banner_color');
1721+
const preview = document.getElementById('classification-banner-preview');
1722+
function updatePreview() {
1723+
preview.textContent = textInput.value || 'Banner Preview';
1724+
preview.style.background = colorInput.value;
1725+
}
1726+
if (textInput && colorInput && preview) {
1727+
textInput.addEventListener('input', updatePreview);
1728+
colorInput.addEventListener('input', updatePreview);
1729+
}
1730+
});
1731+
</script>
16881732

16891733
{% block scripts %}
16901734

application/single_app/templates/base.html

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,23 @@
2222

2323
<style>
2424
body {
25+
/* Default: navbar height only */
2526
padding-top: 56px;
2627
overflow-x: hidden;
2728
height: 100%;
2829
}
30+
/* Add this: if banner is present, increase padding-top */
31+
#classification-banner + nav.navbar.fixed-top {
32+
top: 40px; /* Height of the banner */
33+
}
34+
#classification-banner {
35+
height: 40px;
36+
line-height: 40px;
37+
}
38+
/* Adjust body padding if banner is present */
39+
body.has-classification-banner {
40+
padding-top: 96px; /* 56px navbar + 40px banner */
41+
}
2942

3043
.main-content {
3144
margin-top: 10px;
@@ -109,9 +122,26 @@
109122
{% block head %}{% endblock %}
110123
</head>
111124

112-
<body class="d-flex flex-column min-vh-100">
125+
<body class="d-flex flex-column min-vh-100{% if app_settings.classification_banner_enabled and app_settings.classification_banner_text %} has-classification-banner{% endif %}">
126+
{% if app_settings.classification_banner_enabled and app_settings.classification_banner_text %}
127+
<div id="classification-banner"
128+
style="background: {{ app_settings.classification_banner_color or '#ffc107' }};
129+
color: #212529;
130+
text-align: center;
131+
font-weight: bold;
132+
padding: 0.5em 0;
133+
font-size: 1.1em;
134+
letter-spacing: 0.5px;
135+
position: fixed;
136+
top: 0;
137+
left: 0;
138+
width: 100%;
139+
z-index: 1051;">
140+
{{ app_settings.classification_banner_text }}
141+
</div>
142+
{% endif %}
113143
<!-- Navigation Bar -->
114-
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
144+
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top" style="{% if app_settings.classification_banner_enabled and app_settings.classification_banner_text %}top: 40px;{% endif %}">
115145
<div class="container-fluid">
116146
{% if app_settings.show_logo %}
117147
{% if app_settings.custom_logo_base64 %}

deploysimplechat_banner.zip

3.08 MB
Binary file not shown.

0 commit comments

Comments
 (0)