New modal to permit admin select user repo for work
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
1859a715df
commit
f79c7b43cd
@ -57,6 +57,11 @@ func initializeGitLabOIDC(router *gin.Engine, authrouter *gin.RouterGroup, admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
authrouter.GET("/api/gitlabcri/repositories", GitLab_GetMyRepositories)
|
authrouter.GET("/api/gitlabcri/repositories", GitLab_GetMyRepositories)
|
||||||
|
|
||||||
|
usersRoutes := authrouter.Group("/api/users/:uid")
|
||||||
|
usersRoutes.Use(userHandler)
|
||||||
|
usersRoutes.Use(sameUserMiddleware)
|
||||||
|
usersRoutes.GET("/gitlabcri/repositories", GitLab_GetMyRepositories)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(OAUTH_GITLAB_FILE); err == nil {
|
if _, err := os.Stat(OAUTH_GITLAB_FILE); err == nil {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
export { className as class };
|
export { className as class };
|
||||||
|
|
||||||
export let work = {};
|
export let work = {};
|
||||||
|
export let user = null;
|
||||||
export let readonly = false;
|
export let readonly = false;
|
||||||
|
|
||||||
let repo_work = null;
|
let repo_work = null;
|
||||||
@ -36,24 +37,28 @@
|
|||||||
show_logs = repo.getBuildLogs()
|
show_logs = repo.getBuildLogs()
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh_repo_work() {
|
function refresh_repo_work(user) {
|
||||||
repo_work = getRepositories(work.id);
|
if (user != null) {
|
||||||
|
repo_work = getRepositories(work.id, user.id);
|
||||||
|
} else {
|
||||||
|
repo_work = getRepositories(work.id);
|
||||||
|
}
|
||||||
repo_work.then((repos) => {
|
repo_work.then((repos) => {
|
||||||
repo_used = repos[0];
|
repo_used = repos[0];
|
||||||
updatePullState(repos[0])
|
updatePullState(repos[0])
|
||||||
}, () => {
|
}, () => {
|
||||||
repo_used = new WorkRepository({id_work: work.id});
|
repo_used = new WorkRepository({id_work: work.id});
|
||||||
remote_repos = getRemoteRepositories();
|
remote_repos = getRemoteRepositories(user?user.id:null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
refresh_repo_work();
|
$: refresh_repo_work(user);
|
||||||
|
|
||||||
let submitInProgress = false;
|
let submitInProgress = false;
|
||||||
function submitWorkRepository() {
|
function submitWorkRepository() {
|
||||||
submitInProgress = true;
|
submitInProgress = true;
|
||||||
repo_used.save().then(() => {
|
repo_used.save(user).then(() => {
|
||||||
submitInProgress = false;
|
submitInProgress = false;
|
||||||
refresh_repo_work();
|
refresh_repo_work(user);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
submitInProgress = false;
|
submitInProgress = false;
|
||||||
ToastsStore.addErrorToast({
|
ToastsStore.addErrorToast({
|
||||||
@ -66,7 +71,7 @@
|
|||||||
submitInProgress = true;
|
submitInProgress = true;
|
||||||
repo.retrieveWork().then(() => {
|
repo.retrieveWork().then(() => {
|
||||||
submitInProgress = false;
|
submitInProgress = false;
|
||||||
refresh_repo_work();
|
refresh_repo_work(user);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
submitInProgress = false;
|
submitInProgress = false;
|
||||||
ToastsStore.addErrorToast({msg: "Une erreur s'est produite : " + error});
|
ToastsStore.addErrorToast({msg: "Une erreur s'est produite : " + error});
|
||||||
@ -124,7 +129,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="btn btn-outline-danger float-end mt-1"
|
class="btn btn-outline-danger float-end mt-1"
|
||||||
disable={submitInProgress || readonly}
|
disable={submitInProgress || readonly}
|
||||||
on:click={() => repo.delete().then(() => { refresh_repo_work() }, (error) => ToastsStore.addErrorToast({msg: "Une erreur s'est produite durant la suppression du lien : " + error}))}
|
on:click={() => repo.delete().then(() => { refresh_repo_work(user) }, (error) => ToastsStore.addErrorToast({msg: "Une erreur s'est produite durant la suppression du lien : " + error}))}
|
||||||
>
|
>
|
||||||
Supprimer cette liaison
|
Supprimer cette liaison
|
||||||
</button>
|
</button>
|
||||||
@ -169,7 +174,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="mt-2 btn btn-info"
|
class="mt-2 btn btn-info"
|
||||||
title="Rafraîchir la liste des dépôts"
|
title="Rafraîchir la liste des dépôts"
|
||||||
on:click={() => remote_repos = getRemoteRepositories()}
|
on:click={() => remote_repos = getRemoteRepositories(user?user.id:null)}
|
||||||
>
|
>
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
<i class="bi bi-arrow-clockwise"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -69,12 +69,15 @@ export class WorkRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save(user) {
|
||||||
let url = this.id?`repositories/${this.id}`:'repositories';
|
let url = this.id?`repositories/${this.id}`:'repositories';
|
||||||
|
|
||||||
if (this.id_work) {
|
if (this.id_work) {
|
||||||
url = `works/${this.id_work}/` + url;
|
url = `works/${this.id_work}/` + url;
|
||||||
}
|
}
|
||||||
|
if (user != null) {
|
||||||
|
url = `users/${user.id}/` + url;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await fetch("api/"+url, {
|
const res = await fetch("api/"+url, {
|
||||||
method: this.id?'PUT':'POST',
|
method: this.id?'PUT':'POST',
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import DateFormat from '../../../components/DateFormat.svelte';
|
import DateFormat from '../../../components/DateFormat.svelte';
|
||||||
import SubmissionStatus from '../../../components/SubmissionStatus.svelte';
|
import SubmissionStatus from '../../../components/SubmissionStatus.svelte';
|
||||||
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
||||||
|
import WorkRepository from '../../../components/WorkRepository.svelte';
|
||||||
import { getRepositories } from '../../../lib/repositories';
|
import { getRepositories } from '../../../lib/repositories';
|
||||||
import { ToastsStore } from '../../../stores/toasts';
|
import { ToastsStore } from '../../../stores/toasts';
|
||||||
import { getUsers } from '../../../lib/users';
|
import { getUsers } from '../../../lib/users';
|
||||||
@ -38,6 +39,7 @@
|
|||||||
|
|
||||||
let show_logs = null;
|
let show_logs = null;
|
||||||
let run_pull_for = {repo: null, user: null, tag: null};
|
let run_pull_for = {repo: null, user: null, tag: null};
|
||||||
|
let search_repo_for = {repo: null, user: null};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await work then w}
|
{#await work then w}
|
||||||
@ -96,7 +98,16 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:catch err}
|
{:catch err}
|
||||||
-
|
<div class="d-flex justify-content-between">
|
||||||
|
-
|
||||||
|
<button
|
||||||
|
class="btn btn-sm btn-info mx-1"
|
||||||
|
title="Choisir un dépôt"
|
||||||
|
on:click={() => { search_repo_for = { repo: null, user, modal: new bootstrap.Modal(document.getElementById('repoModal'))}; search_repo_for.modal.show(); }}
|
||||||
|
>
|
||||||
|
<i class="bi bi-search"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -136,6 +147,22 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" tabindex="-1" id="repoModal">
|
||||||
|
<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.tag) } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) }; search_repo_for.user = null; }}>
|
||||||
|
<div class="modal-header">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
{#if search_repo_for.user}
|
||||||
|
<WorkRepository work={w} user={search_repo_for.user} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
<div class="modal fade" tabindex="-1" id="logsModal">
|
<div class="modal fade" tabindex="-1" id="logsModal">
|
||||||
|
Reference in New Issue
Block a user