Skip to content
Snippets Groups Projects
Commit 94f78063 authored by thomas.blanc.2@etu.univ-amu.fr's avatar thomas.blanc.2@etu.univ-amu.fr
Browse files

Added verified support

parent 33dac6c6
No related branches found
No related tags found
No related merge requests found
......@@ -288,5 +288,19 @@ export const api = {
} catch (error) {
return null
}
},
async setVerified (id) {
const url = serverurl + 'models/setVerified' + '?id=' + id
const token = await localStorage.getItem('token')
const response = await fetch(url, {
headers: {
Authorization: 'Bearer ' + token
}
})
try {
return await response.json()
} catch (error) {
return null
}
}
}
<template>
<b-menu>
<div>
<b-menu-list label="Verified">
<b-checkbox v-model="verifiedOnly" @input="changeTag">Verified models only</b-checkbox>
</b-menu-list>
<b-menu-list v-for="category in tags" v-bind:key="category.name" :label="category.name">
<div v-for="tag in category.tags" v-bind:key="tag.name" class="field">
<b-field v-for="tag in category.tags" v-bind:key="tag.name">
<b-checkbox
:native-value="tag.name"
v-model="checkboxGroup"
@input="changeTag">{{tag.name}}</b-checkbox>
</div>
</b-field>
</b-menu-list>
</div>
</b-menu>
......@@ -20,20 +23,12 @@ export default {
data () {
return {
checkboxGroup: [],
perfValue: 0
verifiedOnly: false
}
},
methods: {
changeTag () {
this.$emit('setTags', this.checkboxGroup, this.convertPerf())
},
convertPerf () {
switch (this.perfValue) {
case 0 : return 10
case 1 : return 100
case 2 : return 1000
case 3 : return 10000
}
this.$emit('setTags', this.checkboxGroup, this.verifiedOnly)
}
}
}
......
......@@ -5,7 +5,7 @@
<div class="media-content">
<div class="content">
<p>
<strong>{{model.name}}</strong>
<strong>{{model.name}}</strong> <b-icon v-if="model.isVerified" type="is-success" icon="check"/>
<br>
<small>{{model.author.username}}</small> - <small>{{new Date(model.lastModified).toLocaleDateString()}}</small>
<br>
......
......@@ -2,7 +2,7 @@
<b-table :data="models" :loading="isLoading" striped hoverable>
<template slot-scope="props">
<b-table-column field="name" label="Model name" searchable sortable>
{{ props.row.name }}
{{ props.row.name }} <b-icon v-if="props.row.isVerified" icon="check"/>
</b-table-column>
<b-table-column field="vote" label="Votes" sortable>
......
......@@ -10,20 +10,26 @@
{{ props.row.name }}
</b-table-column>
<b-table-column field="verified" label="Verified status" sortable>
<b-icon v-if="props.row.isVerified" icon="check"/>
<b-icon v-else icon="close"/>
</b-table-column>
<b-table-column field="vote" label="Votes" sortable>
{{ props.row.votes }}
</b-table-column>
<b-table-column field="date" label="Last modification" centered sortable>
{{ new Date(props.row.modificationDate).toLocaleDateString() }}
{{ new Date(props.row.lastModified).toLocaleDateString() }}
</b-table-column>
<b-table-column field="date" label="Added" centered sortable>
{{ new Date(props.row.addedDate).toLocaleDateString() }}
{{ new Date(props.row.added).toLocaleDateString() }}
</b-table-column>
<b-table-column label="" centered>
<b-button class="actionButton" icon-left="eye" type="is-info" tag="router-link" :to="{ name: 'Model', query: { id: props.row.id } }" outlined/>
<b-button class="actionButton" icon-left="check" type="is-success" @click="setVerifiedPrompt(props.row.id, props.row.name)" outlined/>
<b-button class="actionButton" icon-left="delete" type="is-danger" @click="removePrompt(props.row.id, props.row.name, 'model')" outlined/>
</b-table-column>
</template>
......@@ -136,11 +142,11 @@ export default {
hasIcon: true,
onConfirm: async () => {
switch (mode) {
case 'user' : api.removeUser(id); break
case 'model' : api.removeModel(id); break
case 'tag' : api.removeTag(id); break
case 'category' : api.removeCategory(id); break
case 'comment' : api.removeComment(id); break
case 'user' : await api.removeUser(id); break
case 'model' : await api.removeModel(id); break
case 'tag' : await api.removeTag(id); break
case 'category' : await api.removeCategory(id); break
case 'comment' : await api.removeComment(id); break
}
this.$buefy.toast.open(name + ' deleted')
this.modelList = await api.getModelList()
......@@ -175,6 +181,20 @@ export default {
this.tagList = await api.getTags()
}
})
},
setVerifiedPrompt (id, name) {
this.$buefy.dialog.confirm({
message: 'Set verified status for ' + name + ' ?',
cancelText: 'Abort',
confirmText: 'Set',
type: 'is-success',
hasIcon: true,
onConfirm: async () => {
await api.setVerified(id)
this.$buefy.toast.open(name + ' verified status has been changed')
this.modelList = await api.getModelList()
}
})
}
}
}
......
......@@ -7,7 +7,7 @@
<div v-else>
<div class="columns box">
<div class="column is-two-thirds">
<h1 class="title is-1">{{model.name}}</h1>
<h1 class="title is-1">{{model.name}} <b-tag v-if="model.isVerified" type="is-success" size="is-large">Verified</b-tag></h1>
<h2 class="subtitle">{{model.shortDescription}}</h2>
<b-taglist>
<b-tag v-for="tag in model.tags" v-bind:key="tag.name" type="is-info">{{tag.name}}</b-tag>
......
......@@ -54,6 +54,7 @@ export default {
paramTags: '',
paramSearch: '',
paramOrder: '',
paramVerified: false,
resultSize: 10,
page: 1,
isLoading: true
......@@ -78,9 +79,9 @@ export default {
this.paramOrder = order
this.result = await api.search(this.paramSearch, this.paramTags, null, this.paramOrder, this.resultSize, this.page)
},
async setTags (tags, perfValue) {
async setTags (tags, verifiedOnly) {
this.paramTags = tags
this.paramPerf = perfValue
this.paramVerified = verifiedOnly
this.result = await api.search(this.paramSearch, this.paramTags, null, this.paramOrder, this.resultSize, this.page)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment