|
|
@ -1671,12 +1671,46 @@ function initVueComponents(){ |
|
|
|
reposTotalCount: 0, |
|
|
|
reposFilter: 'all', |
|
|
|
searchQuery: '', |
|
|
|
isLoading: false |
|
|
|
isLoading: false, |
|
|
|
repoTypes: { |
|
|
|
'all': { |
|
|
|
count: 0, |
|
|
|
searchMode: '', |
|
|
|
}, |
|
|
|
'forks': { |
|
|
|
count: 0, |
|
|
|
searchMode: 'fork', |
|
|
|
}, |
|
|
|
'mirrors': { |
|
|
|
count: 0, |
|
|
|
searchMode: 'mirror', |
|
|
|
}, |
|
|
|
'sources': { |
|
|
|
count: 0, |
|
|
|
searchMode: 'source', |
|
|
|
}, |
|
|
|
'collaborative': { |
|
|
|
count: 0, |
|
|
|
searchMode: 'collaborative', |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
showMoreReposLink: function() { |
|
|
|
return this.repos.length > 0 && this.repos.length < this.repoTypes[this.reposFilter].count; |
|
|
|
}, |
|
|
|
searchURL: function() { |
|
|
|
return this.suburl + '/api/v1/repos/search?uid=' + this.uid + '&q=' + this.searchQuery + '&limit=' + this.searchLimit + '&mode=' + this.repoTypes[this.reposFilter].searchMode + (this.reposFilter !== 'all' ? '&exclusive=1' : ''); |
|
|
|
}, |
|
|
|
repoTypeCount: function() { |
|
|
|
return this.repoTypes[this.reposFilter].count; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
mounted: function() { |
|
|
|
this.searchRepos(); |
|
|
|
this.searchRepos(this.reposFilter); |
|
|
|
|
|
|
|
var self = this; |
|
|
|
Vue.nextTick(function() { |
|
|
@ -1691,6 +1725,9 @@ function initVueComponents(){ |
|
|
|
|
|
|
|
changeReposFilter: function(filter) { |
|
|
|
this.reposFilter = filter; |
|
|
|
this.repos = []; |
|
|
|
this.repoTypes[filter].count = 0; |
|
|
|
this.searchRepos(filter); |
|
|
|
}, |
|
|
|
|
|
|
|
showRepo: function(repo, filter) { |
|
|
@ -1708,28 +1745,31 @@ function initVueComponents(){ |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
searchRepos: function() { |
|
|
|
searchRepos: function(reposFilter) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
this.isLoading = true; |
|
|
|
|
|
|
|
var searchedMode = this.repoTypes[reposFilter].searchMode; |
|
|
|
var searchedURL = this.searchURL; |
|
|
|
var searchedQuery = this.searchQuery; |
|
|
|
$.getJSON(this.searchURL(), function(result, textStatus, request) { |
|
|
|
if (searchedQuery == self.searchQuery) { |
|
|
|
|
|
|
|
$.getJSON(searchedURL, function(result, textStatus, request) { |
|
|
|
if (searchedURL == self.searchURL) { |
|
|
|
self.repos = result.data; |
|
|
|
if (searchedQuery == "") { |
|
|
|
self.reposTotalCount = request.getResponseHeader('X-Total-Count'); |
|
|
|
var count = request.getResponseHeader('X-Total-Count'); |
|
|
|
if (searchedQuery === '' && searchedMode === '') { |
|
|
|
self.reposTotalCount = count; |
|
|
|
} |
|
|
|
self.repoTypes[reposFilter].count = count; |
|
|
|
} |
|
|
|
}).always(function() { |
|
|
|
if (searchedQuery == self.searchQuery) { |
|
|
|
if (searchedURL == self.searchURL) { |
|
|
|
self.isLoading = false; |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
searchURL: function() { |
|
|
|
return this.suburl + '/api/v1/repos/search?uid=' + this.uid + '&q=' + this.searchQuery + '&limit=' + this.searchLimit; |
|
|
|
}, |
|
|
|
|
|
|
|
repoClass: function(repo) { |
|
|
|
if (repo.fork) { |
|
|
|
return 'octicon octicon-repo-forked'; |
|
|
|