Skip to content
Snippets Groups Projects
Commit beeeb7cb authored by gltron's avatar gltron
Browse files

Added search filters & model page

parent 00606767
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ export default { ...@@ -20,7 +20,6 @@ export default {
font-family: Avenir, Helvetica, Arial, sans-serif; font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50; color: #2c3e50;
} }
</style> </style>
<template> <template>
<b-menu> <b-menu>
<div> <div>
<b-menu-list v-for="tag in tags" v-bind:key="tag.name"> <b-menu-list label="Performance">
<b-slider lazy></b-slider>
</b-menu-list>
<b-menu-list v-for="tag in tags" v-bind:key="tag.name" :label="tag.name">
<div v-for="type in tag.types" v-bind:key="type" class="field"> <div v-for="type in tag.types" v-bind:key="type" class="field">
<b-checkbox>{{type}}</b-checkbox> <b-checkbox
:native-value="type"
v-model="checkboxGroup"
@input="changeTag">{{type}}</b-checkbox>
</div> </div>
</b-menu-list> </b-menu-list>
</div> </div>
...@@ -13,10 +19,22 @@ ...@@ -13,10 +19,22 @@
<script> <script>
export default { export default {
name: 'Filters', name: 'Filters',
props: ['tags'] props: ['tags'],
data () {
return {
checkboxGroup: []
}
},
methods: {
changeTag () {
this.$emit('setTags', this.checkboxGroup)
}
}
} }
</script> </script>
<style> <style scoped>
.menu {
margin: 15px;
}
</style> </style>
<template> <template>
<div class="box"> <a class="box" v-on:click="onClick">
<article class="media"> <article class="media">
<figure></figure> <figure></figure>
</article> </article>
...@@ -13,20 +13,27 @@ ...@@ -13,20 +13,27 @@
{{model.shortDescription}} {{model.shortDescription}}
</p> </p>
<b-taglist> <b-taglist>
<b-tag v-for="tag in model.tags" v-bind:key="tag.name" type="is-info">{{tag.type}}</b-tag> <b-tag v-for="tag in model.tags" v-bind:key="tag.type" type="is-info">{{tag.type}}</b-tag>
</b-taglist> </b-taglist>
</div> </div>
</div> </div>
</div> </a>
</template> </template>
<script> <script>
export default { export default {
name: 'ModelCard', name: 'ModelCard',
props: ['model'] props: ['model'],
methods: {
onClick () {
this.$router.push({ name: 'Model', params: { model: this.model } })
}
}
} }
</script> </script>
<style> <style>
.box {
margin-bottom: 10px;
}
</style> </style>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
type="search" type="search"
icon="magnify" icon="magnify"
v-model="search" v-model="search"
v-on:keyup.enter="onSearch" v-on:keyup.enter.native="onSearch"
> >
</b-input> </b-input>
</b-field> </b-field>
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
}, },
methods: { methods: {
onSearch () { onSearch () {
this.$router.push({ name: 'Search', query: { n: this.search } })
} }
} }
} }
......
...@@ -24,6 +24,12 @@ const routes = [ ...@@ -24,6 +24,12 @@ const routes = [
path: '/search', path: '/search',
name: 'Search', name: 'Search',
component: () => import('../views/Search.vue') component: () => import('../views/Search.vue')
},
{
path: '/model',
name: 'Model',
component: () => import('../views/Model.vue'),
props: true
} }
] ]
......
...@@ -19,6 +19,7 @@ export default { ...@@ -19,6 +19,7 @@ export default {
.home { .home {
padding-top: 50px; padding-top: 50px;
text-align: center;
} }
</style> </style>
<template>
<div class="model container">
<div class="title">
{{model.name}}
</div>
<div class="content">
<p>
<strong></strong>
<br>
<small>{{model.author}}</small> - <small>{{model.modificationDate}}</small>
<br>
{{model.shortDescription}}
</p>
<hr>
<b-taglist>
<b-tag v-for="tag in model.tags" v-bind:key="tag.type" type="is-info">{{tag.type}}</b-tag>
</b-taglist>
<hr>
{{model.longDescription}}
</div>
</div>
</template>
<script>
export default {
name: 'Model',
props: ['model']
}
</script>
<style>
</style>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="search container"> <div class="search container">
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<Filters v-bind:tags="tags"/> <Filters v-bind:tags="tags" v-on:setTags="getModels"/>
</div> </div>
<div v-if="models" class="column is-four-fifths"> <div v-if="models" class="column is-four-fifths">
<div v-for="model in models" v-bind:key="model.name"> <div v-for="model in models" v-bind:key="model.name">
...@@ -31,6 +31,10 @@ export default { ...@@ -31,6 +31,10 @@ export default {
return { return {
tags: '', tags: '',
models: true, models: true,
paramTags: '',
paramSearch: '',
resultSize: 10,
page: 1,
isLoading: true isLoading: true
} }
}, },
...@@ -40,6 +44,14 @@ export default { ...@@ -40,6 +44,14 @@ export default {
this.isLoading = false this.isLoading = false
}, },
methods: { methods: {
setParams (tags) {
const searchParam = this.$route.query.n
var tagsParam
if (tags) tagsParam = tags
else tagsParam = this.$route.query.t
this.$router.push({ name: 'Search', query: { n: searchParam, t: tagsParam } })
},
async getTags () { async getTags () {
const url = this.$serverurl + 'tags' const url = this.$serverurl + 'tags'
const response = await fetch(url) const response = await fetch(url)
...@@ -49,8 +61,22 @@ export default { ...@@ -49,8 +61,22 @@ export default {
return null return null
} }
}, },
async getModels () { async getModels (tags) {
const url = this.$serverurl + 'search' this.setParams(tags)
const url = new URL(this.$serverurl + 'search')
const params = new URLSearchParams()
const nameParam = this.$route.query.n
var tagsParam = this.$route.query.t
if (nameParam) params.append('n', nameParam)
if (tagsParam) params.append('t', tagsParam)
params.append('size', this.resultSize)
params.append('page', this.page)
console.log('get models ' + nameParam + ' + ' + tags)
url.search = params
const response = await fetch(url) const response = await fetch(url)
try { try {
return await response.json() return await response.json()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment