@@ -20,16 +20,20 @@ document.getElementsByClassName('brand')[0].textContent = short_title;
20
20
21
21
let url_user = `https://api.github.com/users/${ github_user } ` ,
22
22
url_repos = `${ url_user } /repos?sort=pushed&per_page=100` ,
23
+ url_issues = `https://api.github.com/search/issues?q=user:${ github_user } &sort=updated&order=desc` ,
23
24
months_short = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' . split ( ' ' ) ;
24
25
25
26
if ( DEV ) {
26
27
url_user = '/data/user.json' ;
27
28
url_repos = '/data/repos.json' ;
29
+ url_issues = '/data/issues.json' ;
28
30
}
29
31
30
32
let coder = new Vue ( {
31
33
el : '#coder' ,
32
34
data : {
35
+ activetab : 'repos' ,
36
+ latest_issues : null ,
33
37
repos : [ ] ,
34
38
response : { } ,
35
39
sort_orders : { } ,
@@ -122,6 +126,12 @@ let coder = new Vue({
122
126
series : this . repo_types . values } ) ;
123
127
} ,
124
128
methods : {
129
+ fetchIssues : function ( ) {
130
+ this . $http . get ( url_issues ) . then ( response => {
131
+ this . response . issues = response ;
132
+ this . latest_issues = response . body . items ;
133
+ } ) ;
134
+ } ,
125
135
fetchRepos : function ( ) {
126
136
this . $http . get ( url_repos ) . then ( response => {
127
137
this . response . repos = response ;
@@ -150,11 +160,17 @@ let coder = new Vue({
150
160
repoRanking : function ( property ) {
151
161
return this . repos_pushed . filter ( d => d [ property ] ) . sort ( ( a , b ) => b [ property ] - a [ property ] ) ;
152
162
} ,
153
- sortBy : function ( key , type = 'number' ) {
163
+ showTab : function ( name ) {
164
+ this . activetab = name ;
165
+ if ( ! this . latest_issues ) {
166
+ this . fetchIssues ( ) ;
167
+ }
168
+ } ,
169
+ sortBy : function ( key , type = 'number' , property = 'repos' ) {
154
170
let default_value = type === 'string' ? '' : 0 ;
155
171
this . sort_key = key ;
156
172
this . sort_orders [ key ] = ( this . sort_orders [ key ] || 1 ) * - 1 ;
157
- this . repos . sort ( ( a , b ) => {
173
+ this [ property ] . sort ( ( a , b ) => {
158
174
let x = a [ key ] || default_value ,
159
175
y = b [ key ] || default_value ;
160
176
if ( type === 'string' ) {
0 commit comments