Skip to content

[WIP] Improve dashboard repo search #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ $(document).ready(function () {
initWebhook();
initAdmin();
initCodeView();
initDashboardSearch();

// Repo clone url.
if ($('#repo-clone-url').length > 0) {
Expand Down Expand Up @@ -1478,15 +1479,6 @@ $(function () {
if ($('.user.signin').length > 0) return;
$('form').areYouSure();

$("#search_repo").on('change paste keyup',function(){
var value = $(this).val();
if(!value){
$('.list-search-style').html('');
} else{
$('.list-search-style').html('.search-list li:not([data-title*="' + value + '"]) {display: none;}');
}
});

// Parse SSH Key
$("#ssh-key-content").on('change paste keyup',function(){
var value = $(this).val();
Expand All @@ -1496,3 +1488,46 @@ $(function () {
}
});
});

function initDashboardSearch() {
var el = document.getElementById('dashboard-repo-search');
if (!el) {
return;
}

new Vue({
delimiters: ['<%', '%>'],
el: el,
data: {
repos: [],
searchQuery: ''
},
mounted: function() {
this.searchRepos();
},
methods: {
searchKeyUp: function() {
this.searchRepos();
},

searchRepos: function() {
var self = this;
$.getJSON('/api/v1/repos/search?q=' + self.searchQuery, function(result) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And all of sudden I feel the urge to write an API-client for javascript (I hate hard-coded URLs 😆 )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work if gitea is reached on a subfolder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Exactly my point :trollface:

self.repos = result.data;
});
},

repoClass: function(repo) {
if (repo.fork) {
return 'octicon octicon-repo-forked';
} else if (repo.private) {
return 'octicon octicon-repo-forked';
} else if (repo.mirror) {
return 'octicon octicon-repo-clone';
} else {
return 'octicon octicon-repo';
}
}
}
});
}
Loading