Make rendus page more interactive
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4c76dd9728
commit
ce6141e6e0
@ -161,6 +161,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
repositoriesRoutes.DELETE("", func(c *gin.Context) {
|
repositoriesRoutes.DELETE("", func(c *gin.Context) {
|
||||||
|
loggeduser := c.MustGet("LoggedUser").(*User)
|
||||||
repository := c.MustGet("repository").(*Repository)
|
repository := c.MustGet("repository").(*Repository)
|
||||||
work, err := getWork(int(repository.IdWork))
|
work, err := getWork(int(repository.IdWork))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -171,7 +172,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
if !work.Shown || work.Corrected || work.StartAvailability.After(now) || work.EndAvailability.Before(now) {
|
if !loggeduser.IsAdmin && (!work.Shown || work.Corrected || work.StartAvailability.After(now) || work.EndAvailability.Before(now)) {
|
||||||
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "The submission is closed."})
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "The submission is closed."})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,14 @@ export class WorkRepository {
|
|||||||
this.already_used = already_used == true;
|
this.already_used = already_used == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete() {
|
async delete(userid) {
|
||||||
const res = await fetch(this.id_work?`api/works/${this.id_work}/repositories/${this.id}`:`api/repositories/${this.id}`, {
|
let url = this.id_work?`works/${this.id_work}/repositories/${this.id}`:`repositories/${this.id}`;
|
||||||
|
|
||||||
|
if (userid) {
|
||||||
|
url = `users/${userid}/` + url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch("api/" + url, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {'Accept': 'application/json'}
|
headers: {'Accept': 'application/json'}
|
||||||
});
|
});
|
||||||
|
@ -26,14 +26,22 @@
|
|||||||
export let work = null;
|
export let work = null;
|
||||||
let usersP = null;
|
let usersP = null;
|
||||||
let show_dl_btn = { };
|
let show_dl_btn = { };
|
||||||
|
let repositoriesP = { };
|
||||||
work.then((w) => {
|
work.then((w) => {
|
||||||
usersP = getUsers(w.promo, w.group);
|
usersP = getUsers(w.promo, w.group);
|
||||||
usersP.then((users) => {
|
usersP.then((users) => {
|
||||||
nb_users = users.length;
|
nb_users = users.length;
|
||||||
show_dl_btn = { };
|
show_dl_btn = { };
|
||||||
|
for (const user of users) {
|
||||||
|
updateRepoUser(w.id, user.id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function updateRepoUser(wid, userid) {
|
||||||
|
repositoriesP[userid] = getRepositories(wid, userid);
|
||||||
|
}
|
||||||
|
|
||||||
let nb_rendus = 0;
|
let nb_rendus = 0;
|
||||||
let nb_users = 0;
|
let nb_users = 0;
|
||||||
|
|
||||||
@ -69,7 +77,8 @@
|
|||||||
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; show_dl_btn[user.id] = true; }} />
|
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; show_dl_btn[user.id] = true; }} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#await getRepositories(w.id, user.id) then repos}
|
{#if repositoriesP[user.id]}
|
||||||
|
{#await repositoriesP[user.id] then repos}
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
{#each repos as repo (repo.id)}
|
{#each repos as repo (repo.id)}
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
@ -87,13 +96,22 @@
|
|||||||
-
|
-
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
<div style="white-space: nowrap;">
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-primary mx-1"
|
class="btn btn-sm btn-primary mr-1"
|
||||||
title="Rafraîchir"
|
title="Rafraîchir"
|
||||||
on:click={() => { run_pull_for = { repo, user, struct: {tag:''}, modal: new bootstrap.Modal(document.getElementById('pullModal'))}; run_pull_for.modal.show(); }}
|
on:click={() => { run_pull_for = { repo, user, struct: {tag:''}, modal: new bootstrap.Modal(document.getElementById('pullModal'))}; run_pull_for.modal.show(); }}
|
||||||
>
|
>
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
<i class="bi bi-arrow-clockwise"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-sm btn-danger mr-1"
|
||||||
|
title="Désassocier le dépôt"
|
||||||
|
on:click={() => { repo.delete(user.id); updateRepoUser(w.id, user.id); }}
|
||||||
|
>
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@ -109,6 +127,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a
|
<a
|
||||||
@ -128,7 +147,7 @@
|
|||||||
|
|
||||||
<div class="modal fade" tabindex="-1" id="pullModal">
|
<div class="modal fade" tabindex="-1" id="pullModal">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<form class="modal-content" on:submit|preventDefault={() => {run_pull_for.modal.hide(); try { run_pull_for.repo.retrieveWork(run_pull_for.struct) } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) };}}>
|
<form class="modal-content" on:submit|preventDefault={() => {run_pull_for.modal.hide(); try { run_pull_for.repo.retrieveWork(run_pull_for.struct); updateRepoUser(w.id, run_pull_for.user.id); } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) };}}>
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Repository Pull {#if run_pull_for.user}{run_pull_for.user.login}{/if}</h5>
|
<h5 class="modal-title">Repository Pull {#if run_pull_for.user}{run_pull_for.user.login}{/if}</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
@ -156,7 +175,7 @@
|
|||||||
|
|
||||||
<div class="modal fade" tabindex="-1" id="repoModal">
|
<div class="modal fade" tabindex="-1" id="repoModal">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<form class="modal-content" on:submit|preventDefault={() => {search_repo_for.modal.hide(); try { search_repo_for.repo.retrieveWork(run_pull_for.struct) } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) }; search_repo_for.user = null; }}>
|
<form class="modal-content" on:submit|preventDefault={() => {search_repo_for.modal.hide(); try { search_repo_for.repo.retrieveWork(run_pull_for.struct); updateRepoUser(w.id, run_pull_for.user.id); } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) }; search_repo_for.user = null; }}>
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Repository selector {#if search_repo_for.user}{search_repo_for.user.login}{/if}</h5>
|
<h5 class="modal-title">Repository selector {#if search_repo_for.user}{search_repo_for.user.login}{/if}</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
Reference in New Issue
Block a user