jilo-web/app/templates/agent-list.php

38 lines
3.2 KiB
PHP
Raw Normal View History

2024-09-23 18:39:32 +00:00
<!-- jilo agents -->
<div class="card text-center w-75 mx-lef">
2024-10-04 08:36:45 +00:00
<p class="h4 card-header">Jilo Agents on platform <?= $platform_id ?> (<?= $platformDetails[0]['name'] ?>)</p>
2024-09-23 18:39:32 +00:00
<div class="card-body">
<?php foreach ($agentDetails as $agent) { ?>
2024-09-30 09:22:53 +00:00
<p class="card-text text-left" style="text-align: left;">
2024-10-04 08:36:45 +00:00
agent id: <strong><?= $agent['id'] ?></strong>
agent type: <?= $agent['agent_type_id'] ?> (<strong><?= $agent['agent_description'] ?></strong>)
2024-09-30 09:22:53 +00:00
<br />
2024-10-04 08:36:45 +00:00
endpoint: <strong><?= $agent['url'] ?><?= $agent['agent_endpoint'] ?></strong>
2024-09-30 09:22:53 +00:00
<br />
2024-10-01 07:18:53 +00:00
<?php
$payload = [
'iss' => 'Jilo Web',
'aud' => $config['domain'],
'iat' => time(),
'exp' => time() + 3600,
'agent_id' => $agent['id']
];
$jwt = $agentObject->generateAgentToken($payload, $agent['secret_key']);
2024-10-02 19:33:09 +00:00
// print_r($_SESSION);
2024-10-01 07:18:53 +00:00
?>
2024-10-02 13:35:10 +00:00
<?php if (isset($_SESSION["agent{$agent['id']}_cache"])) { ?>
2024-10-04 08:36:45 +00:00
<button id="agent<?= $agent['id'] ?>-fetch" class="btn btn-primary" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="get data from the agent" onclick="fetchData('<?= $agent['id'] ?>', '<?= $agent['url'] ?>', '<?= $agent['agent_endpoint'] ?>', '<?= htmlspecialchars($jwt) ?>', true)">fetch data</button>
<button id="agent<?= $agent['id'] ?>-cache" class="btn btn-secondary" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="load cache" onclick="loadCache('<?= $agent['id'] ?>')">load cache</button>
<button id="agent<?= $agent['id'] ?>-clear" class="btn btn-danger" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="clear cache" onclick="clearCache('<?= $agent['id'] ?>')">clear cache</button>
<span id="cacheInfo<?= $agent['id'] ?>" style="margin: 5px 0;"></span>
2024-09-30 16:48:00 +00:00
<?php } else { ?>
2024-10-04 08:36:45 +00:00
<button id="agent<?= $agent['id'] ?>-fetch" class="btn btn-primary" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="get data from the agent" onclick="fetchData('<?= $agent['id'] ?>', '<?= $agent['url'] ?>', '<?= $agent['agent_endpoint'] ?>', '<?= htmlspecialchars($jwt) ?>')">fetch data</button>
<button style="display: none" disabled id="agent<?= $agent['id'] ?>-cache" class="btn btn-secondary" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="load cache" onclick="loadCache('<?= $agent['id'] ?>')">load cache</button>
<button style="display: none" disabled id="agent<?= $agent['id'] ?>-clear" class="btn btn-danger" data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="clear cache" onclick="clearCache('<?= $agent['id'] ?>')">clear cache</button>
<span style="display: none" id="cacheInfo<?= $agent['id'] ?>" style="margin: 5px 0;"></span>
2024-09-30 16:48:00 +00:00
<?php } ?>
2024-09-30 09:22:53 +00:00
</p>
2024-10-04 08:36:45 +00:00
<pre class="results" id="result<?= $agent['id'] ?>">click a button to display data from the agent.</pre>
2024-09-23 18:39:32 +00:00
<?php } ?>