69 lines
2.8 KiB
PHP
69 lines
2.8 KiB
PHP
|
|
<?= $this->extend('layouts/v2') ?>
|
||
|
|
|
||
|
|
<?= $this->section('content') ?>
|
||
|
|
|
||
|
|
<div class="card bg-base-100 shadow" x-data="apiTester">
|
||
|
|
<div class="card-body">
|
||
|
|
|
||
|
|
<!-- Request Form -->
|
||
|
|
<div class="flex flex-col sm:flex-row gap-2">
|
||
|
|
<select x-model="method" class="select select-bordered w-full sm:w-32">
|
||
|
|
<option value="GET">GET</option>
|
||
|
|
<option value="POST">POST</option>
|
||
|
|
<option value="PATCH">PATCH</option>
|
||
|
|
<option value="DELETE">DELETE</option>
|
||
|
|
</select>
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
x-model="url"
|
||
|
|
placeholder="Enter URL (e.g., /api/patient)"
|
||
|
|
class="input input-bordered flex-1 font-mono"
|
||
|
|
>
|
||
|
|
<button @click="sendRequest" :disabled="loading" class="btn btn-primary gap-2">
|
||
|
|
<span class="loading loading-spinner loading-sm" x-show="loading"></span>
|
||
|
|
<i data-lucide="send" class="w-4 h-4" x-show="!loading"></i>
|
||
|
|
Send
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Request Body (for POST/PATCH) -->
|
||
|
|
<div x-show="method === 'POST' || method === 'PATCH'" x-transition class="mt-4">
|
||
|
|
<label class="label">
|
||
|
|
<span class="label-text">Request Body (JSON)</span>
|
||
|
|
</label>
|
||
|
|
<textarea
|
||
|
|
x-model="body"
|
||
|
|
class="textarea textarea-bordered w-full font-mono h-32"
|
||
|
|
placeholder='{ "key": "value" }'
|
||
|
|
></textarea>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Quick Endpoints -->
|
||
|
|
<div class="flex flex-wrap gap-2 mt-4">
|
||
|
|
<span class="text-base-content/60 text-sm">Quick:</span>
|
||
|
|
<button @click="setEndpoint('GET', '<?= site_url('api/patient') ?>')" class="btn btn-xs btn-ghost">Patients</button>
|
||
|
|
<button @click="setEndpoint('GET', '<?= site_url('api/tests') ?>')" class="btn btn-xs btn-ghost">Tests</button>
|
||
|
|
<button @click="setEndpoint('GET', '<?= site_url('api/valueset') ?>')" class="btn btn-xs btn-ghost">ValueSets</button>
|
||
|
|
<button @click="setEndpoint('GET', '<?= site_url('api/location') ?>')" class="btn btn-xs btn-ghost">Locations</button>
|
||
|
|
<button @click="setEndpoint('GET', '<?= site_url('api/organization/site') ?>')" class="btn btn-xs btn-ghost">Sites</button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Response -->
|
||
|
|
<div class="card bg-base-100 shadow mt-4" x-data x-show="$store.apiResponse.hasResponse" x-transition>
|
||
|
|
<div class="card-body">
|
||
|
|
<div class="flex justify-between items-center mb-4">
|
||
|
|
<h3 class="card-title">Response</h3>
|
||
|
|
<div class="flex items-center gap-2">
|
||
|
|
<div class="badge" :class="$store.apiResponse.statusClass" x-text="$store.apiResponse.status"></div>
|
||
|
|
<span class="text-base-content/60 text-sm" x-text="$store.apiResponse.time + 'ms'"></span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<pre class="bg-base-200 p-4 rounded-lg overflow-auto max-h-96 text-sm font-mono"><code x-text="$store.apiResponse.body"></code></pre>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?= $this->endSection() ?>
|