2023-01-10 17:28:27 +01:00
|
|
|
<script>
|
2023-01-17 09:44:21 +01:00
|
|
|
import CodeViewer from '../../../components/codeviewer.svelte';
|
|
|
|
import ObjectGrid from '../../../components/objectgrid.svelte';
|
|
|
|
import { GetIndexes } from '../../../../wailsjs/go/app/App';
|
|
|
|
|
2023-01-10 17:28:27 +01:00
|
|
|
export let collection;
|
|
|
|
|
2023-01-17 09:44:21 +01:00
|
|
|
let indexes = [];
|
|
|
|
let activeKey = '';
|
|
|
|
let json = '';
|
|
|
|
|
|
|
|
async function getIndexes() {
|
|
|
|
const result = await GetIndexes(collection.hostKey, collection.dbKey, collection.key);
|
|
|
|
if (result) {
|
|
|
|
indexes = result;
|
|
|
|
}
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-01-17 09:44:21 +01:00
|
|
|
function openJson(itemId) {
|
|
|
|
const item = indexes?.filter(i => i.name == itemId);
|
|
|
|
json = JSON.stringify(item, undefined, 2);
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
</script>
|
|
|
|
|
2023-01-17 09:44:21 +01:00
|
|
|
<div class="indexes">
|
|
|
|
<div class="actions">
|
|
|
|
<button class="btn" on:click={getIndexes}>Get indexes</button>
|
|
|
|
<button class="btn danger" disabled={!indexes?.length || !activeKey}>Drop selected</button>
|
|
|
|
<button class="btn">Create…</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ObjectGrid key="name" data={indexes} bind:activeKey on:trigger={e => openJson(e.detail)} />
|
2023-01-10 17:28:27 +01:00
|
|
|
</div>
|
2023-01-17 09:44:21 +01:00
|
|
|
|
|
|
|
<CodeViewer bind:code={json} language="json" />
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.indexes {
|
|
|
|
display: grid;
|
|
|
|
gap: 0.5rem;
|
|
|
|
grid-template: auto 1fr / 1fr;
|
|
|
|
}
|
|
|
|
</style>
|