File size: 2,432 Bytes
2c8f55c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>نظام توزيع المهام الذكي</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        h1 {
            color: #2c3e50;
            text-align: center;
        }
        ul {
            list-style: none;
            padding: 0;
        }
        li {
            background: white;
            margin: 10px 0;
            padding: 15px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        button {
            background: #3498db;
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background: #2980b9;
        }
        #result {
            background: white;
            padding: 15px;
            border-radius: 5px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h1>🚀 نظام توزيع المهام الذكي</h1>
    <ul id="tasks">
        {% for task_id, task in tasks.items() %}
        <li>
            <span>{{ task[0] }}</span>
            <button onclick="runTask('{{ task_id }}')">تشغيل</button>
        </li>
        {% endfor %}
    </ul>

    <div id="result" style="display: {% if result %}block{% else %}none{% endif %};">
        <h2>✅ النتيجة:</h2>
        <pre>{{ result }}</pre>
    </div>

    <script>
        async function runTask(taskId) {
            const response = await fetch("/run_task", {
                method: "POST",
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                },
                body: `task_id=${taskId}`
            });
            const data = await response.text();
            
            // تحديث الصفحة دون إعادة تحميل كاملة
            document.getElementById("result").innerHTML = 
                `<h2>✅ النتيجة:</h2><pre>${JSON.parse(data).result}</pre>`;
            document.getElementById("result").style.display = "block";
        }
    </script>
</body>
</html>