Skip to content

Commit

Permalink
Merge pull request #447 from amihaiemil/446
Browse files Browse the repository at this point in the history
#446 GET Personal Repos Front-End
  • Loading branch information
amihaiemil authored Jun 26, 2021
2 parents d1b6724 + 062872a commit 58b9392
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 65 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/selfxdsd/selfweb/api/Repositories.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public Repositories(final User user) {
/**
* Get the user's personal repos (both public and private).
* @return ResponseEntity.
* @todo #443:60min Modify the front-end part of personal repos. We
* should call this endpoint instead of Github directly.
*/
@GetMapping(
value = "/repositories/personal",
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/selfxdsd/selfweb/api/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
* @author Mihai Andronache ([email protected])
* @version $Id$
* @since 0.0.1
* @todo #43:30min Update the getPublicRepos.js function to fetch the
* github/gitlab repos according to the "provider" attribute returned
* the from "/api/users/self" endpoint.
*/
@RestController
public class Users extends BaseApiController {
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/public/js/getPersonalRepos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
$(document).ready(
function () {
getPersonalRepos();
}
);
/**
* Get the user's personal repos.
*/
function getPersonalRepos() {
$("#repos").find("tbody").html('');
$("#loadingPersonalRepos").show();
$("#personal-repos-info").hide();
$.get(
"/api/repositories/personal",
function(repos) {
(repos || []).forEach(
function(repo){
$("#repos").find("tbody").append(repoAsTableRow(repo));
}
)
$("#loadingPersonalRepos").hide();
$("#personal-repos-info").show();
$('#repos').dataTable();
}
);
}

/**
* Wrap a repo's information between <li> tags, with anchor.
*/
function repoAsTableRow(repo) {
return "<tr><td><a href='/" + repo.provider + "/"+ repo.repoFullName+"'>"
+ repo.repoFullName + "</a></td></tr>"
}
59 changes: 0 additions & 59 deletions src/main/resources/public/js/getPublicRepos.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/templates/repositories.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h4 class="user_name"></h4>
<footer th:replace="footer.html :: footer"></footer>
</body>
<script src="/js/getManagedRepos.js"></script>
<script src="/js/getPublicRepos.js"></script>
<script src="/js/getPersonalRepos.js"></script>
<script src="/js/getOrgRepos.js"></script>
<script>
$(document).ready(
Expand Down

0 comments on commit 58b9392

Please sign in to comment.