Skip to content

Commit d86805e

Browse files
Features/use asgi (#11)
* Use asgi * Use asgi * Fix sonar * Fix sonar --------- Co-authored-by: FERNANDEZ BOADA Daniel <daniel.boada@soprasteria.com>
1 parent 6c86ea3 commit d86805e

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

openscada_lite/web/config_editor/routes.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@
2323

2424
logger = logging.getLogger(__name__)
2525

26+
SYSTEM_CONFIG_FILENAME = "system_config.json"
2627

2728
CONFIG_FILE = os.path.join(
28-
os.path.dirname(__file__), "..", "..", "..", "config", "system_config.json"
29+
os.path.dirname(__file__), "..", "..", "..", "config", SYSTEM_CONFIG_FILENAME
2930
)
3031

3132
config_router = APIRouter(prefix="/config-editor/api", tags=["ConfigEditor"])
3233

3334

3435
def normalize_config_filename(name: str) -> str:
35-
# Always return a valid config filename
36-
if name.endswith("system_config.json"):
36+
if name == "system_config":
37+
return SYSTEM_CONFIG_FILENAME
38+
if name.endswith(SYSTEM_CONFIG_FILENAME):
3739
return name
3840
if name.endswith(".json"):
3941
return name
40-
return f"{name}_system_config.json"
42+
return f"{name}_{SYSTEM_CONFIG_FILENAME}"
4143

4244

4345
@config_router.get("/config/{name}", response_class=JSONResponse)
@@ -55,9 +57,9 @@ async def get_config_by_name(name: str):
5557
@config_router.get("/configs", response_class=JSONResponse)
5658
async def list_configs():
5759
config_dir = os.path.dirname(CONFIG_FILE)
58-
files = [f for f in os.listdir(config_dir) if f.endswith("_system_config.json")]
60+
files = [f for f in os.listdir(config_dir) if f.endswith(f"_{SYSTEM_CONFIG_FILENAME}")]
5961
# Strip suffix for user display
60-
display_names = [f.replace("_system_config.json", "") for f in files]
62+
display_names = [f.replace(f"_{SYSTEM_CONFIG_FILENAME}", "") for f in files]
6163
return display_names
6264

6365

openscada_lite/web/config_editor/static/frontend/src/App.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ export default function App() {
9292
async function openLoadDialog() {
9393
try {
9494
const res = await fetch('/config-editor/api/configs');
95-
const files = await res.json();
95+
let files = await res.json();
96+
// Ensure system_config is present and first
97+
if (!files.includes("system_config")) {
98+
files.unshift("system_config");
99+
} else {
100+
// Move to first position if not already
101+
files = ["system_config", ...files.filter(f => f !== "system_config")];
102+
}
96103
setAvailableConfigs(files);
104+
setSelectedConfig("system_config"); // Default selection
97105
setShowLoadDialog(true);
98106
} catch (err) {
99107
alert('Failed to list configs: ' + err.message);

openscada_lite/web/config_editor/static/frontend/src/components/StreamsTab.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function StreamsTab({ config, setConfig }) {
8686

8787
<label>Port:</label>
8888
<input
89-
type="number"
89+
type="text"
9090
value={streams[selectedKey].port || ""}
9191
onChange={(e) => updateField("port", e.target.value)}
9292
/>

openscada_lite/web/scada/static/frontend/src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import MainView from "./components/MainView";
1717
import "leaflet/dist/leaflet.css";
1818

1919
const TAB_COMPONENTS = {
20-
Main: MainView,
20+
GIS: MainView,
2121
Image: ImageView,
2222
Datapoints: DatapointsView,
2323
Communications: CommunicationsView,

0 commit comments

Comments
 (0)