Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiog1901 committed Jan 30, 2024
1 parent 61d0105 commit 0688c29
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 41 deletions.
4 changes: 2 additions & 2 deletions apiserver/routers/attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def get_presigned_put_url(
# this should append to the new list...
bg_task.add_task(
svc.update_documents,
[{"comp_id": model_name + "_" + str(id), "attachments": ", ".join(attachments)}],
[{"comp_id": model_name + "_" + str(id), "attachments": attachments}],
)
return HTMLResponse(content=data)

Expand Down Expand Up @@ -114,5 +114,5 @@ async def delete_attachement(
# this should add the new list
bg_task.add_task(
svc.update_documents,
[{"comp_id": model_name + "_" + str(id), "attachments": ', '.join(attachments)}],
[{"comp_id": model_name + "_" + str(id), "attachments": attachments}],
)
29 changes: 29 additions & 0 deletions webapp/src/components/FabEditableField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,35 @@
/>
</div>
</div>
<div v-else-if="item_type === 'tags'">
<div v-if="edit_field !== item_name" class="m-1 flex h-8 items-center">
<div
v-for="tag in instance?.[item_name]"
v-bind:key="tag"
class="p-1"
>
<div
class="flex h-8 w-fit min-w-16 items-center justify-center rounded-2xl p-2 text-sm font-semibold"
v-bind:class="getLabel(tag)"
>
{{ tag }}
</div>
</div>


</div>
<div
v-else
class="m-1 h-8 rounded border bg-slate-300 dark:bg-slate-500 dark:text-white"
>
<input
v-model.lazy.trim="new_value"
class="h-full w-full p-2 text-black"
type="text"
autocomplete="off"
/>
</div>
</div>
<div v-else-if="item_type === 'markdown'">
<div
v-if="edit_field !== item_name"
Expand Down
19 changes: 15 additions & 4 deletions webapp/src/layout/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
placeholder="Search..."
reset-title="Remove the query"
v-on:focus="open_ais_hits = true"
></ais-search-box
>
></ais-search-box>
<div
v-if="open_ais_hits"
class="fixed left-0 top-0 z-10 flex h-full w-full items-center justify-center"
Expand Down Expand Up @@ -63,8 +62,20 @@
);
})"
>
<div v-if="item[k] && (!Array.isArray(item[k] || item[k].length > 0))">

<div v-if="item[k] && Array.isArray(item[k]) && item[k].length > 0">
<label
class="font-semibold hover:cursor-pointer hover:underline"
v-on:click="routerSearchLinker(item.comp_id)"
>{{ k }}:
</label>
<div class="flex" v-for="i in item[k]" v-bind:key="i">
<div
class="hover:cursor-pointer hover:underline"
v-on:click="routerSearchLinker(item.comp_id)"
>- {{ i }}</div>
</div>
</div>
<div v-if="item[k] && !Array.isArray(item[k])">
<label
class="font-semibold hover:cursor-pointer hover:underline"
v-on:click="routerSearchLinker(item.comp_id)"
Expand Down
74 changes: 39 additions & 35 deletions webapp/src/views/InstanceView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,31 @@
</div>
</div>

<div class="mb-1 mx-1 text-sm">
owned_by: {{ modelStore.instance?.owned_by }}
</div>
<div class="mb-1 mx-1 text-sm">
permissions: {{ modelStore.instance?.permissions }}
</div>
<FabEditableField
v-bind:instance="modelStore.instance"
item_name="owned_by"
item_type="string"
v-on:save_new_value="save_new_value($event[0], $event[1], $event[2])"
></FabEditableField>

<FabEditableField
v-bind:instance="modelStore.instance"
item_name="permissions"
item_type="string"
v-on:save_new_value="save_new_value($event[0], $event[1], $event[2])"
></FabEditableField>

<hr
id="linebreaker"
class="m-1 rounded-full border border-gray-200 bg-gray-200 dark:border-gray-800 dark:bg-gray-800"
/>

<div class="mb-1 mx-1 text-sm">
tags:
<div
v-for="tag in modelStore.instance?.tags"
v-bind:key="tag"
class="p-1"
>
<div
class="flex h-8 w-fit min-w-16 items-center justify-center rounded-2xl p-2 text-sm font-semibold"
v-bind:class="getLabel(tag)"
>
{{ tag }}
</div>
</div>
</div>
<FabEditableField
v-bind:instance="modelStore.instance"
item_name="tags"
item_type="tags"
v-on:save_new_value="save_new_value($event[0], $event[1], $event[2])"
></FabEditableField>

<hr
id="linebreaker"
Expand Down Expand Up @@ -312,19 +310,6 @@ const attachment = ref("");
const edit_field = ref("");
const new_value = ref("");
const delete_attachment = async () => {
showDeleteAttachmentModal.value = false;
await modelStore.delete_attachment(
instance_type.value,
instance_id.value,
attachment.value,
);
// refresh to get updated list of attachments
modelStore.get_instance(instance_type.value, instance_id.value);
};
const delete_instance = async () => {
showDeleteInstanceModal.value = false;
Expand Down Expand Up @@ -421,7 +406,10 @@ const upload_file = async (e: any) => {
body: e.target.files[0],
});
modelStore.get_instance(instance_type.value, instance_id.value);
modelStore.instance = await modelStore.get_instance(
instance_type.value,
instance_id.value,
);
};
const download_file = async (filename: string) => {
Expand All @@ -439,6 +427,22 @@ const confirm_delete_attachment = async (s: any) => {
attachment.value = s;
};
const delete_attachment = async () => {
showDeleteAttachmentModal.value = false;
await modelStore.delete_attachment(
instance_type.value,
instance_id.value,
attachment.value,
);
// refresh to get updated list of attachments
modelStore.instance = await modelStore.get_instance(
instance_type.value,
instance_id.value,
);
};
// const ff = computed(() => {
// if (modelStore.instance !== undefined) {
// return Object.keys(modelStore.instance)
Expand Down

0 comments on commit 0688c29

Please sign in to comment.