mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Fixed frontend coding style problems
This commit is contained in:
parent
6cc329982a
commit
2ee5c7dadd
@ -1 +1 @@
|
||||
679b6f6f86f66d3499bdecbee288c567
|
||||
499da1237327bf4ddd2de74bfd6635c7
|
@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import BlankState from '$components/blankstate.svelte';
|
||||
import ContextMenu from '$components/contextmenu.svelte';
|
||||
import connections from '$lib/stores/connections';
|
||||
import contextMenu from '$lib/stores/contextmenu';
|
||||
import environment from '$lib/stores/environment';
|
||||
import hosts from '$lib/stores/hosts';
|
||||
@ -10,7 +9,7 @@
|
||||
import About from '$organisms/about.svelte';
|
||||
import Connection from '$organisms/connection/index.svelte';
|
||||
import Settings from '$organisms/settings/index.svelte';
|
||||
import { EventsEmit, EventsOn } from '$wails/runtime';
|
||||
import { EventsOn } from '$wails/runtime';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
const activeHostKey = '';
|
||||
@ -21,9 +20,6 @@
|
||||
let connectionManager;
|
||||
let showWelcomeScreen = undefined;
|
||||
|
||||
$: host = hosts[activeHostKey];
|
||||
$: connection = $connections[activeHostKey];
|
||||
|
||||
hosts.subscribe(h => {
|
||||
if (h && (showWelcomeScreen === undefined)) {
|
||||
showWelcomeScreen = !Object.keys($hosts || {}).length;
|
||||
|
@ -50,7 +50,9 @@
|
||||
return obj;
|
||||
}
|
||||
else if ((typeof obj === 'object') && (obj !== null)) {
|
||||
return Object.entries(obj).map(([ k, item ]) => ({ ...item, [key]: k }));
|
||||
return Object.entries(obj).map(([ k, item ]) => {
|
||||
return { ...item, [key]: k };
|
||||
});
|
||||
}
|
||||
else {
|
||||
return obj;
|
||||
|
@ -12,7 +12,7 @@
|
||||
export let canSelect = true;
|
||||
export let canRemoveItems = false;
|
||||
export let inputsValid = false;
|
||||
// export let actions = [];
|
||||
// export let actions = [];
|
||||
</script>
|
||||
|
||||
<div class="grid">
|
||||
|
87
frontend/src/components/icon.svelte
vendored
87
frontend/src/components/icon.svelte
vendored
@ -16,7 +16,15 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
{#if name === 'radio'}
|
||||
<circle cx="12" cy="12" r="2"></circle><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"></path>
|
||||
{:else if name === 'chev-l'}
|
||||
@ -26,13 +34,13 @@
|
||||
{:else if name === 'chev-d'}
|
||||
<polyline points="6 9 12 15 18 9"></polyline>
|
||||
{:else if name === 'chev-u'}
|
||||
<path d="m18 15-6-6-6 6"/>
|
||||
<path d="m18 15-6-6-6 6" />
|
||||
{:else if name === 'chevs-l'}
|
||||
<path d="m11 17-5-5 5-5M18 17l-5-5 5-5"/>
|
||||
<path d="m11 17-5-5 5-5M18 17l-5-5 5-5" />
|
||||
{:else if name === 'chevs-r'}
|
||||
<path d="m13 17 5-5-5-5M6 17l5-5-5-5"/>
|
||||
<path d="m13 17 5-5-5-5M6 17l5-5-5-5" />
|
||||
{:else if name === 'arr-d'}
|
||||
<path d="M12 5v14M19 12l-7 7-7-7"/>
|
||||
<path d="M12 5v14M19 12l-7 7-7-7" />
|
||||
{:else if name === 'db'}
|
||||
<ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
|
||||
{:else if name === 'x'}
|
||||
@ -44,53 +52,78 @@
|
||||
{:else if name === 'reload'}
|
||||
<polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
||||
{:else if name === 'clipboard'}
|
||||
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect>
|
||||
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8"
|
||||
y="2"
|
||||
width="8"
|
||||
height="4"
|
||||
rx="1"
|
||||
ry="1"></rect>
|
||||
{:else if name === 'edit'}
|
||||
<path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
|
||||
{:else if name === 'check'}
|
||||
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline>
|
||||
{:else if name === 'list'}
|
||||
<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>
|
||||
<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01" />
|
||||
{:else if name === 'table'}
|
||||
<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18"/>
|
||||
<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18" />
|
||||
{:else if name === 'form'}
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" />
|
||||
{:else if name === 'cog'}
|
||||
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
||||
<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />
|
||||
{:else if name === 'zap'}
|
||||
<path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/>
|
||||
<path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z" />
|
||||
{:else if name === 'server'}
|
||||
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><path d="M6 6h.01M6 18h.01"/>
|
||||
<rect x="2"
|
||||
y="2"
|
||||
width="20"
|
||||
height="8"
|
||||
rx="2"
|
||||
ry="2" /><rect x="2"
|
||||
y="14"
|
||||
width="20"
|
||||
height="8"
|
||||
rx="2"
|
||||
ry="2" /><path d="M6 6h.01M6 18h.01" />
|
||||
{:else if name === 'text'}
|
||||
<path d="M4 7V4h16v3M9 20h6M12 4v16"/>
|
||||
<path d="M4 7V4h16v3M9 20h6M12 4v16" />
|
||||
{:else if name === 'hash'}
|
||||
<path d="M4 9h16M4 15h16M10 3 8 21M16 3l-2 18"/>
|
||||
<path d="M4 9h16M4 15h16M10 3 8 21M16 3l-2 18" />
|
||||
{:else if name === 'toggle-l'}
|
||||
<rect x="1" y="5" width="22" height="14" rx="7" ry="7"/><circle cx="8" cy="12" r="3"/>
|
||||
<rect x="1"
|
||||
y="5"
|
||||
width="22"
|
||||
height="14"
|
||||
rx="7"
|
||||
ry="7" /><circle cx="8" cy="12" r="3" />
|
||||
{:else if name === 'cal'}
|
||||
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><path d="M16 2v4M8 2v4M3 10h18"/>
|
||||
<rect x="3"
|
||||
y="4"
|
||||
width="18"
|
||||
height="18"
|
||||
rx="2"
|
||||
ry="2" /><path d="M16 2v4M8 2v4M3 10h18" />
|
||||
{:else if name === 'code'}
|
||||
<path d="m16 18 6-6-6-6M8 6l-6 6 6 6"/>
|
||||
<path d="m16 18 6-6-6-6M8 6l-6 6 6 6" />
|
||||
{:else if name === 'target'}
|
||||
<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>
|
||||
<circle cx="12" cy="12" r="10" /><circle cx="12" cy="12" r="6" /><circle cx="12" cy="12" r="2" />
|
||||
{:else if name === 'trash'}
|
||||
<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M10 11v6M14 11v6"/>
|
||||
<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M10 11v6M14 11v6" />
|
||||
{:else if name === 'anchor'}
|
||||
<circle cx="12" cy="5" r="3"/><path d="M12 22V8M5 12H2a10 10 0 0 0 20 0h-3"/>
|
||||
<circle cx="12" cy="5" r="3" /><path d="M12 22V8M5 12H2a10 10 0 0 0 20 0h-3" />
|
||||
{:else if name === 'o'}
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
{:else if name === 'info'}
|
||||
<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>
|
||||
<circle cx="12" cy="12" r="10" /><path d="M12 16v-4M12 8h.01" />
|
||||
{:else if name === 'play'}
|
||||
<path d="m5 3 14 9-14 9V3z"/>
|
||||
<path d="m5 3 14 9-14 9V3z" />
|
||||
{:else if name === 'upload'}
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/>
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12" />
|
||||
{:else if name === 'save'}
|
||||
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><path d="M17 21v-8H7v8M7 3v5h8"/>
|
||||
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" /><path d="M17 21v-8H7v8M7 3v5h8" />
|
||||
{:else if name === 're'}
|
||||
<path d="m17 1 4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/>
|
||||
<path d="m17 1 4 4-4 4" /><path d="M3 11V9a4 4 0 0 1 4-4h14M7 23l-4-4 4-4" /><path d="M21 13v2a4 4 0 0 1-4 4H3" />
|
||||
{:else if name === 'chart'}
|
||||
<path d="M18 20V10M12 20V4M6 20v-6"/>
|
||||
<path d="M18 20V10M12 20V4M6 20v-6" />
|
||||
{:else if name === '?'}
|
||||
<circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line>
|
||||
{/if}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { jsonLooseParse, looseJsonIsValid } from '$lib/strings';
|
||||
import { looseJsonIsValid } from '$lib/strings';
|
||||
import { createEventDispatcher, onDestroy } from 'svelte';
|
||||
import Icon from './icon.svelte';
|
||||
import Modal from './modal.svelte';
|
||||
|
@ -20,7 +20,7 @@
|
||||
<label for="collationLocale">Locale</label>
|
||||
<div class="field">
|
||||
<select id="collationLocale" bind:value={collation.locale}>
|
||||
{#each Object.entries(locales) as [value, name]}
|
||||
{#each Object.entries(locales) as [ value, name ]}
|
||||
<option {value}>({value}) {name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -10,7 +10,7 @@ const defer = listener => {
|
||||
listener();
|
||||
}
|
||||
else {
|
||||
listeners.push(listener)
|
||||
listeners.push(listener);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
Rolens
|
||||
<span class="version">{$environment.version}</span>
|
||||
</div>
|
||||
<div class="description">Intuitive MongoDB <br/> administration tool</div>
|
||||
<div class="description">Intuitive MongoDB <br /> administration tool</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const pipeline = stages.map(stage => ({ [stage.type]: jsonLooseParse(stage.data) }));
|
||||
const pipeline = stages.map(stage => {
|
||||
return { [stage.type]: jsonLooseParse(stage.data) };
|
||||
});
|
||||
await Aggregate(
|
||||
collection.hostKey,
|
||||
collection.dbKey,
|
||||
@ -66,19 +68,20 @@
|
||||
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<label class="field">
|
||||
<ObjectEditor bind:text={stage.data} on:inited={e => {
|
||||
e.detail.editor.dispatch({
|
||||
changes: {
|
||||
from: 0,
|
||||
to: e.detail.editor.state.doc.length,
|
||||
insert: '{\n\t\n}',
|
||||
},
|
||||
selection: {
|
||||
anchor: 3,
|
||||
},
|
||||
});
|
||||
e.detail.editor.focus();
|
||||
}} />
|
||||
<ObjectEditor bind:text={stage.data}
|
||||
on:inited={e => {
|
||||
e.detail.editor.dispatch({
|
||||
changes: {
|
||||
from: 0,
|
||||
to: e.detail.editor.state.doc.length,
|
||||
insert: '{\n\t\n}',
|
||||
},
|
||||
selection: {
|
||||
anchor: 3,
|
||||
},
|
||||
});
|
||||
e.detail.editor.focus();
|
||||
}} />
|
||||
</label>
|
||||
</Details>
|
||||
{/each}
|
||||
|
@ -48,7 +48,7 @@
|
||||
<label class="field">
|
||||
<span class="label">View to use</span>
|
||||
<select bind:value={viewKey}>
|
||||
{#each Object.entries(views.forCollection(collection.hostKey, collection.dbKey, collection.key)) as [key, { name }]}
|
||||
{#each Object.entries(views.forCollection(collection.hostKey, collection.dbKey, collection.key)) as [ key, { name } ]}
|
||||
<option value={key}>{name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
{#if item && view}
|
||||
{#each view?.columns?.filter(c => inputTypes.includes(c.inputType)) || [] as column, index}
|
||||
<!-- svelte-ignore a11y-label-has-associated-control because FormInput contains one -->
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<label class="column">
|
||||
<div class="label">
|
||||
<Icon name={iconMap[column.inputType]} />
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
$: tabs = Object.entries(views.forCollection(collection.hostKey, collection.dbKey, collection.key))
|
||||
.sort((a, b) => sortTabKeys(a[0], b[0]))
|
||||
.map(([ key, v ]) => ({ key, title: v.name, closable: key !== 'list' }));
|
||||
.map(([ key, v ]) => {
|
||||
return { key, title: v.name, closable: key !== 'list' };
|
||||
});
|
||||
|
||||
function sortTabKeys(a, b) {
|
||||
if (a === 'list') {
|
||||
@ -70,11 +72,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
$views[activeViewKey].columns = Object.keys(firstItem).sort().map(key => ({
|
||||
key,
|
||||
showInTable: true,
|
||||
inputType: 'none',
|
||||
}));
|
||||
$views[activeViewKey].columns = Object.keys(firstItem).sort().map(key => {
|
||||
return {
|
||||
key,
|
||||
showInTable: true,
|
||||
inputType: 'none',
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function moveColumn(oldIndex, delta) {
|
||||
|
@ -38,8 +38,8 @@
|
||||
let querying = false;
|
||||
let objectViewerSuccessMessage = '';
|
||||
|
||||
// $: code = `db.${collection.key}.find(${form.query || '{}'}${form.fields && form.fields !== '{}' ? `, ${form.fields}` : ''}).sort(${form.sort})${form.skip ? `.skip(${form.skip})` : ''}${form.limit ? `.limit(${form.limit})` : ''};`;
|
||||
$: viewsForCollection = views.forCollection(collection.hostKey, collection.dbKey, collection.key);
|
||||
$: code = `db.${collection.key}.find(${form.query || '{}'}${form.fields && form.fields !== '{}' ? `, ${form.fields}` : ''}).sort(${form.sort})${form.skip ? `.skip(${form.skip})` : ''}${form.limit ? `.limit(${form.limit})` : ''};`;
|
||||
$: lastPage = (submittedForm.limit && result?.results?.length) ? Math.max(0, Math.ceil((result.total - submittedForm.limit) / submittedForm.limit)) : 0;
|
||||
$: activePage = (submittedForm.limit && submittedForm.skip && result?.results?.length) ? submittedForm.skip / submittedForm.limit : 0;
|
||||
|
||||
@ -162,7 +162,12 @@
|
||||
<div class="form-row one">
|
||||
<label class="field">
|
||||
<span class="label">Query or id</span>
|
||||
<input type="text" class="code" bind:this={queryField} bind:value={form.query} use:input={{ type: 'json', autofocus: true }} placeholder={defaults.query} />
|
||||
<input type="text"
|
||||
class="code"
|
||||
bind:this={queryField}
|
||||
bind:value={form.query}
|
||||
use:input={{ type: 'json', autofocus: true }}
|
||||
placeholder={defaults.query} />
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
@ -179,12 +184,22 @@
|
||||
|
||||
<label class="field">
|
||||
<span class="label">Skip</span>
|
||||
<input type="number" min="0" bind:value={form.skip} use:input placeholder={defaults.skip} list="skipstops" />
|
||||
<input type="number"
|
||||
min="0"
|
||||
bind:value={form.skip}
|
||||
use:input
|
||||
placeholder={defaults.skip}
|
||||
list="skipstops" />
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
<span class="label">Limit</span>
|
||||
<input type="number" min="0" bind:value={form.limit} use:input placeholder={defaults.limit} list="limits" />
|
||||
<input type="number"
|
||||
min="0"
|
||||
bind:value={form.limit}
|
||||
use:input
|
||||
placeholder={defaults.limit}
|
||||
list="limits" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@ -219,7 +234,9 @@
|
||||
{:else}
|
||||
<Grid
|
||||
key="_id"
|
||||
columns={$views[collection.viewKey]?.columns?.map(c => ({ key: c.key, title: c.key })) || []}
|
||||
columns={$views[collection.viewKey]?.columns?.map(c => {
|
||||
return { key: c.key, title: c.key };
|
||||
}) || []}
|
||||
showHeaders={true}
|
||||
items={result.results ? result.results.map(r => EJSON.deserialize(r)) : []}
|
||||
bind:activePath
|
||||
@ -238,7 +255,7 @@
|
||||
<div>
|
||||
<label class="field inline">
|
||||
<select bind:value={collection.viewKey}>
|
||||
{#each Object.entries(viewsForCollection) as [key, view]}
|
||||
{#each Object.entries(viewsForCollection) as [ key, view ]}
|
||||
<option value={key}>{view.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -57,7 +57,8 @@
|
||||
{ key: 'remove', icon: 'trash', title: 'Remove' },
|
||||
{ key: 'indexes', icon: 'list', title: 'Indexes' },
|
||||
{ key: 'aggregate', icon: 're', title: 'Aggregate' },
|
||||
]} bind:selectedKey={tab} />
|
||||
]}
|
||||
bind:selectedKey={tab} />
|
||||
|
||||
<div class="container">
|
||||
{#if tab === 'stats'} <Stats {collection} />
|
||||
|
@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import Icon from '$components/icon.svelte';
|
||||
import ObjectGrid from '$components/objectgrid.svelte';
|
||||
import ObjectViewer from '$components/objectviewer.svelte';
|
||||
import { DropIndex, GetIndexes } from '$wails/go/app/App';
|
||||
import IndexDetail from './components/indexdetail.svelte';
|
||||
|
||||
|
@ -60,9 +60,7 @@
|
||||
|
||||
function showDocs() {
|
||||
dispatch('performFind', {
|
||||
query: insertedIds.length === 1
|
||||
? `{ "_id": ${JSON.stringify(insertedIds[0])} }`
|
||||
: `{ "_id": { "$in": [ ${insertedIds.map(id => JSON.stringify(id)).join(', ')} ] } }`,
|
||||
query: insertedIds.length === 1 ? `{ "_id": ${JSON.stringify(insertedIds[0])} }` : `{ "_id": { "$in": [ ${insertedIds.map(id => JSON.stringify(id)).join(', ')} ] } }`,
|
||||
});
|
||||
}
|
||||
|
||||
@ -146,11 +144,11 @@
|
||||
<Grid
|
||||
key="id"
|
||||
items={newItems}
|
||||
columns={
|
||||
$views[collection.viewKey]?.columns
|
||||
?.filter(c => inputTypes.includes(c.inputType))
|
||||
.map(c => ({ ...c, id: randomString(8), title: c.key })) || []
|
||||
}
|
||||
columns={$views[collection.viewKey]?.columns
|
||||
?.filter(c => inputTypes.includes(c.inputType))
|
||||
.map(c => {
|
||||
return { ...c, id: randomString(8), title: c.key };
|
||||
}) || []}
|
||||
showHeaders={true}
|
||||
canSelect={false}
|
||||
canRemoveItems={true}
|
||||
@ -188,7 +186,7 @@
|
||||
{/if}
|
||||
<label class="field inline">
|
||||
<select bind:value={collection.viewKey}>
|
||||
{#each Object.entries(viewsForCollection) as [key, view]}
|
||||
{#each Object.entries(viewsForCollection) as [ key, view ]}
|
||||
<option value={key}>{key === 'list' ? 'Raw JSON' : view.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -11,7 +11,7 @@
|
||||
let many = true;
|
||||
let result = undefined;
|
||||
let editor;
|
||||
$: code = `db.${collection.key}.remove(${json});`;
|
||||
// $: code = `db.${collection.key}.remove(${json});`;
|
||||
|
||||
async function removeItems() {
|
||||
result = await RemoveItems(
|
||||
|
@ -11,7 +11,7 @@
|
||||
const allOperators = Object.values(atomicUpdateOperators).map(Object.keys).flat();
|
||||
const form = { query: '{}', parameters: [ { type: '$set' } ] };
|
||||
let updatedCount;
|
||||
$: code = buildCode(form);
|
||||
// $: code = buildCode(form);
|
||||
$: invalid = !form.query || form.parameters?.some(param => {
|
||||
if (!param.value) {
|
||||
return true;
|
||||
@ -26,26 +26,28 @@
|
||||
}
|
||||
});
|
||||
|
||||
function buildCode(form) {
|
||||
let operation = '{ ' + form.parameters.filter(p => p.type).map(p => `${p.type}: ${p.value || '{}'}`).join(', ') + ' }';
|
||||
if (operation === '{ }') {
|
||||
operation = '{}';
|
||||
}
|
||||
// function buildCode(form) {
|
||||
// let operation = '{ ' + form.parameters.filter(p => p.type).map(p => `${p.type}: ${p.value || '{}'}`).join(', ') + ' }';
|
||||
// if (operation === '{ }') {
|
||||
// operation = '{}';
|
||||
// }
|
||||
|
||||
let options = (form.upsert || form.many) ? ', { ' : '';
|
||||
form.upsert && (options += 'upsert: true');
|
||||
form.upsert && form.many && (options += ', ');
|
||||
form.many && (options += 'multi: true');
|
||||
(form.upsert || form.many) && (options += ' }');
|
||||
// let options = (form.upsert || form.many) ? ', { ' : '';
|
||||
// form.upsert && (options += 'upsert: true');
|
||||
// form.upsert && form.many && (options += ', ');
|
||||
// form.many && (options += 'multi: true');
|
||||
// (form.upsert || form.many) && (options += ' }');
|
||||
|
||||
const code = `db.${collection.key}.update(${form.query || '{}'}, ${operation}${options});`;
|
||||
return code;
|
||||
}
|
||||
// const code = `db.${collection.key}.update(${form.query || '{}'}, ${operation}${options});`;
|
||||
// return code;
|
||||
// }
|
||||
|
||||
async function submitQuery() {
|
||||
const f = deepClone(form);
|
||||
f.query = convertLooseJson(f.query);
|
||||
f.parameters = f.parameters.map(param => ({ ...param, value: convertLooseJson(param.value) }));
|
||||
f.parameters = f.parameters.map(param => {
|
||||
return { ...param, value: convertLooseJson(param.value) };
|
||||
});
|
||||
updatedCount = await UpdateItems(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(f));
|
||||
}
|
||||
|
||||
@ -120,9 +122,9 @@
|
||||
<fieldset class="parameter">
|
||||
<label class="field">
|
||||
<select bind:value={param.type} class="type">
|
||||
{#each Object.entries(atomicUpdateOperators) as [groupName, options]}
|
||||
{#each Object.entries(atomicUpdateOperators) as [ groupName, options ]}
|
||||
<optgroup label={groupName}>
|
||||
{#each Object.entries(options) as [key, label]}
|
||||
{#each Object.entries(options) as [ key, label ]}
|
||||
<option value={key} disabled={form.parameters.some(p => p.type === key) && (key !== param.type)}>
|
||||
{label}
|
||||
</option>
|
||||
|
@ -7,7 +7,7 @@
|
||||
let copySucceeded = false;
|
||||
|
||||
async function copy() {
|
||||
const json = JSON.stringify(collection.stats, undefined, '\t');
|
||||
const json = JSON.stringify(database.stats, undefined, '\t');
|
||||
await navigator.clipboard.writeText(json);
|
||||
copySucceeded = true;
|
||||
setTimeout(() => copySucceeded = false, 1500);
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
<Modal bind:show={info} title="Perform dump">
|
||||
<form on:submit|preventDefault={performDump}>
|
||||
<!-- svelte-ignore a11y-label-has-associated-control - input is in DirectoryChooser -->
|
||||
<label class="field">
|
||||
<span class="label">Output destination:</span>
|
||||
<DirectoryChooser bind:value={info.outdir} />
|
||||
@ -83,7 +82,9 @@
|
||||
hideChildrenToggles
|
||||
items={[
|
||||
{ id: undefined, name: '(localhost)' },
|
||||
...Object.keys($hosts).map(id => ({ id, name: $hosts[id]?.name })),
|
||||
...Object.keys($hosts).map(id => {
|
||||
return { id, name: $hosts[id]?.name };
|
||||
}),
|
||||
]}
|
||||
on:select={e => selectHost(e.detail?.itemKey)}
|
||||
/>
|
||||
@ -97,9 +98,9 @@
|
||||
hideChildrenToggles
|
||||
items={[
|
||||
{ id: undefined, name: '(all databases)' },
|
||||
...($connections[info.hostKey]?.databases
|
||||
? Object.keys($connections[info.hostKey].databases).map(id => ({ id, name: id }))
|
||||
: []
|
||||
...($connections[info.hostKey]?.databases ? Object.keys($connections[info.hostKey].databases).map(id => {
|
||||
return { id, name: id };
|
||||
}) : []
|
||||
),
|
||||
]}
|
||||
on:select={e => selectDatabase(e.detail?.itemKey)}
|
||||
@ -114,9 +115,9 @@
|
||||
hideChildrenToggles
|
||||
items={[
|
||||
{ id: undefined, name: '(all collections)' },
|
||||
...($connections[info.hostKey]?.databases[info.dbKey]?.collections
|
||||
? Object.keys($connections[info.hostKey].databases[info.dbKey].collections).map(id => ({ id, name: id }))
|
||||
: []
|
||||
...($connections[info.hostKey]?.databases[info.dbKey]?.collections ? Object.keys($connections[info.hostKey].databases[info.dbKey].collections).map(id => {
|
||||
return { id, name: id };
|
||||
}) : []
|
||||
),
|
||||
]}
|
||||
on:select={e => selectCollection(e.detail?.itemKey)}
|
||||
|
@ -14,7 +14,7 @@
|
||||
host.hostKey = hostKey;
|
||||
}
|
||||
|
||||
$: if (hostKey || dbKey) {
|
||||
$: if (hostKey) {
|
||||
tab = 'status';
|
||||
}
|
||||
|
||||
@ -26,8 +26,9 @@
|
||||
{#key host}
|
||||
<TabBar tabs={[
|
||||
{ key: 'status', icon: 'chart', title: 'Host status' },
|
||||
{ key: 'systemInfo', icon: 'server', title: 'System info' }
|
||||
]} bind:selectedKey={tab} />
|
||||
{ key: 'systemInfo', icon: 'server', title: 'System info' },
|
||||
]}
|
||||
bind:selectedKey={tab} />
|
||||
|
||||
<div class="container">
|
||||
{#if tab === 'status'} <Status {host} />
|
||||
|
@ -7,7 +7,7 @@
|
||||
let copySucceeded = false;
|
||||
|
||||
async function copy() {
|
||||
const json = JSON.stringify(collection.stats, undefined, '\t');
|
||||
const json = JSON.stringify(host.status, undefined, '\t');
|
||||
await navigator.clipboard.writeText(json);
|
||||
copySucceeded = true;
|
||||
setTimeout(() => copySucceeded = false, 1500);
|
||||
|
@ -7,7 +7,7 @@
|
||||
let copySucceeded = false;
|
||||
|
||||
async function copy() {
|
||||
const json = JSON.stringify(collection.stats, undefined, '\t');
|
||||
const json = JSON.stringify(host.systemInfo, undefined, '\t');
|
||||
await navigator.clipboard.writeText(json);
|
||||
copySucceeded = true;
|
||||
setTimeout(() => copySucceeded = false, 1500);
|
||||
|
@ -2,10 +2,9 @@
|
||||
import Grid from '$components/grid.svelte';
|
||||
import { startProgress } from '$lib/progress';
|
||||
import connections from '$lib/stores/connections';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher, tick } from 'svelte';
|
||||
import { DropCollection, DropDatabase, OpenCollection, OpenConnection, OpenDatabase, RemoveHost, TruncateCollection } from '../../../wailsjs/go/app/App';
|
||||
import hosts from '$lib/stores/hosts';
|
||||
import { tick } from 'svelte';
|
||||
import windowTitle from '$lib/stores/windowtitle';
|
||||
|
||||
export let activeHostKey = '';
|
||||
@ -17,10 +16,7 @@
|
||||
// $: activeGridPath[0] = activeHostKey || undefined;
|
||||
// $: activeGridPath[1] = activeDbKey || undefined;
|
||||
// $: activeGridPath[2] = activeCollKey || undefined;
|
||||
$: host = $hosts[activeHostKey];
|
||||
$: connection = $connections[activeHostKey];
|
||||
$: database = connection?.databases[activeDbKey];
|
||||
$: collection = database?.collections?.[activeCollKey];
|
||||
|
||||
export async function reload() {
|
||||
activeHostKey && await openConnection(activeHostKey);
|
||||
@ -79,7 +75,7 @@
|
||||
|
||||
for (const collKey of collections || []) {
|
||||
$connections[activeHostKey].databases[dbKey].collections[collKey] =
|
||||
$connections[activeHostKey].databases[dbKey].collections[collKey] ||{};
|
||||
$connections[activeHostKey].databases[dbKey].collections[collKey] || {};
|
||||
}
|
||||
|
||||
progress.end();
|
||||
@ -129,44 +125,50 @@
|
||||
striped={false}
|
||||
columns={[ { key: 'name' }, { key: 'count', right: true } ]}
|
||||
bind:activePath={activeGridPath}
|
||||
items={Object.keys($hosts).map(hostKey => ({
|
||||
id: hostKey,
|
||||
name: $hosts[hostKey].name,
|
||||
icon: 'server',
|
||||
children: Object.keys(connection?.databases || {}).sort().map(dbKey => ({
|
||||
id: dbKey,
|
||||
name: dbKey,
|
||||
icon: 'db',
|
||||
count: Object.keys(connection.databases[dbKey].collections || {}).length || '',
|
||||
children: Object.keys(connection.databases[dbKey].collections).sort().map(collKey => ({
|
||||
id: collKey,
|
||||
name: collKey,
|
||||
icon: 'list',
|
||||
menu: [
|
||||
{ label: 'Export collection (JSON, CSV)…', fn: () => dispatch('exportCollection', collKey) },
|
||||
{ label: 'Dump collection (BSON via mongodump)…', fn: () => dispatch('dumpCollection', collKey) },
|
||||
{ separator: true },
|
||||
{ label: 'Rename collection…', fn: () => dispatch('renameCollection', collKey) },
|
||||
{ label: 'Truncate collection…', fn: () => truncateCollection(dbKey, collKey) },
|
||||
{ label: 'Drop collection…', fn: () => dropCollection(dbKey, collKey) },
|
||||
{ separator: true },
|
||||
{ label: 'New collection…', fn: () => dispatch('newCollection') },
|
||||
],
|
||||
})) || [],
|
||||
items={Object.keys($hosts).map(hostKey => {
|
||||
return {
|
||||
id: hostKey,
|
||||
name: $hosts[hostKey].name,
|
||||
icon: 'server',
|
||||
children: Object.keys(connection?.databases || {}).sort().map(dbKey => {
|
||||
return {
|
||||
id: dbKey,
|
||||
name: dbKey,
|
||||
icon: 'db',
|
||||
count: Object.keys(connection.databases[dbKey].collections || {}).length || '',
|
||||
children: Object.keys(connection.databases[dbKey].collections).sort().map(collKey => {
|
||||
return {
|
||||
id: collKey,
|
||||
name: collKey,
|
||||
icon: 'list',
|
||||
menu: [
|
||||
{ label: 'Export collection (JSON, CSV)…', fn: () => dispatch('exportCollection', collKey) },
|
||||
{ label: 'Dump collection (BSON via mongodump)…', fn: () => dispatch('dumpCollection', collKey) },
|
||||
{ separator: true },
|
||||
{ label: 'Rename collection…', fn: () => dispatch('renameCollection', collKey) },
|
||||
{ label: 'Truncate collection…', fn: () => truncateCollection(dbKey, collKey) },
|
||||
{ label: 'Drop collection…', fn: () => dropCollection(dbKey, collKey) },
|
||||
{ separator: true },
|
||||
{ label: 'New collection…', fn: () => dispatch('newCollection') },
|
||||
],
|
||||
};
|
||||
}) || [],
|
||||
menu: [
|
||||
{ label: 'Drop database…', fn: () => dropDatabase(dbKey) },
|
||||
{ separator: true },
|
||||
{ label: 'New database…', fn: () => dispatch('newDatabase') },
|
||||
{ label: 'New collection…', fn: () => dispatch('newCollection') },
|
||||
],
|
||||
};
|
||||
}),
|
||||
menu: [
|
||||
{ label: 'Drop database…', fn: () => dropDatabase(dbKey) },
|
||||
{ separator: true },
|
||||
{ label: 'New database…', fn: () => dispatch('newDatabase') },
|
||||
{ label: 'New collection…', fn: () => dispatch('newCollection') },
|
||||
{ separator: true },
|
||||
{ label: `Edit host ${$hosts[hostKey].name}…`, fn: () => dispatch('editHost', hostKey) },
|
||||
{ label: 'Remove host…', fn: () => removeHost(hostKey) },
|
||||
],
|
||||
})),
|
||||
menu: [
|
||||
{ label: 'New database…', fn: () => dispatch('newDatabase') },
|
||||
{ separator: true },
|
||||
{ label: `Edit host ${$hosts[hostKey].name}…`, fn: () => dispatch('editHost', hostKey) },
|
||||
{ label: `Remove host…`, fn: () => removeHost(hostKey) },
|
||||
],
|
||||
}))}
|
||||
};
|
||||
})}
|
||||
on:select={e => {
|
||||
const key = e.detail.itemKey;
|
||||
switch (e.detail?.level) {
|
||||
|
@ -1,10 +1,9 @@
|
||||
<script>
|
||||
import { startProgress } from '$lib/progress';
|
||||
import connections from '$lib/stores/connections';
|
||||
import { Hosts, RenameCollection } from '$wails/go/app/App';
|
||||
import { RenameCollection } from '$wails/go/app/App';
|
||||
import { EnterText } from '$wails/go/ui/UI';
|
||||
import { EventsOn } from '$wails/runtime/runtime';
|
||||
import { onMount } from 'svelte';
|
||||
import HostView from './host/index.svelte';
|
||||
import DatabaseView from './database/index.svelte';
|
||||
import CollectionView from './collection/index.svelte';
|
||||
@ -135,7 +134,7 @@
|
||||
<HostDetail
|
||||
bind:show={showHostDetail}
|
||||
on:reload={hosts.update}
|
||||
hostKey={activeHostKey}
|
||||
hostKey={hostDetailKey}
|
||||
/>
|
||||
|
||||
<DumpInfo bind:info={exportInfo} />
|
||||
|
@ -27,7 +27,7 @@
|
||||
</span>
|
||||
|
||||
<label for="defaultExportDirectory">Default export directory</label>
|
||||
<!-- svelte-ignore a11y-label-has-associated-control - input is in DirectoryChooser -->
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<label class="field">
|
||||
<DirectoryChooser id="defaultExportDirectory" bind:value={$settings.defaultExportDirectory} />
|
||||
</label>
|
||||
|
Loading…
Reference in New Issue
Block a user