branch bow-v2-go updated (38b4e52 -> 0017d99)
This is an automated email from the git hooks/post-receive script. New change to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git from 38b4e52 introduction de vuex pour avoir un etat partage sur la recherche en cours ajout nuage de tags ajout indication de navigation new e67e1d3 amelioration de la reponse json en mettant toutes les infos dans un objet 'info' new f9dc98c les tags sont maintenant des tableaux (et pas des string spliter si besoin) new 0017d99 Navigation fonctionnel (par tag ou offset) The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0017d992d26a52cdc6e5b7112938b62d2ec3a4a4 Author: Benjamin <poussin@codelutin.com> Date: Fri May 22 03:45:03 2020 +0200 Navigation fonctionnel (par tag ou offset) commit f9dc98cb8181dae0d7a2c57f9e9dc073d4cb998a Author: Benjamin <poussin@codelutin.com> Date: Thu May 21 00:32:07 2020 +0200 les tags sont maintenant des tableaux (et pas des string spliter si besoin) commit e67e1d35bf6b8672ec9a9b8ec68e5306e735ccc2 Author: Benjamin <poussin@codelutin.com> Date: Wed May 20 22:56:37 2020 +0200 amelioration de la reponse json en mettant toutes les infos dans un objet 'info' Summary of changes: pkg/http/bookmarkResource.go | 4 +- pkg/repository/bookmarkRepository.go | 27 +++++------ web/src/App.vue | 10 +++- web/src/components/CloudTags.vue | 75 +++++++++++++++--------------- web/src/components/SearchInput.vue | 66 ++++++++++++++++---------- web/src/components/bookmark/Tags.vue | 9 +--- web/src/components/layout/Header.vue | 24 +--------- web/src/components/layout/Sidebar.vue | 8 ---- web/src/main.js | 87 +++++++++++++++++++++++++++++++++++ web/src/store/index.js | 17 ++++--- web/src/views/Home.vue | 38 +++++++++------ web/src/views/Login.vue | 2 +- 12 files changed, 225 insertions(+), 142 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit e67e1d35bf6b8672ec9a9b8ec68e5306e735ccc2 Author: Benjamin <poussin@codelutin.com> Date: Wed May 20 22:56:37 2020 +0200 amelioration de la reponse json en mettant toutes les infos dans un objet 'info' --- pkg/repository/bookmarkRepository.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 8e1db09..978e8e5 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -47,22 +47,19 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags string, q := &query{sql: `WITH __all AS (select * from bookmark where uri=$1) SELECT json_agg(__all.*) as j FROM __all`} result, err = q.QueryString(currentUser, uri) } else { - tagsJSON := "{" + strings.Join(strings.Fields(tags), ",") + "}" + tagsJoined := strings.Join(strings.Fields(tags), ",") q := &query{sql: fmt.Sprintf(`WITH - __query AS (select * from bookmark where tags @> $1::text[]), - __orderby AS (select '%[1]s' as orderby), - __orderdesc AS (select to_json('%[2]s' = 'desc') as orderdesc), - __first AS (select %[3]d as first), - __limit AS (select %[4]d as limit), - __total AS (select count(id) as total from __query), + __query AS (select * from bookmark where tags @> string_to_array($1, ',')), + __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'desc') as orderdesc, $2::TEXT as tags, $3::TEXT as fulltext from __query), + __infoJson AS (select row_to_json(i.*) as info from __info i), __allTags AS (select unnest(tags) as tag from __query), __tags AS (select tag, count(tag) from __allTags group by tag order by 2 desc), __jsonTags AS (select ('[' || json_agg(a.tag) || ', ' || json_agg(a.count) || ']')::json as tags from __tags a), __result AS (select * from __query order by %[1]s %[2]s OFFSET %[3]d LIMIT %[4]d), __jsonResult AS (SELECT json_agg(r.*) as result FROM __result r) - select row_to_json(v) from (select * from __first, __limit, __total, __orderby, __orderdesc, __jsonTags, __jsonResult) v; + select row_to_json(v) from (select * from __infoJson, __jsonTags, __jsonResult) v; `, orderBy, orderDirection, first, maxResult)} - result, err = q.QueryString(currentUser, tagsJSON) + result, err = q.QueryString(currentUser, tagsJoined, tags, fulltext) } if err != nil { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit f9dc98cb8181dae0d7a2c57f9e9dc073d4cb998a Author: Benjamin <poussin@codelutin.com> Date: Thu May 21 00:32:07 2020 +0200 les tags sont maintenant des tableaux (et pas des string spliter si besoin) --- pkg/http/bookmarkResource.go | 4 +-- pkg/repository/bookmarkRepository.go | 18 +++++----- web/src/components/SearchInput.vue | 66 ++++++++++++++++++++++-------------- web/src/views/Home.vue | 34 ++++++++++++------- 4 files changed, 73 insertions(+), 49 deletions(-) diff --git a/pkg/http/bookmarkResource.go b/pkg/http/bookmarkResource.go index 05737cb..3ce52a8 100644 --- a/pkg/http/bookmarkResource.go +++ b/pkg/http/bookmarkResource.go @@ -20,7 +20,7 @@ func getBookmarks(w http.ResponseWriter, r *http.Request) { queryParams := r.URL.Query() id := queryParams.Get(constant.ID) uri := queryParams.Get(constant.URI) - tags := queryParams.Get(constant.Tags) + tags := queryParams[constant.Tags] fulltext := queryParams.Get(constant.Fulltext) log.Println("query: ", queryParams) @@ -53,7 +53,7 @@ func getBookmark(w http.ResponseWriter, r *http.Request) { currentUser := r.Context().Value(constant.User).(model.BowUser) id := mux.Vars(r)["id"] - json, err := repository.BookmarkJSON(currentUser, id, "", "", "", "", false, 0) + json, err := repository.BookmarkJSON(currentUser, id, "", []string{}, "", "", false, 0) if err != nil { utils.Throw(w, err) return diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 978e8e5..0782cfc 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -19,7 +19,7 @@ si id est non vide alors fait une recherche exact sur l'id si uri est non vide alors fait une recherche exact sur l'uri sinon fait une recherche sur les critères: tags, fulltext */ -func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags string, fulltext string, orderBy string, orderDesc bool, first int) (string, error) { +func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []string, fulltext string, orderBy string, orderDesc bool, first int) (string, error) { var result string var err error @@ -47,10 +47,10 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags string, q := &query{sql: `WITH __all AS (select * from bookmark where uri=$1) SELECT json_agg(__all.*) as j FROM __all`} result, err = q.QueryString(currentUser, uri) } else { - tagsJoined := strings.Join(strings.Fields(tags), ",") + tagsJoined := strings.Join(tags, ",") q := &query{sql: fmt.Sprintf(`WITH __query AS (select * from bookmark where tags @> string_to_array($1, ',')), - __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'desc') as orderdesc, $2::TEXT as tags, $3::TEXT as fulltext from __query), + __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'desc') as orderdesc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), __infoJson AS (select row_to_json(i.*) as info from __info i), __allTags AS (select unnest(tags) as tag from __query), __tags AS (select tag, count(tag) from __allTags group by tag order by 2 desc), @@ -59,7 +59,7 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags string, __jsonResult AS (SELECT json_agg(r.*) as result FROM __result r) select row_to_json(v) from (select * from __infoJson, __jsonTags, __jsonResult) v; `, orderBy, orderDirection, first, maxResult)} - result, err = q.QueryString(currentUser, tagsJoined, tags, fulltext) + result, err = q.QueryString(currentUser, tagsJoined, fulltext) } if err != nil { @@ -73,17 +73,17 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags string, RenameTag renomme ou supprime un tag si newName est vide */ func RenameTag(currentUser model.BowUser, oldName string, newName string) (int64, error) { - tagArray := "{" + oldName + "}" + // tagArray := "{" + oldName + "}" var q *query var count int64 var err error if newName == "" { - q = &query{sql: `UPDATE bookmark SET tags=array_remove(tags, $2) where tags @> $1::text[]`} - count, err = q.execOnNRow(currentUser, tagArray, oldName) + q = &query{sql: `UPDATE bookmark SET tags=array_remove(tags, $2) where tags @> ARRAY[$1]`} + count, err = q.execOnNRow(currentUser, oldName, oldName) } else { - q = &query{sql: `UPDATE bookmark SET tags=array_replace(tags, $2, $3) where tags @> $1::text[]`} - count, err = q.execOnNRow(currentUser, tagArray, oldName, newName) + q = &query{sql: `UPDATE bookmark SET tags=array_replace(tags, $2, $3) where tags @> ARRAY[$1]`} + count, err = q.execOnNRow(currentUser, oldName, oldName, newName) } if err != nil { return 0, utils.NewHTTPError500(err, currentUser) diff --git a/web/src/components/SearchInput.vue b/web/src/components/SearchInput.vue index 775fee5..a1c559b 100644 --- a/web/src/components/SearchInput.vue +++ b/web/src/components/SearchInput.vue @@ -1,39 +1,33 @@ <template> <div class="search"> <form @submit.prevent="search"> - <div> + <label> tags: - <input type="text" v-model="mTags" @keyup.enter="search" /> - </div> - <div> + <TagsInput id="tags" :selected="mTags" :noCreation="true" @keyup.enter="search"></TagsInput> + </label> + <label> fulltext: <input type="text" v-model="mFulltext" @keyup.enter="search" /> - </div> + </label> </form> <form @submit.prevent="action"> - <div> + <label> web: <input type="text" v-model="mQuery" @keyup.enter="action" /> - </div> + </label> </form> </div> </template> <script> import { Component, Vue, Watch } from 'vue-property-decorator' +import TagsInput from '@/components/common/TagsInput' @Component({ name: 'SearchInput', - components: {} + components: { TagsInput } }) class SearchInput extends Vue { - tags = '' - fulltext = '' - query = '' - orderby = 'creationdate' - orderdesc = false - first = 0 - mTags = '' mFulltext = '' mQuery = '' @@ -67,6 +61,7 @@ class SearchInput extends Vue { this.mOrderby && (query.orderBy = this.mOrderby) this.mOrderdesc && (query.orderDesc = this.mOrderdesc) this.mFulltext && (query.first = this.mFirst) + console.log("XXXX Query", query) this.$router.push({ name: 'Home', query }) } } @@ -75,15 +70,37 @@ class SearchInput extends Vue { console.log('search', this.mQuery) } + get tags() { + const tags = this.$route.query.tags + if (!tags) { + return [] + } + + return Array.isArray(tags) ? [...tags] : [tags] + } + + get fulltext() { + return this.$route.query.fulltext + } + + get query() { + return this.$route.query.query + } + + get orderby() { + return this.$route.query.orderby || 'creationdate' + } + + get orderdesc() { + return this.$route.query.orderdesc || false + } + + get first() { + return this.$route.query.first || 0 + } + update(route) { - this.tags = route.query.tags - this.fulltext = route.query.fulltext - this.query = route.query.query - this.orderby = route.query.orderby - this.orderdesc = route.query.orderdesc - this.first = route.query.first - - this.mTags = this.tags || '' + this.mTags = this.tags this.mFulltext = this.fulltext || '' this.mQuery = this.query || '' this.mOrderby = this.orderby || '' @@ -96,7 +113,6 @@ class SearchInput extends Vue { console.log('onRouteChange SearchInput', to, from) this.update(to) } - } export default SearchInput @@ -116,4 +132,4 @@ form { input { width: 100px; } -</style> \ No newline at end of file +</style> diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index a6008e9..541995e 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -3,16 +3,15 @@ <div>{{ errorMsg }}</div> <CloudTags></CloudTags> <div class="navigation"> - <button><<</button> <button><</button> - {{ 1 + queryResponse.first }}-{{ queryResponse.first + queryResponse.limit }} - <button>></button> <button>>></button> / {{ queryResponse.total }} + <button><<</button> + <button><</button> + {{ 1 + queryResponse.info.first }}-{{ queryResponse.info.first + queryResponse.info.limit }} + <button>></button> + <button>>></button> + / {{ queryResponse.info.total }} </div> <div class="bookmarks-list"> - <Bookmark - v-for="bookmark in bookmarks" - :key="bookmark.id" - :bookmark="bookmark" - ></Bookmark> + <Bookmark v-for="bookmark in bookmarks" :key="bookmark.id" :bookmark="bookmark"></Bookmark> </div> </div> </template> @@ -37,7 +36,7 @@ class Home extends Vue { @Prop orderdesc @Prop first - mTags = this.tags || '' + mTags = this.forceArrayTags(this.tags) mFulltext = this.fulltext || '' mQuery = this.query || '' mOrderby = this.orderby || '' @@ -45,15 +44,24 @@ class Home extends Vue { mFirst = this.first || 0 errorMsg = '' - queryResponse = {} + queryResponse = {info:{}, tags:{}, result: {}} + get bookmarks() { return this.queryResponse.result } + forceArrayTags(tags) { + if (!tags) { + return [] + } + + return Array.isArray(tags) ? [...tags] : [tags] + } + fetchBookmark() { let searchParams = new URLSearchParams() this.id && searchParams.append('id', this.id) - this.mTags && searchParams.append('tags', this.mTags) + this.mTags && this.mTags.forEach((t) => searchParams.append('tags', t)) this.mFulltext && searchParams.append('fulltext', this.mFulltext) this.mQuery && searchParams.append('query', this.mQuery) this.mOrderby && searchParams.append('orderby', this.mOrderby) @@ -61,11 +69,11 @@ class Home extends Vue { this.mFirst && searchParams.append('first', this.mFirst) this.$fetch.get(`/bookmarks?${searchParams.toString()}`).then( - data => { + (data) => { this.queryResponse = data this.$store.commit('queryResponse', data) }, - err => { + (err) => { this.errorMsg = err.cause } ) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit 0017d992d26a52cdc6e5b7112938b62d2ec3a4a4 Author: Benjamin <poussin@codelutin.com> Date: Fri May 22 03:45:03 2020 +0200 Navigation fonctionnel (par tag ou offset) --- web/src/App.vue | 10 +++- web/src/components/CloudTags.vue | 75 +++++++++++++++--------------- web/src/components/bookmark/Tags.vue | 9 +--- web/src/components/layout/Header.vue | 24 +--------- web/src/components/layout/Sidebar.vue | 8 ---- web/src/main.js | 87 +++++++++++++++++++++++++++++++++++ web/src/store/index.js | 17 ++++--- web/src/views/Home.vue | 14 +++--- web/src/views/Login.vue | 2 +- 9 files changed, 154 insertions(+), 92 deletions(-) diff --git a/web/src/App.vue b/web/src/App.vue index 4b2d485..0ab65db 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -41,10 +41,16 @@ class App extends Vue { } } + reload() { + this.$store.commit('user', this.$storage.get('bow-user') || {}) + this.$store.commit('authenticated', !!this.$storage.getCookie('bow-token')) + this.insertOpenSearch() + } + beforeMount() { console.log('beforeMounted App') - this.insertOpenSearch() - this.$storage.addListener('bow-user', this.insertOpenSearch, this) + this.reload() + this.$storage.addListener('bow-user', this.reload, this) } } export default App diff --git a/web/src/components/CloudTags.vue b/web/src/components/CloudTags.vue index 8bf9d7b..9ed0d8d 100644 --- a/web/src/components/CloudTags.vue +++ b/web/src/components/CloudTags.vue @@ -1,7 +1,7 @@ <template> - <div class="cloud-tags"> - <span class="tag" v-for="(tag, i) in tags" :key="tag" :style="{fontSize: getFont(counts[i]) + 'px'}">{{ tag }}</span> - </div> + <div class="cloud-tags"> + <span class="tag" v-for="(tag, i) in tags" :key="tag" :style="{ fontSize: getFont(i) + 'px' }" @click="addTagToQuery(tag)">{{ tag }}</span> + </div> </template> <script> @@ -12,35 +12,35 @@ import { Component, Vue } from 'vue-property-decorator' components: {} }) class CloudTags extends Vue { - - get user() { - return this.$storage.get('bow-user') - } - - get tags() { - return this.$store.state.tags[0].slice(0, this.user.maxtagincloud) - } - - get counts() { - return this.$store.state.tags[1] - } - - get tmax() { - return this.counts[0] || 1 - } - - get tmin() { - return this.counts[this.counts.length - 1] || 0 + addTagToQuery(tag) { + this.addTagsAndGo([tag]) + } + + get tags() { + return this.queryTags.slice(0, this.user.maxtagincloud) + } + + get counts() { + return this.queryTagsCount + } + + get tmax() { + return this.queryTagsCount[0] || 1 + } + + get tmin() { + return this.queryTagsCount[this.queryTagsCount.length - 1] || 0 + } + + getFont(index) { + let count = this.counts[index] + let result = (30 * (count - this.tmin)) / (this.tmax - this.tmin) + if (result < 10) { + result = 10 } - getFont(count) { - let result = 30 * (count - this.tmin) / (this.tmax - this.tmin) - if (result < 10) { - result = 10 - } - - return result - } + return result + } } export default CloudTags @@ -48,12 +48,15 @@ export default CloudTags <style lang="less" scoped> .cloud-tags { - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: center; + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; } .tag { - margin: 4px; + margin: 4px; +} +.tag:hover { + color: wheat; } -</style> \ No newline at end of file +</style> diff --git a/web/src/components/bookmark/Tags.vue b/web/src/components/bookmark/Tags.vue index c3b892c..ff0b67f 100644 --- a/web/src/components/bookmark/Tags.vue +++ b/web/src/components/bookmark/Tags.vue @@ -16,14 +16,7 @@ class Tags extends Vue { @Prop tags addTag(tag) { - console.log(tag) - let tags; - if (this.$route.query.tags) { - tags = this.$route.query.tags + ' ' + tag - } else { - tags = tag - } - this.$router.push({ name: 'Home', query: { tags } }) + this.addTagsAndGo([tag]) } } diff --git a/web/src/components/layout/Header.vue b/web/src/components/layout/Header.vue index 221ffbe..851d84b 100644 --- a/web/src/components/layout/Header.vue +++ b/web/src/components/layout/Header.vue @@ -7,7 +7,7 @@ <SearchInput></SearchInput> <div id="header-user-infos"> - <span v-if="authenticated" v-on:authenticated="loadData()"> + <span v-if="authenticated"> <router-link to="/preferences"> {{ this.user.login }} (bow user since {{ new Date(this.user.creationdate).getFullYear() }}) </router-link> @@ -34,34 +34,12 @@ import SearchInput from '@/components/SearchInput' components: { SearchInput } }) class Header extends Vue { - user = {} - authenticated = false - logout() { this.$fetch .delete(`/users/${this.user.id}/auth`) - .then(() => this.loadData()) .then(() => this.$storage.delete('bow-user')) .then(() => this.$router.push({ name: 'Login' })) } - - loadData() { - console.log('loadData Header') - this.user = this.$storage.get('bow-user') || {} - this.authenticated = !!this.$storage.getCookie('bow-token') - } - - beforeMount() { - console.log('beforeMounted Header') - this.loadData() - this.$storage.addListener('bow-user', this.loadData, this) - } - - // beforeUpdate() { - // console.log('beforeUpdate Header') - // this.user = this.$storage.get('bow-user') - // this.token = this.$storage.getCookie('bow-token') - // } } export default Header diff --git a/web/src/components/layout/Sidebar.vue b/web/src/components/layout/Sidebar.vue index 13d7c22..495f8d9 100644 --- a/web/src/components/layout/Sidebar.vue +++ b/web/src/components/layout/Sidebar.vue @@ -29,22 +29,14 @@ import { Component, Vue } from 'vue-property-decorator' components: {} }) class Sidebar extends Vue { - user = {} statsUrl = '' add() { this.$router.push({ name: 'Edit', params: { id: 'new' } }) } - loadData() { - console.log('loadData Header') - this.user = this.$storage.get('bow-user') || {} - } - beforeMount() { this.statsUrl = this.$fetch.createUrl('/system/stats') - this.loadData() - this.$storage.addListener('bow-user', this.loadData, this) } } diff --git a/web/src/main.js b/web/src/main.js index 4a0ecfe..c017a64 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -24,6 +24,93 @@ Vue.config.productionTip = false Vue.prototype.$fetch = FetchHelper Vue.prototype.$storage = StoreHelper +Vue.mixin({ + methods: { + getCurrentQuery() { + let query = {} + query.tags = this.queryInfo.tags + query.fulltext = this.queryInfo.fulltext + query.query = this.queryInfo.query + query.orderby = this.queryInfo.orderby + query.orderdesc = this.queryInfo.orderdesc + query.first = this.queryInfo.first + return query + }, + go: function(query) { + console.log('go', query) + this.$router.push({ name: 'Home', query }) + }, + goFirst: function() { + let query = { ...this.currentQuery } + query.first = 0 + this.go(query) + }, + goNext: function() { + let query = { ...this.currentQuery } + query.first = query.first + this.user.maxresult + if (query.first > this.queryInfo.total - this.user.maxresult) { + query.first = this.queryInfo.total - this.user.maxresult + } + this.go(query) + }, + goPrev: function() { + let query = { ...this.currentQuery } + query.first = query.first - this.user.maxresult + if (query.first < 0) { + query.first = 0 + } + this.go(query) + }, + goLast: function() { + let query = { ...this.currentQuery } + query.first = this.queryInfo.total - this.user.maxresult + if (query.first < 0) { + query.first = 0 + } + this.go(query) + }, + addTagsAndGo: function(tags) { + console.log('addTagsAndGo', tags) + + let query = { ...this.currentQuery } + query.tags = query.tags.concat(tags) + this.go(query) + } + }, + computed: { + authenticated: function() { + return this.$store.state.authenticated + }, + user: function() { + return this.$store.state.user + }, + currentQuery: function() { + let i = this.queryInfo + // id ? uri ? + return { + first: i.first, + tags: i.tags, + fulltext: i.fulltext, + query: i.query, + orderby: i.orderby, + orderdesc: i.orderdesc + } + }, + queryInfo: function() { + return this.$store.state.query.info + }, + queryTags: function() { + return this.$store.state.query.tags[0] + }, + queryTagsCount: function() { + return this.$store.state.query.tags[1] + }, + queryResult: function() { + return this.$store.state.query.result + } + } +}) + new Vue({ router, store, diff --git a/web/src/store/index.js b/web/src/store/index.js index bbbbc16..b78a3ce 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -5,17 +5,20 @@ Vue.use(Vuex) export default new Vuex.Store({ state: { + authenticated: false, user: {}, - tags: [[],[]], - result: [], - size: 0 + query: {info: {}, tags:[[],[]], result: []} }, getters: {}, mutations: { - queryResponse(state, payload) { - state.tags = payload.tags - state.result = payload.result - state.size = payload.size + query(state, payload) { + state.query = payload + }, + user(state, payload) { + state.user = payload + }, + authenticated(state, payload) { + state.authenticated = payload } }, actions: {} diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index 541995e..5fb0141 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -3,11 +3,11 @@ <div>{{ errorMsg }}</div> <CloudTags></CloudTags> <div class="navigation"> - <button><<</button> - <button><</button> - {{ 1 + queryResponse.info.first }}-{{ queryResponse.info.first + queryResponse.info.limit }} - <button>></button> - <button>>></button> + <button @click="goFirst()"><<</button> + <button @click="goPrev()"><</button> + {{ 1 + queryInfo.first }}-{{ queryInfo.first + queryInfo.limit }} + <button @click="goNext()">></button> + <button @click="goLast()">>></button> / {{ queryResponse.info.total }} </div> <div class="bookmarks-list"> @@ -47,7 +47,7 @@ class Home extends Vue { queryResponse = {info:{}, tags:{}, result: {}} get bookmarks() { - return this.queryResponse.result + return this.queryResult } forceArrayTags(tags) { @@ -71,7 +71,7 @@ class Home extends Vue { this.$fetch.get(`/bookmarks?${searchParams.toString()}`).then( (data) => { this.queryResponse = data - this.$store.commit('queryResponse', data) + this.$store.commit('query', data) }, (err) => { this.errorMsg = err.cause diff --git a/web/src/views/Login.vue b/web/src/views/Login.vue index 8d647bc..b4a1406 100644 --- a/web/src/views/Login.vue +++ b/web/src/views/Login.vue @@ -44,7 +44,7 @@ class Login extends Vue { this.$fetch.post('/users/auth', this.data).then( (user) => { console.log('ok', user) - this.$storage.set('bow-user', user) + this.$storage.set('bow-user', user) // tout se recharge dans App.vue, suite a cette modif if (this.$route.params.nextUrl != null) { this.$router.push(this.$route.params.nextUrl) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm