Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -316,22 +316,23 @@ def delete_current_ticket(selected_option):
|
|
| 316 |
|
| 317 |
def format_ticket_detail(ticket):
|
| 318 |
status_label, _ = get_ticket_status_display(ticket)
|
|
|
|
| 319 |
if "CHƯA TRẢ LỜI" in status_label and "HỎI THÊM" not in status_label:
|
| 320 |
-
status_str = "
|
| 321 |
-
status_color = "#
|
| 322 |
elif "HỎI THÊM" in status_label:
|
| 323 |
-
status_str = "
|
| 324 |
-
status_color = "#
|
| 325 |
else:
|
| 326 |
-
status_str = "
|
| 327 |
-
status_color = "#
|
| 328 |
|
| 329 |
reply_str = ticket.get('admin_reply', 'Chưa có phản hồi.')
|
| 330 |
-
|
| 331 |
-
header_html = f"""<div style="font-size:
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
</div>"""
|
| 336 |
|
| 337 |
history_conversation = ""
|
|
@@ -341,20 +342,16 @@ def format_ticket_detail(ticket):
|
|
| 341 |
time_stamp = msg.get("time", "")
|
| 342 |
text = msg.get("text", "")
|
| 343 |
if sender == "USER":
|
| 344 |
-
history_conversation += f"""<div
|
| 345 |
-
<b style="font-size: 15px; color: #1e7e34;">👤 Nhà nông ({time_stamp}):</b> {text}
|
| 346 |
-
</div>"""
|
| 347 |
else:
|
| 348 |
-
history_conversation += f"""<div
|
| 349 |
-
<b style="font-size: 15px; color: #1b4f72;">👨⚕️ Chuyên gia ({time_stamp}):</b> {text}
|
| 350 |
-
</div>"""
|
| 351 |
|
| 352 |
if not history_conversation:
|
| 353 |
-
history_conversation = f"""<div
|
| 354 |
|
| 355 |
-
conversation_html = f"""<div style="font-size:
|
| 356 |
-
|
| 357 |
-
|
| 358 |
{history_conversation}
|
| 359 |
</div>"""
|
| 360 |
|
|
@@ -450,7 +447,7 @@ def check_user_expert_status():
|
|
| 450 |
last_ticket = user_tickets[-1]
|
| 451 |
img_p = last_ticket.get('image_path', None)
|
| 452 |
h_info, c_info = format_ticket_detail(last_ticket)
|
| 453 |
-
return h_info + "<
|
| 454 |
|
| 455 |
def submit_expert_request(user_question, selected_plant, input_image):
|
| 456 |
global current_detected_disease_context
|
|
@@ -490,7 +487,7 @@ def submit_expert_request(user_question, selected_plant, input_image):
|
|
| 490 |
tickets.append(new_ticket)
|
| 491 |
save_expert_tickets(tickets)
|
| 492 |
h_info, c_info = format_ticket_detail(new_ticket)
|
| 493 |
-
return "📩 Đã gửi câu hỏi đến Hộp thư chờ Chuyên gia! Chuyên gia sẽ sớm xem xét và trả lời.", h_info + "<
|
| 494 |
|
| 495 |
def go_to_history_panel():
|
| 496 |
global current_user_role
|
|
@@ -702,7 +699,7 @@ LEAF_HERO_HEAD = r"""
|
|
| 702 |
const C = {
|
| 703 |
leaves: LEAF_CASES, cycleSeconds: 16, trailCycles: 2.6, compress: 0.42,
|
| 704 |
maxTurns: 3, planeSpread: 1, eccentricity: 0.25, alignToCourse: 1,
|
| 705 |
-
driftSpeed: 1.5, driftDir: [272, 53], viewRadius:
|
| 706 |
lead: 0.12, focus: [0.74, 0.42], scrim: "left", scrimStrength: 0.90,
|
| 707 |
moteCount: 400, glow: 1, showCoreBeam: true, interactive: true, crossColor: "#2d7a12",
|
| 708 |
pulseColor: "#10b981", rayColor: "#8fd45a"
|
|
@@ -716,14 +713,17 @@ LEAF_HERO_HEAD = r"""
|
|
| 716 |
else {
|
| 717 |
// đặt chữ thập vào giữa khoảng trống bên phải khối đăng nhập (khối ~13vw + 27rem)
|
| 718 |
const panelRight = 0.13 * w + Math.min(432, 0.81 * w);
|
| 719 |
-
const fx = ((panelRight + w) / 2) / w;
|
| 720 |
-
C.focus = [Math.min(0.
|
| 721 |
}
|
| 722 |
C.scrim = narrow ? "top" : "left";
|
| 723 |
C.scrimStrength = narrow ? 0.90 : 0.90;
|
| 724 |
-
C.viewRadius = narrow ? 2.
|
| 725 |
C.lead = narrow ? 0.05 : 0.12;
|
| 726 |
C.glow = narrow ? 0.8 : 1;
|
|
|
|
|
|
|
|
|
|
| 727 |
}
|
| 728 |
applyResponsive();
|
| 729 |
|
|
@@ -810,7 +810,7 @@ LEAF_HERO_HEAD = r"""
|
|
| 810 |
else if (edge === 1) { x = width - rng() * width * 0.25; y = rng() * height; }
|
| 811 |
else if (edge === 2) { x = rng() * width; y = rng() * height * 0.2; }
|
| 812 |
else { x = rng() * width; y = height - rng() * height * 0.2; }
|
| 813 |
-
BORDER_LEAVES.push({ x, y, size: (40 + rng() * 60) *
|
| 814 |
}
|
| 815 |
}
|
| 816 |
function drawBorderLeaves(t) {
|
|
@@ -854,7 +854,7 @@ LEAF_HERO_HEAD = r"""
|
|
| 854 |
const T = 1.05, p = (clk % T) / T, g = (x, mu, s) => Math.exp(-((x - mu) * (x - mu)) / (2 * s * s));
|
| 855 |
return Math.min(1, g(p, 0.07, 0.045) + 0.58 * g(p, 0.27, 0.05));
|
| 856 |
}
|
| 857 |
-
function crossBaseR() { return Math.max(
|
| 858 |
|
| 859 |
// Tia sáng xoay quanh chữ thập
|
| 860 |
function drawRays(clk, env) {
|
|
@@ -995,7 +995,7 @@ LEAF_HERO_HEAD = r"""
|
|
| 995 |
}
|
| 996 |
|
| 997 |
shots.sort((a, b) => b.depth - a.depth);
|
| 998 |
-
const sizeScale = Math.min(width, height) / 500 *
|
| 999 |
const drawShot = (o, index) => {
|
| 1000 |
const depth = Math.min(1.3, Math.max(0.5, o.s)), size = o.el.p.size * depth * sizeScale, bright = (o.el.p.glow ?? 1) * k, R = size * 3;
|
| 1001 |
ctx.globalAlpha = Math.min(0.7, 0.5 * bright); ctx.drawImage(glowSprite(o.el.p.color), o.x - R, o.y - R, R * 2, R * 2); ctx.globalAlpha = 1;
|
|
@@ -1004,9 +1004,11 @@ LEAF_HERO_HEAD = r"""
|
|
| 1004 |
|
| 1005 |
let idx = 0;
|
| 1006 |
while (idx < shots.length && shots[idx].depth > camDist) drawShot(shots[idx], idx++);
|
|
|
|
| 1007 |
drawRays(clock, env);
|
| 1008 |
drawHeartbeat(clock, env);
|
| 1009 |
drawCross(k, env);
|
|
|
|
| 1010 |
while (idx < shots.length) drawShot(shots[idx], idx++);
|
| 1011 |
drawBorderLeaves(t);
|
| 1012 |
|
|
@@ -1035,10 +1037,11 @@ LEAF_HERO_HEAD = r"""
|
|
| 1035 |
let prevOnLogin = null;
|
| 1036 |
setInterval(function () {
|
| 1037 |
const el = document.getElementById("login_wrapper");
|
| 1038 |
-
const
|
|
|
|
| 1039 |
document.body.classList.toggle("leaf-on", onLogin);
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
// Khi vừa quay lại màn đăng nhập (vd sau khi đăng xuất) -> đưa trang về đầu để login không bị lạc
|
| 1043 |
if (onLogin && prevOnLogin === false) { try { window.scrollTo(0, 0); } catch (e) {} }
|
| 1044 |
prevOnLogin = onLogin;
|
|
@@ -1056,158 +1059,173 @@ LEAF_HERO_HEAD = r"""
|
|
| 1056 |
"""
|
| 1057 |
|
| 1058 |
custom_css = """
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1062 |
}
|
| 1063 |
-
|
| 1064 |
-
.
|
| 1065 |
-
|
| 1066 |
-
|
|
|
|
| 1067 |
}
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
| 1074 |
-
|
| 1075 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
}
|
| 1077 |
-
.
|
| 1078 |
-
|
|
|
|
|
|
|
|
|
|
| 1079 |
}
|
| 1080 |
-
.
|
| 1081 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1082 |
}
|
| 1083 |
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
.main-title-layout { display: flex; align-items: center; justify-content: center; gap: 15px; margin: 0 auto; width: fit-content; }
|
| 1092 |
-
.medical-cross-red {
|
| 1093 |
-
width: 42px; height: 42px; background: #e74c3c; position: relative; border-radius: 8px; flex-shrink: 0;
|
| 1094 |
-
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35); display: inline-block; vertical-align: middle;
|
| 1095 |
-
animation: pulseGlow 2.5s infinite ease-in-out;
|
| 1096 |
}
|
| 1097 |
-
.
|
| 1098 |
-
.
|
| 1099 |
-
.
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
.
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
border: none !important; border-radius: 12px !important; box-shadow: 0 5px 15px rgba(0, 121, 101, 0.2) !important; height: 48px; cursor: pointer;
|
| 1109 |
-
transition: all 0.25s ease !important;
|
| 1110 |
}
|
| 1111 |
-
.scan-btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
-
border-radius: 12px !important;
|
| 1121 |
-
height: 48px !important;
|
| 1122 |
-
cursor: pointer !important;
|
| 1123 |
-
box-shadow: 0 6px 18px rgba(211, 84, 0, 0.4) !important;
|
| 1124 |
-
transition: all 0.25s ease !important;
|
| 1125 |
-
margin-top: 10px !important;
|
| 1126 |
}
|
| 1127 |
-
.
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
box-shadow: 0 8px 24px rgba(230, 126, 34, 0.55) !important;
|
| 1131 |
}
|
| 1132 |
-
|
| 1133 |
-
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
height: 32px !important; font-size: 13px !important; cursor: pointer; transition: all 0.2s ease !important;
|
| 1137 |
-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important; display: inline-flex !important; align-items: center; justify-content: center;
|
| 1138 |
}
|
| 1139 |
-
.
|
|
|
|
| 1140 |
|
| 1141 |
-
/*
|
| 1142 |
-
.
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
display: flex !important; align-items: center !important; justify-content: center !important; white-space: nowrap !important;
|
| 1148 |
}
|
| 1149 |
-
.
|
| 1150 |
|
| 1151 |
-
/*
|
| 1152 |
.delete-btn-style {
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
cursor: pointer !important;
|
| 1160 |
-
height: 100% !important;
|
| 1161 |
-
min-height: 82px !important;
|
| 1162 |
-
margin: 0 !important;
|
| 1163 |
-
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25) !important;
|
| 1164 |
-
transition: all 0.25s ease !important;
|
| 1165 |
-
display: flex !important;
|
| 1166 |
-
align-items: center !important;
|
| 1167 |
-
justify-content: center !important;
|
| 1168 |
-
}
|
| 1169 |
-
.delete-btn-style:hover {
|
| 1170 |
-
filter: brightness(1.1) !important;
|
| 1171 |
-
transform: translateY(-1px) !important;
|
| 1172 |
-
box-shadow: 0 6px 18px rgba(192, 57, 43, 0.4) !important;
|
| 1173 |
}
|
|
|
|
| 1174 |
|
| 1175 |
-
|
| 1176 |
-
background: linear-gradient(135deg, #f39c12, #d35400) !important; color: white !important; font-weight: 700 !important;
|
| 1177 |
-
border: none !important; border-radius: 12px !important; cursor: pointer; height: 48px !important;
|
| 1178 |
-
box-shadow: 0 5px 15px rgba(243, 156, 18, 0.3) !important; transition: all 0.25s ease !important;
|
| 1179 |
-
}
|
| 1180 |
-
.history-back-btn-style:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(211, 84, 0, 0.45) !important; }
|
| 1181 |
-
.hospital-header { background: linear-gradient(135deg, #004b39 0%, #007965 60%, #00bfa5 100%); color: white; padding: 25px; border-radius: 20px; margin-bottom: 15px; }
|
| 1182 |
-
.gr-group {
|
| 1183 |
-
border: 1px solid #d4deda !important;
|
| 1184 |
-
background: #ffffff !important;
|
| 1185 |
-
border-radius: 16px !important;
|
| 1186 |
-
margin-bottom: 12px !important;
|
| 1187 |
-
}
|
| 1188 |
#prescription_col .textbox_custom {
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
}
|
|
|
|
|
|
|
| 1193 |
#chatbot_col {
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
}
|
| 1200 |
#chatbot_col .chatbot_custom {
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
}
|
| 1205 |
-
.chatbot-title-container { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 8px; }
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1210 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1211 |
/* ===================== LEAF HERO LOGIN (v4) ===================== */
|
| 1212 |
#leaf-bg {
|
| 1213 |
position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0;
|
|
@@ -1234,12 +1252,14 @@ body.leaf-on footer { display: none !important; }
|
|
| 1234 |
#login_content_col {
|
| 1235 |
position: fixed !important; top: 0 !important; bottom: 0 !important; left: 13vw !important; right: auto !important;
|
| 1236 |
z-index: 20 !important;
|
| 1237 |
-
width: 27rem !important; max-width: 80vw !important; margin: 0 !important;
|
|
|
|
| 1238 |
box-sizing: border-box !important;
|
| 1239 |
-
display: flex !important; flex-direction: column !important; justify-content: center !important; gap:
|
| 1240 |
overflow-y: auto !important;
|
| 1241 |
background: transparent !important; border: none !important; box-shadow: none !important;
|
| 1242 |
-webkit-backdrop-filter: none !important; backdrop-filter: none !important;
|
|
|
|
| 1243 |
}
|
| 1244 |
/* Khối sát nhau: bỏ margin thừa của Gradio, thu gọn ô lỗi rỗng */
|
| 1245 |
#login_wrapper .block, #login_wrapper .form { margin: 0 !important; }
|
|
@@ -1251,29 +1271,33 @@ body.leaf-on footer { display: none !important; }
|
|
| 1251 |
}
|
| 1252 |
|
| 1253 |
/* Brand head: badge (nhịp tim) + tên trung tâm nổi bật */
|
| 1254 |
-
.lv4-head { display: flex; align-items:
|
| 1255 |
-
.lv4-badge { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px;
|
| 1256 |
display: grid; place-items: center;
|
| 1257 |
background: radial-gradient(circle at 35% 30%, #8fcb5e, #2f8b1c);
|
| 1258 |
box-shadow: 0 8px 20px -8px rgba(45,122,18,0.7), inset 0 1px 0 rgba(255,255,255,0.5); }
|
| 1259 |
.lv4-badge svg { width: 23px; height: 23px; }
|
| 1260 |
.lv4-heart { transform-origin: center; animation: lv4-beat 1.05s ease-in-out infinite; }
|
| 1261 |
.lv4-copy { min-width: 0; }
|
| 1262 |
-
.lv4-title { margin: 0; font-weight: 800; line-height: 1.
|
| 1263 |
font-size: clamp(1.5rem, 2.6vw, 2.1rem); color: #16281a; }
|
| 1264 |
.lv4-accent { background: linear-gradient(120deg, #34d399, #059669 55%, #2d7a12);
|
| 1265 |
-webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
|
| 1266 |
-
.lv4-sub { margin: .
|
| 1267 |
@keyframes lv4-beat { 0%,100%{transform:scale(1);} 6%{transform:scale(1.22);} 12%{transform:scale(1);} 26%{transform:scale(1.13);} 34%{transform:scale(1);} }
|
| 1268 |
-
@
|
|
|
|
|
|
|
| 1269 |
|
| 1270 |
/* Ô nhập kiểu leaf v4 */
|
| 1271 |
#login_wrapper .gr-form, #login_wrapper .block, #login_wrapper .form { background: transparent !important; border: none !important; box-shadow: none !important; }
|
| 1272 |
-
#login_wrapper label span, #login_wrapper .gr-box label { color: #
|
|
|
|
| 1273 |
#login_wrapper input[type="text"], #login_wrapper input[type="password"] {
|
| 1274 |
-
background: rgba(255,255,255,0.
|
| 1275 |
-
border-radius: 14px !important; color: #16281a !important; font-size: 15px !important; min-height:
|
| 1276 |
padding: 0 16px !important; -webkit-backdrop-filter: blur(6px) !important; backdrop-filter: blur(6px) !important;
|
|
|
|
| 1277 |
transition: all 0.2s ease !important;
|
| 1278 |
}
|
| 1279 |
#login_wrapper input::placeholder { color: #5f7255 !important; }
|
|
@@ -1285,15 +1309,20 @@ body.leaf-on footer { display: none !important; }
|
|
| 1285 |
|
| 1286 |
/* Nút lớn KÍCH HOẠT PHIÊN XÉT NGHIỆM */
|
| 1287 |
#login_wrapper .scan-btn {
|
| 1288 |
-
|
| 1289 |
-
|
|
|
|
| 1290 |
color: #fff !important; border: none !important; cursor: pointer;
|
| 1291 |
background: linear-gradient(135deg, #10b981, #047857) !important;
|
| 1292 |
box-shadow: 0 16px 34px -14px rgba(5,150,105,0.75), inset 0 1px 0 rgba(255,255,255,0.25) !important;
|
| 1293 |
transition: all 0.2s ease !important;
|
| 1294 |
}
|
|
|
|
|
|
|
| 1295 |
#login_wrapper .scan-btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 20px 40px -14px rgba(5,150,105,0.85) !important; }
|
|
|
|
| 1296 |
#login_wrapper .scan-btn:active { transform: translateY(0); }
|
|
|
|
| 1297 |
|
| 1298 |
/* Tài khoản thử nghiệm */
|
| 1299 |
.lv4-demo { margin-top: .8rem; font-size: .8rem; color: #5f7255; }
|
|
@@ -1311,6 +1340,43 @@ body.leaf-on footer { display: none !important; }
|
|
| 1311 |
/* =================== END LEAF HERO LOGIN =================== */
|
| 1312 |
"""
|
| 1313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1314 |
initial_ticket_text, initial_ticket_img = check_user_expert_status()
|
| 1315 |
|
| 1316 |
with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI", css=custom_css, head=LEAF_HERO_HEAD) as demo:
|
|
@@ -1321,11 +1387,9 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
|
|
| 1321 |
<div class="lv4-badge" aria-hidden="true">
|
| 1322 |
<svg class="lv4-heart" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#fff" stroke-width="3.4" stroke-linecap="round"/></svg>
|
| 1323 |
</div>
|
| 1324 |
-
<
|
| 1325 |
-
<h1 class="lv4-title">Trung tâm Chẩn đoán & Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</h1>
|
| 1326 |
-
<p class="lv4-sub">Xác thực để mở phiên xét nghiệm mô lá.</p>
|
| 1327 |
-
</div>
|
| 1328 |
</div>
|
|
|
|
| 1329 |
""")
|
| 1330 |
username_input = gr.Textbox(label="Tên đăng nhập", placeholder="Nhập tên đăng nhập", max_lines=1)
|
| 1331 |
password_input = gr.Textbox(label="Mật khẩu", type="password", placeholder="••••••••", max_lines=1)
|
|
@@ -1342,33 +1406,27 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
|
|
| 1342 |
with gr.Column(visible=False) as main_panel:
|
| 1343 |
with gr.Row(elem_classes="hospital-header"):
|
| 1344 |
with gr.Column(scale=10, elem_classes="hospital-header-center"):
|
| 1345 |
-
gr.HTML(
|
| 1346 |
-
|
| 1347 |
-
<div class="medical-cross-red"></div>
|
| 1348 |
-
<h1>TRUNG TÂM CHẨN ĐOÁN & ĐIỀU TRỊ BỆNH CÂY TRỒNG CÔNG NGHỆ CAO</h1>
|
| 1349 |
-
</div>
|
| 1350 |
-
<p>Hệ thống tự động phân tích thị giác học sâu v8, phát hiện mầm bệnh thực vật và kết xuất phác đồ điều trị thời gian thực</p>
|
| 1351 |
-
""")
|
| 1352 |
-
with gr.Column(scale=2, min_width=210):
|
| 1353 |
with gr.Row():
|
| 1354 |
-
btn_logout = gr.Button("
|
| 1355 |
with gr.Row():
|
| 1356 |
with gr.Column(scale=10):
|
| 1357 |
with gr.Group(elem_classes="gr-group"):
|
| 1358 |
-
gr.
|
| 1359 |
plant_dropdown = gr.Dropdown(
|
| 1360 |
choices=["Cây lúa", "Cây ớt", "Cây cà chua", "Cây dâu tây", "Cây cà phê", "Cây ngô (Bắp)"],
|
| 1361 |
value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
|
| 1362 |
with gr.Group(elem_classes="gr-group"):
|
| 1363 |
image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370)
|
| 1364 |
gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
|
| 1365 |
-
btn_analyze = gr.Button("
|
| 1366 |
gr.HTML("</div>")
|
| 1367 |
with gr.Column(scale=11, elem_id="prescription_col"):
|
| 1368 |
with gr.Group(elem_classes="gr-group"):
|
| 1369 |
-
gr.
|
| 1370 |
image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370)
|
| 1371 |
-
gr.
|
| 1372 |
text_output = gr.Textbox(
|
| 1373 |
label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
|
| 1374 |
lines=5,
|
|
@@ -1377,8 +1435,8 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
|
|
| 1377 |
|
| 1378 |
with gr.Column(scale=12, elem_id="chatbot_col"):
|
| 1379 |
with gr.Row(elem_classes="chatbot-title-container"):
|
| 1380 |
-
gr.
|
| 1381 |
-
btn_history_nav = gr.Button("
|
| 1382 |
chatbot = gr.Chatbot(
|
| 1383 |
value=[{"role": "assistant", "content": "🤖 Hệ thống đang đợi mẫu quét. Sau khi phân tích xong ảnh lá, tôi sẽ tự động nắm thông tin bệnh lý để kê đơn thuốc chính xác cho bà con!"}],
|
| 1384 |
height=550,
|
|
@@ -1391,75 +1449,84 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
|
|
| 1391 |
btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
|
| 1392 |
|
| 1393 |
with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
|
| 1394 |
-
gr.
|
| 1395 |
-
gr.
|
| 1396 |
expert_user_query = gr.Textbox(label="Thắc mắc về tình trạng lá cây / nghi ngờ bệnh:", placeholder="Ví dụ: AI đoán cháy bìa lá nhưng tui nghi là đốm vằn, nhờ chuyên gia xem kỹ lại...", lines=2)
|
| 1397 |
-
btn_send_expert = gr.Button("
|
| 1398 |
expert_status_box = gr.HTML(value=initial_ticket_text)
|
| 1399 |
expert_ticket_img_view = gr.Image(value=initial_ticket_img, label="Ảnh mẫu lá bệnh do nhà nông gửi lên", height=250, interactive=False)
|
| 1400 |
|
| 1401 |
-
gr.HTML("<div class='footer-text'>
|
| 1402 |
|
| 1403 |
with gr.Column(visible=False) as history_panel:
|
| 1404 |
with gr.Row(elem_classes="hospital-header"):
|
| 1405 |
with gr.Column(scale=10):
|
| 1406 |
gr.HTML("""
|
| 1407 |
-
<
|
| 1408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1409 |
""")
|
| 1410 |
with gr.Column(scale=2, min_width=150):
|
| 1411 |
-
btn_back_to_clinic = gr.Button("
|
| 1412 |
|
| 1413 |
with gr.Row():
|
| 1414 |
with gr.Column(visible=True) as user_diagnose_col:
|
| 1415 |
-
gr.
|
| 1416 |
history_diagnose_box = gr.Textbox(
|
| 1417 |
value=load_diagnose_history(),
|
| 1418 |
label="Lịch sử các ca bệnh đã quét",
|
| 1419 |
lines=15,
|
| 1420 |
interactive=False )
|
| 1421 |
-
btn_clear_diagnose = gr.Button("
|
| 1422 |
with gr.Column(visible=True) as user_chat_col:
|
| 1423 |
-
gr.
|
| 1424 |
history_chat_box = gr.Textbox(
|
| 1425 |
value=load_chat_history(),
|
| 1426 |
label="Lịch sử chat kê đơn thuốc",
|
| 1427 |
lines=15,
|
| 1428 |
interactive=False
|
| 1429 |
)
|
| 1430 |
-
btn_clear_chat = gr.Button("
|
| 1431 |
-
|
| 1432 |
-
gr.HTML("<hr style='margin: 25px 0; border: 1px solid #d4deda;'>")
|
| 1433 |
|
|
|
|
|
|
|
| 1434 |
with gr.Group(elem_classes="gr-group"):
|
| 1435 |
-
gr.
|
| 1436 |
|
| 1437 |
with gr.Row(elem_id="expert_select_row"):
|
| 1438 |
admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
|
| 1439 |
-
btn_delete_ticket = gr.Button("
|
| 1440 |
|
| 1441 |
with gr.Row():
|
| 1442 |
with gr.Column(scale=1):
|
| 1443 |
admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
|
| 1444 |
with gr.Column(scale=1):
|
| 1445 |
-
admin_ticket_img_display = gr.Image(label="
|
| 1446 |
|
| 1447 |
with gr.Row():
|
| 1448 |
admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
|
| 1449 |
|
| 1450 |
with gr.Row():
|
| 1451 |
with gr.Column(scale=1, visible=False) as admin_control_panel:
|
| 1452 |
-
gr.
|
| 1453 |
-
gr.
|
| 1454 |
-
admin_reply_input = gr.Textbox(label="
|
| 1455 |
-
btn_submit_admin_reply = gr.Button("
|
| 1456 |
admin_reply_status = gr.Markdown("")
|
| 1457 |
|
| 1458 |
with gr.Group(visible=True) as user_followup_panel:
|
| 1459 |
-
gr.
|
| 1460 |
-
gr.
|
| 1461 |
-
user_followup_input = gr.Textbox(label="Nội dung câu hỏi thêm
|
| 1462 |
-
btn_send_followup = gr.Button("
|
| 1463 |
|
| 1464 |
btn_login.click(
|
| 1465 |
login_auth,
|
|
|
|
| 316 |
|
| 317 |
def format_ticket_detail(ticket):
|
| 318 |
status_label, _ = get_ticket_status_display(ticket)
|
| 319 |
+
# Màu mang thông tin: hổ phách = đang chờ xử lý, xanh = đã xong.
|
| 320 |
if "CHƯA TRẢ LỜI" in status_label and "HỎI THÊM" not in status_label:
|
| 321 |
+
status_str = "Đang chờ chuyên gia trả lời"
|
| 322 |
+
status_color = "#b45309"
|
| 323 |
elif "HỎI THÊM" in status_label:
|
| 324 |
+
status_str = "Nhà nông đã hỏi thêm — chờ phản hồi"
|
| 325 |
+
status_color = "#b45309"
|
| 326 |
else:
|
| 327 |
+
status_str = "Đã được chuyên gia trả lời"
|
| 328 |
+
status_color = "#047857"
|
| 329 |
|
| 330 |
reply_str = ticket.get('admin_reply', 'Chưa có phản hồi.')
|
| 331 |
+
|
| 332 |
+
header_html = f"""<div style="font-size: 14.5px; color: #16281a; line-height: 1.7;">
|
| 333 |
+
<b>Mã yêu cầu:</b> #{ticket['id']} · <b>Thời gian:</b> {ticket['time']}<br>
|
| 334 |
+
<b>Loại cây:</b> <span style="color: #047857; font-weight: 700;">{ticket['plant']}</span><br>
|
| 335 |
+
<b>Câu hỏi từ nhà nông:</b> <span class="chip-q">{ticket['user_query']}</span>
|
| 336 |
</div>"""
|
| 337 |
|
| 338 |
history_conversation = ""
|
|
|
|
| 342 |
time_stamp = msg.get("time", "")
|
| 343 |
text = msg.get("text", "")
|
| 344 |
if sender == "USER":
|
| 345 |
+
history_conversation += f"""<div class="msg msg-user"><b>Nhà nông ({time_stamp}):</b> {text}</div>"""
|
|
|
|
|
|
|
| 346 |
else:
|
| 347 |
+
history_conversation += f"""<div class="msg msg-expert"><b>Chuyên gia ({time_stamp}):</b> {text}</div>"""
|
|
|
|
|
|
|
| 348 |
|
| 349 |
if not history_conversation:
|
| 350 |
+
history_conversation = f"""<div class="msg msg-expert">{reply_str}</div>"""
|
| 351 |
|
| 352 |
+
conversation_html = f"""<div style="font-size: 14.5px; color: #16281a; line-height: 1.7; width: 100%;">
|
| 353 |
+
<b>Trạng thái:</b> <span class="chip-status" style="color: {status_color};">{status_str}</span><br>
|
| 354 |
+
<b>Nội dung trao đổi với chuyên gia:</b>
|
| 355 |
{history_conversation}
|
| 356 |
</div>"""
|
| 357 |
|
|
|
|
| 447 |
last_ticket = user_tickets[-1]
|
| 448 |
img_p = last_ticket.get('image_path', None)
|
| 449 |
h_info, c_info = format_ticket_detail(last_ticket)
|
| 450 |
+
return h_info + "<hr class='soft-rule'>" + c_info, img_p
|
| 451 |
|
| 452 |
def submit_expert_request(user_question, selected_plant, input_image):
|
| 453 |
global current_detected_disease_context
|
|
|
|
| 487 |
tickets.append(new_ticket)
|
| 488 |
save_expert_tickets(tickets)
|
| 489 |
h_info, c_info = format_ticket_detail(new_ticket)
|
| 490 |
+
return "📩 Đã gửi câu hỏi đến Hộp thư chờ Chuyên gia! Chuyên gia sẽ sớm xem xét và trả lời.", h_info + "<hr class='soft-rule'>" + c_info, saved_img_path
|
| 491 |
|
| 492 |
def go_to_history_panel():
|
| 493 |
global current_user_role
|
|
|
|
| 699 |
const C = {
|
| 700 |
leaves: LEAF_CASES, cycleSeconds: 16, trailCycles: 2.6, compress: 0.42,
|
| 701 |
maxTurns: 3, planeSpread: 1, eccentricity: 0.25, alignToCourse: 1,
|
| 702 |
+
driftSpeed: 1.5, driftDir: [272, 53], viewRadius: 2.6, tilt: 45, spin: 252, roll: 13.5,
|
| 703 |
lead: 0.12, focus: [0.74, 0.42], scrim: "left", scrimStrength: 0.90,
|
| 704 |
moteCount: 400, glow: 1, showCoreBeam: true, interactive: true, crossColor: "#2d7a12",
|
| 705 |
pulseColor: "#10b981", rayColor: "#8fd45a"
|
|
|
|
| 713 |
else {
|
| 714 |
// đặt chữ thập vào giữa khoảng trống bên phải khối đăng nhập (khối ~13vw + 27rem)
|
| 715 |
const panelRight = 0.13 * w + Math.min(432, 0.81 * w);
|
| 716 |
+
const fx = ((panelRight + w * 0.92) / 2) / w; /* dời tâm ra giữa-phải để không trống bên phải */
|
| 717 |
+
C.focus = [Math.min(0.80, Math.max(0.60, fx)), 0.5];
|
| 718 |
}
|
| 719 |
C.scrim = narrow ? "top" : "left";
|
| 720 |
C.scrimStrength = narrow ? 0.90 : 0.90;
|
| 721 |
+
C.viewRadius = narrow ? 2.2 : 2.6;
|
| 722 |
C.lead = narrow ? 0.05 : 0.12;
|
| 723 |
C.glow = narrow ? 0.8 : 1;
|
| 724 |
+
/* Ở màn hẹp (<=767px) khối đăng nhập chiếm gần hết bề ngang -> chữ thập buộc phải
|
| 725 |
+
nằm trong vùng đó. Làm nó mờ hẳn (watermark) để không phá chữ, thay vì đè cứng lên form. */
|
| 726 |
+
C.heroAlpha = narrow ? 0.16 : 1;
|
| 727 |
}
|
| 728 |
applyResponsive();
|
| 729 |
|
|
|
|
| 810 |
else if (edge === 1) { x = width - rng() * width * 0.25; y = rng() * height; }
|
| 811 |
else if (edge === 2) { x = rng() * width; y = rng() * height * 0.2; }
|
| 812 |
else { x = rng() * width; y = height - rng() * height * 0.2; }
|
| 813 |
+
BORDER_LEAVES.push({ x, y, size: (40 + rng() * 60) * 1.14, baseAngle: (rng() - 0.5) * 1.2, swaySpeed: 0.4 + rng() * 0.8, swayAmp: 0.06 + rng() * 0.1, phase: rng() * TAU, color: LEAF_GREENS[Math.floor(rng() * LEAF_GREENS.length)], alpha: 0.35 + rng() * 0.45 });
|
| 814 |
}
|
| 815 |
}
|
| 816 |
function drawBorderLeaves(t) {
|
|
|
|
| 854 |
const T = 1.05, p = (clk % T) / T, g = (x, mu, s) => Math.exp(-((x - mu) * (x - mu)) / (2 * s * s));
|
| 855 |
return Math.min(1, g(p, 0.07, 0.045) + 0.58 * g(p, 0.27, 0.05));
|
| 856 |
}
|
| 857 |
+
function crossBaseR() { return Math.max(32, Math.min(width, height) * 0.0713); } /* to hơn ~20% */
|
| 858 |
|
| 859 |
// Tia sáng xoay quanh chữ thập
|
| 860 |
function drawRays(clk, env) {
|
|
|
|
| 995 |
}
|
| 996 |
|
| 997 |
shots.sort((a, b) => b.depth - a.depth);
|
| 998 |
+
const sizeScale = Math.min(width, height) / 500 * 1.14; /* lá to hơn ~20% */
|
| 999 |
const drawShot = (o, index) => {
|
| 1000 |
const depth = Math.min(1.3, Math.max(0.5, o.s)), size = o.el.p.size * depth * sizeScale, bright = (o.el.p.glow ?? 1) * k, R = size * 3;
|
| 1001 |
ctx.globalAlpha = Math.min(0.7, 0.5 * bright); ctx.drawImage(glowSprite(o.el.p.color), o.x - R, o.y - R, R * 2, R * 2); ctx.globalAlpha = 1;
|
|
|
|
| 1004 |
|
| 1005 |
let idx = 0;
|
| 1006 |
while (idx < shots.length && shots[idx].depth > camDist) drawShot(shots[idx], idx++);
|
| 1007 |
+
ctx.save(); ctx.globalAlpha = C.heroAlpha ?? 1;
|
| 1008 |
drawRays(clock, env);
|
| 1009 |
drawHeartbeat(clock, env);
|
| 1010 |
drawCross(k, env);
|
| 1011 |
+
ctx.restore();
|
| 1012 |
while (idx < shots.length) drawShot(shots[idx], idx++);
|
| 1013 |
drawBorderLeaves(t);
|
| 1014 |
|
|
|
|
| 1037 |
let prevOnLogin = null;
|
| 1038 |
setInterval(function () {
|
| 1039 |
const el = document.getElementById("login_wrapper");
|
| 1040 |
+
const exists = !!el;
|
| 1041 |
+
const onLogin = exists && el.offsetParent !== null;
|
| 1042 |
document.body.classList.toggle("leaf-on", onLogin);
|
| 1043 |
+
document.body.classList.toggle("app-on", exists && !onLogin); /* khu làm việc: lá vẫn bay nhưng rất mờ */
|
| 1044 |
+
active = true;
|
| 1045 |
// Khi vừa quay lại màn đăng nhập (vd sau khi đăng xuất) -> đưa trang về đầu để login không bị lạc
|
| 1046 |
if (onLogin && prevOnLogin === false) { try { window.scrollTo(0, 0); } catch (e) {} }
|
| 1047 |
prevOnLogin = onLogin;
|
|
|
|
| 1059 |
"""
|
| 1060 |
|
| 1061 |
custom_css = """
|
| 1062 |
+
/* ================= HỆ THỐNG THIẾT KẾ CHUNG (đồng bộ với màn đăng nhập) ================= */
|
| 1063 |
+
:root {
|
| 1064 |
+
--ink: #16281a;
|
| 1065 |
+
--ink-2: #3d5233;
|
| 1066 |
+
--ink-3: #6b7c68;
|
| 1067 |
+
--emerald: #10b981;
|
| 1068 |
+
--emerald-d: #047857;
|
| 1069 |
+
--leaf: #2d7a12;
|
| 1070 |
+
--line: rgba(90,110,70,0.20);
|
| 1071 |
+
--card: rgba(255,255,255,0.78);
|
| 1072 |
+
--card-2: rgba(255,255,255,0.62);
|
| 1073 |
+
--warn: #b45309; /* cảnh báo bệnh — màu mang thông tin, không trang trí */
|
| 1074 |
+
--danger: #b91c1c; /* chỉ dùng cho hành động xoá */
|
| 1075 |
+
--r: 16px;
|
| 1076 |
}
|
| 1077 |
+
|
| 1078 |
+
.gradio-container {
|
| 1079 |
+
background: transparent !important;
|
| 1080 |
+
font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
|
| 1081 |
+
color: var(--ink) !important;
|
| 1082 |
}
|
| 1083 |
+
body { background: #eaf5da !important; }
|
| 1084 |
+
body.app-on #leaf-bg { opacity: 0.12; } /* lá bay rất mờ phía sau khu làm việc */
|
| 1085 |
+
body.app-on footer { display: none !important; }
|
| 1086 |
+
|
| 1087 |
+
/* ---------------- Topbar mảnh (thay banner gradient lớn) ---------------- */
|
| 1088 |
+
.hospital-header {
|
| 1089 |
+
background: var(--card) !important;
|
| 1090 |
+
-webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
|
| 1091 |
+
border: 1px solid rgba(255,255,255,0.6) !important;
|
| 1092 |
+
box-shadow: 0 10px 30px -20px rgba(20,60,25,0.5) !important;
|
| 1093 |
+
color: var(--ink) !important;
|
| 1094 |
+
padding: 10px 16px !important; border-radius: 18px !important; margin-bottom: 14px !important;
|
| 1095 |
+
align-items: center !important;
|
| 1096 |
}
|
| 1097 |
+
.topbar { display: flex; align-items: center; gap: .75rem; min-width: 0; }
|
| 1098 |
+
.tb-badge {
|
| 1099 |
+
width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px; display: grid; place-items: center;
|
| 1100 |
+
background: radial-gradient(circle at 35% 30%, #8fcb5e, #2f8b1c);
|
| 1101 |
+
box-shadow: 0 8px 18px -8px rgba(45,122,18,0.7), inset 0 1px 0 rgba(255,255,255,0.5);
|
| 1102 |
}
|
| 1103 |
+
.tb-badge svg { width: 21px; height: 21px; }
|
| 1104 |
+
.tb-name { font-weight: 800; font-size: 15.5px; line-height: 1.25; letter-spacing: -.01em; color: var(--ink); }
|
| 1105 |
+
.tb-sub { font-size: 10.5px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
|
| 1106 |
+
.hospital-header-center { text-align: left !important; width: 100%; }
|
| 1107 |
+
|
| 1108 |
+
/* ---------------- Thẻ nội dung ---------------- */
|
| 1109 |
+
.gr-group {
|
| 1110 |
+
border: 1px solid var(--line) !important;
|
| 1111 |
+
background: var(--card) !important;
|
| 1112 |
+
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
| 1113 |
+
border-radius: var(--r) !important;
|
| 1114 |
+
margin-bottom: 12px !important;
|
| 1115 |
+
box-shadow: 0 10px 26px -22px rgba(20,60,25,0.55) !important;
|
| 1116 |
}
|
| 1117 |
|
| 1118 |
+
/* ------ Tiêu đề mục: số thứ tự + icon + chữ IN HOA (cùng ngôn ngữ với nhãn ở màn đăng nhập) ------ */
|
| 1119 |
+
.sec-head { display: flex; align-items: center; gap: .55rem; margin: 12px 12px 8px; }
|
| 1120 |
+
.sec-num {
|
| 1121 |
+
width: 22px; height: 22px; flex: 0 0 22px; border-radius: 7px; display: grid; place-items: center;
|
| 1122 |
+
font-size: 11.5px; font-weight: 800; color: #fff;
|
| 1123 |
+
background: linear-gradient(135deg, var(--emerald), var(--emerald-d));
|
| 1124 |
+
box-shadow: 0 6px 14px -8px rgba(5,150,105,0.9);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1125 |
}
|
| 1126 |
+
.sec-ico { width: 17px; height: 17px; flex: 0 0 17px; color: var(--emerald-d); }
|
| 1127 |
+
.sec-title { font-size: 11.5px; font-weight: 800; letter-spacing: .085em; line-height: 1.4; text-transform: uppercase; color: var(--ink-2); }
|
| 1128 |
+
.sec-note { margin: 0 12px 12px; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); }
|
| 1129 |
+
|
| 1130 |
+
/* ---------------- Nút chính ---------------- */
|
| 1131 |
+
.scan-btn {
|
| 1132 |
+
background: linear-gradient(135deg, var(--emerald), var(--emerald-d)) !important;
|
| 1133 |
+
color: #fff !important; font-weight: 800 !important; letter-spacing: .04em !important;
|
| 1134 |
+
border: none !important; border-radius: 13px !important; min-height: 48px !important; cursor: pointer;
|
| 1135 |
+
box-shadow: 0 14px 30px -14px rgba(5,150,105,0.8), inset 0 1px 0 rgba(255,255,255,0.25) !important;
|
| 1136 |
+
transition: all .2s ease !important;
|
|
|
|
|
|
|
| 1137 |
}
|
| 1138 |
+
.scan-btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 18px 36px -14px rgba(5,150,105,0.9) !important; }
|
| 1139 |
+
.scan-btn:active { transform: translateY(0); }
|
| 1140 |
+
|
| 1141 |
+
/* Nút phụ (đăng xuất / quay lại / lịch sử): viền nhẹ, không tô đặc */
|
| 1142 |
+
.logout-btn-style, .history-back-btn-style, .inline-history-btn {
|
| 1143 |
+
background: rgba(255,255,255,0.72) !important; color: var(--emerald-d) !important;
|
| 1144 |
+
border: 1px solid rgba(16,185,129,0.42) !important; font-weight: 700 !important;
|
| 1145 |
+
border-radius: 12px !important; cursor: pointer; box-shadow: none !important; filter: none !important;
|
| 1146 |
+
transition: all .2s ease !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1147 |
}
|
| 1148 |
+
.logout-btn-style:hover, .history-back-btn-style:hover, .inline-history-btn:hover {
|
| 1149 |
+
background: rgba(16,185,129,0.13) !important; border-color: var(--emerald) !important;
|
| 1150 |
+
color: var(--emerald-d) !important; transform: translateY(-1px); filter: none !important;
|
|
|
|
| 1151 |
}
|
| 1152 |
+
.logout-btn-style {
|
| 1153 |
+
height: 42px !important; min-width: 0 !important; padding: 0 18px !important; font-size: 13px !important;
|
| 1154 |
+
margin: 0 !important; white-space: nowrap !important;
|
| 1155 |
+
display: flex !important; align-items: center !important; justify-content: center !important;
|
|
|
|
|
|
|
| 1156 |
}
|
| 1157 |
+
.history-back-btn-style { height: 44px !important; }
|
| 1158 |
+
.inline-history-btn { height: 34px !important; font-size: 12.5px !important; padding: 0 14px !important; display: inline-flex !important; align-items: center; justify-content: center; }
|
| 1159 |
|
| 1160 |
+
/* Gửi chuyên gia — hành động chính của thẻ đó */
|
| 1161 |
+
.expert-send-btn {
|
| 1162 |
+
background: linear-gradient(135deg, #0ea371, var(--emerald-d)) !important; color: #fff !important;
|
| 1163 |
+
font-weight: 800 !important; font-size: 14.5px !important; border: none !important;
|
| 1164 |
+
border-radius: 13px !important; height: 48px !important; cursor: pointer !important; margin-top: 10px !important;
|
| 1165 |
+
box-shadow: 0 14px 30px -14px rgba(5,150,105,0.8) !important; transition: all .25s ease !important;
|
|
|
|
| 1166 |
}
|
| 1167 |
+
.expert-send-btn:hover { filter: brightness(1.06) !important; transform: translateY(-1px) !important; }
|
| 1168 |
|
| 1169 |
+
/* Xoá — đỏ vì đây thật sự là hành động phá huỷ dữ liệu */
|
| 1170 |
.delete-btn-style {
|
| 1171 |
+
background: rgba(185,28,28,0.08) !important; color: var(--danger) !important;
|
| 1172 |
+
border: 1px solid rgba(185,28,28,0.35) !important;
|
| 1173 |
+
font-weight: 700 !important; font-size: 13.5px !important; border-radius: 12px !important;
|
| 1174 |
+
cursor: pointer !important; height: 100% !important; min-height: 82px !important; margin: 0 !important;
|
| 1175 |
+
box-shadow: none !important; transition: all .2s ease !important;
|
| 1176 |
+
display: flex !important; align-items: center !important; justify-content: center !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1177 |
}
|
| 1178 |
+
.delete-btn-style:hover { background: rgba(185,28,28,0.16) !important; border-color: var(--danger) !important; filter: none !important; transform: none !important; }
|
| 1179 |
|
| 1180 |
+
/* ---------------- Khu 3: đơn thuốc (ưu tiên cao) ---------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1181 |
#prescription_col .textbox_custom {
|
| 1182 |
+
border-left: 4px solid var(--emerald) !important;
|
| 1183 |
+
background: rgba(255,255,255,0.85) !important;
|
| 1184 |
+
border-radius: 13px !important;
|
| 1185 |
}
|
| 1186 |
+
|
| 1187 |
+
/* ---------------- Khu 4: chatbot (ưu tiên thấp hơn — nhẹ hơn về thị giác) ---------------- */
|
| 1188 |
#chatbot_col {
|
| 1189 |
+
background: var(--card-2) !important;
|
| 1190 |
+
border: 1px solid var(--line) !important;
|
| 1191 |
+
border-radius: var(--r) !important;
|
| 1192 |
+
padding: 14px !important; margin-top: 10px !important;
|
| 1193 |
+
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
| 1194 |
}
|
| 1195 |
#chatbot_col .chatbot_custom {
|
| 1196 |
+
border-left: 3px solid rgba(16,185,129,0.5) !important;
|
| 1197 |
+
background: rgba(255,255,255,0.62) !important;
|
| 1198 |
+
border-radius: 12px !important;
|
| 1199 |
}
|
| 1200 |
+
.chatbot-title-container { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; margin-bottom: 8px; }
|
| 1201 |
+
|
| 1202 |
+
/* ---------------- Ô nhập trong khu làm việc ---------------- */
|
| 1203 |
+
.gradio-container input[type="text"], .gradio-container input[type="password"],
|
| 1204 |
+
.gradio-container textarea, .gradio-container select { border-radius: 12px !important; }
|
| 1205 |
+
.gradio-container label span { color: var(--ink-2) !important; }
|
| 1206 |
+
|
| 1207 |
+
.soft-rule { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
|
| 1208 |
+
.danger-soft, button.danger-soft {
|
| 1209 |
+
background: rgba(185,28,28,0.08) !important; color: var(--danger) !important;
|
| 1210 |
+
border: 1px solid rgba(185,28,28,0.32) !important; font-weight: 700 !important;
|
| 1211 |
+
border-radius: 12px !important; box-shadow: none !important;
|
| 1212 |
}
|
| 1213 |
+
.danger-soft:hover, button.danger-soft:hover { background: rgba(185,28,28,0.15) !important; border-color: var(--danger) !important; filter: none !important; }
|
| 1214 |
+
|
| 1215 |
+
/* Bong bóng hội thoại trong hồ sơ (sinh từ Python) */
|
| 1216 |
+
.msg { padding: 10px 14px; margin: 8px 0; border-radius: 12px; font-size: 14.5px; line-height: 1.55; color: var(--ink); }
|
| 1217 |
+
.msg b { font-size: 14px; }
|
| 1218 |
+
.msg-user { background: rgba(16,185,129,0.10); border-left: 4px solid var(--emerald); }
|
| 1219 |
+
.msg-user b { color: var(--emerald-d); }
|
| 1220 |
+
.msg-expert { background: rgba(255,255,255,0.85); border-left: 4px solid var(--leaf); }
|
| 1221 |
+
.msg-expert b { color: var(--leaf); }
|
| 1222 |
+
.chip-status { font-weight: 800; }
|
| 1223 |
+
.chip-q { background: rgba(16,185,129,0.12); padding: 2px 8px; border-radius: 6px; font-weight: 700; }
|
| 1224 |
+
|
| 1225 |
+
.footer-text { text-align: center; margin-top: 22px; color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
|
| 1226 |
+
|
| 1227 |
+
@keyframes pulseGlow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
|
| 1228 |
+
|
| 1229 |
/* ===================== LEAF HERO LOGIN (v4) ===================== */
|
| 1230 |
#leaf-bg {
|
| 1231 |
position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0;
|
|
|
|
| 1252 |
#login_content_col {
|
| 1253 |
position: fixed !important; top: 0 !important; bottom: 0 !important; left: 13vw !important; right: auto !important;
|
| 1254 |
z-index: 20 !important;
|
| 1255 |
+
width: 27rem !important; max-width: 80vw !important; margin: 0 !important;
|
| 1256 |
+
padding: 0 0 12vh 0 !important; /* padding-bottom kéo khối lên cao hơn một chút cho thoáng */
|
| 1257 |
box-sizing: border-box !important;
|
| 1258 |
+
display: flex !important; flex-direction: column !important; justify-content: center !important; gap: 12px !important;
|
| 1259 |
overflow-y: auto !important;
|
| 1260 |
background: transparent !important; border: none !important; box-shadow: none !important;
|
| 1261 |
-webkit-backdrop-filter: none !important; backdrop-filter: none !important;
|
| 1262 |
+
animation: lv4-in .6s cubic-bezier(.16,1,.3,1) both;
|
| 1263 |
}
|
| 1264 |
/* Khối sát nhau: bỏ margin thừa của Gradio, thu gọn ô lỗi rỗng */
|
| 1265 |
#login_wrapper .block, #login_wrapper .form { margin: 0 !important; }
|
|
|
|
| 1271 |
}
|
| 1272 |
|
| 1273 |
/* Brand head: badge (nhịp tim) + tên trung tâm nổi bật */
|
| 1274 |
+
.lv4-head { display: flex; align-items: center; gap: .85rem; margin-bottom: .35rem; }
|
| 1275 |
+
.lv4-badge { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px;
|
| 1276 |
display: grid; place-items: center;
|
| 1277 |
background: radial-gradient(circle at 35% 30%, #8fcb5e, #2f8b1c);
|
| 1278 |
box-shadow: 0 8px 20px -8px rgba(45,122,18,0.7), inset 0 1px 0 rgba(255,255,255,0.5); }
|
| 1279 |
.lv4-badge svg { width: 23px; height: 23px; }
|
| 1280 |
.lv4-heart { transform-origin: center; animation: lv4-beat 1.05s ease-in-out infinite; }
|
| 1281 |
.lv4-copy { min-width: 0; }
|
| 1282 |
+
.lv4-title { margin: 0; min-width: 0; font-weight: 800; line-height: 1.15; letter-spacing: -.015em;
|
| 1283 |
font-size: clamp(1.5rem, 2.6vw, 2.1rem); color: #16281a; }
|
| 1284 |
.lv4-accent { background: linear-gradient(120deg, #34d399, #059669 55%, #2d7a12);
|
| 1285 |
-webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
|
| 1286 |
+
.lv4-sub { margin: .5rem 0 0; font-size: .9rem; line-height: 1.5; color: #4a5f47; }
|
| 1287 |
@keyframes lv4-beat { 0%,100%{transform:scale(1);} 6%{transform:scale(1.22);} 12%{transform:scale(1);} 26%{transform:scale(1.13);} 34%{transform:scale(1);} }
|
| 1288 |
+
@keyframes lv4-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
|
| 1289 |
+
@keyframes lv4-sheen { to { left: 150%; } }
|
| 1290 |
+
@media (prefers-reduced-motion: reduce){ .lv4-heart{ animation: none; } #login_content_col{ animation: none !important; } }
|
| 1291 |
|
| 1292 |
/* Ô nhập kiểu leaf v4 */
|
| 1293 |
#login_wrapper .gr-form, #login_wrapper .block, #login_wrapper .form { background: transparent !important; border: none !important; box-shadow: none !important; }
|
| 1294 |
+
#login_wrapper label span, #login_wrapper .gr-box label { color: #4a5f47 !important; font-size: 11px !important; font-weight: 700 !important; letter-spacing: .1em !important; text-transform: uppercase !important; }
|
| 1295 |
+
#login_wrapper [data-testid="status-tracker"], #login_wrapper .status-tracker { display: none !important; }
|
| 1296 |
#login_wrapper input[type="text"], #login_wrapper input[type="password"] {
|
| 1297 |
+
background: rgba(255,255,255,0.62) !important; border: 1px solid rgba(90,110,70,0.3) !important;
|
| 1298 |
+
border-radius: 14px !important; color: #16281a !important; font-size: 15px !important; min-height: 52px !important;
|
| 1299 |
padding: 0 16px !important; -webkit-backdrop-filter: blur(6px) !important; backdrop-filter: blur(6px) !important;
|
| 1300 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), 0 1px 2px rgba(20,50,25,0.04) !important;
|
| 1301 |
transition: all 0.2s ease !important;
|
| 1302 |
}
|
| 1303 |
#login_wrapper input::placeholder { color: #5f7255 !important; }
|
|
|
|
| 1309 |
|
| 1310 |
/* Nút lớn KÍCH HOẠT PHIÊN XÉT NGHIỆM */
|
| 1311 |
#login_wrapper .scan-btn {
|
| 1312 |
+
position: relative !important; overflow: hidden !important;
|
| 1313 |
+
border-radius: 14px !important; min-height: 54px !important; margin-top: 4px !important; width: 100% !important;
|
| 1314 |
+
font-size: 15px !important; font-weight: 800 !important; letter-spacing: .06em !important; text-transform: uppercase !important;
|
| 1315 |
color: #fff !important; border: none !important; cursor: pointer;
|
| 1316 |
background: linear-gradient(135deg, #10b981, #047857) !important;
|
| 1317 |
box-shadow: 0 16px 34px -14px rgba(5,150,105,0.75), inset 0 1px 0 rgba(255,255,255,0.25) !important;
|
| 1318 |
transition: all 0.2s ease !important;
|
| 1319 |
}
|
| 1320 |
+
#login_wrapper .scan-btn::after { content: ""; position: absolute; top: 0; left: -120%; width: 55%; height: 100%;
|
| 1321 |
+
background: linear-gradient(100deg, transparent, rgba(255,255,255,0.35), transparent); transform: skewX(-18deg); pointer-events: none; }
|
| 1322 |
#login_wrapper .scan-btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 20px 40px -14px rgba(5,150,105,0.85) !important; }
|
| 1323 |
+
#login_wrapper .scan-btn:hover::after { animation: lv4-sheen 1.1s ease; }
|
| 1324 |
#login_wrapper .scan-btn:active { transform: translateY(0); }
|
| 1325 |
+
@media (prefers-reduced-motion: reduce){ #login_wrapper .scan-btn:hover::after { animation: none; } }
|
| 1326 |
|
| 1327 |
/* Tài khoản thử nghiệm */
|
| 1328 |
.lv4-demo { margin-top: .8rem; font-size: .8rem; color: #5f7255; }
|
|
|
|
| 1340 |
/* =================== END LEAF HERO LOGIN =================== */
|
| 1341 |
"""
|
| 1342 |
|
| 1343 |
+
# ── Bộ icon nét mảnh + tiêu đề mục (thay emoji, đồng bộ với nhãn IN HOA ở màn đăng nhập) ──
|
| 1344 |
+
ICO_INTAKE = '<path d="M4 13h4l1.5 2.5h5L16 13h4"/><path d="M6 4h12l2 9v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4l2-9Z"/>'
|
| 1345 |
+
ICO_SCAN = '<path d="M4 8V6a2 2 0 0 1 2-2h2M16 4h2a2 2 0 0 1 2 2v2M20 16v2a2 2 0 0 1-2 2h-2M8 20H6a2 2 0 0 1-2-2v-2"/><circle cx="12" cy="12" r="3"/>'
|
| 1346 |
+
ICO_RX = '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h4"/>'
|
| 1347 |
+
ICO_CHAT = '<path d="M20 12a7 7 0 0 1-7 7H8l-4 3v-10a7 7 0 0 1 7-7h2a7 7 0 0 1 7 7Z"/><path d="M9 11h6M9 14h4"/>'
|
| 1348 |
+
ICO_EXPERT = '<path d="M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"/><circle cx="9.5" cy="7" r="3.5"/><path d="m16.5 10.5 2 2 4-4"/>'
|
| 1349 |
+
ICO_ARCHIVE = '<rect x="3" y="4" width="18" height="4" rx="1"/><path d="M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8"/><path d="M10 12h4"/>'
|
| 1350 |
+
ICO_REPLY = '<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v5"/>'
|
| 1351 |
+
|
| 1352 |
+
def _svg(icon):
|
| 1353 |
+
return (f'<svg class="sec-ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" '
|
| 1354 |
+
f'stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{icon}</svg>')
|
| 1355 |
+
|
| 1356 |
+
def sec_head(num, title, icon):
|
| 1357 |
+
"""Tiêu đề mục có đánh số — chỉ dùng cho quy trình khám thật sự theo thứ tự 1→4."""
|
| 1358 |
+
return (f'<div class="sec-head"><span class="sec-num">{num}</span>{_svg(icon)}'
|
| 1359 |
+
f'<span class="sec-title">{title}</span></div>')
|
| 1360 |
+
|
| 1361 |
+
def sec_head_plain(title, icon):
|
| 1362 |
+
"""Tiêu đề mục không đánh số — cho các khu nằm ngoài quy trình tuần tự."""
|
| 1363 |
+
return f'<div class="sec-head">{_svg(icon)}<span class="sec-title">{title}</span></div>'
|
| 1364 |
+
|
| 1365 |
+
def sec_note(text):
|
| 1366 |
+
return f'<p class="sec-note">{text}</p>'
|
| 1367 |
+
|
| 1368 |
+
TOPBAR_HTML = """
|
| 1369 |
+
<div class="topbar">
|
| 1370 |
+
<div class="tb-badge" aria-hidden="true">
|
| 1371 |
+
<svg class="lv4-heart" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#fff" stroke-width="3.4" stroke-linecap="round"/></svg>
|
| 1372 |
+
</div>
|
| 1373 |
+
<div>
|
| 1374 |
+
<div class="tb-name">Trung tâm Chẩn đoán & Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</div>
|
| 1375 |
+
<div class="tb-sub">Phòng xét nghiệm số · YOLOv8 & Gemini</div>
|
| 1376 |
+
</div>
|
| 1377 |
+
</div>
|
| 1378 |
+
"""
|
| 1379 |
+
|
| 1380 |
initial_ticket_text, initial_ticket_img = check_user_expert_status()
|
| 1381 |
|
| 1382 |
with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI", css=custom_css, head=LEAF_HERO_HEAD) as demo:
|
|
|
|
| 1387 |
<div class="lv4-badge" aria-hidden="true">
|
| 1388 |
<svg class="lv4-heart" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#fff" stroke-width="3.4" stroke-linecap="round"/></svg>
|
| 1389 |
</div>
|
| 1390 |
+
<h1 class="lv4-title">Trung tâm Chẩn đoán & Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</h1>
|
|
|
|
|
|
|
|
|
|
| 1391 |
</div>
|
| 1392 |
+
<p class="lv4-sub">Xác thực để mở phiên xét nghiệm mô lá.</p>
|
| 1393 |
""")
|
| 1394 |
username_input = gr.Textbox(label="Tên đăng nhập", placeholder="Nhập tên đăng nhập", max_lines=1)
|
| 1395 |
password_input = gr.Textbox(label="Mật khẩu", type="password", placeholder="••••••••", max_lines=1)
|
|
|
|
| 1406 |
with gr.Column(visible=False) as main_panel:
|
| 1407 |
with gr.Row(elem_classes="hospital-header"):
|
| 1408 |
with gr.Column(scale=10, elem_classes="hospital-header-center"):
|
| 1409 |
+
gr.HTML(TOPBAR_HTML)
|
| 1410 |
+
with gr.Column(scale=2, min_width=150):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1411 |
with gr.Row():
|
| 1412 |
+
btn_logout = gr.Button("Đăng xuất", elem_classes="logout-btn-style")
|
| 1413 |
with gr.Row():
|
| 1414 |
with gr.Column(scale=10):
|
| 1415 |
with gr.Group(elem_classes="gr-group"):
|
| 1416 |
+
gr.HTML(sec_head(1, "Tiếp nhận mẫu xét nghiệm", ICO_INTAKE))
|
| 1417 |
plant_dropdown = gr.Dropdown(
|
| 1418 |
choices=["Cây lúa", "Cây ớt", "Cây cà chua", "Cây dâu tây", "Cây cà phê", "Cây ngô (Bắp)"],
|
| 1419 |
value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
|
| 1420 |
with gr.Group(elem_classes="gr-group"):
|
| 1421 |
image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370)
|
| 1422 |
gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
|
| 1423 |
+
btn_analyze = gr.Button("Quét & chẩn đoán lâm sàng", variant="primary", elem_classes="scan-btn")
|
| 1424 |
gr.HTML("</div>")
|
| 1425 |
with gr.Column(scale=11, elem_id="prescription_col"):
|
| 1426 |
with gr.Group(elem_classes="gr-group"):
|
| 1427 |
+
gr.HTML(sec_head(2, "Kết quả quét thị giác học sâu", ICO_SCAN))
|
| 1428 |
image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370)
|
| 1429 |
+
gr.HTML(sec_head(3, "Đơn thuốc lâm sàng sơ bộ", ICO_RX))
|
| 1430 |
text_output = gr.Textbox(
|
| 1431 |
label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
|
| 1432 |
lines=5,
|
|
|
|
| 1435 |
|
| 1436 |
with gr.Column(scale=12, elem_id="chatbot_col"):
|
| 1437 |
with gr.Row(elem_classes="chatbot-title-container"):
|
| 1438 |
+
gr.HTML(sec_head(4, "Tư vấn thuốc bảo vệ thực vật (AI)", ICO_CHAT))
|
| 1439 |
+
btn_history_nav = gr.Button("Xem lịch sử bệnh án", elem_classes="inline-history-btn")
|
| 1440 |
chatbot = gr.Chatbot(
|
| 1441 |
value=[{"role": "assistant", "content": "🤖 Hệ thống đang đợi mẫu quét. Sau khi phân tích xong ảnh lá, tôi sẽ tự động nắm thông tin bệnh lý để kê đơn thuốc chính xác cho bà con!"}],
|
| 1442 |
height=550,
|
|
|
|
| 1449 |
btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
|
| 1450 |
|
| 1451 |
with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
|
| 1452 |
+
gr.HTML(sec_head_plain("Hỗ trợ tư vấn từ chuyên gia", ICO_EXPERT))
|
| 1453 |
+
gr.HTML(sec_note("Nghi ngờ AI đoán sai hoặc muốn hỏi chi tiết cách điều trị? Gửi câu hỏi tại đây, chỉ chuyên gia mới xem và trả lời trực tiếp cho bạn."))
|
| 1454 |
expert_user_query = gr.Textbox(label="Thắc mắc về tình trạng lá cây / nghi ngờ bệnh:", placeholder="Ví dụ: AI đoán cháy bìa lá nhưng tui nghi là đốm vằn, nhờ chuyên gia xem kỹ lại...", lines=2)
|
| 1455 |
+
btn_send_expert = gr.Button("Gửi yêu cầu cho chuyên gia", elem_classes="expert-send-btn")
|
| 1456 |
expert_status_box = gr.HTML(value=initial_ticket_text)
|
| 1457 |
expert_ticket_img_view = gr.Image(value=initial_ticket_img, label="Ảnh mẫu lá bệnh do nhà nông gửi lên", height=250, interactive=False)
|
| 1458 |
|
| 1459 |
+
gr.HTML("<div class='footer-text'>Bảo mật bởi AI Doctor Lab © 2026 · Ultralytics YOLOv8 & Google Gemini AI</div>")
|
| 1460 |
|
| 1461 |
with gr.Column(visible=False) as history_panel:
|
| 1462 |
with gr.Row(elem_classes="hospital-header"):
|
| 1463 |
with gr.Column(scale=10):
|
| 1464 |
gr.HTML("""
|
| 1465 |
+
<div class="topbar">
|
| 1466 |
+
<div class="tb-badge" aria-hidden="true">
|
| 1467 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">
|
| 1468 |
+
<rect x="3" y="4" width="18" height="4" rx="1"/><path d="M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8"/><path d="M10 12h4"/>
|
| 1469 |
+
</svg>
|
| 1470 |
+
</div>
|
| 1471 |
+
<div>
|
| 1472 |
+
<div class="tb-name">Kho lưu trữ hồ sơ & lịch sử hệ thống</div>
|
| 1473 |
+
<div class="tb-sub">Nhật ký chẩn đoán · Hội thoại · Hộp thư chuyên gia</div>
|
| 1474 |
+
</div>
|
| 1475 |
+
</div>
|
| 1476 |
""")
|
| 1477 |
with gr.Column(scale=2, min_width=150):
|
| 1478 |
+
btn_back_to_clinic = gr.Button("Quay lại phòng khám", elem_classes="history-back-btn-style")
|
| 1479 |
|
| 1480 |
with gr.Row():
|
| 1481 |
with gr.Column(visible=True) as user_diagnose_col:
|
| 1482 |
+
gr.HTML(sec_head_plain("Nhật ký chẩn đoán ảnh", ICO_SCAN))
|
| 1483 |
history_diagnose_box = gr.Textbox(
|
| 1484 |
value=load_diagnose_history(),
|
| 1485 |
label="Lịch sử các ca bệnh đã quét",
|
| 1486 |
lines=15,
|
| 1487 |
interactive=False )
|
| 1488 |
+
btn_clear_diagnose = gr.Button("Xoá nhật ký chẩn đoán", variant="stop", elem_classes="danger-soft")
|
| 1489 |
with gr.Column(visible=True) as user_chat_col:
|
| 1490 |
+
gr.HTML(sec_head_plain("Nhật ký hội thoại với AI", ICO_CHAT))
|
| 1491 |
history_chat_box = gr.Textbox(
|
| 1492 |
value=load_chat_history(),
|
| 1493 |
label="Lịch sử chat kê đơn thuốc",
|
| 1494 |
lines=15,
|
| 1495 |
interactive=False
|
| 1496 |
)
|
| 1497 |
+
btn_clear_chat = gr.Button("Xoá nhật ký chat", variant="stop", elem_classes="danger-soft")
|
|
|
|
|
|
|
| 1498 |
|
| 1499 |
+
gr.HTML("<hr class='soft-rule'>")
|
| 1500 |
+
|
| 1501 |
with gr.Group(elem_classes="gr-group"):
|
| 1502 |
+
gr.HTML(sec_head_plain("Hộp thư tư vấn chuyên gia", ICO_EXPERT))
|
| 1503 |
|
| 1504 |
with gr.Row(elem_id="expert_select_row"):
|
| 1505 |
admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
|
| 1506 |
+
btn_delete_ticket = gr.Button("Xoá hội thoại này", elem_classes="delete-btn-style", scale=2)
|
| 1507 |
|
| 1508 |
with gr.Row():
|
| 1509 |
with gr.Column(scale=1):
|
| 1510 |
admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
|
| 1511 |
with gr.Column(scale=1):
|
| 1512 |
+
admin_ticket_img_display = gr.Image(label="Mẫu lá bệnh do nhà nông gửi lên", height=300, interactive=False)
|
| 1513 |
|
| 1514 |
with gr.Row():
|
| 1515 |
admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
|
| 1516 |
|
| 1517 |
with gr.Row():
|
| 1518 |
with gr.Column(scale=1, visible=False) as admin_control_panel:
|
| 1519 |
+
gr.HTML("<hr class='soft-rule'>")
|
| 1520 |
+
gr.HTML(sec_head_plain("Gửi phản hồi bệnh án từ chuyên gia", ICO_REPLY))
|
| 1521 |
+
admin_reply_input = gr.Textbox(label="Phản hồi chuyên gia / Phác đồ điều trị chuẩn", placeholder="Gõ câu trả lời của chuyên gia tại đây...", lines=4)
|
| 1522 |
+
btn_submit_admin_reply = gr.Button("Gửi câu trả lời cho nhà nông", variant="primary", elem_classes="scan-btn")
|
| 1523 |
admin_reply_status = gr.Markdown("")
|
| 1524 |
|
| 1525 |
with gr.Group(visible=True) as user_followup_panel:
|
| 1526 |
+
gr.HTML("<hr class='soft-rule'>")
|
| 1527 |
+
gr.HTML(sec_head_plain("Hỏi tiếp chuyên gia về bệnh án này", ICO_CHAT))
|
| 1528 |
+
user_followup_input = gr.Textbox(label="Nội dung câu hỏi thêm", placeholder="Ví dụ: Cảm ơn chuyên gia, cho tôi hỏi thêm phun thuốc này buổi sáng hay chiều thì tốt hơn...", lines=2)
|
| 1529 |
+
btn_send_followup = gr.Button("Gửi câu hỏi tiếp tục", variant="primary", elem_classes="scan-btn")
|
| 1530 |
|
| 1531 |
btn_login.click(
|
| 1532 |
login_auth,
|