-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsys_settings.py
More file actions
101 lines (86 loc) · 3.87 KB
/
sys_settings.py
File metadata and controls
101 lines (86 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- coding: utf-8 -*-
"""
Copyright (c) Lodve Berre and NTNU Technology Transfer AS 2024.
This file is part of Really Nice IRL.
Really Nice IRL is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
Really Nice IRL is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Really Nice IRL. If not, see:
<https://www.gnu.org/licenses/agpl-3.0.html>.
"""
import streamlit as st
import base
import ui
from streamlit import session_state as ss
def on_save_system_settings():
"""
Event handler for saving the current system settings to the database.
Returns
-------
None.
"""
settings = ss.system_settings
settings.logo_uri = ss.logo_uri
settings.logo_uri_dark = ss.logo_uri_dark
settings.logo_uri_light = ss.logo_uri_light
settings.noreply_address = ss.noreply_address
settings.noreply_body = ss.noreply_body
settings.show_valuations = int(ss.show_valuations)
settings.forward_ass_comments = int(ss.forward_ass_comments)
settings.update()
edited_rows = ss.startup_value_matrix['edited_rows']
base.update_startup_values(edited_rows)
edited_rows = ss.license_value_matrix['edited_rows']
base.update_license_values(edited_rows)
#
# The actual UI.
#
dark_mode = (st.context.theme.type == 'dark')
ui.add_logo(dark_mode)
sys_settings = base.get_system_settings()
cols1 = st.columns(3)
cols1[0].text_input("Dark mode logo URI",
key="logo_uri_dark",
value=sys_settings.logo_uri_dark,
help="URI to the logo to use in the top left corner when in dark mode. Must be on-line, as Streamlit doesn't support SVG images in-line.")
cols1[1].text_input("Light mode logo URI",
key="logo_uri_light",
value=sys_settings.logo_uri_light,
help="URI to the logo to use in the top left corner when in light mode. Must be on-line, as Streamlit doesn't support SVG images in-line.")
cols1[2].text_input("Logo web page link",
key='logo_uri',
value=sys_settings.logo_uri,
help="The web page to redirect users to when they click the logo image in the top left corner.")
cols2 = st.columns(3, vertical_alignment="bottom")
cols2[0].checkbox("Keep assessment comments",
key="forward_ass_comments",
value=sys_settings.forward_ass_comments,
help="If checked, comments made in the targets and action points UI will be kept when making a new assessment.")
cols2[1].checkbox("Show valuations",
key="show_valuations",
value=sys_settings.show_valuations)
cols3 = st.columns(2, vertical_alignment="top")
cols3[0].text_input("noreply e-mail to use when e-mailing new users",
key="noreply_address",
value=sys_settings.noreply_address)
cols3[1].text_area("Welcome text to use in e-mail to new users",
key="noreply_body",
value=sys_settings.noreply_body)
st.markdown("Startup Valuation Matrix")
st.data_editor(base.get_irl_startup_value_matrix(),
use_container_width=True,
hide_index=True,
key="startup_value_matrix")
st.markdown("License Valuation Matrix")
st.data_editor(base.get_irl_license_value_matrix(),
use_container_width=True,
hide_index=True,
key="license_value_matrix")
st.button("Apply system settings",
on_click=on_save_system_settings)