Spaces:
Sleeping
Sleeping
init
Browse files- .gitignore +1 -0
- app/app_device_routes.py +110 -0
- app/static/css/device-style.css +184 -24
- app/static/js/app-device.js +305 -304
- app/templates/index.html +21 -21
- docs/project_plan.md +58 -2
.gitignore
CHANGED
|
@@ -19,6 +19,7 @@ var/
|
|
| 19 |
*.egg-info/
|
| 20 |
.installed.cfg
|
| 21 |
*.egg
|
|
|
|
| 22 |
|
| 23 |
# Virtual Environment
|
| 24 |
venv/
|
|
|
|
| 19 |
*.egg-info/
|
| 20 |
.installed.cfg
|
| 21 |
*.egg
|
| 22 |
+
LocalPCAgent/
|
| 23 |
|
| 24 |
# Virtual Environment
|
| 25 |
venv/
|
app/app_device_routes.py
CHANGED
|
@@ -562,5 +562,115 @@ def register_device_routes(app, login_required, DEVICE_SERVER_URL):
|
|
| 562 |
logger.debug("์์ ID๊ฐ ์์ฑ๋์ง ์์ ์ญ์ ๊ฑด๋<0xEB>๋.")
|
| 563 |
elif not get_device_url():
|
| 564 |
logger.warning("์ฅ์น ์๋ฒ URL์ด ์์ด ์์ ํ๋ก๊ทธ๋จ ์ญ์ ๊ฑด๋<0xEB>๋.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
# register_device_routes ํจ์์ ๋
|
|
|
|
| 562 |
logger.debug("์์ ID๊ฐ ์์ฑ๋์ง ์์ ์ญ์ ๊ฑด๋<0xEB>๋.")
|
| 563 |
elif not get_device_url():
|
| 564 |
logger.warning("์ฅ์น ์๋ฒ URL์ด ์์ด ์์ ํ๋ก๊ทธ๋จ ์ญ์ ๊ฑด๋<0xEB>๋.")
|
| 565 |
+
@app.route('/api/device/scan-ports', methods=['GET'])
|
| 566 |
+
@login_required
|
| 567 |
+
def scan_device_ports():
|
| 568 |
+
"""๋ก์ปฌPC์ ์ฐ๊ฒฐ๋ ์ฅ์น(COM ํฌํธ ๋ฐ USB ์ฅ์น) ๋ชฉ๋ก ์กฐํ API"""
|
| 569 |
+
logger.info("์ฅ์น ํฌํธ ์ค์บ ์์ฒญ")
|
| 570 |
+
|
| 571 |
+
try:
|
| 572 |
+
# ํ๋ก๊ทธ๋จ ID (์ฅ์น ์ค์บ ์คํฌ๋ฆฝํธ ID - scan_ports)
|
| 573 |
+
program_id = "scan_ports"
|
| 574 |
+
|
| 575 |
+
# ํ์ฌ ์ฅ์น ์๋ฒ URL ๊ฐ์ ธ์ค๊ธฐ
|
| 576 |
+
current_device_url = get_device_url()
|
| 577 |
+
if not current_device_url:
|
| 578 |
+
logger.error("์ฅ์น ์๋ฒ URL์ด ์ค์ ๋์ง ์์์ต๋๋ค.")
|
| 579 |
+
return jsonify({
|
| 580 |
+
"success": False,
|
| 581 |
+
"error": "์ฅ์น ์๋ฒ URL์ด ์ค์ ๋์ง ์์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค."
|
| 582 |
+
}), 503 # Service Unavailable
|
| 583 |
+
|
| 584 |
+
# ์ฅ์น ์ค์บ ํ๋ก๊ทธ๋จ ์คํ (ํ๋ก๊ทธ๋จ ID: scan_ports)
|
| 585 |
+
api_path = f"/api/programs/{program_id}/execute"
|
| 586 |
+
logger.info(f"์ฅ์น ํฌํธ ์ค์บ ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ: {current_device_url}{api_path}")
|
| 587 |
+
|
| 588 |
+
# ์์ฒญ ์ ์ก: ์ฅ์น ์ค์บ ์คํฌ๋ฆฝํธ ์คํ
|
| 589 |
+
response = requests.post(
|
| 590 |
+
f"{current_device_url}{api_path}",
|
| 591 |
+
json={}, # ํ์ํ ํ๋ผ๋ฏธํฐ๊ฐ ์์ผ๋ฉด ์ฌ๊ธฐ์ ์ถ๊ฐ
|
| 592 |
+
timeout=20 # ์ฅ์น ์ค์บ์ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆด ์ ์์ผ๋ฏ๋ก ํ์์์ ์ฆ๊ฐ
|
| 593 |
+
)
|
| 594 |
+
logger.debug(f"์ฅ์น ํฌํธ ์ค์บ ์๋ต ์ํ ์ฝ๋: {response.status_code}")
|
| 595 |
+
|
| 596 |
+
if response.status_code == 200:
|
| 597 |
+
try:
|
| 598 |
+
data = response.json()
|
| 599 |
+
# LocalPCAgent ์๋ต์์ ํ์ํ ์ ๋ณด ์ถ์ถ
|
| 600 |
+
if data.get("success", False):
|
| 601 |
+
# ์ค์บ ๊ฒฐ๊ณผ ์ถ๋ ฅ ๊ฐ์ ธ์ค๊ธฐ
|
| 602 |
+
output = data.get("output", "")
|
| 603 |
+
|
| 604 |
+
try:
|
| 605 |
+
# ์ถ๋ ฅ์ด JSON ํ์์ธ์ง ํ์ธ ๋ฐ ํ์ฑ
|
| 606 |
+
scan_results = json.loads(output)
|
| 607 |
+
logger.info("์ฅ์น ํฌํธ ์ค์บ ๊ฒฐ๊ณผ ํ์ฑ ์ฑ๊ณต")
|
| 608 |
+
|
| 609 |
+
# ๊ฒฐ๊ณผ ๋ฐํ
|
| 610 |
+
return jsonify({
|
| 611 |
+
"success": True,
|
| 612 |
+
"timestamp": scan_results.get("timestamp", ""),
|
| 613 |
+
"system_info": scan_results.get("system_info", {}),
|
| 614 |
+
"devices": scan_results.get("devices", {})
|
| 615 |
+
})
|
| 616 |
+
except json.JSONDecodeError as json_err:
|
| 617 |
+
logger.error(f"์ฅ์น ํฌํธ ์ค์บ ๊ฒฐ๊ณผ JSON ํ์ฑ ์คํจ: {json_err}")
|
| 618 |
+
return jsonify({
|
| 619 |
+
"success": False,
|
| 620 |
+
"error": "์ฅ์น ํฌํธ ์ค์บ ๊ฒฐ๊ณผ๋ฅผ JSON์ผ๋ก ํ์ฑํ ์ ์์ต๋๋ค.",
|
| 621 |
+
"raw_output": output[:1000] # ๊ธด ์ถ๋ ฅ์ ์๋ผ์ ๋ฐํ
|
| 622 |
+
}), 500
|
| 623 |
+
else:
|
| 624 |
+
# ํ๋ก๊ทธ๋จ ์คํ์ ์ฑ๊ณตํ์ง๋ง ์ค์บ ์์ฒด๊ฐ ์คํจํ ๊ฒฝ์ฐ
|
| 625 |
+
error_message = data.get("error", "์ ์ ์๋ ์ค๋ฅ")
|
| 626 |
+
logger.error(f"์ฅ์น ํฌํธ ์ค์บ ํ๋ก๊ทธ๋จ ์ค๋ฅ: {error_message}")
|
| 627 |
+
return jsonify({
|
| 628 |
+
"success": False,
|
| 629 |
+
"error": f"์ฅ์น ํฌํธ ์ค์บ ํ๋ก๊ทธ๋จ ์ค๋ฅ: {error_message}"
|
| 630 |
+
}), 500
|
| 631 |
+
except Exception as parse_err:
|
| 632 |
+
logger.error(f"์ฅ์น ํฌํธ ์ค์บ ์๋ต ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {parse_err}")
|
| 633 |
+
return jsonify({
|
| 634 |
+
"success": False,
|
| 635 |
+
"error": f"์ฅ์น ํฌํธ ์ค์บ ์๋ต ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(parse_err)}"
|
| 636 |
+
}), 500
|
| 637 |
+
else:
|
| 638 |
+
# API ์์ฒญ ์์ฒด๊ฐ ์คํจํ ๊ฒฝ์ฐ
|
| 639 |
+
error_message = f"์ฅ์น ํฌํธ ์ค์บ API ์์ฒญ ์คํจ (์ํ ์ฝ๋: {response.status_code})"
|
| 640 |
+
try:
|
| 641 |
+
error_data = response.json()
|
| 642 |
+
if 'error' in error_data:
|
| 643 |
+
error_message += f": {error_data['error']}"
|
| 644 |
+
except:
|
| 645 |
+
if response.text:
|
| 646 |
+
error_message += f": {response.text[:200]}"
|
| 647 |
+
|
| 648 |
+
logger.error(error_message)
|
| 649 |
+
return jsonify({
|
| 650 |
+
"success": False,
|
| 651 |
+
"error": error_message
|
| 652 |
+
}), response.status_code
|
| 653 |
|
| 654 |
+
except requests.exceptions.Timeout:
|
| 655 |
+
error_message = "์ฅ์น ํฌํธ ์ค์บ ์์ฒญ ์๊ฐ ์ด๊ณผ"
|
| 656 |
+
logger.error(error_message)
|
| 657 |
+
return jsonify({
|
| 658 |
+
"success": False,
|
| 659 |
+
"error": error_message
|
| 660 |
+
}), 504 # Gateway Timeout
|
| 661 |
+
|
| 662 |
+
except requests.exceptions.ConnectionError:
|
| 663 |
+
error_message = f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ ({get_device_url()})"
|
| 664 |
+
logger.error(error_message)
|
| 665 |
+
return jsonify({
|
| 666 |
+
"success": False,
|
| 667 |
+
"error": "์ฅ์น ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์."
|
| 668 |
+
}), 502 # Bad Gateway
|
| 669 |
+
|
| 670 |
+
except Exception as e:
|
| 671 |
+
logger.error(f"์ฅ์น ํฌํธ ์ค์บ ์์ฒญ ์ฒ๋ฆฌ ์ค ์์ธ ๋ฐ์: {e}", exc_info=True)
|
| 672 |
+
return jsonify({
|
| 673 |
+
"success": False,
|
| 674 |
+
"error": f"์ฅ์น ํฌํธ ์ค์บ ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(e)}"
|
| 675 |
+
}), 500 # Internal Server Error
|
| 676 |
# register_device_routes ํจ์์ ๋
|
app/static/css/device-style.css
CHANGED
|
@@ -84,7 +84,9 @@
|
|
| 84 |
}
|
| 85 |
|
| 86 |
/* ์ฅ์น ๊ธฐ๋ฅ ์ปจํ
์ด๋ */
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
background-color: var(--bg-color-secondary);
|
| 89 |
border-radius: 8px;
|
| 90 |
padding: 15px;
|
|
@@ -92,11 +94,13 @@
|
|
| 92 |
display: none; /* ์ด๊ธฐ์๋ ์จ๊น */
|
| 93 |
}
|
| 94 |
|
| 95 |
-
.device-functions.active
|
| 96 |
-
|
|
|
|
| 97 |
}
|
| 98 |
|
| 99 |
-
.device-functions h3
|
|
|
|
| 100 |
margin-top: 0;
|
| 101 |
margin-bottom: 15px;
|
| 102 |
color: var(--text-color-primary);
|
|
@@ -146,27 +150,14 @@
|
|
| 146 |
}
|
| 147 |
|
| 148 |
/* ํ๋ก๊ทธ๋จ ์คํ ์ปจํ
์ด๋ */
|
| 149 |
-
.program-control {
|
| 150 |
-
background-color: var(--bg-color-secondary);
|
| 151 |
-
border-radius: 8px;
|
| 152 |
-
padding: 15px;
|
| 153 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 154 |
-
display: none; /* ์ด๊ธฐ์๋ ์จ๊น */
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
.program-control.active {
|
| 158 |
-
display: block;
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
.program-control h3 {
|
| 162 |
-
margin-top: 0;
|
| 163 |
-
margin-bottom: 15px;
|
| 164 |
-
color: var(--text-color-primary);
|
| 165 |
-
font-size: 1.2rem;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
.program-list-container {
|
| 169 |
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
}
|
| 171 |
|
| 172 |
.program-list {
|
|
@@ -179,6 +170,7 @@
|
|
| 179 |
padding: 10px;
|
| 180 |
text-align: left;
|
| 181 |
border-bottom: 1px solid var(--border-color);
|
|
|
|
| 182 |
}
|
| 183 |
|
| 184 |
.program-list th {
|
|
@@ -230,6 +222,7 @@
|
|
| 230 |
border-radius: 4px;
|
| 231 |
margin-top: 10px;
|
| 232 |
font-size: 0.9rem;
|
|
|
|
| 233 |
}
|
| 234 |
|
| 235 |
.execute-result.success {
|
|
@@ -250,6 +243,62 @@
|
|
| 250 |
border: 1px solid rgba(255, 193, 7, 0.2);
|
| 251 |
}
|
| 252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
/* ๋ก๋ฉ ํ์ */
|
| 254 |
.loading-spinner {
|
| 255 |
display: inline-block;
|
|
@@ -307,10 +356,121 @@
|
|
| 307 |
padding: 8px 12px;
|
| 308 |
cursor: pointer;
|
| 309 |
font-size: 0.9rem;
|
| 310 |
-
margin-top: 10px;
|
|
|
|
| 311 |
transition: background-color 0.2s;
|
| 312 |
}
|
| 313 |
|
| 314 |
.retry-button:hover {
|
| 315 |
background-color: var(--secondary-color-dark);
|
| 316 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
/* ์ฅ์น ๊ธฐ๋ฅ ์ปจํ
์ด๋ */
|
| 87 |
+
/* ์๋ฒ ์ฐ๊ฒฐ ํ ํ์ฑํ๋๋ ์น์
๋ค์ ๊ธฐ๋ณธ ์คํ์ผ */
|
| 88 |
+
.device-functions,
|
| 89 |
+
.program-control {
|
| 90 |
background-color: var(--bg-color-secondary);
|
| 91 |
border-radius: 8px;
|
| 92 |
padding: 15px;
|
|
|
|
| 94 |
display: none; /* ์ด๊ธฐ์๋ ์จ๊น */
|
| 95 |
}
|
| 96 |
|
| 97 |
+
.device-functions.active,
|
| 98 |
+
.program-control.active {
|
| 99 |
+
display: block; /* ํ์ฑํ ์ ๋ณด์ */
|
| 100 |
}
|
| 101 |
|
| 102 |
+
.device-functions h3,
|
| 103 |
+
.program-control h3 {
|
| 104 |
margin-top: 0;
|
| 105 |
margin-bottom: 15px;
|
| 106 |
color: var(--text-color-primary);
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
/* ํ๋ก๊ทธ๋จ ์คํ ์ปจํ
์ด๋ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
.program-list-container {
|
| 154 |
margin-bottom: 20px;
|
| 155 |
+
/* ์คํฌ๋กค์ด ํ์ํ ๊ฒฝ์ฐ๋ฅผ ๋๋น */
|
| 156 |
+
max-height: 300px;
|
| 157 |
+
overflow-y: auto;
|
| 158 |
+
border: 1px solid var(--border-color);
|
| 159 |
+
border-radius: 4px;
|
| 160 |
+
padding: 10px;
|
| 161 |
}
|
| 162 |
|
| 163 |
.program-list {
|
|
|
|
| 170 |
padding: 10px;
|
| 171 |
text-align: left;
|
| 172 |
border-bottom: 1px solid var(--border-color);
|
| 173 |
+
font-size: 0.9rem;
|
| 174 |
}
|
| 175 |
|
| 176 |
.program-list th {
|
|
|
|
| 222 |
border-radius: 4px;
|
| 223 |
margin-top: 10px;
|
| 224 |
font-size: 0.9rem;
|
| 225 |
+
min-height: 20px; /* ๊ฒฐ๊ณผ ์์ ๋๋ ์ต์ ๋์ด ์ ์ง */
|
| 226 |
}
|
| 227 |
|
| 228 |
.execute-result.success {
|
|
|
|
| 243 |
border: 1px solid rgba(255, 193, 7, 0.2);
|
| 244 |
}
|
| 245 |
|
| 246 |
+
/* ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ */
|
| 247 |
+
.custom-command-container {
|
| 248 |
+
display: flex;
|
| 249 |
+
gap: 10px;
|
| 250 |
+
margin-bottom: 15px;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.custom-command-container input {
|
| 254 |
+
flex: 1;
|
| 255 |
+
padding: 10px;
|
| 256 |
+
border: 1px solid var(--border-color);
|
| 257 |
+
border-radius: 4px;
|
| 258 |
+
font-size: 0.95rem;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.custom-command-container button {
|
| 262 |
+
background-color: var(--primary-color);
|
| 263 |
+
color: white;
|
| 264 |
+
border: none;
|
| 265 |
+
border-radius: 4px;
|
| 266 |
+
padding: 10px 15px;
|
| 267 |
+
cursor: pointer;
|
| 268 |
+
font-weight: 500;
|
| 269 |
+
transition: background-color 0.2s;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.custom-command-container button:hover {
|
| 273 |
+
background-color: var(--primary-color-dark);
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
.custom-command-container button:disabled {
|
| 277 |
+
background-color: var(--disabled-color);
|
| 278 |
+
cursor: not-allowed;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/* ๋ช
๋ น์ด ์คํ ๊ฒฐ๊ณผ ์คํ์ผ */
|
| 282 |
+
.command-output, .command-error {
|
| 283 |
+
margin-top: 10px;
|
| 284 |
+
padding: 10px;
|
| 285 |
+
background-color: var(--bg-color-tertiary);
|
| 286 |
+
border-radius: 4px;
|
| 287 |
+
border: 1px solid var(--border-color);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.command-output pre, .command-error pre {
|
| 291 |
+
white-space: pre-wrap;
|
| 292 |
+
word-wrap: break-word;
|
| 293 |
+
font-size: 0.85rem;
|
| 294 |
+
margin: 0;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.command-error pre {
|
| 298 |
+
color: #dc3545; /* ์ค๋ฅ ํ
์คํธ ์์ */
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
|
| 302 |
/* ๋ก๋ฉ ํ์ */
|
| 303 |
.loading-spinner {
|
| 304 |
display: inline-block;
|
|
|
|
| 356 |
padding: 8px 12px;
|
| 357 |
cursor: pointer;
|
| 358 |
font-size: 0.9rem;
|
| 359 |
+
margin-top: 10px; /* ํ์์ ์กฐ์ */
|
| 360 |
+
margin-left: 10px; /* ์ ์์์ ๊ฐ๊ฒฉ */
|
| 361 |
transition: background-color 0.2s;
|
| 362 |
}
|
| 363 |
|
| 364 |
.retry-button:hover {
|
| 365 |
background-color: var(--secondary-color-dark);
|
| 366 |
}
|
| 367 |
+
|
| 368 |
+
/* ================== ์ฅ์น ํฌํธ ์กฐํ ์คํ์ผ ์ถ๊ฐ ================== */
|
| 369 |
+
.ports-status {
|
| 370 |
+
margin: 10px 0;
|
| 371 |
+
padding: 10px;
|
| 372 |
+
border-radius: 5px;
|
| 373 |
+
min-height: 20px;
|
| 374 |
+
font-size: 0.9rem; /* ๋ค๋ฅธ ์ํ ๋ฉ์์ง์ ์ผ๊ด์ฑ */
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.ports-status.success {
|
| 378 |
+
background-color: rgba(0, 200, 83, 0.1); /* ๊ธฐ์กด .success ์คํ์ผ๊ณผ ์ ์ฌํ๊ฒ */
|
| 379 |
+
color: #00c853; /* ์ข ๋ ๋ฐ์ ๋
น์ */
|
| 380 |
+
border: 1px solid #00c853;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
.ports-status.error {
|
| 384 |
+
background-color: rgba(244, 67, 54, 0.1); /* ๊ธฐ์กด .error ์คํ์ผ๊ณผ ์ ์ฌํ๊ฒ */
|
| 385 |
+
color: #f44336; /* ์ข ๋ ๋ฐ์ ๋นจ๊ฐ */
|
| 386 |
+
border: 1px solid #f44336;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.ports-status.warning {
|
| 390 |
+
background-color: rgba(255, 152, 0, 0.1); /* ๊ธฐ์กด .warning ์คํ์ผ๊ณผ ์ ์ฌํ๊ฒ */
|
| 391 |
+
color: #ff9800; /* ์ข ๋ ๋ฐ์ ์ฃผํฉ */
|
| 392 |
+
border: 1px solid #ff9800;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
.ports-results {
|
| 396 |
+
margin-top: 15px;
|
| 397 |
+
border: 1px solid var(--border-color); /* ๋ณ์ ์ฌ์ฉ */
|
| 398 |
+
border-radius: 5px;
|
| 399 |
+
padding: 0; /* ๋ด๋ถ ์น์
ํจ๋ฉ์ผ๋ก ์กฐ์ */
|
| 400 |
+
max-height: 500px; /* ์ต๋ ๋์ด ์ ํ */
|
| 401 |
+
overflow-y: auto; /* ๋ด์ฉ ๋ง์ผ๋ฉด ์คํฌ๋กค */
|
| 402 |
+
background-color: var(--bg-color-tertiary); /* ์ฝ๊ฐ์ ๋ฐฐ๊ฒฝ์ */
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
/* ํฌํธ ๊ฒฐ๊ณผ ์ปจํ
์ด๋ (๋ด๋ถ ํจ๋ฉ์ฉ) */
|
| 406 |
+
.ports-results-container {
|
| 407 |
+
padding: 15px;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
.ports-section {
|
| 411 |
+
margin-bottom: 20px;
|
| 412 |
+
}
|
| 413 |
+
/* ๋ง์ง๋ง ์น์
์ ํ๋จ ๋ง์ง ์ ๊ฑฐ */
|
| 414 |
+
.ports-section:last-child {
|
| 415 |
+
margin-bottom: 0;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
.ports-section h4 {
|
| 420 |
+
margin-top: 0;
|
| 421 |
+
margin-bottom: 10px;
|
| 422 |
+
font-size: 1rem; /* ๋ค๋ฅธ h3 ์ ์ ์ฌํ๊ฒ */
|
| 423 |
+
color: var(--text-color-primary); /* ๋ณ์ ์ฌ์ฉ */
|
| 424 |
+
border-bottom: 1px solid var(--border-color); /* ๋ณ์ ์ฌ์ฉ */
|
| 425 |
+
padding-bottom: 5px;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
.info-row {
|
| 429 |
+
display: flex;
|
| 430 |
+
margin-bottom: 5px;
|
| 431 |
+
font-size: 0.9rem; /* ๊ธ์ ํฌ๊ธฐ ํต์ผ */
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
.info-label {
|
| 435 |
+
font-weight: bold;
|
| 436 |
+
width: 100px;
|
| 437 |
+
flex-shrink: 0; /* ๋ผ๋ฒจ ๋๋น ๊ณ ์ */
|
| 438 |
+
color: var(--text-color-secondary); /* ์ฝ๊ฐ ์ฐํ ์ */
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.info-value {
|
| 442 |
+
color: var(--text-color-primary);
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
.ports-table {
|
| 446 |
+
width: 100%;
|
| 447 |
+
border-collapse: collapse;
|
| 448 |
+
margin-top: 10px;
|
| 449 |
+
font-size: 0.85rem; /* ํ
์ด๋ธ ๊ธ์ ์ฝ๊ฐ ์๊ฒ */
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
.ports-table th,
|
| 453 |
+
.ports-table td {
|
| 454 |
+
padding: 8px 10px; /* ํจ๋ฉ ์กฐ์ */
|
| 455 |
+
text-align: left;
|
| 456 |
+
border-bottom: 1px solid var(--border-color-lighter, #eee); /* ๋ ์ฐํ ๊ตฌ๋ถ์ , ๋ณ์ ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ */
|
| 457 |
+
vertical-align: top; /* ์ฌ๋ฌ ์ค์ผ ๊ฒฝ์ฐ ์ ์ ๋ ฌ */
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
.ports-table th {
|
| 461 |
+
background-color: var(--bg-color-secondary); /* ์ฝ๊ฐ ๋ค๋ฅธ ๋ฐฐ๊ฒฝ */
|
| 462 |
+
font-weight: 500; /* ๋ณดํต ๋๊ป */
|
| 463 |
+
color: var(--text-color-primary);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
.ports-table tbody tr:hover {
|
| 467 |
+
background-color: var(--bg-color-hover, #f9f9f9); /* ๋ณ์ ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ */
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
.no-ports-message {
|
| 471 |
+
color: var(--text-color-secondary); /* ๋ณ์ ์ฌ์ฉ */
|
| 472 |
+
font-style: italic;
|
| 473 |
+
padding: 10px 0;
|
| 474 |
+
font-size: 0.9rem;
|
| 475 |
+
}
|
| 476 |
+
/* ================== ์ถ๊ฐ ๋ ================================= */
|
app/static/js/app-device.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
/**
|
| 2 |
-
* RAG ๊ฒ์ ์ฑ๋ด ์ฅ์น ์ ์ด JavaScript
|
| 3 |
*/
|
| 4 |
|
| 5 |
// ์ฅ์น ์ ์ด ๋ชจ๋
|
|
@@ -27,32 +27,32 @@ const DeviceControl = {
|
|
| 27 |
deviceStatusResult: null,
|
| 28 |
|
| 29 |
// ํ๋ก๊ทธ๋จ ์คํ (๋ฏธ๋ฆฌ ์ ์๋)
|
| 30 |
-
deviceProgramControl: null,
|
| 31 |
getProgramsBtn: null,
|
| 32 |
programsList: null,
|
| 33 |
programSelectDropdown: null,
|
| 34 |
executeProgramBtn: null,
|
| 35 |
executeResult: null,
|
| 36 |
|
| 37 |
-
// ================== ์ถ๊ฐ ์์ 1/4 ==================
|
| 38 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 39 |
deviceCustomControl: null,
|
| 40 |
customCommandInput: null,
|
| 41 |
executeCustomBtn: null,
|
| 42 |
-
customExecuteResult: null
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
},
|
| 45 |
|
| 46 |
// ๋ชจ๋ ์ด๊ธฐํ
|
| 47 |
init: function() {
|
| 48 |
console.log('์ฅ์น ์ ์ด ๋ชจ๋ ์ด๊ธฐํ ์ค...');
|
| 49 |
-
|
| 50 |
-
// DOM ์์ ์ฐธ์กฐ ๊ฐ์ ธ์ค๊ธฐ
|
| 51 |
this.initElements();
|
| 52 |
-
|
| 53 |
-
// ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก
|
| 54 |
this.initEventListeners();
|
| 55 |
-
|
| 56 |
console.log('์ฅ์น ์ ์ด ๋ชจ๋ ์ด๊ธฐํ ์๋ฃ');
|
| 57 |
},
|
| 58 |
|
|
@@ -80,13 +80,18 @@ const DeviceControl = {
|
|
| 80 |
this.elements.executeProgramBtn = document.getElementById('executeProgramBtn');
|
| 81 |
this.elements.executeResult = document.getElementById('executeResult');
|
| 82 |
|
| 83 |
-
// ================== ์ถ๊ฐ ์์ 2/4 ==================
|
| 84 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 85 |
this.elements.deviceCustomControl = document.getElementById('deviceCustomControl');
|
| 86 |
this.elements.customCommandInput = document.getElementById('customCommandInput');
|
| 87 |
this.elements.executeCustomBtn = document.getElementById('executeCustomBtn');
|
| 88 |
this.elements.customExecuteResult = document.getElementById('customExecuteResult');
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
console.log('์ฅ์น ์ ์ด DOM ์์ ์ฐธ์กฐ ์ด๊ธฐํ ์๋ฃ');
|
| 92 |
},
|
|
@@ -153,7 +158,6 @@ const DeviceControl = {
|
|
| 153 |
});
|
| 154 |
}
|
| 155 |
|
| 156 |
-
// ================== ์ถ๊ฐ ์์ 3/4 ==================
|
| 157 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ๋ฒํผ ํด๋ฆญ
|
| 158 |
if (this.elements.executeCustomBtn) {
|
| 159 |
this.elements.executeCustomBtn.addEventListener('click', () => {
|
|
@@ -174,7 +178,15 @@ const DeviceControl = {
|
|
| 174 |
}
|
| 175 |
});
|
| 176 |
}
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
console.log('์ฅ์น ์ ์ด ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก ์๋ฃ');
|
| 180 |
},
|
|
@@ -189,8 +201,8 @@ const DeviceControl = {
|
|
| 189 |
tabContents.forEach(content => content.classList.remove('active'));
|
| 190 |
|
| 191 |
// ์ฅ์น ์ ์ด ํญ ํ์ฑํ
|
| 192 |
-
this.elements.deviceTab.classList.add('active');
|
| 193 |
-
this.elements.deviceSection.classList.add('active');
|
| 194 |
|
| 195 |
console.log('์ฅ์น ์ ์ด ํญ์ผ๋ก ์ ํ ์๋ฃ');
|
| 196 |
},
|
|
@@ -201,7 +213,7 @@ const DeviceControl = {
|
|
| 201 |
const inputUrl = this.elements.deviceServerUrlInput.value.trim();
|
| 202 |
|
| 203 |
// ์ฐ๊ฒฐ ์๋ ์ค UI ์
๋ฐ์ดํธ
|
| 204 |
-
this.elements.connectDeviceServerBtn.disabled = true;
|
| 205 |
this.updateConnectionStatus('connecting', 'ํ๊ฒฝ๋ณ์์ ์ ์ฅ๋ ์๋ฒ๋ก ์ฐ๊ฒฐ ์๋ ์ค...');
|
| 206 |
|
| 207 |
try {
|
|
@@ -215,147 +227,49 @@ const DeviceControl = {
|
|
| 215 |
const data = await response.json();
|
| 216 |
|
| 217 |
if (response.ok && data.success) {
|
| 218 |
-
// ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 219 |
console.log('ํ๊ฒฝ๋ณ์ ์ค์ ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต:', data);
|
| 220 |
this.isConnected = true;
|
| 221 |
-
|
|
|
|
|
|
|
| 222 |
|
| 223 |
// ๊ธฐ๋ฅ UI ํ์ฑํ
|
| 224 |
if(this.elements.deviceBasicFunctions) this.elements.deviceBasicFunctions.classList.add('active');
|
| 225 |
if(this.elements.deviceProgramControl) this.elements.deviceProgramControl.classList.add('active');
|
| 226 |
-
// ================== ์ถ๊ฐ (connectServer ์ฑ๊ณต ์ UI ํ์ฑํ) ==================
|
| 227 |
if(this.elements.deviceCustomControl) this.elements.deviceCustomControl.classList.add('active');
|
| 228 |
-
// ================== ์ถ๊ฐ
|
|
|
|
|
|
|
| 229 |
|
| 230 |
// ์ฅ์น ์ํ ์๋ ์ฒดํฌ
|
| 231 |
this.checkDeviceStatus();
|
| 232 |
-
|
| 233 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ ๋ก๋
|
| 234 |
this.loadProgramsList();
|
| 235 |
-
|
| 236 |
// ์์คํ
์๋ฆผ
|
| 237 |
AppUtils.addSystemNotification(`์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! (ํ๊ฒฝ๋ณ์ URL)`);
|
|
|
|
| 238 |
} else {
|
| 239 |
// ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์คํจ, ์
๋ ฅ๋ URL๋ก ์๋
|
| 240 |
console.warn('ํ๊ฒฝ๋ณ์ ์ค์ ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ, ์
๋ ฅ URL๋ก ์ฌ์๋ํฉ๋๋ค:', data);
|
| 241 |
-
|
| 242 |
-
// ์
๋ ฅ URL์ด ์๋์ง ํ์ธ
|
| 243 |
if (!inputUrl) {
|
| 244 |
console.error('์
๋ ฅ๋ URL์ด ์์ด ์ฐ๊ฒฐ ์คํจ');
|
| 245 |
this.isConnected = false;
|
| 246 |
this.updateConnectionStatus('error', 'ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์คํจ ๋ฐ ์
๋ ฅ๋ URL์ด ์์ต๋๋ค. URL์ ์
๋ ฅํด์ฃผ์ธ์.');
|
| 247 |
-
return;
|
| 248 |
}
|
| 249 |
-
|
| 250 |
// ์
๋ ฅ URL๋ก ์ฌ์๋
|
| 251 |
-
this.
|
| 252 |
-
console.log(`์
๋ ฅํ URL๋ก ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์๋: ${inputUrl}`);
|
| 253 |
-
|
| 254 |
-
// ๋ฐฑ์๋ API ํธ์ถ - ์
๋ ฅ URL ์ฌ์ฉ
|
| 255 |
-
const customUrlResponse = await AppUtils.fetchWithTimeout('/api/device/connect', {
|
| 256 |
-
method: 'POST',
|
| 257 |
-
headers: {
|
| 258 |
-
'Content-Type': 'application/json'
|
| 259 |
-
},
|
| 260 |
-
body: JSON.stringify({ url: inputUrl })
|
| 261 |
-
}, 10000);
|
| 262 |
-
|
| 263 |
-
const customUrlData = await customUrlResponse.json();
|
| 264 |
-
|
| 265 |
-
if (customUrlResponse.ok && customUrlData.success) {
|
| 266 |
-
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 267 |
-
console.log('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต:', customUrlData);
|
| 268 |
-
this.isConnected = true;
|
| 269 |
-
this.updateConnectionStatus('connected', `์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! ์ํ: ${customUrlData.server_status || '์ ์'}`);
|
| 270 |
-
|
| 271 |
-
// ๊ธฐ๋ฅ UI ํ์ฑํ
|
| 272 |
-
if(this.elements.deviceBasicFunctions) this.elements.deviceBasicFunctions.classList.add('active');
|
| 273 |
-
if(this.elements.deviceProgramControl) this.elements.deviceProgramControl.classList.add('active');
|
| 274 |
-
// ================== ์ถ๊ฐ (connectServer ์ฑ๊ณต ์ UI ํ์ฑํ) ==================
|
| 275 |
-
if(this.elements.deviceCustomControl) this.elements.deviceCustomControl.classList.add('active');
|
| 276 |
-
// ================== ์ถ๊ฐ ๋ =============================================
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
// ์ฅ์น ์ํ ์๋ ์ฒดํฌ
|
| 280 |
-
this.checkDeviceStatus();
|
| 281 |
-
|
| 282 |
-
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ ๋ก๋
|
| 283 |
-
this.loadProgramsList();
|
| 284 |
-
|
| 285 |
-
// ์์คํ
์๋ฆผ
|
| 286 |
-
AppUtils.addSystemNotification(`์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! (${inputUrl})`);
|
| 287 |
-
} else {
|
| 288 |
-
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์คํจ
|
| 289 |
-
console.error('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ:', customUrlData);
|
| 290 |
-
this.isConnected = false;
|
| 291 |
-
this.updateConnectionStatus('error', `์๋ฒ ์ฐ๊ฒฐ ์คํจ: ${customUrlData.error || '์๋ฒ ์๋ต ์ค๋ฅ'}`);
|
| 292 |
-
}
|
| 293 |
}
|
| 294 |
} catch (error) {
|
| 295 |
-
// ์์ธ ๋ฐ์
|
| 296 |
-
console.error('์๋ฒ ์ฐ๊ฒฐ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 297 |
this.isConnected = false;
|
| 298 |
-
|
| 299 |
-
// ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์คํจ, ์
๋ ฅ๋ URL๋ก ์๋
|
| 300 |
if (inputUrl) {
|
| 301 |
console.warn('ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์ ์ค๋ฅ ๋ฐ์, ์
๋ ฅ URL๋ก ์ฌ์๋ํฉ๋๋ค');
|
| 302 |
-
|
| 303 |
-
try {
|
| 304 |
-
// ์
๋ ฅ URL๋ก ์ฌ์๋
|
| 305 |
-
this.updateConnectionStatus('connecting', `์
๋ ฅ URL(${inputUrl})๋ก ์ฐ๊ฒฐ ์๋ ์ค...`);
|
| 306 |
-
console.log(`์
๋ ฅํ URL๋ก ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์๋: ${inputUrl}`);
|
| 307 |
-
|
| 308 |
-
// ๋ฐฑ์๋ API ํธ์ถ - ์
๋ ฅ URL ์ฌ์ฉ
|
| 309 |
-
const customUrlResponse = await AppUtils.fetchWithTimeout('/api/device/connect', {
|
| 310 |
-
method: 'POST',
|
| 311 |
-
headers: {
|
| 312 |
-
'Content-Type': 'application/json'
|
| 313 |
-
},
|
| 314 |
-
body: JSON.stringify({ url: inputUrl })
|
| 315 |
-
}, 10000);
|
| 316 |
-
|
| 317 |
-
const customUrlData = await customUrlResponse.json();
|
| 318 |
-
|
| 319 |
-
if (customUrlResponse.ok && customUrlData.success) {
|
| 320 |
-
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 321 |
-
console.log('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต:', customUrlData);
|
| 322 |
-
this.isConnected = true;
|
| 323 |
-
this.updateConnectionStatus('connected', `์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! ์ํ: ${customUrlData.server_status || '์ ์'}`);
|
| 324 |
-
|
| 325 |
-
// ๊ธฐ๋ฅ UI ํ์ฑํ
|
| 326 |
-
if(this.elements.deviceBasicFunctions) this.elements.deviceBasicFunctions.classList.add('active');
|
| 327 |
-
if(this.elements.deviceProgramControl) this.elements.deviceProgramControl.classList.add('active');
|
| 328 |
-
// ================== ์ถ๊ฐ (connectServer ์ฑ๊ณต ์ UI ํ์ฑํ) ==================
|
| 329 |
-
if(this.elements.deviceCustomControl) this.elements.deviceCustomControl.classList.add('active');
|
| 330 |
-
// ================== ์ถ๊ฐ ๋ =============================================
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
// ์ฅ์น ์ํ ์๋ ์ฒดํฌ
|
| 334 |
-
this.checkDeviceStatus();
|
| 335 |
-
|
| 336 |
-
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ ๋ก๋
|
| 337 |
-
this.loadProgramsList();
|
| 338 |
-
|
| 339 |
-
// ์์คํ
์๋ฆผ
|
| 340 |
-
AppUtils.addSystemNotification(`์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! (${inputUrl})`);
|
| 341 |
-
return; // ์ฑ๊ณตํ๋ฉด ์ฌ๊ธฐ์ ์ข
๋ฃ
|
| 342 |
-
} else {
|
| 343 |
-
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์คํจ
|
| 344 |
-
console.error('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ:', customUrlData);
|
| 345 |
-
this.updateConnectionStatus('error', `์๋ฒ ์ฐ๊ฒฐ ์คํจ: ${customUrlData.error || '์๋ฒ ์๋ต ์ค๋ฅ'}`);
|
| 346 |
-
}
|
| 347 |
-
} catch (inputUrlError) {
|
| 348 |
-
// ์
๋ ฅ URL๋ก ์ฌ์๋ ์ค ์ค๋ฅ
|
| 349 |
-
console.error('์
๋ ฅ URL๋ก ์ฌ์๋ ์ค ์ค๋ฅ ๋ฐ์:', inputUrlError);
|
| 350 |
-
|
| 351 |
-
if (inputUrlError.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 352 |
-
this.updateConnectionStatus('error', '์๋ฒ ์ฐ๊ฒฐ ์๊ฐ ์ด๊ณผ. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์.');
|
| 353 |
-
} else {
|
| 354 |
-
this.updateConnectionStatus('error', `์๋ฒ ์ฐ๊ฒฐ ์ค๋ฅ: ${inputUrlError.message}`);
|
| 355 |
-
}
|
| 356 |
-
}
|
| 357 |
} else {
|
| 358 |
-
//
|
| 359 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 360 |
this.updateConnectionStatus('error', 'ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์๊ฐ ์ด๊ณผ. URL์ ์
๋ ฅํ์ฌ ๋ค์ ์๋ํด์ฃผ์ธ์.');
|
| 361 |
} else {
|
|
@@ -364,10 +278,63 @@ const DeviceControl = {
|
|
| 364 |
}
|
| 365 |
} finally {
|
| 366 |
// ๋ฒํผ ๋ค์ ํ์ฑํ
|
| 367 |
-
|
| 368 |
}
|
| 369 |
},
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
// ์ฐ๊ฒฐ ์ํ ์
๋ฐ์ดํธ
|
| 372 |
updateConnectionStatus: function(status, message) {
|
| 373 |
const statusElement = this.elements.deviceConnectionStatus;
|
|
@@ -375,56 +342,44 @@ const DeviceControl = {
|
|
| 375 |
|
| 376 |
// ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 377 |
statusElement.classList.remove('connected', 'disconnected', 'error', 'connecting');
|
| 378 |
-
|
| 379 |
// ์ํ์ ๋ฐ๋ผ ํด๋์ค ์ถ๊ฐ
|
| 380 |
statusElement.classList.add(status);
|
| 381 |
-
|
| 382 |
// ๋ฉ์์ง ์
๋ฐ์ดํธ
|
| 383 |
statusElement.textContent = message;
|
| 384 |
-
|
| 385 |
console.log(`์ฐ๊ฒฐ ์ํ ์
๋ฐ์ดํธ: ${status} - ${message}`);
|
| 386 |
},
|
| 387 |
|
| 388 |
// ์ฅ์น ์ํ ํ์ธ
|
| 389 |
checkDeviceStatus: async function() {
|
| 390 |
if (!this.isConnected) {
|
| 391 |
-
|
| 392 |
console.error('์ฅ์น ์ํ ํ์ธ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 393 |
return;
|
| 394 |
}
|
| 395 |
-
|
| 396 |
// ์ํ ํ์ธ ์ค UI ์
๋ฐ์ดํธ
|
| 397 |
-
|
| 398 |
-
|
| 399 |
|
| 400 |
try {
|
| 401 |
console.log('์ฅ์น ์ํ ํ์ธ ์์ฒญ ์ ์ก');
|
| 402 |
-
|
| 403 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 404 |
-
const response = await AppUtils.fetchWithTimeout('/api/device/status', {
|
| 405 |
-
method: 'GET'
|
| 406 |
-
});
|
| 407 |
-
|
| 408 |
const data = await response.json();
|
| 409 |
|
| 410 |
if (response.ok && data.success) {
|
| 411 |
-
// ์ํ ํ์ธ ์ฑ๊ณต
|
| 412 |
console.log('์ฅ์น ์ํ ํ์ธ ์ฑ๊ณต:', data);
|
| 413 |
this.isStatusChecked = true;
|
| 414 |
// JSON ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ธฐ ์ข๊ฒ ํฌ๋งทํ
ํ์ฌ ํ์
|
| 415 |
-
|
| 416 |
} else {
|
| 417 |
-
// ์ํ ํ์ธ ์คํจ
|
| 418 |
console.error('์ฅ์น ์ํ ํ์ธ ์คํจ:', data);
|
| 419 |
-
|
| 420 |
}
|
| 421 |
} catch (error) {
|
| 422 |
-
// ์์ธ ๋ฐ์
|
| 423 |
console.error('์ฅ์น ์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 424 |
-
|
| 425 |
} finally {
|
| 426 |
-
|
| 427 |
-
this.elements.checkDeviceStatusBtn.disabled = false;
|
| 428 |
}
|
| 429 |
},
|
| 430 |
|
|
@@ -435,8 +390,6 @@ const DeviceControl = {
|
|
| 435 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 436 |
return;
|
| 437 |
}
|
| 438 |
-
|
| 439 |
-
// ์ด๋ฏธ ๋ก๋ฉ ์ค์ด๋ฉด ์ค๋ณต ์์ฒญ ๋ฐฉ์ง
|
| 440 |
if (this.isLoadingPrograms) {
|
| 441 |
console.log('์ด๋ฏธ ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ๋ก๋ฉ ์ค');
|
| 442 |
return;
|
|
@@ -444,131 +397,76 @@ const DeviceControl = {
|
|
| 444 |
|
| 445 |
// ๋ก๋ฉ ์ค UI ์
๋ฐ์ดํธ
|
| 446 |
this.isLoadingPrograms = true;
|
| 447 |
-
if(this.elements.getProgramsBtn) this.elements.getProgramsBtn.disabled = true;
|
| 448 |
-
if(this.elements.programsList) {
|
| 449 |
-
this.elements.programsList.innerHTML =
|
| 450 |
-
<div class="loading-message">
|
| 451 |
-
${AppUtils.createLoadingSpinner()} ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ๋ก๋ ์ค...
|
| 452 |
-
</div>
|
| 453 |
-
`;
|
| 454 |
}
|
| 455 |
|
| 456 |
-
|
| 457 |
try {
|
| 458 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์์ฒญ ์ ์ก');
|
| 459 |
-
|
| 460 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 461 |
-
const response = await AppUtils.fetchWithTimeout('/api/device/programs', {
|
| 462 |
-
method: 'GET'
|
| 463 |
-
});
|
| 464 |
-
|
| 465 |
const data = await response.json();
|
| 466 |
|
| 467 |
if (response.ok && data.success) {
|
| 468 |
-
// ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต
|
| 469 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต:', data);
|
| 470 |
this.programsList = data.programs || [];
|
| 471 |
-
|
| 472 |
-
// ๋ชฉ๋ก ํ์
|
| 473 |
this.displayProgramsList();
|
| 474 |
-
|
| 475 |
-
// ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ
|
| 476 |
this.updateProgramsDropdown();
|
| 477 |
-
|
| 478 |
-
// ์คํ ๋ฒํผ ์ํ ์
๋ฐ์ดํธ
|
| 479 |
this.updateExecuteButton();
|
| 480 |
} else {
|
| 481 |
-
// ๋ชฉ๋ก ์กฐํ ์คํจ
|
| 482 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์คํจ:', data);
|
| 483 |
this.showProgramsError(`ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`);
|
| 484 |
}
|
| 485 |
} catch (error) {
|
| 486 |
-
// ์์ธ ๋ฐ์
|
| 487 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 488 |
this.showProgramsError(`ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 489 |
} finally {
|
| 490 |
-
// ๋ก๋ฉ ์ํ ๋ฐ ๋ฒํผ ์ํ ๋ณต์
|
| 491 |
this.isLoadingPrograms = false;
|
| 492 |
-
if(this.elements.getProgramsBtn) this.elements.getProgramsBtn.disabled = false;
|
| 493 |
}
|
| 494 |
},
|
| 495 |
|
| 496 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ํ์
|
| 497 |
displayProgramsList: function() {
|
| 498 |
const programsListElement = this.elements.programsList;
|
| 499 |
-
|
| 500 |
|
| 501 |
if (!this.programsList || this.programsList.length === 0) {
|
| 502 |
-
programsListElement.innerHTML =
|
| 503 |
-
<div class="no-programs-message">
|
| 504 |
-
<i class="fas fa-info-circle"></i> ๋ฑ๋ก๋ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค.
|
| 505 |
-
</div>
|
| 506 |
-
`;
|
| 507 |
return;
|
| 508 |
}
|
| 509 |
-
|
| 510 |
// ํ
์ด๋ธ ํํ๋ก ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ํ์
|
| 511 |
-
let html =
|
| 512 |
-
<table class="program-list">
|
| 513 |
-
<thead>
|
| 514 |
-
<tr>
|
| 515 |
-
<th>์ด๋ฆ</th>
|
| 516 |
-
<th>์ค๋ช
</th>
|
| 517 |
-
<th>๊ฒฝ๋ก</th>
|
| 518 |
-
</tr>
|
| 519 |
-
</thead>
|
| 520 |
-
<tbody>
|
| 521 |
-
`;
|
| 522 |
-
|
| 523 |
-
// ํ๋ก๊ทธ๋จ ํญ๋ชฉ ์์ฑ
|
| 524 |
this.programsList.forEach(program => {
|
| 525 |
-
html +=
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
</tr>
|
| 531 |
-
`;
|
| 532 |
});
|
| 533 |
-
|
| 534 |
-
html += `
|
| 535 |
-
</tbody>
|
| 536 |
-
</table>
|
| 537 |
-
<div style="margin-top: 10px; font-size: 0.9em; color: #666;">
|
| 538 |
-
์ด ${this.programsList.length}๊ฐ ํ๋ก๊ทธ๋จ
|
| 539 |
-
</div>
|
| 540 |
-
`;
|
| 541 |
-
|
| 542 |
programsListElement.innerHTML = html;
|
| 543 |
},
|
| 544 |
|
| 545 |
// ํ๋ก๊ทธ๋จ ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ
|
| 546 |
updateProgramsDropdown: function() {
|
| 547 |
const dropdown = this.elements.programSelectDropdown;
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
// ๊ธฐ์กด ์ต์
์ ๊ฑฐ
|
| 551 |
-
dropdown.innerHTML = '';
|
| 552 |
|
| 553 |
-
//
|
| 554 |
const defaultOption = document.createElement('option');
|
| 555 |
defaultOption.value = '';
|
| 556 |
-
defaultOption.textContent = this.programsList.length > 0
|
| 557 |
-
? '-- ์คํํ ํ๋ก๊ทธ๋จ ์ ํ --'
|
| 558 |
-
: '-- ํ๋ก๊ทธ๋จ ์์ --';
|
| 559 |
dropdown.appendChild(defaultOption);
|
| 560 |
|
| 561 |
-
// ํ๋ก๊ทธ๋จ ์ต์
์ถ๊ฐ
|
| 562 |
this.programsList.forEach(program => {
|
| 563 |
const option = document.createElement('option');
|
| 564 |
option.value = program.id || '';
|
| 565 |
option.textContent = program.name || '์ ์ ์์';
|
| 566 |
-
|
| 567 |
-
// ์ค๋ช
์ด ์์ผ๋ฉด ๊ดํธ๋ก ์ถ๊ฐ
|
| 568 |
if (program.description) {
|
| 569 |
option.textContent += ` (${program.description})`;
|
| 570 |
}
|
| 571 |
-
|
| 572 |
dropdown.appendChild(option);
|
| 573 |
});
|
| 574 |
},
|
|
@@ -577,23 +475,18 @@ const DeviceControl = {
|
|
| 577 |
updateExecuteButton: function() {
|
| 578 |
const dropdown = this.elements.programSelectDropdown;
|
| 579 |
const executeBtn = this.elements.executeProgramBtn;
|
| 580 |
-
if (!dropdown || !executeBtn) return;
|
| 581 |
-
|
| 582 |
-
// ์ ํ๋ ํ๋ก๊ทธ๋จ์ด ์์ ๋๋ง ๋ฒํผ ํ์ฑํ
|
| 583 |
-
executeBtn.disabled = !dropdown.value;
|
| 584 |
},
|
| 585 |
|
| 586 |
// ํ๋ก๊ทธ๋จ ์คํ (๋ฏธ๋ฆฌ ์ ์๋)
|
| 587 |
executeProgram: async function(programId) {
|
| 588 |
if (!this.isConnected) {
|
| 589 |
this.showExecuteResult('error', '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.');
|
| 590 |
-
console.error('ํ๋ก๊ทธ๋จ ์คํ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 591 |
return;
|
| 592 |
}
|
| 593 |
-
|
| 594 |
if (!programId) {
|
| 595 |
this.showExecuteResult('error', '์ค๋ฅ: ์คํํ ํ๋ก๊ทธ๋จ์ ์ ํํด์ฃผ์ธ์.');
|
| 596 |
-
console.error('ํ๋ก๊ทธ๋จ ์คํ ์๋ ์ค ์ค๋ฅ: ํ๋ก๊ทธ๋จ ID ์์');
|
| 597 |
return;
|
| 598 |
}
|
| 599 |
|
|
@@ -603,49 +496,38 @@ const DeviceControl = {
|
|
| 603 |
|
| 604 |
try {
|
| 605 |
console.log(`ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์ ์ก: ${programId}`);
|
| 606 |
-
|
| 607 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 608 |
const response = await AppUtils.fetchWithTimeout(`/api/device/programs/${programId}/execute`, {
|
| 609 |
method: 'POST',
|
| 610 |
-
headers: {
|
| 611 |
-
'Content-Type': 'application/json'
|
| 612 |
-
},
|
| 613 |
body: JSON.stringify({})
|
| 614 |
-
}, 15000); // 15์ด ํ์์์
|
| 615 |
|
| 616 |
const data = await response.json();
|
| 617 |
-
|
| 618 |
if (response.ok && data.success) {
|
| 619 |
-
// ์คํ ์ฑ๊ณต
|
| 620 |
console.log('ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต:', data);
|
| 621 |
this.showExecuteResult('success', `์คํ ์ฑ๊ณต: ${data.message || 'ํ๋ก๊ทธ๋จ์ด ์ฑ๊ณต์ ์ผ๋ก ์คํ๋์์ต๋๋ค.'}`);
|
| 622 |
-
|
| 623 |
-
// ์์คํ
์๋ฆผ
|
| 624 |
AppUtils.addSystemNotification(`ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต: ${this.getSelectedProgramName()}`);
|
| 625 |
} else {
|
| 626 |
-
// ์คํ ์คํจ
|
| 627 |
console.error('ํ๋ก๊ทธ๋จ ์คํ ์คํจ:', data);
|
| 628 |
this.showExecuteResult('error', `์คํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`);
|
| 629 |
}
|
| 630 |
} catch (error) {
|
| 631 |
-
// ์์ธ ๋ฐ์
|
| 632 |
console.error('ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 633 |
-
|
| 634 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 635 |
this.showExecuteResult('error', 'ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์๊ฐ ์ด๊ณผ. ์๋ฒ ์๋ต์ด ์์ต๋๋ค.');
|
| 636 |
} else {
|
| 637 |
this.showExecuteResult('error', `ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 638 |
}
|
| 639 |
} finally {
|
| 640 |
-
|
| 641 |
-
if(this.elements.executeProgramBtn) this.elements.executeProgramBtn.disabled = false;
|
| 642 |
}
|
| 643 |
},
|
| 644 |
|
| 645 |
// ์ ํ๋ ํ๋ก๊ทธ๋จ ์ด๋ฆ ๊ฐ์ ธ์ค๊ธฐ
|
| 646 |
getSelectedProgramName: function() {
|
| 647 |
const dropdown = this.elements.programSelectDropdown;
|
| 648 |
-
if (!dropdown) return '์ ์ ์๋ ํ๋ก๊ทธ๋จ';
|
| 649 |
const selectedOption = dropdown.options[dropdown.selectedIndex];
|
| 650 |
return selectedOption ? selectedOption.textContent : '์ ์ ์๋ ํ๋ก๊ทธ๋จ';
|
| 651 |
},
|
|
@@ -653,42 +535,28 @@ const DeviceControl = {
|
|
| 653 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์ค๋ฅ ํ์
|
| 654 |
showProgramsError: function(errorMessage) {
|
| 655 |
const programsListElement = this.elements.programsList;
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
programsListElement.innerHTML =
|
| 659 |
-
<div class="error-message">
|
| 660 |
-
<i class="fas fa-exclamation-circle"></i> ${errorMessage}
|
| 661 |
-
<button class="retry-button" id="retryLoadProgramsBtn">
|
| 662 |
-
<i class="fas fa-sync"></i> ๋ค์ ์๋
|
| 663 |
-
</button>
|
| 664 |
-
</div>
|
| 665 |
-
`;
|
| 666 |
-
|
| 667 |
-
// ์ฌ์๋ ๋ฒํผ ์ด๋ฒคํธ ๋ฆฌ์ค๋
|
| 668 |
-
// ์ด์ ์ ์ถ๊ฐ๋ ๋ฆฌ์ค๋๊ฐ ์๋ค๋ฉด ์ ๊ฑฐํ๊ณ ๋ค์ ์ถ๊ฐํ๋ ๊ฒ์ด ์์ ํ ์ ์์
|
| 669 |
const retryBtn = document.getElementById('retryLoadProgramsBtn');
|
| 670 |
if (retryBtn) {
|
| 671 |
-
|
|
|
|
| 672 |
document.getElementById('retryLoadProgramsBtn').addEventListener('click', () => {
|
| 673 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์ฌ์๋ ๋ฒํผ ํด๋ฆญ');
|
| 674 |
this.loadProgramsList();
|
| 675 |
});
|
| 676 |
}
|
| 677 |
-
|
| 678 |
},
|
| 679 |
|
| 680 |
// ์คํ ๊ฒฐ๊ณผ ํ์ (๋ฏธ๋ฆฌ ์ ์๋ ํ๋ก๊ทธ๋จ ์ฉ)
|
| 681 |
showExecuteResult: function(status, message) {
|
| 682 |
const resultElement = this.elements.executeResult;
|
| 683 |
-
if (!resultElement) return;
|
| 684 |
|
| 685 |
-
// ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 686 |
-
resultElement.
|
| 687 |
|
| 688 |
-
// ๋ด์ฉ ์ด๊ธฐํ
|
| 689 |
-
resultElement.innerHTML = '';
|
| 690 |
-
|
| 691 |
-
// ์ํ์ ๋ฐ๋ผ ์ฒ๋ฆฌ
|
| 692 |
switch (status) {
|
| 693 |
case 'success':
|
| 694 |
resultElement.classList.add('success');
|
|
@@ -710,18 +578,14 @@ const DeviceControl = {
|
|
| 710 |
}
|
| 711 |
},
|
| 712 |
|
| 713 |
-
// ================== ์ถ๊ฐ ์์ 4/4 ==================
|
| 714 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 715 |
executeCustomProgram: async function(command) {
|
| 716 |
if (!this.isConnected) {
|
| 717 |
this.showCustomExecuteResult('error', '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.');
|
| 718 |
-
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 719 |
return;
|
| 720 |
}
|
| 721 |
-
|
| 722 |
if (!command || command.trim() === '') {
|
| 723 |
this.showCustomExecuteResult('error', '์ค๋ฅ: ์คํํ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.');
|
| 724 |
-
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์๋ ์ค ์ค๋ฅ: ๋ช
๋ น์ด ์์');
|
| 725 |
return;
|
| 726 |
}
|
| 727 |
|
|
@@ -731,58 +595,38 @@ const DeviceControl = {
|
|
| 731 |
|
| 732 |
try {
|
| 733 |
console.log(`์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์ ์ก: ${command}`);
|
| 734 |
-
|
| 735 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 736 |
const response = await AppUtils.fetchWithTimeout('/api/device/execute-custom', {
|
| 737 |
method: 'POST',
|
| 738 |
-
headers: {
|
| 739 |
-
'Content-Type': 'application/json'
|
| 740 |
-
},
|
| 741 |
body: JSON.stringify({ command: command })
|
| 742 |
}, 15000); // 15์ด ํ์์์
|
| 743 |
|
| 744 |
const data = await response.json();
|
| 745 |
-
|
| 746 |
if (response.ok && data.success) {
|
| 747 |
-
// ์คํ ์ฑ๊ณต
|
| 748 |
console.log('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต:', data);
|
| 749 |
-
|
| 750 |
-
// ๊ฒฐ๊ณผ ํ์
|
| 751 |
let successMessage = `๋ช
๋ น์ด ์คํ ์ฑ๊ณต: ${data.message || ''}`;
|
| 752 |
-
|
| 753 |
-
// ์ถ๋ ฅ ๋ด์ฉ์ด ์์ผ๋ฉด ์ถ๊ฐ (HTML ์์ ์ฒ๋ฆฌ ํฌํจ)
|
| 754 |
if (data.output && data.output.trim()) {
|
| 755 |
successMessage += `<div class="command-output"><pre>${AppUtils.escapeHtml(data.output)}</pre></div>`;
|
| 756 |
}
|
| 757 |
-
|
| 758 |
this.showCustomExecuteResult('success', successMessage);
|
| 759 |
-
|
| 760 |
-
// ์์คํ
์๋ฆผ
|
| 761 |
AppUtils.addSystemNotification(`์ฌ์ฉ์ ์ ์ ๋ช
๋ น์ด ์คํ ์ฑ๊ณต: ${command}`);
|
| 762 |
} else {
|
| 763 |
-
// ์คํ ์คํจ
|
| 764 |
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์คํจ:', data);
|
| 765 |
-
|
| 766 |
let errorMessage = `์คํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`;
|
| 767 |
-
|
| 768 |
-
// ์ค๋ฅ ์ถ๋ ฅ์ด ์์ผ๋ฉด ์ถ๊ฐ (HTML ์์ ์ฒ๋ฆฌ ํฌํจ)
|
| 769 |
if (data.error_output && data.error_output.trim()) {
|
| 770 |
errorMessage += `<div class="command-error"><pre>${AppUtils.escapeHtml(data.error_output)}</pre></div>`;
|
| 771 |
}
|
| 772 |
-
|
| 773 |
this.showCustomExecuteResult('error', errorMessage);
|
| 774 |
}
|
| 775 |
} catch (error) {
|
| 776 |
-
// ์์ธ ๋ฐ์
|
| 777 |
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 778 |
-
|
| 779 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 780 |
this.showCustomExecuteResult('error', '๋ช
๋ น์ด ์คํ ์์ฒญ ์๊ฐ ์ด๊ณผ. ์๋ฒ ์๋ต์ด ์์ต๋๋ค.');
|
| 781 |
} else {
|
| 782 |
this.showCustomExecuteResult('error', `๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 783 |
}
|
| 784 |
} finally {
|
| 785 |
-
// ๋ฒํผ ๋ค์ ํ์ฑํ
|
| 786 |
if(this.elements.executeCustomBtn) this.elements.executeCustomBtn.disabled = false;
|
| 787 |
}
|
| 788 |
},
|
|
@@ -790,19 +634,14 @@ const DeviceControl = {
|
|
| 790 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ๊ฒฐ๊ณผ ํ์
|
| 791 |
showCustomExecuteResult: function(status, message) {
|
| 792 |
const resultElement = this.elements.customExecuteResult;
|
| 793 |
-
if (!resultElement) return;
|
| 794 |
-
|
| 795 |
-
// ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 796 |
-
resultElement.classList.remove('success', 'error', 'warning');
|
| 797 |
|
| 798 |
-
//
|
| 799 |
-
resultElement.innerHTML = '';
|
| 800 |
|
| 801 |
-
// ์ํ์ ๋ฐ๋ผ ์ฒ๋ฆฌ
|
| 802 |
switch (status) {
|
| 803 |
case 'success':
|
| 804 |
resultElement.classList.add('success');
|
| 805 |
-
// HTML ๋ฉ์์ง ์ฝ์
์ ์ฃผ์ (innerHTML ์ฌ์ฉ)
|
| 806 |
resultElement.innerHTML = `<i class="fas fa-check-circle"></i> ${message}`;
|
| 807 |
break;
|
| 808 |
case 'error':
|
|
@@ -814,15 +653,177 @@ const DeviceControl = {
|
|
| 814 |
resultElement.innerHTML = `<i class="fas fa-exclamation-triangle"></i> ${message}`;
|
| 815 |
break;
|
| 816 |
case 'loading':
|
| 817 |
-
// ๋ก๋ฉ ์คํผ๋ ํจ์๊ฐ AppUtils์ ์๋ค๊ณ ๊ฐ์
|
| 818 |
resultElement.innerHTML = `${AppUtils.createLoadingSpinner()} ${message}`;
|
| 819 |
break;
|
| 820 |
default:
|
| 821 |
resultElement.textContent = message; // ๊ธฐ๋ณธ์ ํ
์คํธ๋ง ํ์
|
| 822 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
}
|
| 824 |
-
// ================== ์ถ๊ฐ ๋
|
| 825 |
-
|
|
|
|
| 826 |
|
| 827 |
// ํ์ด์ง ๋ก๋ ์๋ฃ ์ ๋ชจ๋ ์ด๊ธฐํ
|
| 828 |
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
| 1 |
/**
|
| 2 |
+
* RAG ๊ฒ์ ์ฑ๋ด ์ฅ์น ์ ์ด JavaScript (ํฌํธ ์ค์บ ๊ธฐ๋ฅ ์ถ๊ฐ๋จ)
|
| 3 |
*/
|
| 4 |
|
| 5 |
// ์ฅ์น ์ ์ด ๋ชจ๋
|
|
|
|
| 27 |
deviceStatusResult: null,
|
| 28 |
|
| 29 |
// ํ๋ก๊ทธ๋จ ์คํ (๋ฏธ๋ฆฌ ์ ์๋)
|
| 30 |
+
deviceProgramControl: null,
|
| 31 |
getProgramsBtn: null,
|
| 32 |
programsList: null,
|
| 33 |
programSelectDropdown: null,
|
| 34 |
executeProgramBtn: null,
|
| 35 |
executeResult: null,
|
| 36 |
|
|
|
|
| 37 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 38 |
deviceCustomControl: null,
|
| 39 |
customCommandInput: null,
|
| 40 |
executeCustomBtn: null,
|
| 41 |
+
customExecuteResult: null,
|
| 42 |
+
|
| 43 |
+
// ================== ํฌํธ ์ค์บ ์์ ์ถ๊ฐ ==================
|
| 44 |
+
devicePortScanControl: null, // ํฌํธ ์ค์บ ์น์
์ปจํ
์ด๋
|
| 45 |
+
scanPortsBtn: null, // ํฌํธ ์ค์บ ๋ฒํผ
|
| 46 |
+
portsStatus: null, // ํฌํธ ์ค์บ ์ํ ํ์ ์์ญ
|
| 47 |
+
portsResults: null // ํฌํธ ์ค์บ ๊ฒฐ๊ณผ ํ์ ์์ญ
|
| 48 |
+
// ================== ์ถ๊ฐ ๋ ============================
|
| 49 |
},
|
| 50 |
|
| 51 |
// ๋ชจ๋ ์ด๊ธฐํ
|
| 52 |
init: function() {
|
| 53 |
console.log('์ฅ์น ์ ์ด ๋ชจ๋ ์ด๊ธฐํ ์ค...');
|
|
|
|
|
|
|
| 54 |
this.initElements();
|
|
|
|
|
|
|
| 55 |
this.initEventListeners();
|
|
|
|
| 56 |
console.log('์ฅ์น ์ ์ด ๋ชจ๋ ์ด๊ธฐํ ์๋ฃ');
|
| 57 |
},
|
| 58 |
|
|
|
|
| 80 |
this.elements.executeProgramBtn = document.getElementById('executeProgramBtn');
|
| 81 |
this.elements.executeResult = document.getElementById('executeResult');
|
| 82 |
|
|
|
|
| 83 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 84 |
this.elements.deviceCustomControl = document.getElementById('deviceCustomControl');
|
| 85 |
this.elements.customCommandInput = document.getElementById('customCommandInput');
|
| 86 |
this.elements.executeCustomBtn = document.getElementById('executeCustomBtn');
|
| 87 |
this.elements.customExecuteResult = document.getElementById('customExecuteResult');
|
| 88 |
+
|
| 89 |
+
// ================== ํฌํธ ์ค์บ ์์ ์ด๊ธฐํ ์ถ๊ฐ ==================
|
| 90 |
+
this.elements.devicePortScanControl = document.getElementById('devicePortScanControl');
|
| 91 |
+
this.elements.scanPortsBtn = document.getElementById('scanPortsBtn');
|
| 92 |
+
this.elements.portsStatus = document.getElementById('portsStatus');
|
| 93 |
+
this.elements.portsResults = document.getElementById('portsResults');
|
| 94 |
+
// ================== ์ถ๊ฐ ๋ =================================
|
| 95 |
|
| 96 |
console.log('์ฅ์น ์ ์ด DOM ์์ ์ฐธ์กฐ ์ด๊ธฐํ ์๋ฃ');
|
| 97 |
},
|
|
|
|
| 158 |
});
|
| 159 |
}
|
| 160 |
|
|
|
|
| 161 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ๋ฒํผ ํด๋ฆญ
|
| 162 |
if (this.elements.executeCustomBtn) {
|
| 163 |
this.elements.executeCustomBtn.addEventListener('click', () => {
|
|
|
|
| 178 |
}
|
| 179 |
});
|
| 180 |
}
|
| 181 |
+
|
| 182 |
+
// ================== ํฌํธ ์ค์บ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ถ๊ฐ ==================
|
| 183 |
+
if (this.elements.scanPortsBtn) {
|
| 184 |
+
this.elements.scanPortsBtn.addEventListener('click', () => {
|
| 185 |
+
console.log('์ฅ์น ํฌํธ ์ค์บ ๋ฒํผ ํด๋ฆญ');
|
| 186 |
+
this.scanDevicePorts();
|
| 187 |
+
});
|
| 188 |
+
}
|
| 189 |
+
// ================== ์ถ๊ฐ ๋ ==================================
|
| 190 |
|
| 191 |
console.log('์ฅ์น ์ ์ด ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก ์๋ฃ');
|
| 192 |
},
|
|
|
|
| 201 |
tabContents.forEach(content => content.classList.remove('active'));
|
| 202 |
|
| 203 |
// ์ฅ์น ์ ์ด ํญ ํ์ฑํ
|
| 204 |
+
if(this.elements.deviceTab) this.elements.deviceTab.classList.add('active');
|
| 205 |
+
if(this.elements.deviceSection) this.elements.deviceSection.classList.add('active');
|
| 206 |
|
| 207 |
console.log('์ฅ์น ์ ์ด ํญ์ผ๋ก ์ ํ ์๋ฃ');
|
| 208 |
},
|
|
|
|
| 213 |
const inputUrl = this.elements.deviceServerUrlInput.value.trim();
|
| 214 |
|
| 215 |
// ์ฐ๊ฒฐ ์๋ ์ค UI ์
๋ฐ์ดํธ
|
| 216 |
+
if(this.elements.connectDeviceServerBtn) this.elements.connectDeviceServerBtn.disabled = true;
|
| 217 |
this.updateConnectionStatus('connecting', 'ํ๊ฒฝ๋ณ์์ ์ ์ฅ๋ ์๋ฒ๋ก ์ฐ๊ฒฐ ์๋ ์ค...');
|
| 218 |
|
| 219 |
try {
|
|
|
|
| 227 |
const data = await response.json();
|
| 228 |
|
| 229 |
if (response.ok && data.success) {
|
| 230 |
+
// ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 231 |
console.log('ํ๊ฒฝ๋ณ์ ์ค์ ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต:', data);
|
| 232 |
this.isConnected = true;
|
| 233 |
+
// ์๋ฒ ์๋ต์์ ์ํ ๋ฉ์์ง๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ๊ธฐ๋ณธ๊ฐ ์ฌ์ฉ
|
| 234 |
+
const serverStatusMsg = data?.data?.status || data?.server_status || '์ ์';
|
| 235 |
+
this.updateConnectionStatus('connected', `์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! ์ํ: ${serverStatusMsg}`);
|
| 236 |
|
| 237 |
// ๊ธฐ๋ฅ UI ํ์ฑํ
|
| 238 |
if(this.elements.deviceBasicFunctions) this.elements.deviceBasicFunctions.classList.add('active');
|
| 239 |
if(this.elements.deviceProgramControl) this.elements.deviceProgramControl.classList.add('active');
|
|
|
|
| 240 |
if(this.elements.deviceCustomControl) this.elements.deviceCustomControl.classList.add('active');
|
| 241 |
+
// ================== ํฌํธ ์ค์บ UI ํ์ฑํ ์ถ๊ฐ ==================
|
| 242 |
+
if(this.elements.devicePortScanControl) this.elements.devicePortScanControl.classList.add('active');
|
| 243 |
+
// ================== ์ถ๊ฐ ๋ ==================================
|
| 244 |
|
| 245 |
// ์ฅ์น ์ํ ์๋ ์ฒดํฌ
|
| 246 |
this.checkDeviceStatus();
|
|
|
|
| 247 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ ๋ก๋
|
| 248 |
this.loadProgramsList();
|
|
|
|
| 249 |
// ์์คํ
์๋ฆผ
|
| 250 |
AppUtils.addSystemNotification(`์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! (ํ๊ฒฝ๋ณ์ URL)`);
|
| 251 |
+
|
| 252 |
} else {
|
| 253 |
// ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์คํจ, ์
๋ ฅ๋ URL๋ก ์๋
|
| 254 |
console.warn('ํ๊ฒฝ๋ณ์ ์ค์ ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ, ์
๋ ฅ URL๋ก ์ฌ์๋ํฉ๋๋ค:', data);
|
|
|
|
|
|
|
| 255 |
if (!inputUrl) {
|
| 256 |
console.error('์
๋ ฅ๋ URL์ด ์์ด ์ฐ๊ฒฐ ์คํจ');
|
| 257 |
this.isConnected = false;
|
| 258 |
this.updateConnectionStatus('error', 'ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์คํจ ๋ฐ ์
๋ ฅ๋ URL์ด ์์ต๋๋ค. URL์ ์
๋ ฅํด์ฃผ์ธ์.');
|
| 259 |
+
return; // ์
๋ ฅ URL ์์ผ๋ฉด ์ฌ๊ธฐ์ ์ข
๋ฃ
|
| 260 |
}
|
|
|
|
| 261 |
// ์
๋ ฅ URL๋ก ์ฌ์๋
|
| 262 |
+
await this.connectWithCustomUrl(inputUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
} catch (error) {
|
| 265 |
+
// ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์๋ ์ค ์์ธ ๋ฐ์
|
| 266 |
+
console.error('ํ๊ฒฝ๋ณ์ URL ์๋ฒ ์ฐ๊ฒฐ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 267 |
this.isConnected = false;
|
|
|
|
|
|
|
| 268 |
if (inputUrl) {
|
| 269 |
console.warn('ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์ ์ค๋ฅ ๋ฐ์, ์
๋ ฅ URL๋ก ์ฌ์๋ํฉ๋๋ค');
|
| 270 |
+
await this.connectWithCustomUrl(inputUrl); // ์
๋ ฅ URL ์ฌ์๋
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
} else {
|
| 272 |
+
// ์
๋ ฅ URL๋ ์๋ ๊ฒฝ์ฐ ์ต์ข
์ค๋ฅ ์ฒ๋ฆฌ
|
| 273 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 274 |
this.updateConnectionStatus('error', 'ํ๊ฒฝ๋ณ์ URL ์ฐ๊ฒฐ ์๊ฐ ์ด๊ณผ. URL์ ์
๋ ฅํ์ฌ ๋ค์ ์๋ํด์ฃผ์ธ์.');
|
| 275 |
} else {
|
|
|
|
| 278 |
}
|
| 279 |
} finally {
|
| 280 |
// ๋ฒํผ ๋ค์ ํ์ฑํ
|
| 281 |
+
if(this.elements.connectDeviceServerBtn) this.elements.connectDeviceServerBtn.disabled = false;
|
| 282 |
}
|
| 283 |
},
|
| 284 |
|
| 285 |
+
// ์ฌ์ฉ์ ์
๋ ฅ URL๋ก ์ฐ๊ฒฐ ์๋ (connectServer ๋ด๋ถ ๋ก์ง ๋ถ๋ฆฌ)
|
| 286 |
+
connectWithCustomUrl: async function(url) {
|
| 287 |
+
this.updateConnectionStatus('connecting', `์
๋ ฅ URL(${url})๋ก ์ฐ๊ฒฐ ์๋ ์ค...`);
|
| 288 |
+
console.log(`์
๋ ฅํ URL๋ก ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์๋: ${url}`);
|
| 289 |
+
|
| 290 |
+
try {
|
| 291 |
+
// ๋ฐฑ์๋ API ํธ์ถ - Flask ๋ฐฑ์๋๊ฐ URL ๋ฐ์์ ์ฒ๋ฆฌ
|
| 292 |
+
const customUrlResponse = await AppUtils.fetchWithTimeout('/api/device/connect', {
|
| 293 |
+
method: 'POST',
|
| 294 |
+
headers: { 'Content-Type': 'application/json' },
|
| 295 |
+
body: JSON.stringify({ url: url })
|
| 296 |
+
}, 10000);
|
| 297 |
+
|
| 298 |
+
const customUrlData = await customUrlResponse.json();
|
| 299 |
+
|
| 300 |
+
if (customUrlResponse.ok && customUrlData.success) {
|
| 301 |
+
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 302 |
+
console.log('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต:', customUrlData);
|
| 303 |
+
this.isConnected = true;
|
| 304 |
+
this.updateConnectionStatus('connected', `์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! ์ํ: ${customUrlData.server_status || '์ ์'}`);
|
| 305 |
+
|
| 306 |
+
// ๊ธฐ๋ฅ UI ํ์ฑํ
|
| 307 |
+
if(this.elements.deviceBasicFunctions) this.elements.deviceBasicFunctions.classList.add('active');
|
| 308 |
+
if(this.elements.deviceProgramControl) this.elements.deviceProgramControl.classList.add('active');
|
| 309 |
+
if(this.elements.deviceCustomControl) this.elements.deviceCustomControl.classList.add('active');
|
| 310 |
+
// ================== ํฌํธ ์ค์บ UI ํ์ฑํ ์ถ๊ฐ ==================
|
| 311 |
+
if(this.elements.devicePortScanControl) this.elements.devicePortScanControl.classList.add('active');
|
| 312 |
+
// ================== ์ถ๊ฐ ๋ ==================================
|
| 313 |
+
|
| 314 |
+
// ์ฅ์น ์ํ ์๋ ์ฒดํฌ
|
| 315 |
+
this.checkDeviceStatus();
|
| 316 |
+
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ ๋ก๋
|
| 317 |
+
this.loadProgramsList();
|
| 318 |
+
// ์์คํ
์๋ฆผ
|
| 319 |
+
AppUtils.addSystemNotification(`์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต! (${url})`);
|
| 320 |
+
} else {
|
| 321 |
+
// ์
๋ ฅ URL ์ฐ๊ฒฐ ์คํจ
|
| 322 |
+
console.error('์
๋ ฅ URL ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์คํจ:', customUrlData);
|
| 323 |
+
this.isConnected = false;
|
| 324 |
+
this.updateConnectionStatus('error', `์๋ฒ ์ฐ๊ฒฐ ์คํจ: ${customUrlData.error || '์๋ฒ ์๋ต ์ค๋ฅ'}`);
|
| 325 |
+
}
|
| 326 |
+
} catch(error) {
|
| 327 |
+
// ์
๋ ฅ URL๋ก ์๋ ์ค ์ค๋ฅ
|
| 328 |
+
console.error('์
๋ ฅ URL๋ก ์ฌ์๋ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 329 |
+
this.isConnected = false;
|
| 330 |
+
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 331 |
+
this.updateConnectionStatus('error', '์๋ฒ ์ฐ๊ฒฐ ์๊ฐ ์ด๊ณผ. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์.');
|
| 332 |
+
} else {
|
| 333 |
+
this.updateConnectionStatus('error', `์๋ฒ ์ฐ๊ฒฐ ์ค๋ฅ: ${error.message}`);
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
},
|
| 337 |
+
|
| 338 |
// ์ฐ๊ฒฐ ์ํ ์
๋ฐ์ดํธ
|
| 339 |
updateConnectionStatus: function(status, message) {
|
| 340 |
const statusElement = this.elements.deviceConnectionStatus;
|
|
|
|
| 342 |
|
| 343 |
// ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 344 |
statusElement.classList.remove('connected', 'disconnected', 'error', 'connecting');
|
|
|
|
| 345 |
// ์ํ์ ๋ฐ๋ผ ํด๋์ค ์ถ๊ฐ
|
| 346 |
statusElement.classList.add(status);
|
|
|
|
| 347 |
// ๋ฉ์์ง ์
๋ฐ์ดํธ
|
| 348 |
statusElement.textContent = message;
|
|
|
|
| 349 |
console.log(`์ฐ๊ฒฐ ์ํ ์
๋ฐ์ดํธ: ${status} - ${message}`);
|
| 350 |
},
|
| 351 |
|
| 352 |
// ์ฅ์น ์ํ ํ์ธ
|
| 353 |
checkDeviceStatus: async function() {
|
| 354 |
if (!this.isConnected) {
|
| 355 |
+
if(this.elements.deviceStatusResult) this.elements.deviceStatusResult.value = '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.';
|
| 356 |
console.error('์ฅ์น ์ํ ํ์ธ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 357 |
return;
|
| 358 |
}
|
|
|
|
| 359 |
// ์ํ ํ์ธ ์ค UI ์
๋ฐ์ดํธ
|
| 360 |
+
if(this.elements.checkDeviceStatusBtn) this.elements.checkDeviceStatusBtn.disabled = true;
|
| 361 |
+
if(this.elements.deviceStatusResult) this.elements.deviceStatusResult.value = '์ฅ์น ์ํ ํ์ธ ์ค...';
|
| 362 |
|
| 363 |
try {
|
| 364 |
console.log('์ฅ์น ์ํ ํ์ธ ์์ฒญ ์ ์ก');
|
|
|
|
| 365 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 366 |
+
const response = await AppUtils.fetchWithTimeout('/api/device/status', { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
| 367 |
const data = await response.json();
|
| 368 |
|
| 369 |
if (response.ok && data.success) {
|
|
|
|
| 370 |
console.log('์ฅ์น ์ํ ํ์ธ ์ฑ๊ณต:', data);
|
| 371 |
this.isStatusChecked = true;
|
| 372 |
// JSON ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ธฐ ์ข๊ฒ ํฌ๋งทํ
ํ์ฌ ํ์
|
| 373 |
+
if(this.elements.deviceStatusResult) this.elements.deviceStatusResult.value = JSON.stringify(data.data || data, null, 2); // data.data ์ฐ์ ํ์ธ
|
| 374 |
} else {
|
|
|
|
| 375 |
console.error('์ฅ์น ์ํ ํ์ธ ์คํจ:', data);
|
| 376 |
+
if(this.elements.deviceStatusResult) this.elements.deviceStatusResult.value = `์ํ ํ์ธ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`;
|
| 377 |
}
|
| 378 |
} catch (error) {
|
|
|
|
| 379 |
console.error('์ฅ์น ์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 380 |
+
if(this.elements.deviceStatusResult) this.elements.deviceStatusResult.value = `์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`;
|
| 381 |
} finally {
|
| 382 |
+
if(this.elements.checkDeviceStatusBtn) this.elements.checkDeviceStatusBtn.disabled = false;
|
|
|
|
| 383 |
}
|
| 384 |
},
|
| 385 |
|
|
|
|
| 390 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 391 |
return;
|
| 392 |
}
|
|
|
|
|
|
|
| 393 |
if (this.isLoadingPrograms) {
|
| 394 |
console.log('์ด๋ฏธ ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ๋ก๋ฉ ์ค');
|
| 395 |
return;
|
|
|
|
| 397 |
|
| 398 |
// ๋ก๋ฉ ์ค UI ์
๋ฐ์ดํธ
|
| 399 |
this.isLoadingPrograms = true;
|
| 400 |
+
if(this.elements.getProgramsBtn) this.elements.getProgramsBtn.disabled = true;
|
| 401 |
+
if(this.elements.programsList) {
|
| 402 |
+
this.elements.programsList.innerHTML = `<div class="loading-message">${AppUtils.createLoadingSpinner()} ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ๋ก๋ ์ค...</div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
}
|
| 404 |
|
|
|
|
| 405 |
try {
|
| 406 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์์ฒญ ์ ์ก');
|
|
|
|
| 407 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 408 |
+
const response = await AppUtils.fetchWithTimeout('/api/device/programs', { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
| 409 |
const data = await response.json();
|
| 410 |
|
| 411 |
if (response.ok && data.success) {
|
|
|
|
| 412 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต:', data);
|
| 413 |
this.programsList = data.programs || [];
|
|
|
|
|
|
|
| 414 |
this.displayProgramsList();
|
|
|
|
|
|
|
| 415 |
this.updateProgramsDropdown();
|
|
|
|
|
|
|
| 416 |
this.updateExecuteButton();
|
| 417 |
} else {
|
|
|
|
| 418 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์คํจ:', data);
|
| 419 |
this.showProgramsError(`ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`);
|
| 420 |
}
|
| 421 |
} catch (error) {
|
|
|
|
| 422 |
console.error('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 423 |
this.showProgramsError(`ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 424 |
} finally {
|
|
|
|
| 425 |
this.isLoadingPrograms = false;
|
| 426 |
+
if(this.elements.getProgramsBtn) this.elements.getProgramsBtn.disabled = false;
|
| 427 |
}
|
| 428 |
},
|
| 429 |
|
| 430 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ํ์
|
| 431 |
displayProgramsList: function() {
|
| 432 |
const programsListElement = this.elements.programsList;
|
| 433 |
+
if (!programsListElement) return;
|
| 434 |
|
| 435 |
if (!this.programsList || this.programsList.length === 0) {
|
| 436 |
+
programsListElement.innerHTML = `<div class="no-programs-message"><i class="fas fa-info-circle"></i> ๋ฑ๋ก๋ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค.</div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
return;
|
| 438 |
}
|
|
|
|
| 439 |
// ํ
์ด๋ธ ํํ๋ก ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ํ์
|
| 440 |
+
let html = `<table class="program-list"><thead><tr><th>์ด๋ฆ</th><th>์ค๋ช
</th><th>๊ฒฝ๋ก</th></tr></thead><tbody>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
this.programsList.forEach(program => {
|
| 442 |
+
html += `<tr>
|
| 443 |
+
<td>${AppUtils.escapeHtml(program.name || '์ ์ ์์')}</td>
|
| 444 |
+
<td>${AppUtils.escapeHtml(program.description || '-')}</td>
|
| 445 |
+
<td>${AppUtils.escapeHtml(program.path || '-')}</td>
|
| 446 |
+
</tr>`;
|
|
|
|
|
|
|
| 447 |
});
|
| 448 |
+
html += `</tbody></table><div style="margin-top: 10px; font-size: 0.9em; color: #666;">์ด ${this.programsList.length}๊ฐ ํ๋ก๊ทธ๋จ</div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
programsListElement.innerHTML = html;
|
| 450 |
},
|
| 451 |
|
| 452 |
// ํ๋ก๊ทธ๋จ ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ
|
| 453 |
updateProgramsDropdown: function() {
|
| 454 |
const dropdown = this.elements.programSelectDropdown;
|
| 455 |
+
if (!dropdown) return;
|
|
|
|
|
|
|
|
|
|
| 456 |
|
| 457 |
+
dropdown.innerHTML = ''; // ๊ธฐ์กด ์ต์
์ ๊ฑฐ
|
| 458 |
const defaultOption = document.createElement('option');
|
| 459 |
defaultOption.value = '';
|
| 460 |
+
defaultOption.textContent = this.programsList.length > 0 ? '-- ์คํํ ํ๋ก๊ทธ๋จ ์ ํ --' : '-- ํ๋ก๊ทธ๋จ ์์ --';
|
|
|
|
|
|
|
| 461 |
dropdown.appendChild(defaultOption);
|
| 462 |
|
|
|
|
| 463 |
this.programsList.forEach(program => {
|
| 464 |
const option = document.createElement('option');
|
| 465 |
option.value = program.id || '';
|
| 466 |
option.textContent = program.name || '์ ์ ์์';
|
|
|
|
|
|
|
| 467 |
if (program.description) {
|
| 468 |
option.textContent += ` (${program.description})`;
|
| 469 |
}
|
|
|
|
| 470 |
dropdown.appendChild(option);
|
| 471 |
});
|
| 472 |
},
|
|
|
|
| 475 |
updateExecuteButton: function() {
|
| 476 |
const dropdown = this.elements.programSelectDropdown;
|
| 477 |
const executeBtn = this.elements.executeProgramBtn;
|
| 478 |
+
if (!dropdown || !executeBtn) return;
|
| 479 |
+
executeBtn.disabled = !dropdown.value; // ์ ํ๋ ํ๋ก๊ทธ๋จ์ด ์์ ๋๋ง ํ์ฑํ
|
|
|
|
|
|
|
| 480 |
},
|
| 481 |
|
| 482 |
// ํ๋ก๊ทธ๋จ ์คํ (๋ฏธ๋ฆฌ ์ ์๋)
|
| 483 |
executeProgram: async function(programId) {
|
| 484 |
if (!this.isConnected) {
|
| 485 |
this.showExecuteResult('error', '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.');
|
|
|
|
| 486 |
return;
|
| 487 |
}
|
|
|
|
| 488 |
if (!programId) {
|
| 489 |
this.showExecuteResult('error', '์ค๋ฅ: ์คํํ ํ๋ก๊ทธ๋จ์ ์ ํํด์ฃผ์ธ์.');
|
|
|
|
| 490 |
return;
|
| 491 |
}
|
| 492 |
|
|
|
|
| 496 |
|
| 497 |
try {
|
| 498 |
console.log(`ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์ ์ก: ${programId}`);
|
|
|
|
| 499 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 500 |
const response = await AppUtils.fetchWithTimeout(`/api/device/programs/${programId}/execute`, {
|
| 501 |
method: 'POST',
|
| 502 |
+
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
|
|
| 503 |
body: JSON.stringify({})
|
| 504 |
+
}, 15000); // 15์ด ํ์์์
|
| 505 |
|
| 506 |
const data = await response.json();
|
|
|
|
| 507 |
if (response.ok && data.success) {
|
|
|
|
| 508 |
console.log('ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต:', data);
|
| 509 |
this.showExecuteResult('success', `์คํ ์ฑ๊ณต: ${data.message || 'ํ๋ก๊ทธ๋จ์ด ์ฑ๊ณต์ ์ผ๋ก ์คํ๋์์ต๋๋ค.'}`);
|
|
|
|
|
|
|
| 510 |
AppUtils.addSystemNotification(`ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต: ${this.getSelectedProgramName()}`);
|
| 511 |
} else {
|
|
|
|
| 512 |
console.error('ํ๋ก๊ทธ๋จ ์คํ ์คํจ:', data);
|
| 513 |
this.showExecuteResult('error', `์คํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`);
|
| 514 |
}
|
| 515 |
} catch (error) {
|
|
|
|
| 516 |
console.error('ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
|
|
|
| 517 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 518 |
this.showExecuteResult('error', 'ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์๊ฐ ์ด๊ณผ. ์๋ฒ ์๋ต์ด ์์ต๋๋ค.');
|
| 519 |
} else {
|
| 520 |
this.showExecuteResult('error', `ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 521 |
}
|
| 522 |
} finally {
|
| 523 |
+
if(this.elements.executeProgramBtn) this.elements.executeProgramBtn.disabled = false;
|
|
|
|
| 524 |
}
|
| 525 |
},
|
| 526 |
|
| 527 |
// ์ ํ๋ ํ๋ก๊ทธ๋จ ์ด๋ฆ ๊ฐ์ ธ์ค๊ธฐ
|
| 528 |
getSelectedProgramName: function() {
|
| 529 |
const dropdown = this.elements.programSelectDropdown;
|
| 530 |
+
if (!dropdown || dropdown.selectedIndex < 0) return '์ ์ ์๋ ํ๋ก๊ทธ๋จ'; // ์ธ๋ฑ์ค ์ฒดํฌ ์ถ๊ฐ
|
| 531 |
const selectedOption = dropdown.options[dropdown.selectedIndex];
|
| 532 |
return selectedOption ? selectedOption.textContent : '์ ์ ์๋ ํ๋ก๊ทธ๋จ';
|
| 533 |
},
|
|
|
|
| 535 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์ค๋ฅ ํ์
|
| 536 |
showProgramsError: function(errorMessage) {
|
| 537 |
const programsListElement = this.elements.programsList;
|
| 538 |
+
if (!programsListElement) return;
|
| 539 |
+
|
| 540 |
+
programsListElement.innerHTML = `<div class="error-message"><i class="fas fa-exclamation-circle"></i> ${errorMessage} <button class="retry-button" id="retryLoadProgramsBtn"><i class="fas fa-sync"></i> ๋ค์ ์๋</button></div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
const retryBtn = document.getElementById('retryLoadProgramsBtn');
|
| 542 |
if (retryBtn) {
|
| 543 |
+
// ๊ธฐ์กด ๋ฆฌ์ค๋ ์ ๊ฑฐ ํ ์ถ๊ฐ (์ค๋ณต ๋ฐฉ์ง)
|
| 544 |
+
retryBtn.replaceWith(retryBtn.cloneNode(true));
|
| 545 |
document.getElementById('retryLoadProgramsBtn').addEventListener('click', () => {
|
| 546 |
console.log('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์ฌ์๋ ๋ฒํผ ํด๋ฆญ');
|
| 547 |
this.loadProgramsList();
|
| 548 |
});
|
| 549 |
}
|
|
|
|
| 550 |
},
|
| 551 |
|
| 552 |
// ์คํ ๊ฒฐ๊ณผ ํ์ (๋ฏธ๋ฆฌ ์ ์๋ ํ๋ก๊ทธ๋จ ์ฉ)
|
| 553 |
showExecuteResult: function(status, message) {
|
| 554 |
const resultElement = this.elements.executeResult;
|
| 555 |
+
if (!resultElement) return;
|
| 556 |
|
| 557 |
+
resultElement.classList.remove('success', 'error', 'warning'); // ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 558 |
+
resultElement.innerHTML = ''; // ๋ด์ฉ ์ด๊ธฐํ
|
| 559 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
switch (status) {
|
| 561 |
case 'success':
|
| 562 |
resultElement.classList.add('success');
|
|
|
|
| 578 |
}
|
| 579 |
},
|
| 580 |
|
|
|
|
| 581 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 582 |
executeCustomProgram: async function(command) {
|
| 583 |
if (!this.isConnected) {
|
| 584 |
this.showCustomExecuteResult('error', '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.');
|
|
|
|
| 585 |
return;
|
| 586 |
}
|
|
|
|
| 587 |
if (!command || command.trim() === '') {
|
| 588 |
this.showCustomExecuteResult('error', '์ค๋ฅ: ์คํํ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.');
|
|
|
|
| 589 |
return;
|
| 590 |
}
|
| 591 |
|
|
|
|
| 595 |
|
| 596 |
try {
|
| 597 |
console.log(`์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์ ์ก: ${command}`);
|
|
|
|
| 598 |
// ๋ฐฑ์๋ API ํธ์ถ
|
| 599 |
const response = await AppUtils.fetchWithTimeout('/api/device/execute-custom', {
|
| 600 |
method: 'POST',
|
| 601 |
+
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
|
|
| 602 |
body: JSON.stringify({ command: command })
|
| 603 |
}, 15000); // 15์ด ํ์์์
|
| 604 |
|
| 605 |
const data = await response.json();
|
|
|
|
| 606 |
if (response.ok && data.success) {
|
|
|
|
| 607 |
console.log('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์ฑ๊ณต:', data);
|
|
|
|
|
|
|
| 608 |
let successMessage = `๋ช
๋ น์ด ์คํ ์ฑ๊ณต: ${data.message || ''}`;
|
|
|
|
|
|
|
| 609 |
if (data.output && data.output.trim()) {
|
| 610 |
successMessage += `<div class="command-output"><pre>${AppUtils.escapeHtml(data.output)}</pre></div>`;
|
| 611 |
}
|
|
|
|
| 612 |
this.showCustomExecuteResult('success', successMessage);
|
|
|
|
|
|
|
| 613 |
AppUtils.addSystemNotification(`์ฌ์ฉ์ ์ ์ ๋ช
๋ น์ด ์คํ ์ฑ๊ณต: ${command}`);
|
| 614 |
} else {
|
|
|
|
| 615 |
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์คํจ:', data);
|
|
|
|
| 616 |
let errorMessage = `์คํ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`;
|
|
|
|
|
|
|
| 617 |
if (data.error_output && data.error_output.trim()) {
|
| 618 |
errorMessage += `<div class="command-error"><pre>${AppUtils.escapeHtml(data.error_output)}</pre></div>`;
|
| 619 |
}
|
|
|
|
| 620 |
this.showCustomExecuteResult('error', errorMessage);
|
| 621 |
}
|
| 622 |
} catch (error) {
|
|
|
|
| 623 |
console.error('์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
|
|
|
| 624 |
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 625 |
this.showCustomExecuteResult('error', '๋ช
๋ น์ด ์คํ ์์ฒญ ์๊ฐ ์ด๊ณผ. ์๋ฒ ์๋ต์ด ์์ต๋๋ค.');
|
| 626 |
} else {
|
| 627 |
this.showCustomExecuteResult('error', `๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 628 |
}
|
| 629 |
} finally {
|
|
|
|
| 630 |
if(this.elements.executeCustomBtn) this.elements.executeCustomBtn.disabled = false;
|
| 631 |
}
|
| 632 |
},
|
|
|
|
| 634 |
// ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ๊ฒฐ๊ณผ ํ์
|
| 635 |
showCustomExecuteResult: function(status, message) {
|
| 636 |
const resultElement = this.elements.customExecuteResult;
|
| 637 |
+
if (!resultElement) return;
|
|
|
|
|
|
|
|
|
|
| 638 |
|
| 639 |
+
resultElement.classList.remove('success', 'error', 'warning'); // ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 640 |
+
resultElement.innerHTML = ''; // ๋ด์ฉ ์ด๊ธฐํ
|
| 641 |
|
|
|
|
| 642 |
switch (status) {
|
| 643 |
case 'success':
|
| 644 |
resultElement.classList.add('success');
|
|
|
|
| 645 |
resultElement.innerHTML = `<i class="fas fa-check-circle"></i> ${message}`;
|
| 646 |
break;
|
| 647 |
case 'error':
|
|
|
|
| 653 |
resultElement.innerHTML = `<i class="fas fa-exclamation-triangle"></i> ${message}`;
|
| 654 |
break;
|
| 655 |
case 'loading':
|
|
|
|
| 656 |
resultElement.innerHTML = `${AppUtils.createLoadingSpinner()} ${message}`;
|
| 657 |
break;
|
| 658 |
default:
|
| 659 |
resultElement.textContent = message; // ๊ธฐ๋ณธ์ ํ
์คํธ๋ง ํ์
|
| 660 |
}
|
| 661 |
+
},
|
| 662 |
+
|
| 663 |
+
// ================== ํฌํธ ์ค์บ ํจ์ ์ถ๊ฐ ==================
|
| 664 |
+
// ์ฅ์น ํฌํธ ์ค์บ ํจ์
|
| 665 |
+
scanDevicePorts: async function() {
|
| 666 |
+
if (!this.isConnected) {
|
| 667 |
+
this.showPortsStatus('error', '์ค๋ฅ: ๋จผ์ ์๋ฒ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค.');
|
| 668 |
+
console.error('์ฅ์น ํฌํธ ์ค์บ ์๋ ์ค ์ค๋ฅ: ์๋ฒ ์ฐ๊ฒฐ ์๋จ');
|
| 669 |
+
return;
|
| 670 |
+
}
|
| 671 |
+
// ์ค์บ ์ค UI ์
๋ฐ์ดํธ
|
| 672 |
+
if(this.elements.scanPortsBtn) this.elements.scanPortsBtn.disabled = true;
|
| 673 |
+
this.showPortsStatus('loading', '์ฅ์น ํฌํธ ์ค์บ ์ค...');
|
| 674 |
+
|
| 675 |
+
try {
|
| 676 |
+
console.log('์ฅ์น ํฌํธ ์ค์บ ์์ฒญ ์ ์ก');
|
| 677 |
+
// ๋ฐฑ์๋ API ํธ์ถ
|
| 678 |
+
const response = await AppUtils.fetchWithTimeout('/api/device/scan-ports', {
|
| 679 |
+
method: 'GET'
|
| 680 |
+
}, 30000); // ์ฅ์น ์ค์บ์ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆด ์ ์์ผ๋ฏ๋ก ํ์์์ 30์ด๋ก ์ค์
|
| 681 |
+
|
| 682 |
+
const data = await response.json();
|
| 683 |
+
|
| 684 |
+
if (response.ok && data.success) {
|
| 685 |
+
// ์ค์บ ์ฑ๊ณต
|
| 686 |
+
console.log('์ฅ์น ํฌํธ ์ค์บ ์ฑ๊ณต:', data);
|
| 687 |
+
// ๊ฒฐ๊ณผ ํ์
|
| 688 |
+
this.displayPortsResults(data);
|
| 689 |
+
this.showPortsStatus('success', '์ฅ์น ํฌํธ ์ค์บ์ด ์๋ฃ๋์์ต๋๋ค.');
|
| 690 |
+
} else {
|
| 691 |
+
// ์ค์บ ์คํจ
|
| 692 |
+
console.error('์ฅ์น ํฌํธ ์ค์บ ์คํจ:', data);
|
| 693 |
+
this.showPortsStatus('error', `์ค์บ ์คํจ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}`);
|
| 694 |
+
}
|
| 695 |
+
} catch (error) {
|
| 696 |
+
// ์์ธ ๋ฐ์
|
| 697 |
+
console.error('์ฅ์น ํฌํธ ์ค์บ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 698 |
+
if (error.message.includes('์๊ฐ์ด ์ด๊ณผ')) {
|
| 699 |
+
this.showPortsStatus('error', '์ฅ์น ํฌํธ ์ค์บ ์์ฒญ ์๊ฐ ์ด๊ณผ. ์๋ฒ ์๋ต์ด ์์ต๋๋ค.');
|
| 700 |
+
} else {
|
| 701 |
+
this.showPortsStatus('error', `์ฅ์น ํฌํธ ์ค์บ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`);
|
| 702 |
+
}
|
| 703 |
+
} finally {
|
| 704 |
+
// ๋ฒํผ ๋ค์ ํ์ฑํ
|
| 705 |
+
if(this.elements.scanPortsBtn) this.elements.scanPortsBtn.disabled = false;
|
| 706 |
+
}
|
| 707 |
+
},
|
| 708 |
+
|
| 709 |
+
// ์ฅ์น ํฌํธ ์ค์บ ๊ฒฐ๊ณผ ํ์
|
| 710 |
+
displayPortsResults: function(data) {
|
| 711 |
+
const portsResultsElement = this.elements.portsResults;
|
| 712 |
+
if (!portsResultsElement) return; // ์์ ์์ผ๋ฉด ์ข
๋ฃ
|
| 713 |
+
|
| 714 |
+
// ์์คํ
์ ๋ณด
|
| 715 |
+
const systemInfo = data.system_info || {};
|
| 716 |
+
const devices = data.devices || {};
|
| 717 |
+
const serialPorts = devices.serial || [];
|
| 718 |
+
const usbDevices = devices.usb || [];
|
| 719 |
+
const windowsUsbDevices = devices.windows_usb || []; // windows_usb ํค ์ถ๊ฐ
|
| 720 |
+
|
| 721 |
+
// HTML ์์ฑ ์์
|
| 722 |
+
let html = `<div class="ports-results-container">`;
|
| 723 |
+
|
| 724 |
+
// ์์คํ
์ ๋ณด ์น์
|
| 725 |
+
html += `<div class="ports-section">
|
| 726 |
+
<h4>์์คํ
์ ๋ณด</h4>
|
| 727 |
+
<div class="info-row"><span class="info-label">OS:</span><span class="info-value">${AppUtils.escapeHtml(systemInfo.os || '์ ์ ์์')} ${AppUtils.escapeHtml(systemInfo.version || '')}</span></div>
|
| 728 |
+
<div class="info-row"><span class="info-label">์์คํ
:</span><span class="info-value">${AppUtils.escapeHtml(systemInfo.platform || '์ ์ ์์')}</span></div>
|
| 729 |
+
<div class="info-row"><span class="info-label">์กฐํ ์๊ฐ:</span><span class="info-value">${AppUtils.escapeHtml(data.timestamp || '์ ์ ์์')}</span></div>
|
| 730 |
+
</div>`;
|
| 731 |
+
|
| 732 |
+
// ์๋ฆฌ์ผ ํฌํธ ์น์
|
| 733 |
+
html += `<div class="ports-section"><h4>์๋ฆฌ์ผ ํฌํธ (${serialPorts.length}๊ฐ)</h4>`;
|
| 734 |
+
if (serialPorts.length === 0) {
|
| 735 |
+
html += `<p class="no-ports-message">๋ฐ๊ฒฌ๋ ์๋ฆฌ์ผ ํฌํธ๊ฐ ์์ต๋๋ค.</p>`;
|
| 736 |
+
} else {
|
| 737 |
+
html += `<table class="ports-table"><thead><tr><th>ํฌํธ</th><th>์ค๋ช
</th><th>์ ์กฐ์ฌ</th><th>VID:PID</th></tr></thead><tbody>`;
|
| 738 |
+
serialPorts.forEach(port => {
|
| 739 |
+
const vidPid = (port.vid && port.pid) ? `${port.vid}:${port.pid}` : '์ ์ ์์';
|
| 740 |
+
html += `<tr>
|
| 741 |
+
<td>${AppUtils.escapeHtml(port.port || '')}</td>
|
| 742 |
+
<td>${AppUtils.escapeHtml(port.description || '')}</td>
|
| 743 |
+
<td>${AppUtils.escapeHtml(port.manufacturer || '')}</td>
|
| 744 |
+
<td>${AppUtils.escapeHtml(vidPid)}</td>
|
| 745 |
+
</tr>`;
|
| 746 |
+
});
|
| 747 |
+
html += `</tbody></table>`;
|
| 748 |
+
}
|
| 749 |
+
html += `</div>`;
|
| 750 |
+
|
| 751 |
+
// USB ์ฅ์น ์น์
(pyserial list_ports ๊ธฐ๋ฐ)
|
| 752 |
+
html += `<div class="ports-section"><h4>USB ์ฅ์น (pyserial) (${usbDevices.length}๊ฐ)</h4>`;
|
| 753 |
+
if (usbDevices.length === 0) {
|
| 754 |
+
html += `<p class="no-ports-message">๋ฐ๊ฒฌ๋ USB ์ฅ์น๊ฐ ์์ต๋๋ค.</p>`;
|
| 755 |
+
} else {
|
| 756 |
+
html += `<table class="ports-table"><thead><tr><th>VID:PID</th><th>์ ํ๋ช
</th><th>์ ์กฐ์ฌ</th><th>์์น</th></tr></thead><tbody>`;
|
| 757 |
+
usbDevices.forEach(device => {
|
| 758 |
+
const vidPid = (device.vid && device.pid) ? `${device.vid}:${device.pid}` : '์ ์ ์์';
|
| 759 |
+
html += `<tr>
|
| 760 |
+
<td>${AppUtils.escapeHtml(vidPid)}</td>
|
| 761 |
+
<td>${AppUtils.escapeHtml(device.product || '')}</td>
|
| 762 |
+
<td>${AppUtils.escapeHtml(device.manufacturer || '')}</td>
|
| 763 |
+
<td>${AppUtils.escapeHtml(device.location || '')}</td>
|
| 764 |
+
</tr>`;
|
| 765 |
+
});
|
| 766 |
+
html += `</tbody></table>`;
|
| 767 |
+
}
|
| 768 |
+
html += `</div>`;
|
| 769 |
+
|
| 770 |
+
// Windows WMI USB ์ฅ์น ์น์
(์๋ ๊ฒฝ์ฐ)
|
| 771 |
+
if (windowsUsbDevices && windowsUsbDevices.length > 0) {
|
| 772 |
+
html += `<div class="ports-section"><h4>Windows USB ์ฅ์น (WMI) (${windowsUsbDevices.length}๊ฐ)</h4>`;
|
| 773 |
+
html += `<table class="ports-table"><thead><tr><th>์ด๋ฆ</th><th>์ค๋ช
</th><th>์ ์กฐ์ฌ</th><th>VID:PID</th></tr></thead><tbody>`;
|
| 774 |
+
windowsUsbDevices.forEach(device => {
|
| 775 |
+
const vidPid = (device.vid && device.pid) ? `${device.vid}:${device.pid}` : '์ ์ ์์';
|
| 776 |
+
html += `<tr>
|
| 777 |
+
<td>${AppUtils.escapeHtml(device.name || '')}</td>
|
| 778 |
+
<td>${AppUtils.escapeHtml(device.description || '')}</td>
|
| 779 |
+
<td>${AppUtils.escapeHtml(device.manufacturer || '')}</td>
|
| 780 |
+
<td>${AppUtils.escapeHtml(vidPid)}</td>
|
| 781 |
+
</tr>`;
|
| 782 |
+
});
|
| 783 |
+
html += `</tbody></table></div>`;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
// ์ปจํ
์ด๋ ๋ซ๊ธฐ
|
| 787 |
+
html += `</div>`;
|
| 788 |
+
|
| 789 |
+
// HTML ์ค์
|
| 790 |
+
portsResultsElement.innerHTML = html;
|
| 791 |
+
},
|
| 792 |
+
|
| 793 |
+
// ํฌํธ ์ค์บ ์ํ ํ์
|
| 794 |
+
showPortsStatus: function(status, message) {
|
| 795 |
+
const statusElement = this.elements.portsStatus;
|
| 796 |
+
if (!statusElement) return; // ์์ ์์ผ๋ฉด ์ข
๋ฃ
|
| 797 |
+
|
| 798 |
+
// ๋ชจ๋ ์ํ ํด๋์ค ์ ๊ฑฐ
|
| 799 |
+
statusElement.classList.remove('success', 'error', 'warning');
|
| 800 |
+
// ๋ด์ฉ ์ด๊ธฐํ
|
| 801 |
+
statusElement.innerHTML = '';
|
| 802 |
+
|
| 803 |
+
// ์ํ์ ๋ฐ๋ผ ์ฒ๋ฆฌ
|
| 804 |
+
switch (status) {
|
| 805 |
+
case 'success':
|
| 806 |
+
statusElement.classList.add('success');
|
| 807 |
+
statusElement.innerHTML = `<i class="fas fa-check-circle"></i> ${message}`;
|
| 808 |
+
break;
|
| 809 |
+
case 'error':
|
| 810 |
+
statusElement.classList.add('error');
|
| 811 |
+
statusElement.innerHTML = `<i class="fas fa-exclamation-circle"></i> ${message}`;
|
| 812 |
+
break;
|
| 813 |
+
case 'warning':
|
| 814 |
+
statusElement.classList.add('warning');
|
| 815 |
+
statusElement.innerHTML = `<i class="fas fa-exclamation-triangle"></i> ${message}`;
|
| 816 |
+
break;
|
| 817 |
+
case 'loading':
|
| 818 |
+
statusElement.innerHTML = `${AppUtils.createLoadingSpinner()} ${message}`;
|
| 819 |
+
break;
|
| 820 |
+
default:
|
| 821 |
+
statusElement.textContent = message;
|
| 822 |
+
}
|
| 823 |
}
|
| 824 |
+
// ================== ์ถ๊ฐ ๋ ============================
|
| 825 |
+
|
| 826 |
+
}; // DeviceControl ๊ฐ์ฒด ๋
|
| 827 |
|
| 828 |
// ํ์ด์ง ๋ก๋ ์๋ฃ ์ ๋ชจ๋ ์ด๊ธฐํ
|
| 829 |
document.addEventListener('DOMContentLoaded', function() {
|
app/templates/index.html
CHANGED
|
@@ -16,8 +16,7 @@
|
|
| 16 |
<div class="llm-selector">
|
| 17 |
<label for="llmSelect">LLM ์ ํ:</label>
|
| 18 |
<select id="llmSelect">
|
| 19 |
-
|
| 20 |
-
</select>
|
| 21 |
</div>
|
| 22 |
<div class="user-info">
|
| 23 |
<span>์ฌ์ฉ์: {% if session.username %}{{ session.username }}{% else %}์๋{% endif %}</span>
|
|
@@ -34,7 +33,6 @@
|
|
| 34 |
</header>
|
| 35 |
|
| 36 |
<main>
|
| 37 |
-
<!-- ๋ํ ํญ -->
|
| 38 |
<section id="chatSection" class="tab-content active">
|
| 39 |
<div class="chat-container">
|
| 40 |
<div class="chat-messages" id="chatMessages">
|
|
@@ -44,7 +42,7 @@
|
|
| 44 |
</div>
|
| 45 |
</div>
|
| 46 |
</div>
|
| 47 |
-
|
| 48 |
<div class="chat-input-container">
|
| 49 |
<textarea id="userInput" placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์..." rows="1"></textarea>
|
| 50 |
<button id="micButton" class="mic-button">
|
|
@@ -54,7 +52,7 @@
|
|
| 54 |
<i class="fas fa-paper-plane"></i>
|
| 55 |
</button>
|
| 56 |
</div>
|
| 57 |
-
|
| 58 |
<div id="recordingStatus" class="recording-status hidden">
|
| 59 |
<div class="recording-indicator">
|
| 60 |
<div class="recording-pulse"></div>
|
|
@@ -67,34 +65,33 @@
|
|
| 67 |
</div>
|
| 68 |
</section>
|
| 69 |
|
| 70 |
-
<!-- ๋ฌธ์๊ด๋ฆฌ ํญ -->
|
| 71 |
<section id="docsSection" class="tab-content">
|
| 72 |
<div class="docs-container">
|
| 73 |
<div class="upload-section">
|
| 74 |
<h2>๋ฌธ์ ์
๋ก๋</h2>
|
| 75 |
<p>์ง์๋ฒ ์ด์ค์ ์ถ๊ฐํ ๋ฌธ์๋ฅผ ์
๋ก๋ํ์ธ์. (์ง์ ํ์: .txt, .md, .csv)</p>
|
| 76 |
-
|
| 77 |
<form id="uploadForm" enctype="multipart/form-data">
|
| 78 |
<div class="file-upload">
|
| 79 |
<input type="file" id="documentFile" name="document" accept=".txt,.md,.csv">
|
| 80 |
<label for="documentFile">ํ์ผ ์ ํ</label>
|
| 81 |
<span id="fileName">์ ํ๋ ํ์ผ ์์</span>
|
| 82 |
</div>
|
| 83 |
-
|
| 84 |
<button type="submit" id="uploadButton" class="upload-button">
|
| 85 |
<i class="fas fa-upload"></i> ์
๋ก๋
|
| 86 |
</button>
|
| 87 |
</form>
|
| 88 |
-
|
| 89 |
<div id="uploadStatus" class="upload-status hidden"></div>
|
| 90 |
</div>
|
| 91 |
-
|
| 92 |
<div class="docs-list-section">
|
| 93 |
<h2>๋ฌธ์ ๋ชฉ๋ก</h2>
|
| 94 |
<button id="refreshDocsButton" class="refresh-button">
|
| 95 |
<i class="fas fa-sync-alt"></i> ์๋ก๊ณ ์นจ
|
| 96 |
</button>
|
| 97 |
-
|
| 98 |
<div class="docs-list-container">
|
| 99 |
<table id="docsList" class="docs-list">
|
| 100 |
<thead>
|
|
@@ -105,15 +102,14 @@
|
|
| 105 |
</tr>
|
| 106 |
</thead>
|
| 107 |
<tbody>
|
| 108 |
-
|
| 109 |
-
</tbody>
|
| 110 |
</table>
|
| 111 |
-
|
| 112 |
<div id="docsLoading" class="loading-indicator">
|
| 113 |
<div class="spinner"></div>
|
| 114 |
<p>๋ฌธ์ ๋ก๋ฉ ์ค...</p>
|
| 115 |
</div>
|
| 116 |
-
|
| 117 |
<div id="noDocsMessage" class="no-docs-message hidden">
|
| 118 |
<p>์ง์๋ฒ ์ด์ค์ ๋ฑ๋ก๋ ๋ฌธ์๊ฐ ์์ต๋๋ค. ๋ฌธ์๋ฅผ ์
๋ก๋ํด ์ฃผ์ธ์.</p>
|
| 119 |
</div>
|
|
@@ -121,8 +117,7 @@
|
|
| 121 |
</div>
|
| 122 |
</div>
|
| 123 |
</section>
|
| 124 |
-
|
| 125 |
-
<!-- ์ฅ์น ์ ์ด ํญ -->
|
| 126 |
<section id="deviceSection" class="tab-content">
|
| 127 |
<div class="device-connection">
|
| 128 |
<h3>1. ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ</h3>
|
|
@@ -157,8 +152,7 @@
|
|
| 157 |
<button id="executeProgramBtn" class="execute-btn" disabled>์ ํํ ํ๋ก๊ทธ๋จ ์คํ</button>
|
| 158 |
<div id="executeResult" class="execute-result"></div>
|
| 159 |
</div>
|
| 160 |
-
|
| 161 |
-
<!-- ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ ์น์
์ถ๊ฐ -->
|
| 162 |
<div id="deviceCustomControl" class="program-control">
|
| 163 |
<h3>4. ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ</h3>
|
| 164 |
<div class="custom-command-container">
|
|
@@ -167,7 +161,13 @@
|
|
| 167 |
</div>
|
| 168 |
<div id="customExecuteResult" class="execute-result"></div>
|
| 169 |
</div>
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
</main>
|
| 172 |
|
| 173 |
<footer>
|
|
@@ -183,4 +183,4 @@
|
|
| 183 |
<script src="{{ url_for('static', filename='js/app-device.js') }}"></script>
|
| 184 |
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
| 185 |
</body>
|
| 186 |
-
</html>
|
|
|
|
| 16 |
<div class="llm-selector">
|
| 17 |
<label for="llmSelect">LLM ์ ํ:</label>
|
| 18 |
<select id="llmSelect">
|
| 19 |
+
</select>
|
|
|
|
| 20 |
</div>
|
| 21 |
<div class="user-info">
|
| 22 |
<span>์ฌ์ฉ์: {% if session.username %}{{ session.username }}{% else %}์๋{% endif %}</span>
|
|
|
|
| 33 |
</header>
|
| 34 |
|
| 35 |
<main>
|
|
|
|
| 36 |
<section id="chatSection" class="tab-content active">
|
| 37 |
<div class="chat-container">
|
| 38 |
<div class="chat-messages" id="chatMessages">
|
|
|
|
| 42 |
</div>
|
| 43 |
</div>
|
| 44 |
</div>
|
| 45 |
+
|
| 46 |
<div class="chat-input-container">
|
| 47 |
<textarea id="userInput" placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์..." rows="1"></textarea>
|
| 48 |
<button id="micButton" class="mic-button">
|
|
|
|
| 52 |
<i class="fas fa-paper-plane"></i>
|
| 53 |
</button>
|
| 54 |
</div>
|
| 55 |
+
|
| 56 |
<div id="recordingStatus" class="recording-status hidden">
|
| 57 |
<div class="recording-indicator">
|
| 58 |
<div class="recording-pulse"></div>
|
|
|
|
| 65 |
</div>
|
| 66 |
</section>
|
| 67 |
|
|
|
|
| 68 |
<section id="docsSection" class="tab-content">
|
| 69 |
<div class="docs-container">
|
| 70 |
<div class="upload-section">
|
| 71 |
<h2>๋ฌธ์ ์
๋ก๋</h2>
|
| 72 |
<p>์ง์๋ฒ ์ด์ค์ ์ถ๊ฐํ ๋ฌธ์๋ฅผ ์
๋ก๋ํ์ธ์. (์ง์ ํ์: .txt, .md, .csv)</p>
|
| 73 |
+
|
| 74 |
<form id="uploadForm" enctype="multipart/form-data">
|
| 75 |
<div class="file-upload">
|
| 76 |
<input type="file" id="documentFile" name="document" accept=".txt,.md,.csv">
|
| 77 |
<label for="documentFile">ํ์ผ ์ ํ</label>
|
| 78 |
<span id="fileName">์ ํ๋ ํ์ผ ์์</span>
|
| 79 |
</div>
|
| 80 |
+
|
| 81 |
<button type="submit" id="uploadButton" class="upload-button">
|
| 82 |
<i class="fas fa-upload"></i> ์
๋ก๋
|
| 83 |
</button>
|
| 84 |
</form>
|
| 85 |
+
|
| 86 |
<div id="uploadStatus" class="upload-status hidden"></div>
|
| 87 |
</div>
|
| 88 |
+
|
| 89 |
<div class="docs-list-section">
|
| 90 |
<h2>๋ฌธ์ ๋ชฉ๋ก</h2>
|
| 91 |
<button id="refreshDocsButton" class="refresh-button">
|
| 92 |
<i class="fas fa-sync-alt"></i> ์๋ก๊ณ ์นจ
|
| 93 |
</button>
|
| 94 |
+
|
| 95 |
<div class="docs-list-container">
|
| 96 |
<table id="docsList" class="docs-list">
|
| 97 |
<thead>
|
|
|
|
| 102 |
</tr>
|
| 103 |
</thead>
|
| 104 |
<tbody>
|
| 105 |
+
</tbody>
|
|
|
|
| 106 |
</table>
|
| 107 |
+
|
| 108 |
<div id="docsLoading" class="loading-indicator">
|
| 109 |
<div class="spinner"></div>
|
| 110 |
<p>๋ฌธ์ ๋ก๋ฉ ์ค...</p>
|
| 111 |
</div>
|
| 112 |
+
|
| 113 |
<div id="noDocsMessage" class="no-docs-message hidden">
|
| 114 |
<p>์ง์๋ฒ ์ด์ค์ ๋ฑ๋ก๋ ๋ฌธ์๊ฐ ์์ต๋๋ค. ๋ฌธ์๋ฅผ ์
๋ก๋ํด ์ฃผ์ธ์.</p>
|
| 115 |
</div>
|
|
|
|
| 117 |
</div>
|
| 118 |
</div>
|
| 119 |
</section>
|
| 120 |
+
|
|
|
|
| 121 |
<section id="deviceSection" class="tab-content">
|
| 122 |
<div class="device-connection">
|
| 123 |
<h3>1. ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ</h3>
|
|
|
|
| 152 |
<button id="executeProgramBtn" class="execute-btn" disabled>์ ํํ ํ๋ก๊ทธ๋จ ์คํ</button>
|
| 153 |
<div id="executeResult" class="execute-result"></div>
|
| 154 |
</div>
|
| 155 |
+
|
|
|
|
| 156 |
<div id="deviceCustomControl" class="program-control">
|
| 157 |
<h3>4. ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ</h3>
|
| 158 |
<div class="custom-command-container">
|
|
|
|
| 161 |
</div>
|
| 162 |
<div id="customExecuteResult" class="execute-result"></div>
|
| 163 |
</div>
|
| 164 |
+
|
| 165 |
+
<div id="devicePortScanControl" class="program-control"> <h3>5. ์ฅ์น ํฌํธ ์กฐํ</h3>
|
| 166 |
+
<div class="function-buttons">
|
| 167 |
+
<button id="scanPortsBtn">์ฅ์น ํฌํธ ์ค์บ</button>
|
| 168 |
+
</div>
|
| 169 |
+
<div id="portsStatus" class="ports-status"></div> <div id="portsResults" class="ports-results"></div> </div>
|
| 170 |
+
</section>
|
| 171 |
</main>
|
| 172 |
|
| 173 |
<footer>
|
|
|
|
| 183 |
<script src="{{ url_for('static', filename='js/app-device.js') }}"></script>
|
| 184 |
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
| 185 |
</body>
|
| 186 |
+
</html>
|
docs/project_plan.md
CHANGED
|
@@ -24,10 +24,63 @@
|
|
| 24 |
- `static/js/app-device.js`์ ์ฅ์น ์ ์ด JavaScript ์ฝ๋
|
| 25 |
- `static/css/device-style.css`์ ์ฅ์น ์ ์ด ์คํ์ผ
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
## ๋จ์ ์์
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
- [ ] ์ ์ฒด ์์คํ
ํ
์คํธ ๋ฐ ๋๋ฒ๊น
|
| 29 |
-
|
| 30 |
-
- ๋ค์ํ ์ฅ์น ์ฐ๊ฒฐ ์๋๋ฆฌ์ค ํ
์คํธ
|
| 31 |
|
| 32 |
## ํ์ผ ๊ตฌ์กฐ
|
| 33 |
- `app_revised.py`: ๋ฉ์ธ Flask ์ ํ๋ฆฌ์ผ์ด์
|
|
@@ -54,6 +107,8 @@
|
|
| 54 |
- `docs/`: ํ๋ก์ ํธ ๋ฌธ์
|
| 55 |
- `project_plan.md`: ํ๋ก์ ํธ ๊ณํ ๋ฌธ์
|
| 56 |
- `cleanup_plan.md`: ์ฝ๋ ์ ๋ฆฌ ๊ณํ ๋ฌธ์
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## LocalPCAgent ํตํฉ ์์ฝ
|
| 59 |
- **๋ฐฑ์๋ API**: `app/app_device_routes.py`์ ๊ตฌํ
|
|
@@ -63,6 +118,7 @@
|
|
| 63 |
- `/api/device/programs`: ์คํ ๊ฐ๋ฅํ ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ
|
| 64 |
- `/api/device/programs/<program_id>/execute`: ๋ฑ๋ก๋ ํ๋ก๊ทธ๋จ ์คํ
|
| 65 |
- `/api/device/execute-custom`: ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
|
|
|
| 66 |
|
| 67 |
- **ํ๋ฐํธ์๋**: ๊ธฐ๋ฅ ์์ฑ
|
| 68 |
- ์ฅ์น ์ ์ด ํญ UI: `templates/index.html`์ ๊ตฌํ
|
|
|
|
| 24 |
- `static/js/app-device.js`์ ์ฅ์น ์ ์ด JavaScript ์ฝ๋
|
| 25 |
- `static/css/device-style.css`์ ์ฅ์น ์ ์ด ์คํ์ผ
|
| 26 |
|
| 27 |
+
## ํ์ฌ ์ํ
|
| 28 |
+
์ฝ๋ ๊ฒํ ๊ฒฐ๊ณผ ๋๋ถ๋ถ์ ํตํฉ ์์
์ด ์ด๋ฏธ ์๋ฃ๋ ์ํ์
๋๋ค:
|
| 29 |
+
- Flask ๋ฐฑ์๋์ LocalPCAgent API ์๋ํฌ์ธํธ๊ฐ ๊ตฌํ๋์ด ์์ต๋๋ค (`app_device_routes.py`)
|
| 30 |
+
- ํ๋ก ํธ์๋ UI์ ์ฅ์น ์ ์ด ํญ์ด ์ถ๊ฐ๋์ด ์์ต๋๋ค (`index.html`)
|
| 31 |
+
- ์ฅ์น ์ ์ด๋ฅผ ์ํ JavaScript ๋ก์ง์ด ๊ตฌํ๋์ด ์์ต๋๋ค (`app-device.js`)
|
| 32 |
+
- ๊ธฐ๋ณธ ๊ธฐ๋ฅ๊ณผ ์ฌ์ฉ์ ์ ์ ๋ช
๋ น์ด ์คํ ๊ธฐ๋ฅ์ด ๋ชจ๋ ๊ตฌํ๋์ด ์์ต๋๋ค
|
| 33 |
+
|
| 34 |
+
## ์ถ๊ฐ ๊ฐ๋ฐ ๊ณํ: ์ฅ์น ๋ชฉ๋ก ์กฐํ ๊ธฐ๋ฅ ์ถ๊ฐ
|
| 35 |
+
|
| 36 |
+
### ๊ฐ๋ฐ ๋ชฉํ
|
| 37 |
+
๋ก์ปฌPC์ ์ฐ๊ฒฐ๋ ์ฅ์น(ํนํ COM ํฌํธ์ USB ์ฅ์น)๋ฅผ ์กฐํํ๋ ๊ธฐ๋ฅ์ ์ถ๊ฐํฉ๋๋ค.
|
| 38 |
+
|
| 39 |
+
### ๊ตฌํ ์๊ตฌ์ฌํญ
|
| 40 |
+
1. **๋ก์ปฌPC ์ฅ์น ์กฐํ Python ํ๋ก๊ทธ๋จ ๊ฐ๋ฐ**
|
| 41 |
+
- COM ํฌํธ ๋ฐ USB ์ฅ์น ๋ชฉ๋ก ์กฐํ
|
| 42 |
+
- ์ฅ์น๋ณ ์์ธ ์ ๋ณด(์ ์กฐ์ฌ, ์ ํ๋ช
, ์๋ฆฌ์ผ ๋ฒํธ ๋ฑ) ์์ง
|
| 43 |
+
- ๋ฉํฐ ํ๋ซํผ ์ง์(Windows, Linux, macOS)
|
| 44 |
+
|
| 45 |
+
2. **LocalPCAgent API ํ์ฅ**
|
| 46 |
+
- ์ฅ์น ๋ชฉ๋ก ์กฐํ API ์๋ํฌ์ธํธ ์ถ๊ฐ
|
| 47 |
+
- ์กฐํ ๊ฒฐ๊ณผ ํจ์จ์ ์ธ ์ ์ก ๋ฐฉ์ ๊ตฌํ
|
| 48 |
+
|
| 49 |
+
3. **UI ํ์ฅ**
|
| 50 |
+
- ์ฅ์น ์ ์ด ํญ์ ์ฅ์น ๋ชฉ๋ก ์กฐํ ์น์
์ถ๊ฐ
|
| 51 |
+
- ์กฐํ ๊ฒฐ๊ณผ ํ์ UI ๊ตฌํ
|
| 52 |
+
- ์ฅ์น ํ์
๋ณ ํํฐ๋ง ๊ธฐ๋ฅ ๊ตฌํ
|
| 53 |
+
|
| 54 |
+
### ๊ธฐ์ ์คํ
|
| 55 |
+
- ๋ฐฑ์๋: Python(`pyserial`, `pyusb`), Flask
|
| 56 |
+
- ํ๋ก ํธ์๋: HTML, CSS, JavaScript
|
| 57 |
+
- ํต์ : REST API, JSON ํฌ๋งท
|
| 58 |
+
|
| 59 |
+
### ๊ตฌํ ๊ณํ
|
| 60 |
+
1. **๋ก์ปฌPC ์ฅ์น ์กฐํ Python ์คํฌ๋ฆฝํธ ๊ฐ๋ฐ**
|
| 61 |
+
- `scan_devices.py` ์คํฌ๋ฆฝํธ ์์ฑ
|
| 62 |
+
- ํ
์คํธ ๋ฐ ๋๋ฒ๊น
|
| 63 |
+
|
| 64 |
+
2. **LocalPCAgent์ ํตํฉ**
|
| 65 |
+
- LocalPCAgent ํ๋ก๊ทธ๋จ ๋ชฉ๋ก์ ๋ฑ๋ก
|
| 66 |
+
- API ์๋ํฌ์ธํธ ํ
์คํธ
|
| 67 |
+
|
| 68 |
+
3. **Flask ๋ฐฑ์๋ API ํ์ฅ**
|
| 69 |
+
- `app_device_routes.py`์ ์ฅ์น ์กฐํ API ์ถ๊ฐ
|
| 70 |
+
- ๋ฐ์ดํฐ ํฌ๋งท ๋ฐ ์ค๋ฅ ์ฒ๋ฆฌ ๊ตฌํ
|
| 71 |
+
|
| 72 |
+
4. **ํ๋ก ํธ์๋ UI ๊ฐ๋ฐ**
|
| 73 |
+
- `index.html`์ ์ฅ์น ๋ชฉ๋ก ์กฐํ ์น์
์ถ๊ฐ
|
| 74 |
+
- `app-device.js`์ ์ฅ์น ์กฐํ ๊ด๋ จ ํจ์ ์ถ๊ฐ
|
| 75 |
+
- ํ์์ CSS ์คํ์ผ ์ถ๊ฐ
|
| 76 |
+
|
| 77 |
## ๋จ์ ์์
|
| 78 |
+
- [ ] ๋ก์ปฌPC ์ฅ์น ์กฐํ Python ์คํฌ๋ฆฝํธ ๊ฐ๋ฐ
|
| 79 |
+
- [ ] LocalPCAgent ์๋ฒ์ ์ฅ์น ์กฐํ ๊ธฐ๋ฅ ํตํฉ
|
| 80 |
+
- [ ] Flask ๋ฐฑ์๋ ์ฅ์น ์กฐํ API ๊ตฌํ
|
| 81 |
+
- [ ] ํ๋ก ํธ์๋ UI ํ์ฅ
|
| 82 |
- [ ] ์ ์ฒด ์์คํ
ํ
์คํธ ๋ฐ ๋๋ฒ๊น
|
| 83 |
+
- [ ] ์ต์ข
์ฝ๋ ๋ฆฌ๋ทฐ ๋ฐ ๋ฌธ์ํ ๋ณด์
|
|
|
|
| 84 |
|
| 85 |
## ํ์ผ ๊ตฌ์กฐ
|
| 86 |
- `app_revised.py`: ๋ฉ์ธ Flask ์ ํ๋ฆฌ์ผ์ด์
|
|
|
|
| 107 |
- `docs/`: ํ๋ก์ ํธ ๋ฌธ์
|
| 108 |
- `project_plan.md`: ํ๋ก์ ํธ ๊ณํ ๋ฌธ์
|
| 109 |
- `cleanup_plan.md`: ์ฝ๋ ์ ๋ฆฌ ๊ณํ ๋ฌธ์
|
| 110 |
+
- **์ ๊ท ํ์ผ:**
|
| 111 |
+
- `LocalPCAgent/programs/scan_devices.py`: ์ฅ์น ์กฐํ Python ์คํฌ๋ฆฝํธ
|
| 112 |
|
| 113 |
## LocalPCAgent ํตํฉ ์์ฝ
|
| 114 |
- **๋ฐฑ์๋ API**: `app/app_device_routes.py`์ ๊ตฌํ
|
|
|
|
| 118 |
- `/api/device/programs`: ์คํ ๊ฐ๋ฅํ ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ
|
| 119 |
- `/api/device/programs/<program_id>/execute`: ๋ฑ๋ก๋ ํ๋ก๊ทธ๋จ ์คํ
|
| 120 |
- `/api/device/execute-custom`: ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ ์คํ
|
| 121 |
+
- **์ถ๊ฐ ์์ :** `/api/device/scan-ports`: COM ํฌํธ ๋ฐ USB ์ฅ์น ๋ชฉ๋ก ์กฐํ
|
| 122 |
|
| 123 |
- **ํ๋ฐํธ์๋**: ๊ธฐ๋ฅ ์์ฑ
|
| 124 |
- ์ฅ์น ์ ์ด ํญ UI: `templates/index.html`์ ๊ตฌํ
|