diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-03-24 20:52:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 20:52:21 +0100 |
commit | 7075b22bda0da70108f150208a8b8f0898854eb1 (patch) | |
tree | 62825a0b60991682d5c6b401b195fe7f833c535d | |
parent | 67baef47414e15de9fd11c83275b8f30e8e21250 (diff) | |
parent | b8b7cd6876f72c6de16e47e8f5b5c4a3f5674560 (diff) |
Merge pull request #12 from gico-net/feat/repo-page
Repository page
-rw-r--r-- | public/index.html | 1 | ||||
-rw-r--r-- | src/router.js | 7 | ||||
-rw-r--r-- | src/sass/_commit.sass | 4 | ||||
-rw-r--r-- | src/sass/main.sass | 3 | ||||
-rw-r--r-- | src/store.js | 10 | ||||
-rw-r--r-- | src/views/Commit.vue | 2 | ||||
-rw-r--r-- | src/views/Repository.vue | 59 | ||||
-rw-r--r-- | src/views/Search.vue | 4 |
8 files changed, 86 insertions, 4 deletions
diff --git a/public/index.html b/public/index.html index c806cd9..a284103 100644 --- a/public/index.html +++ b/public/index.html @@ -5,6 +5,7 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <link rel="icon" href="<%= BASE_URL %>favicon.ico"> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.2/css/all.css"> <title>Gico</title> </head> <body> diff --git a/src/router.js b/src/router.js index 9be8616..0cfdc1e 100644 --- a/src/router.js +++ b/src/router.js @@ -3,6 +3,7 @@ import VueRouter from 'vue-router' import Home from '@/views/Home.vue' import Commit from '@/views/Commit.vue' +import Repository from '@/views/Repository.vue' import Search from '@/views/Search.vue' Vue.use(VueRouter) @@ -20,6 +21,12 @@ const routes = [ props: true }, { + path: '/repo/:user/:name', + name: 'Repository', + component: Repository, + props: true + }, + { path: '/search', name: 'Search', component: Search, diff --git a/src/sass/_commit.sass b/src/sass/_commit.sass index 514d82b..cc7312d 100644 --- a/src/sass/_commit.sass +++ b/src/sass/_commit.sass @@ -4,8 +4,10 @@ border-bottom: #ccc 1px solid padding: 20px 10px margin: 0 - &:hover + &:not(.no-hover):hover background-color: darken(#fbfcfc, 3%) + span.secondary + color: $secondary .head > div span diff --git a/src/sass/main.sass b/src/sass/main.sass index deab05d..ed7484c 100644 --- a/src/sass/main.sass +++ b/src/sass/main.sass @@ -11,3 +11,6 @@ body flex-direction: column-reverse > div margin-bottom: 42px + +.open-github + float: right diff --git a/src/store.js b/src/store.js index 1afad67..1483402 100644 --- a/src/store.js +++ b/src/store.js @@ -111,6 +111,16 @@ export default new Vuex.Store({ commit('load_commit', await response.json()); }) }, + // Get all commits from a repository + async get_repo_commits({commit}, data) { + commit('loading_state', true) + let path = `${this.state.api}/commit/?repository_user=${data.user}&repository_name=${data.name}` + await fetch(path) + .then(async response => { + commit('load_commits', await response.json()); + }) + commit('loading_state', false) + }, // Get email async get_email({commit}, data) { await fetch(`${this.state.api}/email/search/?q=${data.email}`) diff --git a/src/views/Commit.vue b/src/views/Commit.vue index 5fbeb13..475a308 100644 --- a/src/views/Commit.vue +++ b/src/views/Commit.vue @@ -4,7 +4,7 @@ b-container(v-if="loading") b-overlay(:show="true" spinner-large) b-container(v-else) - .commit(v-if="error404") + .commit.no-hover(v-if="error404") h2 Commit not found commit-card( :data="commit" diff --git a/src/views/Repository.vue b/src/views/Repository.vue new file mode 100644 index 0000000..ade55d3 --- /dev/null +++ b/src/views/Repository.vue @@ -0,0 +1,59 @@ +<template lang="pug"> + main + header-blue + b-container(v-if="loading") + b-overlay(:show="true" spinner-large) + b-container(v-else) + .commit.no-hover + h1 {{ user }}/ + span.secondary {{ name }} + b-button.open-github( + :href="'https://github.com/'+user+'/'+name" + variant="outline-dark" target="_new" + ) Open on GitHub + i.fab.fa-github + section(v-if="commits.length > 0") + .commit.no-hover + h2 Commits found {{ (commits.length == 1000)?"1000+":commits.length }} + commit-card( + v-for="i in commits" :key="i.hash" :data="i" + :author="emails[i.author_email]" + :committer="emails[i.committer_email]" + :expand="true" + ) +</template> + +<script> +import HeaderBlue from '@/components/HeaderBlue'; +import Commit from '@/components/Commit'; + +export default { + name: "Repository", + props: ["user", "name"], + components: { + 'header-blue': HeaderBlue, + 'commit-card': Commit, + }, + data() { + return { + error404: false + } + }, + async mounted() { + this.$store.dispatch('set_loading', true); + this.$store.dispatch('get_repo_commits', {user: this.user, name: this.name}); + this.$store.dispatch('get_emails'); + }, + computed: { + loading: function() { + return this.$store.getters.loading; + }, + commits: function() { + return this.$store.getters.commits; + }, + emails: function() { + return this.$store.getters.emails; + }, + }, +} +</script> diff --git a/src/views/Search.vue b/src/views/Search.vue index c173567..5cbfe33 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -4,9 +4,9 @@ b-container(v-if="loading") b-overlay(:show="true" spinner-large) b-container(v-else) - .commit + .commit.no-hover h2 Commits found {{ commits.length }} - .commit(style="padding: 50px" v-if="loading") + .commit.no-hover(style="padding: 50px" v-if="loading") b-overlay(:show="true" spinner-large) commit-card( v-else |