From 45e5a794ae423e81afa7fdde329f34e3d4a0bcd3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sat, 20 Mar 2021 18:01:09 +0100 Subject: feat: add top authors section --- src/components/TopAuthor.vue | 16 ++++++++++++++++ src/sass/_commit.sass | 18 ++++++++++++++++++ src/sass/main.sass | 6 ++++++ src/store.js | 23 +++++++++++++++++++++++ src/views/Home.vue | 25 +++++++++++++++++++++++-- 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/components/TopAuthor.vue diff --git a/src/components/TopAuthor.vue b/src/components/TopAuthor.vue new file mode 100644 index 0000000..e8a0241 --- /dev/null +++ b/src/components/TopAuthor.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/sass/_commit.sass b/src/sass/_commit.sass index 64a315c..d59afa0 100644 --- a/src/sass/_commit.sass +++ b/src/sass/_commit.sass @@ -86,3 +86,21 @@ border-radius: 2px @include breakpoint(phablet) max-width: 180px + +.top-author + display: grid + grid-template-columns: 80% 20% + .user + display: flex + img + width: 30px + height: 30px + margin-right: 5px + strong + text-overflow: ellipsis + white-space: nowrap + overflow: hidden + + .number + justify-self: end + color: $secondary diff --git a/src/sass/main.sass b/src/sass/main.sass index 09acd39..deab05d 100644 --- a/src/sass/main.sass +++ b/src/sass/main.sass @@ -5,3 +5,9 @@ body color: #2c3e50 font-family: $font-family background-color: #fbfcfc + +#home + @include breakpoint(phablet) + flex-direction: column-reverse + > div + margin-bottom: 42px diff --git a/src/store.js b/src/store.js index 2fd04eb..79bdaff 100644 --- a/src/store.js +++ b/src/store.js @@ -7,16 +7,24 @@ export default new Vuex.Store({ state: { api: process.env.VUE_APP_BACKEND_URL, loading: false, + loading_top_authors: false, commits: [], + top_authors: [], emails: {}, }, getters: { loading: state => { return state.loading }, + loading_top_authors: state => { + return state.loading_top_authors + }, commits: state => { return state.commits }, + top_authors: state => { + return state.top_authors + }, emails: state => { return state.emails }, @@ -25,9 +33,15 @@ export default new Vuex.Store({ loading_state: (state, value) => { state.loading = value }, + loading_top_authors_state: (state, value) => { + state.loading_top_authors = value + }, load_commits: (state, value) => { state.commits = value }, + load_top_authors: (state, value) => { + state.top_authors = value + }, load_emails: (state, value) => { state.emails = value }, @@ -56,6 +70,15 @@ export default new Vuex.Store({ commit('load_emails', emails_obj); }) }, + /// Get the ranking of commits authors + async get_top_authors({commit}) { + commit('loading_top_authors_state', true) + await fetch(`${this.state.api}/commit/top/`) + .then(async response => { + commit('load_top_authors', await response.json()); + }) + commit('loading_top_authors_state', false) + } }, modules: { } diff --git a/src/views/Home.vue b/src/views/Home.vue index 3ca1445..49e42b3 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -2,7 +2,7 @@ main header-blue b-container - b-row + b-row#home b-col(md="8" sm="12") h2 List of commits section#commits @@ -14,22 +14,37 @@ :author="emails[i.author_email]" :committer="emails[i.committer_email]" ) - b-col + b-col(md="4" sm="12") + h2 Top authors + b-list-group + b-list-group-item(v-if="loading_top_authors") + b-overlay(:show="true" spinner-large) + b-list-group-item( + v-else v-for="author in top_authors.slice(0, 7)" :key="author.email" + button + ) + author( + :data="author" + :avatar="emails[author.author_email]" + )