Skip to content

Commit db4c645

Browse files
committed
Update UI
1 parent 375e55f commit db4c645

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed

src/assets/loaders/bars.svg

+1
Loading

src/assets/loaders/block.svg

+17
Loading

src/components/home/OrgList.vue

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<div>
3+
<v-card flat>
4+
<v-list>
5+
<v-list-tile
6+
v-for="org in orgsData"
7+
:key="org.name"
8+
@click="viewOrg(org.name)"
9+
avatar
10+
ripple
11+
>
12+
<v-list-tile-avatar>
13+
<img :src="org.avatar">
14+
</v-list-tile-avatar>
15+
16+
<v-list-tile-content>
17+
<v-list-tile-title v-html="org.name"></v-list-tile-title>
18+
</v-list-tile-content>
19+
</v-list-tile>
20+
</v-list>
21+
</v-card>
22+
</div>
23+
</template>
24+
25+
<script>
26+
export default {
27+
name: 'OrgList',
28+
computed: {
29+
orgsData() {
30+
return this.$store.getters.orgsData;
31+
}
32+
},
33+
methods: {
34+
viewOrg(name) {
35+
this.$router.push({ name: 'orgView', params: { name: name } });
36+
}
37+
}
38+
};
39+
</script>
40+
41+
<style lang="scss" scoped>
42+
</style>

src/components/home/UserDetails.vue

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div>
3+
<v-card flat ripple>
4+
<v-layout justify-center row>
5+
<v-flex>
6+
<v-avatar size="80">
7+
<img :src="userData.dp">
8+
</v-avatar>
9+
</v-flex>
10+
<v-flex>
11+
<div class="username ml-3">{{userData.username}}</div>
12+
<div class="github-name ml-3">{{userData.githubName}}</div>
13+
</v-flex>
14+
</v-layout>
15+
</v-card>
16+
</div>
17+
</template>
18+
19+
<script>
20+
export default {
21+
name: 'UserDetails',
22+
computed: {
23+
userData() {
24+
return this.$store.getters.userData;
25+
}
26+
}
27+
};
28+
</script>
29+
30+
<style lang="scss" scoped>
31+
.username {
32+
font-size: 20px;
33+
}
34+
.github-name {
35+
color: grey;
36+
font-size: 15px;
37+
}
38+
</style>

src/components/org/Org.vue

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<template>
2+
<div>
3+
<div v-if="!isLoading">
4+
<v-card flat>
5+
<OrgDetails :dp="org.avatar_url" :name="org.login"/>
6+
<OrgRepos :orgName="org.login" :repos="orgRepos"/>
7+
</v-card>
8+
</div>
9+
10+
<div v-if="isLoading">
11+
<img src="@/assets/loaders/block.svg" alt="loading...">
12+
</div>
13+
</div>
14+
</template>
15+
16+
<script>
17+
import OrgDetails from './OrgDetails';
18+
import OrgRepos from './OrgRepos';
19+
import axios from 'axios';
20+
import AxiosHelper from '../../config/AxiosHelper';
21+
import AuthService from '../../services/authService';
22+
23+
const authService = new AuthService();
24+
25+
export default {
26+
name: 'Org',
27+
data() {
28+
return {
29+
org: [],
30+
orgRepos: [],
31+
isLoading: false
32+
};
33+
},
34+
components: {
35+
OrgDetails,
36+
OrgRepos
37+
},
38+
computed: {
39+
name() {
40+
return this.$route.params.name;
41+
}
42+
},
43+
methods: {
44+
loadOrg() {
45+
axios
46+
.get(`${AxiosHelper.baseUrl}/orgs/${this.name}`, {
47+
headers: {
48+
Authorization: `token ${authService.getToken()}`
49+
}
50+
})
51+
.then(res => {
52+
this.org = res.data;
53+
this.loadOrgRepos();
54+
})
55+
.catch(err => console.log(err));
56+
},
57+
58+
//Can be done in a single call
59+
loadOrgRepos() {
60+
axios
61+
.get(`${AxiosHelper.baseUrl}/orgs/${this.name}/repos`, {
62+
headers: {
63+
Authorization: `token ${authService.getToken()}`
64+
}
65+
})
66+
.then(res => {
67+
this.isLoading = false;
68+
this.orgRepos = res.data;
69+
})
70+
.catch(err => console.log(err));
71+
}
72+
},
73+
created() {
74+
this.isLoading = true;
75+
this.loadOrg();
76+
}
77+
};
78+
</script>
79+
80+
<style lang="scss" scoped>
81+
</style>

src/views/HomeView.vue

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<template>
2+
<div>
3+
<v-layout class="ma-5" justify-center>
4+
<div v-if="!isLoading">
5+
<UserDetails/>
6+
<div class="mt-5 orgs">Organizations</div>
7+
<OrgList/>
8+
</div>
9+
<div v-if="isLoading">
10+
<img src="@/assets/loaders/block.svg" alt="loading...">
11+
</div>
12+
</v-layout>
13+
</div>
14+
</template>
15+
16+
<script>
17+
import UserDetails from '../components/home/UserDetails';
18+
import OrgList from '../components/home/OrgList';
19+
20+
export default {
21+
name: 'HomeView',
22+
computed: {
23+
isLoading() {
24+
return this.$store.state.user == '' && this.$store.state.userOrgs == ''
25+
? true
26+
: false;
27+
}
28+
},
29+
components: {
30+
UserDetails,
31+
OrgList
32+
},
33+
created() {
34+
this.$store.dispatch('loadUser');
35+
this.$store.dispatch('loadUserOrgs');
36+
}
37+
};
38+
</script>
39+
40+
<style lang="scss" scoped>
41+
.orgs {
42+
font-size: 20px;
43+
}
44+
</style>

0 commit comments

Comments
 (0)