-
Notifications
You must be signed in to change notification settings - Fork 2
Implementation of project page #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development_2.0.0
Are you sure you want to change the base?
Changes from all commits
2ab42c6
3adece2
50e1551
7d0884a
5661496
7636f2d
1d0b80c
e3ec58b
91b1a8d
76b97ae
1f316b0
125543f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| window.env = { | ||
| SERVER_DOMAIN_NAME_API: 'http://127.0.0.1:8000/api', | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| <template> | ||
| <v-app> | ||
| <v-main> | ||
| <router-view /> | ||
| </v-main> | ||
| </v-app> | ||
| <ProjectForm /> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| // | ||
| import ProjectForm from './components/projects/ProjectForm.vue' | ||
abdahmed22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </script> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,15 @@ | ||
| import axios, { AxiosInstance } from 'axios'; | ||
|
|
||
| const AuthClient: AxiosInstance = axios.create({ | ||
| baseURL: import.meta.env.VITE_APP_ENDPOINT, | ||
| timeout: 1000, | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'Authorization': 'Bearer ' + localStorage.getItem("token"), | ||
| }, | ||
| }); | ||
|
|
||
| const BaseClient: AxiosInstance = axios.create({ | ||
| baseURL: import.meta.env.VITE_APP_ENDPOINT, | ||
| timeout: 1000, | ||
| }); | ||
|
|
||
| export { AuthClient, BaseClient }; | ||
| import axios, { AxiosInstance } from 'axios' | ||
|
|
||
| export const AuthClient: AxiosInstance = axios.create({ | ||
| baseURL: window.env.SERVER_DOMAIN_NAME_API, | ||
| timeout: 1000, | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| Authorization: localStorage.getItem('token'), | ||
| }, | ||
| }) | ||
|
|
||
| export const BaseClient: AxiosInstance = axios.create({ | ||
| baseURL: window.env.SERVER_DOMAIN_NAME_API, | ||
| timeout: 1000, | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { AuthClient } from './axios' | ||
| import { Project } from '@/types/types' | ||
|
|
||
| export async function postProject (project :Partial<Project>) { | ||
| return AuthClient.post('/dashboard/projects/', project) | ||
| } | ||
|
|
||
| export async function getProjects (page :number) { | ||
| return AuthClient.get('/dashboard/projects/', { | ||
| params: { | ||
| page, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| export async function searchProject (searchInput: string) { | ||
| await AuthClient.get(`/project/search/${searchInput}`) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||
| <template> | ||||||
| <v-form | ||||||
| ref="form" | ||||||
| fast-fail | ||||||
| @submit.prevent | ||||||
| > | ||||||
| <v-text-field | ||||||
| v-model="project.title" | ||||||
| base-color="blue" | ||||||
| clearable | ||||||
| color="blue" | ||||||
| label="Title" | ||||||
| required | ||||||
| :rules="titleRules" | ||||||
| /> | ||||||
|
|
||||||
| <v-text-field | ||||||
| v-model="project.short_description" | ||||||
| base-color="blue" | ||||||
| clearable | ||||||
| color="blue" | ||||||
| label="Description" | ||||||
| required | ||||||
| :rules="descriptionRules" | ||||||
| /> | ||||||
| <v-switch | ||||||
| v-model="githubRepo" | ||||||
| base-color="blue" | ||||||
| label="Github repository" | ||||||
| /> | ||||||
|
|
||||||
| <v-text-field | ||||||
| v-if="githubRepo" | ||||||
| v-model="project.repo_link" | ||||||
| clearable | ||||||
| label="Git repository" | ||||||
| :rules="githubRepoRules" | ||||||
| /> | ||||||
|
|
||||||
| <v-col class="text-right"> | ||||||
| <v-btn | ||||||
| class="me-4" | ||||||
| color="blue" | ||||||
| :disabled="!form?.isValid || loading" | ||||||
| :loading="loading" | ||||||
| size="large" | ||||||
| text="Submit" | ||||||
| type="submit" | ||||||
| @click="createProject" | ||||||
| /> | ||||||
| </v-col> | ||||||
| </v-form> | ||||||
| </template> | ||||||
|
|
||||||
| <script lang="ts"> | ||||||
| import { ref } from 'vue' | ||||||
| import { postProject } from '@/api/projectService' | ||||||
| import { Project } from '@/types/types' | ||||||
| import { descriptionRules, githubRepoRules, titleRules } from '@/utilities/validators' | ||||||
| import { useNotifier } from 'vue3-notifier' | ||||||
|
|
||||||
| export default { | ||||||
|
|
||||||
| name: 'ProjectForm', | ||||||
| setup () { | ||||||
| const notifier = useNotifier('top right') | ||||||
|
|
||||||
| const githubRepo = ref<boolean>(false) | ||||||
|
|
||||||
| const form = ref() | ||||||
|
|
||||||
| const loading = ref(false) | ||||||
|
|
||||||
| const project = ref<Partial<Project>>( | ||||||
| { | ||||||
| title: '', | ||||||
| short_description: '', | ||||||
| repo_link: '', | ||||||
| } | ||||||
| ) | ||||||
|
|
||||||
| const createProject = async () => { | ||||||
| loading.value = true | ||||||
| let projectObject: Partial<Project> = { | ||||||
| title: project.value.title, | ||||||
| short_description: project.value.short_description, | ||||||
| } | ||||||
| if (project.value.repo_link !== '') { | ||||||
| projectObject = { | ||||||
| ...projectObject, | ||||||
| repo_link: project.value.repo_link, | ||||||
| } | ||||||
| } | ||||||
| postProject(projectObject) | ||||||
| .then((response: any) => { | ||||||
| notifier.notify({ | ||||||
| title: 'Success', | ||||||
| description: response.data.message, | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, you could do
Suggested change
|
||||||
| showProgressBar: true, | ||||||
| timeout: 7_000, | ||||||
| type: 'success', | ||||||
| }) | ||||||
| loading.value = false | ||||||
| }) | ||||||
| .catch((err: any) => { | ||||||
| let description = 'Can not create project' | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (err.response) { | ||||||
| description = err.response.data.detail | ||||||
| } | ||||||
| notifier.notify({ | ||||||
| title: 'Fail', | ||||||
| description, | ||||||
| showProgressBar: true, | ||||||
| timeout: 7_000, | ||||||
| type: 'error', | ||||||
| }) | ||||||
| loading.value = false | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| return { | ||||||
| form, | ||||||
| loading, | ||||||
| project, | ||||||
| githubRepo, | ||||||
| titleRules, | ||||||
| descriptionRules, | ||||||
| githubRepoRules, | ||||||
| createProject, | ||||||
| } | ||||||
| }, | ||||||
| } | ||||||
| </script> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export {} | ||
|
|
||
| declare global { | ||
| interface Window { | ||
| env: { | ||
| SERVER_DOMAIN_NAME_API: string; | ||
| }; | ||
| } | ||
| } |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <template> | ||
| <p>To be implemented</p> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
|
|
||
| export default { | ||
|
|
||
| name: 'ProjectDetailsView', | ||
| components: { | ||
| }, | ||
| setup () { | ||
| return { | ||
| } | ||
| }, | ||
| } | ||
| </script> |
Uh oh!
There was an error while loading. Please reload this page.