Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<el-button @click="neuronSearch">open neuron search</el-button>
<el-button @click="keywordSearch">keyword search</el-button>
<el-button @click="getFacets">Get facets</el-button>
<el-button @click="showFlatmapImages">Show Flatmap Images</el-button>
</div>
<SideBar
:envVars="envVars"
Expand All @@ -23,6 +24,7 @@
:tabs="tabs"
:activeTabId="activeId"
:connectivityInfo="connectivityInput"
:flatmapImages="flatmapImages"
@tabClicked="tabClicked"
@search-changed="searchChanged($event)"
@hover-changed="hoverChanged($event)"
Expand All @@ -37,6 +39,7 @@
import SideBar from './components/SideBar.vue'
import EventBus from './components/EventBus.js'
import exampleConnectivityInput from './exampleConnectivityInput.js'
import flatmapImages from './data/flatmapImages.js';

const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);

Expand Down Expand Up @@ -101,7 +104,11 @@ export default {
data: function () {
return {
contextArray: [null, null],
tabArray: [{ title: 'Flatmap', id: 1, type: 'search'}, { title: 'Connectivity', id: 2, type: 'connectivity' }],
tabArray: [
{ title: 'Flatmap', id: 1, type: 'search'},
{ title: 'Connectivity', id: 2, type: 'connectivity' },
{ title: 'Images', id: 3, type: 'flatmapImages' },
],
sideBarVisibility: true,
envVars: {
API_LOCATION: import.meta.env.VITE_APP_API_LOCATION,
Expand All @@ -114,6 +121,7 @@ export default {
ROOT_URL: import.meta.env.VITE_APP_ROOT_URL,
},
connectivityInput: exampleConnectivityInput,
flatmapImages: flatmapImages,
activeId: 1,
}
},
Expand Down Expand Up @@ -224,6 +232,12 @@ export default {
let facets = await this.$refs.sideBar.getAlgoliaFacets()
console.log('Algolia facets:', facets)
},
showFlatmapImages: function () {
if (this.$refs.sideBar) {
this.$refs.sideBar.setDrawerOpen(true);
this.$refs.sideBar.tabClicked({id: 3, type: 'flatmapImages'})
}
},
},
mounted: function () {
console.log('mounted app')
Expand Down
3 changes: 3 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ declare module 'vue' {
ElIconArrowRight: typeof import('@element-plus/icons-vue')['ArrowRight']
ElIconLocation: typeof import('@element-plus/icons-vue')['Location']
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
ElIconWarnTriangleFilled: typeof import('@element-plus/icons-vue')['WarnTriangleFilled']
ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElTag: typeof import('element-plus/es')['ElTag']
ExternalResourceCard: typeof import('./components/ExternalResourceCard.vue')['default']
FlatmapImages: typeof import('./components/FlatmapImages.vue')['default']
ImageGallery: typeof import('./components/ImageGallery.vue')['default']
SearchFilters: typeof import('./components/SearchFilters.vue')['default']
SearchHistory: typeof import('./components/SearchHistory.vue')['default']
Expand Down
142 changes: 142 additions & 0 deletions src/components/FlatmapImages.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<template>
<div class="flatmap-images">
<div v-for="(image, i) in images" :key="i" class="card">
<div class="card-left">
<a href="#" class="card-image">
<el-image :src="image.imgSrc" loading="lazy">
<template #error>
<div class="image-slot">Loading<span class="dot">...</span></div>
</template>
</el-image>
</a>
</div>
<div class="card-right">
<div class="card-title">{{ 'Image Title' }}</div>
</div>
</div>
</div>
</template>

<script>
import { ElImage } from 'element-plus';
import MissingImage from '@/../assets/missing-image.svg'

const BASE64PREFIX = 'data:image/png;base64,';

export default {
name: 'FlatmapImages',
components: {
ElImage,
},
props: {
images: {
type: Object,
default: () => null,
}
},
mounted: function() {
this.images.forEach(async (image) => {
return this.mapImage(image);
});
},
watch: {
images: function (data) {
this.images = data.map((image) => {
return this.mapImage(image)
});
},
},
methods: {
mapImage: async function (image) {
const imgSrc = await this.transformedImage(image.thumbnail);
if (imgSrc) {
image.imgSrc = imgSrc;
} else {
image.imgSrc = MissingImage;
}
},
transformedImage: async function(imgUrl) {
try {
const response = await fetch(imgUrl);
if (!response.ok) {
return null;
}
const data = await response.text();
return BASE64PREFIX + data;
} catch (error) {
return null;
}
}
}
}
</script>
<style scoped lang="scss">
.flatmap-images {
height: 100%;
overflow-y: auto;
padding: 1rem;
background-color: #f7faff;

.card {
display: flex;
flex-direction: row;
gap: 1rem;

+ .card {
margin-top: 1rem;
}
}

.card-left {

}

.card-right {

}

.card-image {
display: block;
text-decoration: none;
outline: none;

.el-image {
display: block;
width: 200px;
height: 150px;

:deep(img) {
aspect-ratio: 4/3;
object-fit: cover;
}
}

.image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-secondary);
font-size: 14px;
}

.dot {
animation: dot 2s infinite steps(3, start);
overflow: hidden;
}
}

.card-title {
font-family: Asap;
font-size: 14px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: 1.5;
letter-spacing: 1.05px;
color: #484848;
}
}
</style>
24 changes: 22 additions & 2 deletions src/components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<div class="sidebar-container">
<Tabs
v-if="tabs.length > 1 && connectivityInfo"
v-if="tabs.length > 1 && (connectivityInfo || flatmapImages)"
:tabTitles="tabs"
:activeId="activeTabId"
@titleClicked="tabClicked"
Expand All @@ -39,6 +39,13 @@
@show-connectivity="showConnectivity"
/>
</template>
<!-- Flatmap Images -->
<template v-else-if="tab.type === 'flatmapImages'">
<FlatmapImages
:images="flatmapImages"
v-show="tab.id === activeTabId"
/>
</template>
<template v-else>
<SidebarContent
class="sidebar-content-container"
Expand Down Expand Up @@ -68,6 +75,7 @@ import SidebarContent from './SidebarContent.vue'
import EventBus from './EventBus.js'
import Tabs from './Tabs.vue'
import ConnectivityInfo from './ConnectivityInfo.vue'
import FlatmapImages from './FlatmapImages.vue'

/**
* Aims to provide a sidebar for searching capability for SPARC portal.
Expand All @@ -81,6 +89,7 @@ export default {
Drawer,
Icon,
ConnectivityInfo,
FlatmapImages,
},
name: 'SideBar',
props: {
Expand Down Expand Up @@ -108,7 +117,8 @@ export default {
type: Array,
default: () => [
{ id: 1, title: 'Search', type: 'search' },
{ id: 2, title: 'Connectivity', type: 'connectivity' }
{ id: 2, title: 'Connectivity', type: 'connectivity' },
{ id: 3, title: 'Images', type: 'flatmapImages' },
],
},
/**
Expand All @@ -132,6 +142,13 @@ export default {
type: Object,
default: null,
},
/**
* Flatmap images
*/
flatmapImages: {
type: Object,
default: () => [],
}
},
data: function () {
return {
Expand Down Expand Up @@ -262,6 +279,9 @@ export default {
tabClose: function (id) {
this.$emit('connectivity-info-close');
},
setFlatmapImages: function (images) {
this.flatmapImages.push([...images]);
},
},
created: function () {
this.drawerOpen = this.openAtStart
Expand Down
10 changes: 9 additions & 1 deletion src/components/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</div>
<el-button
v-if="title.id === 2"
v-if="title.type === 'connectivity' || title.type === 'flatmapImages'"
@click="tabClose(title.id)"
class="button-tab-close"
aria-label="Close"
Expand Down Expand Up @@ -118,6 +118,14 @@ $tab-height: 30px;
box-shadow: none !important;
outline: none !important;
background-color: transparent !important;
visibility: hidden;
opacity: 0;
transition: all 0.25s ease;

.title:hover & {
visibility: visible;
opacity: 1;
}

:deep(> span) {
height: $tab-height - 2 !important; // tab height minus border
Expand Down
Loading