qa: Managers can view team and manage theirs todo list
This commit is contained in:
parent
b94beb363b
commit
cd64fc90bf
13 changed files with 526 additions and 24 deletions
|
|
@ -9,11 +9,12 @@
|
|||
import { getExerciceQA } from '$lib/qa';
|
||||
import { exercicesIdx } from '$lib/stores/exercices';
|
||||
import { themesIdx } from '$lib/stores/themes';
|
||||
import { todos } from '$lib/stores/todo';
|
||||
|
||||
export { className as class };
|
||||
let className = '';
|
||||
|
||||
export let team = null;
|
||||
|
||||
function show(id) {
|
||||
goto("exercices/" + id)
|
||||
}
|
||||
|
|
@ -23,7 +24,7 @@
|
|||
setInterval(() => my_exercicesP = update_exercices(), 62000);
|
||||
|
||||
async function update_exercices() {
|
||||
const view = await getQAView();
|
||||
const view = await getQAView(team);
|
||||
my_exercices = [];
|
||||
|
||||
for (const v of view) {
|
||||
|
|
@ -50,7 +51,13 @@
|
|||
>
|
||||
↻
|
||||
</button>
|
||||
<h3>Vos étapes</h3>
|
||||
<h3>
|
||||
{#if team}
|
||||
Étapes de l'équipe
|
||||
{:else}
|
||||
Vos étapes
|
||||
{/if}
|
||||
</h3>
|
||||
{#await my_exercicesP}
|
||||
<div class="text-center">
|
||||
<Spinner size="lg" />
|
||||
|
|
|
|||
|
|
@ -13,10 +13,15 @@
|
|||
export { className as class };
|
||||
let className = '';
|
||||
|
||||
let exo_doneP = getExerciceTested();
|
||||
export let team = null;
|
||||
|
||||
let teamtodos = todos;
|
||||
$: teamtodos = team ? team.todos : todos;
|
||||
|
||||
let exo_doneP = getExerciceTested(team);
|
||||
let tododone = { };
|
||||
|
||||
getQAWork().then((queries) => {
|
||||
getQAWork(team).then((queries) => {
|
||||
for (const q of queries) {
|
||||
tododone[q.id_exercice] = q;
|
||||
}
|
||||
|
|
@ -30,12 +35,12 @@
|
|||
<div class={className}>
|
||||
<button
|
||||
class="btn btn-dark float-end"
|
||||
on:click|preventDefault={() => { todos.refresh(); exo_doneP = getExerciceTested(); }}
|
||||
on:click|preventDefault={() => { todos.refresh(); exo_doneP = getExerciceTested(team); }}
|
||||
>
|
||||
↻
|
||||
</button>
|
||||
<h3>Étapes à tester et valider</h3>
|
||||
{#await todos.refresh()}
|
||||
{#await teamtodos.refresh()}
|
||||
<div class="text-center">
|
||||
<Spinner size="lg" />
|
||||
</div>
|
||||
|
|
@ -54,7 +59,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each $todos as todo (todo.id)}
|
||||
{#each $teamtodos as todo (todo.id)}
|
||||
<tr
|
||||
style:cursor="pointer"
|
||||
class:text-light={!tododone[todo.id_exercice] && !exo_done[todo.id_exercice]}
|
||||
|
|
|
|||
39
qa/ui/src/lib/stores/teams.js
Normal file
39
qa/ui/src/lib/stores/teams.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { writable, derived } from 'svelte/store';
|
||||
|
||||
import { getTeams } from '$lib/teams'
|
||||
|
||||
function createTeamsStore() {
|
||||
const { subscribe, set, update } = writable([]);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
set: (v) => {
|
||||
update((m) => Object.assign(m, v));
|
||||
},
|
||||
|
||||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const list = await getTeams();
|
||||
update((m) => list);
|
||||
return list;
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export const teams = createTeamsStore();
|
||||
|
||||
export const teamsIdx = derived(
|
||||
teams,
|
||||
$teams => {
|
||||
const teams_idx = { };
|
||||
|
||||
for (const e of $teams) {
|
||||
teams_idx[e.id] = e;
|
||||
}
|
||||
|
||||
return teams_idx;
|
||||
},
|
||||
);
|
||||
|
|
@ -2,7 +2,7 @@ import { writable, derived } from 'svelte/store';
|
|||
|
||||
import { getQAView, getQATodo, getQAWork } from '$lib/todo';
|
||||
|
||||
function createTodosStore() {
|
||||
export function createTodosStore(team) {
|
||||
const { subscribe, set, update } = writable([]);
|
||||
|
||||
return {
|
||||
|
|
@ -15,8 +15,8 @@ function createTodosStore() {
|
|||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const list = await getQATodo();
|
||||
list.push(...await getQAWork());
|
||||
const list = await getQATodo(team);
|
||||
list.push(...await getQAWork(team));
|
||||
update((m) => list);
|
||||
return list;
|
||||
},
|
||||
|
|
|
|||
49
qa/ui/src/lib/teams.js
Normal file
49
qa/ui/src/lib/teams.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { createTodosStore } from '$lib/stores/todo.js'
|
||||
|
||||
export const fieldsTeams = ["name", "color", "active", "external_id"];
|
||||
|
||||
export class Team {
|
||||
constructor(res) {
|
||||
if (res) {
|
||||
this.update(res);
|
||||
}
|
||||
|
||||
this.todos = createTodosStore(this);
|
||||
}
|
||||
|
||||
update({ id, name, color, active, external_id }) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.active = active;
|
||||
this.external_id = external_id;
|
||||
}
|
||||
|
||||
toHexColor() {
|
||||
let num = this.color;
|
||||
num >>>= 0;
|
||||
let b = num & 0xFF,
|
||||
g = (num & 0xFF00) >>> 8,
|
||||
r = (num & 0xFF0000) >>> 16,
|
||||
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
||||
return "#" + r.toString(16) + g.toString(16) + b.toString(16);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTeams() {
|
||||
const res = await fetch(`api/teams`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).map((t) => new Team(t));
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTeam(tid) {
|
||||
const res = await fetch(`api/teams/${tid}`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return new Team(await res.json());
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,19 +12,36 @@ export class QATodo {
|
|||
this.id_team = id_team;
|
||||
this.id_exercice = id_exercice;
|
||||
}
|
||||
|
||||
async delete(team) {
|
||||
const res = await fetch(team?`api/teams/${team.id}/todo/${this.id}`:`api/teams/${this.id_team}/todo/${this.id}`, {
|
||||
method: 'DELETE',
|
||||
headers: {'Accept': 'application/json'}
|
||||
});
|
||||
if (res.status < 300) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function getQATodo() {
|
||||
const res = await fetch(`api/qa_work.json`, {headers: {'Accept': 'application/json'}})
|
||||
export async function getQATodo(team) {
|
||||
const res = await fetch(team?`api/teams/${team.id}/qa_work.json`:`api/qa_work.json`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).map((t) => new QATodo(t));
|
||||
const data = await res.json();
|
||||
if (data === null) {
|
||||
return []
|
||||
} else {
|
||||
return data.map((t) => new QATodo(t));
|
||||
}
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getQAWork() {
|
||||
const res = await fetch(`api/qa_mywork.json`, {headers: {'Accept': 'application/json'}})
|
||||
export async function getQAWork(team) {
|
||||
const res = await fetch(team?`api/teams/${team.id}/qa_mywork.json`:`api/qa_mywork.json`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
const data = await res.json()
|
||||
if (data) {
|
||||
|
|
@ -37,8 +54,8 @@ export async function getQAWork() {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getQAView() {
|
||||
const res = await fetch(`api/qa_myexercices.json`, {headers: {'Accept': 'application/json'}})
|
||||
export async function getQAView(team) {
|
||||
const res = await fetch(team?`api/teams/${team.id}/qa_myexercices.json`:`api/qa_myexercices.json`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
const data = await res.json()
|
||||
if (data) {
|
||||
|
|
@ -51,8 +68,8 @@ export async function getQAView() {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getExerciceTested() {
|
||||
const res = await fetch(`api/qa_exercices.json`, {headers: {'Accept': 'application/json'}})
|
||||
export async function getExerciceTested(team) {
|
||||
const res = await fetch(team?`api/teams/${team.id}/qa_exercices.json`:`api/qa_exercices.json`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue