forked from Ivasoft/geovisio-website
Merge branch 'feat/improve-sequence-select' into 'develop'
feat : improve-sequence-select See merge request geovisio/website!100
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
"axios": "^1.2.3",
|
||||
"bootstrap": "^5.2.3",
|
||||
"bootstrap-icons": "^1.10.3",
|
||||
"geovisio": "2.2.0",
|
||||
"geovisio": "2.2.1",
|
||||
"moment": "^2.29.4",
|
||||
"pinia": "^2.1.4",
|
||||
"vue": "^3.2.45",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import type { ViewerInterface } from '@/views/interfaces/common'
|
||||
import type { ViewerInterface, MapInterface } from '@/views/interfaces/common'
|
||||
import { getIgnTiles } from '@/utils/mapAndViewer'
|
||||
import { Viewer, StandaloneMap } from 'geovisio'
|
||||
import { createUrlLink } from '@/utils'
|
||||
@@ -17,7 +17,8 @@ let viewer = ref()
|
||||
const props = defineProps({
|
||||
fetchOptions: { type: Object, default: {} },
|
||||
geovisioViewer: { type: Boolean, default: true },
|
||||
bbox: { type: Array, default: null }
|
||||
bbox: { type: Array, default: null },
|
||||
userId: { type: String, default: '' }
|
||||
})
|
||||
defineExpose({
|
||||
viewer
|
||||
@@ -28,6 +29,7 @@ onMounted(async () => {
|
||||
const zoom = import.meta.env.VITE_ZOOM
|
||||
const center = import.meta.env.VITE_CENTER
|
||||
let paramsViewer: ViewerInterface
|
||||
let paramsMap: MapInterface
|
||||
|
||||
try {
|
||||
if (props.geovisioViewer) {
|
||||
@@ -98,7 +100,7 @@ onMounted(async () => {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
let paramsMap = {}
|
||||
paramsMap = { minZoom: 7 }
|
||||
if (tiles) {
|
||||
const style = tiles.includes('wxs.ign.fr') ? await getIgnTiles() : tiles
|
||||
paramsMap = {
|
||||
@@ -110,9 +112,14 @@ onMounted(async () => {
|
||||
'viewer', // Div ID
|
||||
`${import.meta.env.VITE_API_URL}/api/search`,
|
||||
{
|
||||
...paramsMap
|
||||
...paramsMap,
|
||||
bounds: [props.bbox[0], props.bbox[1], props.bbox[2], props.bbox[3]],
|
||||
zoom: 9
|
||||
}
|
||||
)
|
||||
viewer.value.addEventListener('ready', () => {
|
||||
viewer.value.setFilters({ user: props.userId }, true)
|
||||
})
|
||||
}
|
||||
mapIsLoaded.value = true
|
||||
} catch (err) {
|
||||
|
||||
39
src/tests/unit/components/Footer.spec.js
Normal file
39
src/tests/unit/components/Footer.spec.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { test, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import Footer from '../../../components/Footer.vue'
|
||||
import Link from '../../../components/Link.vue'
|
||||
import i18n from '../config'
|
||||
describe('Template', () => {
|
||||
test('should have the links without the ay11 link', () => {
|
||||
const wrapper = shallowMount(Footer, {
|
||||
global: {
|
||||
stubs: { Link },
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
expect(wrapper.html()).contains('href="https://panoramax.fr/"')
|
||||
expect(wrapper.html()).contains('logo.jpeg')
|
||||
expect(wrapper.html()).contains('Découvrir Panoramax')
|
||||
|
||||
expect(wrapper.html()).contains('href="https://gitlab.com/geovisio"')
|
||||
expect(wrapper.html()).contains('gitlab-logo.svg')
|
||||
expect(wrapper.html()).contains('Voir le code')
|
||||
})
|
||||
test('should have the ay11 link', () => {
|
||||
Object.create(window)
|
||||
const url = 'http://test.ign.fr'
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
href: url
|
||||
},
|
||||
writable: true // possibility to override
|
||||
})
|
||||
const wrapper = shallowMount(Footer, {
|
||||
global: {
|
||||
stubs: { Link },
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
expect(wrapper.html()).contains('Accessibilité : non conforme')
|
||||
})
|
||||
})
|
||||
33
src/tests/unit/components/InformationCard.spec.js
Normal file
33
src/tests/unit/components/InformationCard.spec.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { test, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import InformationCard from '../../../components/InformationCard.vue'
|
||||
import i18n from '../config'
|
||||
describe('Template', () => {
|
||||
describe('Props', () => {
|
||||
test('should have default props', () => {
|
||||
const wrapper = shallowMount(InformationCard, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
expect(wrapper.vm.text).toBe(null)
|
||||
expect(wrapper.vm.title).toBe(null)
|
||||
expect(wrapper.vm.look).toBe('')
|
||||
})
|
||||
test('should have all the props filled', () => {
|
||||
const wrapper = shallowMount(InformationCard, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
},
|
||||
props: {
|
||||
text: 'my text',
|
||||
title: 'my title',
|
||||
look: 'my-look'
|
||||
}
|
||||
})
|
||||
expect(wrapper.html()).contains('my title</h3>')
|
||||
expect(wrapper.html()).contains('my text</p>')
|
||||
expect(wrapper.html()).contains('class="information-block my-look"')
|
||||
})
|
||||
})
|
||||
})
|
||||
80
src/tests/unit/components/InputUpload.spec.js
Normal file
80
src/tests/unit/components/InputUpload.spec.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import { test, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import InputUpload from '../../../components/InputUpload.vue'
|
||||
import i18n from '../config'
|
||||
describe('Template', () => {
|
||||
describe('Props', () => {
|
||||
test('should have default props', () => {
|
||||
const wrapper = shallowMount(InputUpload, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
expect(wrapper.vm.text).toBe(null)
|
||||
expect(wrapper.vm.textPictureType).toBe(null)
|
||||
expect(wrapper.vm.textSecondPart).toBe(null)
|
||||
expect(wrapper.vm.accept).toBe('')
|
||||
})
|
||||
test('should have all the props filled', () => {
|
||||
const wrapper = shallowMount(InputUpload, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
},
|
||||
props: {
|
||||
text: 'my text',
|
||||
textPictureType: 'my textPictureType',
|
||||
textSecondPart: 'my textSecondPart',
|
||||
accept: 'accept'
|
||||
}
|
||||
})
|
||||
expect(wrapper.html()).contains('accept="accept"')
|
||||
expect(wrapper.html()).contains('my text')
|
||||
expect(wrapper.html()).contains('my textSecondPart')
|
||||
expect(wrapper.html()).contains('my textPictureType')
|
||||
})
|
||||
})
|
||||
describe('When the input is dragover', () => {
|
||||
test('should set the component dragging state', async () => {
|
||||
const wrapper = shallowMount(InputUpload, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
await wrapper.find('label').trigger('dragover')
|
||||
expect(wrapper.vm.isDragging).toBe(true)
|
||||
expect(wrapper.html()).contains('class="file-upload dragging"')
|
||||
})
|
||||
})
|
||||
describe('When the input is dragleave', () => {
|
||||
test('should set the component dragging state', async () => {
|
||||
const wrapper = shallowMount(InputUpload, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
await wrapper.find('label').trigger('dragover')
|
||||
await wrapper.find('label').trigger('dragleave')
|
||||
|
||||
expect(wrapper.vm.isDragging).toBe(false)
|
||||
expect(wrapper.html()).contains('class="file-upload"')
|
||||
})
|
||||
})
|
||||
describe('When the input is dropped', () => {
|
||||
test('should emit with value', async () => {
|
||||
const wrapper = shallowMount(InputUpload, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
const dataTransfer = {
|
||||
files: [{ type: 'image/jpeg' }]
|
||||
}
|
||||
const label = await wrapper.find('label')
|
||||
await label.trigger('drop', { dataTransfer })
|
||||
|
||||
expect(wrapper.emitted()).toHaveProperty('trigger')
|
||||
expect(wrapper.emitted().trigger[0][0]).toEqual(dataTransfer.files)
|
||||
})
|
||||
})
|
||||
// TODO TEST -> When the input is changed should emit with value
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BetaText from '../../../components/InstanceName.vue'
|
||||
import InstanceName from '../../../components/InstanceName.vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import fr from '../../../locales/fr.json'
|
||||
|
||||
@@ -16,7 +16,7 @@ const i18n = createI18n({
|
||||
|
||||
describe('Template', () => {
|
||||
it('should render the component with good wording keys', async () => {
|
||||
const wrapper = shallowMount(BetaText, {
|
||||
const wrapper = shallowMount(InstanceName, {
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
mocks: {
|
||||
51
src/tests/unit/components/Modal.spec.js
Normal file
51
src/tests/unit/components/Modal.spec.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import Modal from '../../../components/Modal.vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import fr from '../../../locales/fr.json'
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'fr',
|
||||
fallbackLocale: 'fr',
|
||||
globalInjection: true,
|
||||
legacy: false,
|
||||
messages: {
|
||||
fr
|
||||
}
|
||||
})
|
||||
|
||||
describe('Template', () => {
|
||||
describe('Props', () => {
|
||||
it('should render the default props', async () => {
|
||||
document.body.innerHTML = '<div id="bs-modal"></div>'
|
||||
const wrapper = shallowMount(Modal, {
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
mocks: {
|
||||
$t: (msg) => msg
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(wrapper.vm.uploadErrors).toEqual([])
|
||||
})
|
||||
it('should render the props filled', async () => {
|
||||
document.body.innerHTML = '<div id="bs-modal"></div>'
|
||||
const uploadErrors = [{ message: 'my message', name: 'my name' }]
|
||||
const wrapper = shallowMount(Modal, {
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
mocks: {
|
||||
$t: (msg) => msg
|
||||
}
|
||||
},
|
||||
props: {
|
||||
uploadErrors
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.vm.uploadErrors).toEqual(uploadErrors)
|
||||
expect(wrapper.html()).contains('my name - ')
|
||||
expect(wrapper.html()).contains('my message')
|
||||
})
|
||||
})
|
||||
})
|
||||
36
src/tests/unit/components/share-pictures/Card.spec.js
Normal file
36
src/tests/unit/components/share-pictures/Card.spec.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { test, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import Card from '../../../../components/share-pictures/Card.vue'
|
||||
import i18n from '../../config'
|
||||
describe('Template', () => {
|
||||
describe('Props', () => {
|
||||
test('should have default props', () => {
|
||||
const wrapper = shallowMount(Card, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
}
|
||||
})
|
||||
expect(wrapper.vm.title).toBe(null)
|
||||
expect(wrapper.vm.description).toBe(null)
|
||||
expect(wrapper.vm.imgSrc).toBe(null)
|
||||
expect(wrapper.vm.imgAlt).toBe(null)
|
||||
})
|
||||
test('should have all the props filled', () => {
|
||||
const wrapper = shallowMount(Card, {
|
||||
global: {
|
||||
plugins: [i18n]
|
||||
},
|
||||
props: {
|
||||
title: 'my title',
|
||||
description: 'my description',
|
||||
imgSrc: 'my-imgSrc.jpg',
|
||||
imgAlt: 'my imgAlt'
|
||||
}
|
||||
})
|
||||
expect(wrapper.html()).contains('my title</h2>')
|
||||
expect(wrapper.html()).contains('my description</p>')
|
||||
expect(wrapper.html()).contains('/my-imgSrc.jpg')
|
||||
expect(wrapper.html()).contains('alt="my imgAlt"')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -10,7 +10,7 @@
|
||||
import { ref } from 'vue'
|
||||
import Viewer from '@/components/Viewer.vue'
|
||||
const emit = defineEmits<{ (e: 'trigger', value: string): void }>()
|
||||
const viewerRef = ref<any>(null)
|
||||
const viewerRef = ref<unknown>(null)
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.entry-page {
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
<main class="entry-page">
|
||||
<section class="section-viewer">
|
||||
<Viewer
|
||||
v-if="collectionBbox.length"
|
||||
:fetch-options="{
|
||||
fetchOptions: {
|
||||
credentials: 'include'
|
||||
}
|
||||
}"
|
||||
:sequence-id="seqId"
|
||||
:geovisio-viewer="false"
|
||||
:user-id="getUserId"
|
||||
:bbox="collectionBbox"
|
||||
ref="viewerRef"
|
||||
/>
|
||||
</section>
|
||||
<section class="section-sequence">
|
||||
<h1 class="sequences-title">{{ $t('pages.sequences.title') }}</h1>
|
||||
<ul v-if="!isLoading" class="sequence-list">
|
||||
<li class="sequence-item">
|
||||
<li class="sequence-item sequence-item-head">
|
||||
<div class="sequence-header-item"></div>
|
||||
<div class="sequence-header-item">
|
||||
<Button
|
||||
@@ -67,18 +69,19 @@
|
||||
v-if="userSequences.length"
|
||||
v-for="(item, i) in userSequences"
|
||||
:id="`el-list${i}`"
|
||||
class="sequence-item"
|
||||
:class="[
|
||||
'sequence-item',
|
||||
item.id === seqId ? 'button-item-hover' : ''
|
||||
]"
|
||||
@mouseover="goToSequence(item)"
|
||||
>
|
||||
<router-link
|
||||
:class="[
|
||||
'button-item',
|
||||
item.id === seqId ? 'button-item-hover' : ''
|
||||
]"
|
||||
class="button-item"
|
||||
:to="{
|
||||
name: 'sequence',
|
||||
params: { id: item.id }
|
||||
}"
|
||||
@mouseover.stop
|
||||
>
|
||||
<div class="wrapper-thumb">
|
||||
<img
|
||||
@@ -156,6 +159,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useSequenceStore } from '@/store/sequence'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { scrollIntoSelected } from '@/views/utils/sequence/index'
|
||||
import { useCookies } from 'vue3-cookies'
|
||||
import axios from 'axios'
|
||||
import Viewer from '@/components/Viewer.vue'
|
||||
import Button from '@/components/Button.vue'
|
||||
@@ -168,6 +172,7 @@ import type {
|
||||
} from './interfaces/MySequencesView'
|
||||
import { formatDate } from '@/utils/dates'
|
||||
const { t } = useI18n()
|
||||
const { cookies } = useCookies()
|
||||
const sequenceStore = useSequenceStore()
|
||||
const { toastText, toastLook } = storeToRefs(sequenceStore)
|
||||
|
||||
@@ -226,14 +231,13 @@ function goToSequence(sequence: SequenceLinkInterface) {
|
||||
function getRelChild(sequences: SequenceLinkInterface[]) {
|
||||
return sequences.filter((el: SequenceLinkInterface) => el.rel === 'child')
|
||||
}
|
||||
|
||||
const getUserId = computed<string>(() => cookies.get('user_id'))
|
||||
onMounted(async () => {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const { data } = await axios.get('api/users/me/catalog')
|
||||
const collectionData = await axios.get('api/users/me/collection')
|
||||
collectionBbox.value = collectionData.data.extent.spatial.bbox[0]
|
||||
viewerRef.value.viewer.fitBounds(collectionBbox.value)
|
||||
const sequences = getRelChild(data.links)
|
||||
const sequencesCollection = getRelChild(collectionData.data.links)
|
||||
sequencesCollection.map((el: SequenceLinkInterface) => {
|
||||
@@ -256,6 +260,7 @@ watchEffect(() => {
|
||||
(e: { detail: { seqId: string } }) => {
|
||||
seqId.value = e.detail.seqId
|
||||
scrollIntoSelected(e.detail.seqId, userSequences.value)
|
||||
viewerRef.value.viewer.select(e.detail.seqId)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -295,6 +300,7 @@ watchEffect(() => {
|
||||
justify-content: center;
|
||||
margin: auto;
|
||||
background-color: var(--blue-pale);
|
||||
padding: toRem(2);
|
||||
&:first-child {
|
||||
margin-bottom: toRem(1);
|
||||
padding: toRem(1) toRem(2);
|
||||
@@ -306,6 +312,22 @@ watchEffect(() => {
|
||||
background-color: var(--white);
|
||||
}
|
||||
}
|
||||
.button-item-hover {
|
||||
background-color: var(--blue);
|
||||
&:nth-child(2n) {
|
||||
background-color: var(--blue);
|
||||
}
|
||||
.button-item {
|
||||
& > *,
|
||||
& > :nth-child(2) {
|
||||
color: var(--white);
|
||||
}
|
||||
}
|
||||
}
|
||||
.sequence-item-head:hover {
|
||||
background-color: initial;
|
||||
color: initial;
|
||||
}
|
||||
.wrapper-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -350,7 +372,6 @@ watchEffect(() => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: toRem(2);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
text-decoration: none;
|
||||
@@ -374,19 +395,6 @@ watchEffect(() => {
|
||||
& > :nth-child(2) {
|
||||
color: var(--blue-dark);
|
||||
}
|
||||
&:hover {
|
||||
background-color: var(--blue);
|
||||
& > * {
|
||||
color: var(--white);
|
||||
}
|
||||
}
|
||||
}
|
||||
.button-item-hover {
|
||||
background-color: var(--blue);
|
||||
& > *,
|
||||
& > :nth-child(2) {
|
||||
color: var(--white);
|
||||
}
|
||||
}
|
||||
.bi-images {
|
||||
margin-right: toRem(0.5);
|
||||
|
||||
@@ -247,6 +247,9 @@ h3 {
|
||||
padding: toRem(2) toRem(5) toRem(5);
|
||||
color: var(--grey-dark);
|
||||
}
|
||||
.logged {
|
||||
height: calc(100vh - #{toRem(8)});
|
||||
}
|
||||
.section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
export interface OptionalViewerInterface {
|
||||
export interface MapInterface {
|
||||
startWide?: boolean
|
||||
maxZoom?: number
|
||||
minZoom?: number
|
||||
style?: object | string
|
||||
zoom?: number
|
||||
center?: number[]
|
||||
bounds?: number[]
|
||||
}
|
||||
|
||||
export interface ViewerInterface {
|
||||
fetchOptions?: {
|
||||
credentials: string
|
||||
}
|
||||
hash?: boolean
|
||||
picId?: string
|
||||
widgets?: {
|
||||
customWidget: HTMLAnchorElement
|
||||
}
|
||||
}
|
||||
|
||||
export interface ViewerInterface extends OptionalViewerInterface {
|
||||
map: {
|
||||
startWide: boolean
|
||||
style?: object | string
|
||||
maxZoom?: number
|
||||
zoom?: number
|
||||
center?: number[]
|
||||
}
|
||||
bounds?: number[]
|
||||
map: MapInterface
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
import axios from 'axios'
|
||||
|
||||
function createASequence(title: string): Promise<any> {
|
||||
interface SequenceCreatedInterface {
|
||||
data: {
|
||||
created: string
|
||||
description: string
|
||||
extent: { spatial: object; temporal: object }
|
||||
['geovisio:status']: string
|
||||
id: string
|
||||
keywords: string[]
|
||||
license: string
|
||||
links: object[]
|
||||
providers: object[]
|
||||
stac_extensions: string[]
|
||||
stac_version: string
|
||||
['stats:items']: { count: number }
|
||||
title: string
|
||||
type: string
|
||||
}
|
||||
}
|
||||
|
||||
function createASequence(title: string): Promise<SequenceCreatedInterface> {
|
||||
return axios.post('api/collections', { title: title })
|
||||
}
|
||||
|
||||
|
||||
@@ -3164,10 +3164,10 @@ geojson-vt@^3.2.1:
|
||||
resolved "https://registry.yarnpkg.com/geojson-vt/-/geojson-vt-3.2.1.tgz#f8adb614d2c1d3f6ee7c4265cad4bbf3ad60c8b7"
|
||||
integrity sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg==
|
||||
|
||||
geovisio@2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/geovisio/-/geovisio-2.2.0.tgz#8d67bf4e3fe04699d16d76bfcc0c5ee3e10e88f1"
|
||||
integrity sha512-EGUvDNW4gyYdBSszU8fqgpQHWxeSS04pdSUK0oWvBLV24Fl0PYtDOI6uoUAa/69B1kQbGs5qp4wNCyzll7hIrg==
|
||||
geovisio@2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/geovisio/-/geovisio-2.2.1.tgz#75ded2d10ca0c69464b5c734c0c2b3eeff8db8eb"
|
||||
integrity sha512-E2s6dCXmMSRbtmZ7c4bMCDhgqT5xaKpGZxmbXMfB7+VgLQugiaIyRPKTB5Xtvw3f08FS7mC42WNqZqN5sFitKg==
|
||||
dependencies:
|
||||
"@fortawesome/fontawesome-svg-core" "^6.4.0"
|
||||
"@fortawesome/free-solid-svg-icons" "^6.4.0"
|
||||
|
||||
Reference in New Issue
Block a user