-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from DigitalSlideArchive/ui-imageData_table
UI image data table
- Loading branch information
Showing
21 changed files
with
442 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import { imageRedactionPlan } from "../store/imageStore"; | ||
import { getImages, getRedactionPlan } from "../api/rest"; | ||
import { selectedDirectories } from "../store/directoryStore"; | ||
import ImageDataTable from "./ImageDataTable.vue"; | ||
import InfiniteScroller from "./InfiniteScroller.vue"; | ||
const limit = ref(50); | ||
const offset = ref(1); | ||
const loadImagePlan = async () => { | ||
const newPlan = await getRedactionPlan( | ||
selectedDirectories.value.inputDirectory, | ||
limit.value, | ||
offset.value, | ||
false, | ||
); | ||
imageRedactionPlan.value.data = { | ||
...imageRedactionPlan.value.data, | ||
...newPlan.data, | ||
}; | ||
getThumbnail(newPlan.data); | ||
++offset.value; | ||
}; | ||
const usedColumns = computed(() => imageRedactionPlan.value.tags); | ||
const getThumbnail = async ( | ||
imagedict: Record<string, Record<string, string>>, | ||
) => { | ||
Object.keys(imagedict).forEach(async (image) => { | ||
const response = await getImages( | ||
selectedDirectories.value.inputDirectory + "/" + image, | ||
"thumbnail", | ||
); | ||
if (response.status >= 400) { | ||
imageRedactionPlan.value.data[image].thumbnail = | ||
"/thumbnailPlaceholder.svg"; | ||
return; | ||
} | ||
if (response.body) { | ||
const reader = response.body.getReader(); | ||
const chunks = []; | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
const { done, value } = await reader.read(); | ||
if (done) break; | ||
chunks.push(value); | ||
} | ||
const blob = new Blob(chunks); | ||
const url = URL.createObjectURL(blob); | ||
imageRedactionPlan.value.data[image].thumbnail = url; | ||
} | ||
}); | ||
}; | ||
getThumbnail(imageRedactionPlan.value.data); | ||
</script> | ||
|
||
<template> | ||
<div class="card m-4 pb-4 rounded"> | ||
<InfiniteScroller @infinite-scroll="loadImagePlan"> | ||
<ImageDataTable | ||
:used-columns="usedColumns" | ||
:image-redaction-plan="imageRedactionPlan" | ||
/> | ||
</InfiniteScroller> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,122 @@ | ||
<script setup lang="ts"> | ||
const props = defineProps({ | ||
imageData: { | ||
defineProps({ | ||
imageRedactionPlan: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const sortedData = Object.entries(props.imageData).sort(([keyA], [keyB]) => { | ||
if (keyA === "missing_tags") { | ||
return -1; | ||
} else if (keyB === "missing_tags") { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
usedColumns: { | ||
type: Array<string>, | ||
required: true, | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<table class="table table-auto table-xs w-full"> | ||
<div v-if="!usedColumns" class="m-auto flex justify-center"> | ||
Loading.. <span class="loading loading-bars loading-md"></span> | ||
</div> | ||
<table v-if="usedColumns" class="table table-auto text-center bg-base-100"> | ||
<thead> | ||
<tr> | ||
<th v-for="tag in sortedData" :key="tag[0]"> | ||
{{ tag[0] }} | ||
<tr class="text-base"> | ||
<th class="bg-neutral text-white py-5 px-6">Image File Name</th> | ||
<th class="bg-gray-600 text-white py-5 px-10">Image</th> | ||
<th class="bg-gray-600 text-white">Redaction Status</th> | ||
<th | ||
v-if="Object.keys(imageRedactionPlan.data).includes('missing_tags')" | ||
class="bg-gray-600 text-white p-4" | ||
> | ||
Missing Tags | ||
</th> | ||
<th | ||
v-for="tag in usedColumns" | ||
:key="tag" | ||
class="bg-gray-600 text-white py-5 px-6" | ||
> | ||
{{ tag }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<template v-for="rule in sortedData" :key="rule[0]"> | ||
<td v-if="rule[0] === 'missing_tags'"> | ||
<span v-for="(tag, id) in rule[1][0]" :key="id"> | ||
{{ id }} : {{ tag }} | ||
<tbody class="text-base bg-base-100"> | ||
<tr | ||
v-for="(image, index) in imageRedactionPlan.data" | ||
:key="index" | ||
class="h-[125px]" | ||
> | ||
<th>{{ index }}</th> | ||
<td> | ||
<img :src="image.thumbnail" class="w-20 h-20" /> | ||
</td> | ||
<td> | ||
<div | ||
v-if="image.missing_tags" | ||
class="tooltip tooltip-right" | ||
:data-tip="`${image.missing_tags.length} tag(s) missing redaction rules.`" | ||
> | ||
<i class="ri-error-warning-fill text-red-600 text-xl"></i> | ||
<div v-for="(obj, pos) in image.missing_tags" :key="pos"> | ||
<span v-for="(value, key) in obj" :key="key"> | ||
{{ key }}: {{ value }} | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<div | ||
v-else | ||
class="tooltip tooltip-right" | ||
:data-tip="`No missing redaction rules.`" | ||
> | ||
<i class="ri-checkbox-circle-fill text-green-600 text-xl"></i> | ||
</div> | ||
</td> | ||
<template v-for="tag in usedColumns" :key="tag"> | ||
<td class="text-ellipsis overflow-hidden max-w-[300px]"> | ||
<span | ||
v-if="image[tag]" | ||
:class=" | ||
image[tag].action === 'delete' | ||
? 'line-through text-accent font-bold decoration-2' | ||
: '' | ||
" | ||
> | ||
<span v-if="image[tag].binary"> | ||
{{ image[tag].binary.bytes }} bytes | ||
<span> | ||
{{ image[tag].binary.value.slice(0, 32) }} | ||
</span> | ||
</span> | ||
<span v-else> | ||
{{ | ||
typeof image[tag].value === "object" | ||
? image[tag].value.join(", ") | ||
: image[tag].value | ||
}} | ||
</span> | ||
</span> | ||
</td> | ||
<td v-else> | ||
{{ rule[1] }} | ||
</td> | ||
</template> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
<style scoped> | ||
thead th:first-child { | ||
position: sticky; | ||
left: 0; | ||
z-index: 2; | ||
background-color: #201c35; | ||
} | ||
thead th { | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
tbody th { | ||
position: relative; | ||
} | ||
tbody th:first-child { | ||
position: sticky; | ||
left: 0; | ||
z-index: 1; | ||
background-color: #ffffff; | ||
} | ||
</style> |
Oops, something went wrong.