File size: 3,273 Bytes
5f10e37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
87
88
89
90
91
92
93
94
95
96
97
98
<!doctype html>
<html lang="pt-BR">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <title>Agentes ATCoin Token</title>
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-gray-100 text-gray-900">
  <div class="max-w-6xl mx-auto py-8 px-4">
    <h1 class="text-4xl font-bold text-center mb-8">Agentes da Inteligência Artificial — AIBANK Token</h1>
    <div class="bg-white rounded-xl shadow-md p-6 overflow-x-auto">
      <table class="w-full text-left border-collapse">
        <thead>
          <tr class="bg-gray-800 text-white">
            <th class="p-2">Agente</th>
            <th class="p-2">Status</th>
            <th class="p-2">Última Ação</th>
            <th class="p-2">Próxima Execução</th>
            <th class="p-2">Resultado</th>
          </tr>
        </thead>
        <tbody id="agentes-body"></tbody>
      </table>
    </div>

    <div class="mt-12">
      <h2 class="text-2xl font-semibold text-center mb-4">Performance dos Agentes</h2>
      <canvas id="grafico-retorno" class="w-full max-w-4xl mx-auto"></canvas>
    </div>
  </div>

  <script>

    async function carregarDados() {

      try {

        const resposta = await fetch('data.json');

        const agentes = await resposta.json();

        const tabela = document.getElementById('agentes-body');

        const nomes = [];

        const resultados = [];



        tabela.innerHTML = '';

        agentes.forEach(agente => {

          nomes.push(agente.nome);

          resultados.push(parseFloat(agente.resultado.replace('%', '').replace('+', '')));

          tabela.innerHTML += `

            <tr class="border-b hover:bg-gray-100 transition">

              <td class="p-2 font-medium">${agente.nome}</td>

              <td class="p-2">${agente.status}</td>

              <td class="p-2">${agente.ultima_acao}</td>

              <td class="p-2">${agente.proxima_execucao}</td>

              <td class="p-2">${agente.resultado}</td>

            </tr>`;

        });



        desenharGrafico(nomes, resultados);

      } catch (erro) {

        console.error("Erro ao carregar dados:", erro);

      }

    }



    function desenharGrafico(labels, data) {

      const ctx = document.getElementById('grafico-retorno').getContext('2d');

      if (window.myChart) {

        window.myChart.destroy(); // evita sobreposição

      }

      window.myChart = new Chart(ctx, {

        type: 'bar',

        data: {

          labels,

          datasets: [{

            label: 'ROI (%)',

            data,

            backgroundColor: 'rgba(59, 130, 246, 0.7)',

            borderColor: 'rgba(37, 99, 235, 1)',

            borderWidth: 1

          }]

        },

        options: {

          responsive: true,

          scales: {

            y: { beginAtZero: true }

          },

          animation: {

            duration: 1000,

            easing: 'easeOutBounce'

          }

        }

      });

    }



    carregarDados();

    setInterval(carregarDados, 60000); // atualiza a cada 60s

  </script>
</body>
</html>