refresh schema list

This commit is contained in:
Jan Prochazka
2024-09-19 11:15:44 +02:00
parent 3e5b45de8f
commit 9eb27f5e92
4 changed files with 40 additions and 16 deletions

View File

@@ -42,7 +42,7 @@
return res;
}
$: schemaList = _.uniq(
$: realSchemaList = _.uniq(
_.compact([selectedSchema, ...Object.keys(countBySchema), ...(schemaList?.map(x => x.schemaName) ?? [])])
);
$: countBySchema = computeCountBySchema(objectList ?? []);
@@ -54,10 +54,14 @@
label: 'Schema name',
onConfirm: async name => {
const dbid = { conid, database };
await runOperationOnDatabase(dbid, {
type: 'createSchema',
schemaName: name,
});
await runOperationOnDatabase(
dbid,
{
type: 'createSchema',
schemaName: name,
},
'schema-list-changed'
);
if (selectedSchema) {
selectedSchema = name;
}
@@ -69,10 +73,14 @@
message: `Really drop schema ${$appliedCurrentSchema}?`,
onConfirm: async () => {
const dbid = { conid, database };
runOperationOnDatabase(dbid, {
type: 'dropSchema',
schemaName: $appliedCurrentSchema,
});
runOperationOnDatabase(
dbid,
{
type: 'dropSchema',
schemaName: $appliedCurrentSchema,
},
'schema-list-changed'
);
selectedSchema = null;
},
});
@@ -81,14 +89,14 @@
$: selectedSchema = localStorage.getItem(valueStorageKey ?? '');
</script>
{#if schemaList.length > 0}
{#if realSchemaList.length > 0}
<div class="wrapper">
<div class="mr-1">Schema:</div>
<SelectField
isNative
options={[
{ label: `All schemas (${objectList?.length ?? 0})`, value: '' },
...schemaList.map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
...realSchemaList.map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
// ...schemaList.filter(x => countBySchema[x]).map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
// ...schemaList.filter(x => !countBySchema[x]).map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
]}