Skip to content
Open
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ node_modules
.vite
.env
dist
milestone.db
milestone.db
*.sql

*.toml

*.db
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ Pour accéder à l'aperçu de la version de production, visitez http://milestone
Voici les étapes à suivre pour se connecter en tant qu'administrateur :


1. Copier le fichier `.default` en `.env` avec la commande `cp .default .env` puis le remplir avec un nom d'utilisateur et un mot de passe admin.
1. Renommer le fichier `.default` en `.env` avec la commande `cp .default .env` puis le remplir avec un nom d'utilisateur et un mot de passe admin et vous avez la possibilite de laisser URL de base comme elle est ou la changer mais absolument l'indiquer.
URL de Base du serveur par defaut est : http://localhost:3000/api


2. `node prisma/seed.js` pour injecter les données dans la base de données.
2. Executer la commande `node prisma/seed.js` pour injecter les données dans la base de données.


3. Exécuter la commande `npx prisma generate` pour générer cet utilisateur avec le rôle admin.
Expand Down
1 change: 1 addition & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const showAddTask = ref(false);
const showAddUser = ref(false);
const showScrollToTop = ref(false);
const showWarning = ref(true);

const show = () => {
showForm.value = true;
};
Expand Down
2 changes: 1 addition & 1 deletion components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const login = async (isAdmin = true) => {
: {
name: username.value,
};
const res = await fetch("http://localhost:3000/api/login", {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
10 changes: 8 additions & 2 deletions components/ModifUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<input class="inputStyle" type="password" v-model="passwordInput" />
</div>
<input class="inputStyle inputSubmit" type="submit" value="Modifier" />
<button @click="$emit('close')">Arrêter les modifications</button>
<button @click="$emit('close'), endUserEdit()">Arrêter les modifications</button>
<span v-if="error !== ''">{{ error }}</span>
</form>
</template>
Expand All @@ -31,11 +31,12 @@ const jwt = jwtStore.jwt;
const userStore = useUserStore();
const emit = defineEmits(["close", "errorOnUpdateUser"]);

const { id, name, role, password } = defineProps({
const { id, name, role, password, isSelected } = defineProps({
id: Number,
name: String,
role: String,
password: String,
isSelected: Boolean
});

const nameInput = ref(name);
Expand All @@ -56,6 +57,11 @@ const editUser = async () => {
}
await userStore.setUsers(jwt);
};
const endUserEdit = () => {
for (let currentUser of userStore.users){
currentUser.isSelected = false
}
};
</script>

<style scoped>
Expand Down
25 changes: 11 additions & 14 deletions components/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
v-if="jwtStore.role === 'ADMIN' && task.isSelected"
class="modif-form"
/>
<!-- <button v-if="task.isSelected" @click="endTaskEdit, task.isSelected = false">
Terminer les modifications
</button> -->
</div>
</div>
</div>
Expand All @@ -59,17 +56,17 @@ const error = ref("");

const md = new MarkdownIt();

const endTaskEdit = () => {
taskStore.tasks.sort((a, b) => {
if (a.completed < b.completed) {
return 1;
}
if (a.completed > b.completed) {
return -1;
}
return 0;
});
};
// const endTaskEdit = () => {
// taskStore.tasks.sort((a, b) => {
// if (a.completed < b.completed) {
// return 1;
// }
// if (a.completed > b.completed) {
// return -1;
// }
// return 0;
// });
// };

const scrollToTask = (id) => {
const task = document.getElementById(id);
Expand Down
15 changes: 12 additions & 3 deletions components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
</span>
<ModifUser
v-bind="user"
v-if="showModifUserForm"
@close="showModifUserForm = false"
v-if="showModifUserForm && user.isSelected"
@close="showModifUserForm=false"
@submit="showModifUserForm=false"
@errorOnUpdateUser="
error = `La modification de l'utilisateur ${user.name} a échoué.`
"
Expand Down Expand Up @@ -68,11 +69,19 @@ const error = ref("");

const scrollToUser = (id) => {
showModifUserForm.value = !showModifUserForm.value;

const newId = id.substring(4)
const user = document.getElementById(id);
console.log(user);
setTimeout(() => {
user.scrollIntoView({ behavior: "smooth" });
}, 10);
for (let currentUser of userStore.users){
if (currentUser.id != newId){
currentUser.isSelected = false
} else {
currentUser.isSelected = true
}
}
};

if (users === false) {
Expand Down
17 changes: 0 additions & 17 deletions prisma/migrations/20221021140708_first_migration/migration.sql

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20221101192207_jwt_added/migration.sql

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions prisma/migrations/20221103181417_role_added/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

Binary file removed prisma/milestone.db
Binary file not shown.
2 changes: 1 addition & 1 deletion stores/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useDiscordStore = defineStore("discord", {
}),
actions: {
async fetchDiscordUser(jwt) {
const res = await fetch("http://localhost:3000/api/discord-id", {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/discord-id`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand Down
8 changes: 4 additions & 4 deletions stores/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const useTaskStore = defineStore("tasks", {
actions: {
async setTasks() {
const res = await fetch(
"http://localhost:3000/api/task",
`${import.meta.env.VITE_APP_API_URL}/task`,
{
method: "GET",
}
Expand Down Expand Up @@ -38,7 +38,7 @@ export const useTaskStore = defineStore("tasks", {
async addTask(jwt, title, content, completed) {
console.log("addTask", title, content, completed, jwt);
const res = await fetch(
"http://localhost:3000/api/task",
`${import.meta.env.VITE_APP_API_URL}/task`,
{
method: "POST",
headers: {
Expand Down Expand Up @@ -73,7 +73,7 @@ export const useTaskStore = defineStore("tasks", {

async updateTask(jwt, id, title, content, completed, isContentPrivate) {
const res = await fetch(
"http://localhost:3000/api/task/" + id,
`${import.meta.env.VITE_APP_API_URL}/task/${id}` ,
{
method: "PUT",
headers: {
Expand Down Expand Up @@ -118,7 +118,7 @@ export const useTaskStore = defineStore("tasks", {
return;
}
const res = await fetch(
"http://localhost:3000/api/task/" + id,
`${import.meta.env.VITE_APP_API_URL}/task/${id}`,
{
//await fait attendre que toute la fonction soit déroulée
headers: {
Expand Down
10 changes: 5 additions & 5 deletions stores/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useUserStore = defineStore("users", {
}),
actions: {
async setUsers(jwt) {
const res = await fetch("http://localhost:3000/api/user", {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand All @@ -33,7 +33,7 @@ export const useUserStore = defineStore("users", {
},

async addUser(jwt, name, role, password, discordId, twitchId) {
const res = await fetch("http://localhost:3000/api/user", {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -74,7 +74,7 @@ export const useUserStore = defineStore("users", {
if (!conf) {
return;
}
const res = await fetch(`http://localhost:3000/api/user/${id}`, {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user/${id}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -104,7 +104,7 @@ export const useUserStore = defineStore("users", {
},

async updateUser(jwt, id, name, role, password, discordId, twitchId) {
const res = await fetch(`http://localhost:3000/api/user/${id}`, {
const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user/${id}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -144,7 +144,7 @@ export const useUserStore = defineStore("users", {
async checkThirdPartyUserExistence(userId) {
try {
const res = await fetch(
`http://localhost:3000/api/third-party/${userId}`
`${import.meta.env.VITE_APP_API_URL}`/third-party/`${userId}`
);

const data = await res.json();
Expand Down