Modifica visualizzazione statistiche/elenco modelli
This commit is contained in:
@@ -6,7 +6,6 @@ import ChatInput from "./ChatInput";
|
||||
import SessionTable from "./SessionTable";
|
||||
import NoSessionBox from "./NoSessionBox";
|
||||
import ModelOverview from "./ModelOverview";
|
||||
import LmStats from "./LmStats";
|
||||
|
||||
export default function ChatLayout({
|
||||
theme,
|
||||
@@ -76,10 +75,7 @@ export default function ChatLayout({
|
||||
|
||||
<div className="flex-grow-1 overflow-auto" style={{ minHeight: 0 }}>
|
||||
{showModelPage ? (
|
||||
<div>
|
||||
<LmStats />
|
||||
<ModelOverview onBackToChat={() => setShowModelPage(false)} />
|
||||
</div>
|
||||
<ModelOverview onBackToChat={() => setShowModelPage(false)} />
|
||||
) : (
|
||||
/* AREA SCROLLABILE */
|
||||
<ChatWindow messages={messages} loading={loading} theme={theme} />
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// src/ModelOverview.jsx
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import LmStats from "./LmStats";
|
||||
|
||||
export default function ModelOverview({ onBackToChat }) {
|
||||
const [defaultModel, setDefaultModel] = useState("");
|
||||
const [modelInfo, setModelInfo] = useState([]);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [showStats, setShowStats] = useState(false); // 👈 nuovo stato toggle
|
||||
|
||||
const fetchModelData = async () => {
|
||||
setLoading(true);
|
||||
@@ -58,63 +60,77 @@ export default function ModelOverview({ onBackToChat }) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="d-flex justify-content-between mb-3">
|
||||
<button className="btn btn-outline-primary" onClick={onBackToChat}>
|
||||
⬅ Torna alla chat
|
||||
</button>
|
||||
<button className="btn btn-outline-success" onClick={updateModelData}>
|
||||
🔄 Aggiorna dati modelli
|
||||
</button>
|
||||
<div className="d-flex justify-content-between align-items-center mb-3">
|
||||
<div className="btn-group">
|
||||
<button className="btn btn-outline-primary" onClick={onBackToChat}>
|
||||
⬅ Torna alla chat
|
||||
</button>
|
||||
<button className="btn btn-outline-success" onClick={updateModelData}>
|
||||
🔄 Aggiorna dati modelli
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
className={`btn ${showStats ? "btn-secondary" : "btn-outline-secondary"}`}
|
||||
onClick={() => setShowStats(prev => !prev)}
|
||||
>
|
||||
{showStats ? "📋 Mostra elenco modelli" : "📊 Mostra statistiche"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-3">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder="🔍 Cerca modello per nome..."
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{showStats ? (
|
||||
<LmStats />
|
||||
) : (
|
||||
<>
|
||||
<div className="mb-3">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder="🔍 Cerca modello per nome..."
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="table-responsive">
|
||||
<table className="table table-bordered table-hover align-middle">
|
||||
<thead className="table-light">
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Descrizione</th>
|
||||
{/*<th>Anno</th>*/}
|
||||
<th>Caratteristiche</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loading && (
|
||||
<tr>
|
||||
<td colSpan="4" className="text-center">Caricamento…</td>
|
||||
</tr>
|
||||
)}
|
||||
{!loading && filteredModels.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan="4" className="text-center">Nessun modello trovato</td>
|
||||
</tr>
|
||||
)}
|
||||
{!loading && filteredModels.map((model) => (
|
||||
<tr key={model.name}>
|
||||
<td>{model.name}</td>
|
||||
<td>{model.description || "—"}</td>
|
||||
{/*<td>{model.year || "—"}</td>*/}
|
||||
<td>
|
||||
<ul className="mb-0 small">
|
||||
{Array.isArray(model.features) && model.features.length > 0
|
||||
? model.features.map((f, i) => <li key={i}>{f}</li>)
|
||||
: <li>—</li>}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-bordered table-hover align-middle">
|
||||
<thead className="table-light">
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Caratteristiche</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loading && (
|
||||
<tr>
|
||||
<td colSpan="3" className="text-center">Caricamento…</td>
|
||||
</tr>
|
||||
)}
|
||||
{!loading && filteredModels.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan="3" className="text-center">Nessun modello trovato</td>
|
||||
</tr>
|
||||
)}
|
||||
{!loading && filteredModels.map((model) => (
|
||||
<tr key={model.name}>
|
||||
<td>{model.name}</td>
|
||||
<td>{model.description || "—"}</td>
|
||||
<td>
|
||||
<ul className="mb-0 small">
|
||||
{Array.isArray(model.features) && model.features.length > 0
|
||||
? model.features.map((f, i) => <li key={i}>{f}</li>)
|
||||
: <li>—</li>}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user