From 16b03bb5f2ddd331ac87b227355e1f48f0e1ceeb Mon Sep 17 00:00:00 2001 From: scammo Date: Fri, 25 Jun 2021 19:28:41 +0200 Subject: [PATCH] router, auth, edit, first autocomplete, bascis structure, no design --- public/favicon.ico | Bin 0 -> 1150 bytes public/index.html | 3 +- src/App.vue | 61 ++++++++++- src/assets/custom.css | 4 + src/main.js | 6 +- src/router/index.js | 16 ++- src/views/Index.vue | 14 ++- src/views/Search.vue | 94 +++++++++-------- src/views/profile/Edit.vue | 208 ++++++++++++++++++++++++++++++------- 9 files changed, 314 insertions(+), 92 deletions(-) create mode 100644 public/favicon.ico create mode 100644 src/assets/custom.css diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..37ced2eb4b3b098e43ab62e26dbc423c411f1280 GIT binary patch literal 1150 zcmbVMSxA&o6h5;wsg0?XHYnoqP)%5fCelATyjlhIx(2%F2r8=;%mpZf+LVX_RLXNF)+sHa0dkyoiX18`ag- zF;!Jn*PWc4_#%;rsW}7pfnXpO2n3vce0(S+CB?e2vGHzsdATAmFwi|LEKJxGt&yXcYx=>3!ny20M>Wl$20LM#hD) zv9a2%tu1b0VPOP520_FR4-Xf0c6Q2FR#uFV9SsZ&6d-2ntgI}vtz|+EC^t7(GBGis z+u7OSR##WQVGm_TN5|{U&CMU%+uOf~hK4kWiHWv(d3hGIe`rff3l$X=xsQ&H>JcOJ z!ME_-HXhTGfQ<92skc-4i3H<5)yI=Og>`xU^E)J<>h5=X=#aDTU+Dc`zwy)C^R(GRVI^3 z6A}`Lo#)}N*?uvgZm}Q&d#>OzPkDOdFBJx)YSATH8oX|o}O;D zPfkvz*w|Q6adGhzwOXx3?u@9}JKRGTRwvYuz`xqw-ma^usaeEX6{yhzKR-V~e0)3! zg+h^BE|=xx0Kmfaf$0H~xh_Jo@e{SL2bMQ4RIy(9;qyqGir?xnLZB)WG*^ar-gi0%LY literal 0 HcmV?d00001 diff --git a/public/index.html b/public/index.html index 0f97498..d35b8d0 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,8 @@ - + + Kompetenz Inventar der WTF eG diff --git a/src/App.vue b/src/App.vue index dee2924..b99daf3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,67 @@ \ No newline at end of file + + \ No newline at end of file diff --git a/src/assets/custom.css b/src/assets/custom.css new file mode 100644 index 0000000..155a220 --- /dev/null +++ b/src/assets/custom.css @@ -0,0 +1,4 @@ +.container{ + min-height: calc(100vh - 70px - 24px); +} + \ No newline at end of file diff --git a/src/main.js b/src/main.js index aba5b45..a51e673 100644 --- a/src/main.js +++ b/src/main.js @@ -3,11 +3,15 @@ import App from './App.vue' import router from './router' import 'bootstrap/dist/css/bootstrap.min.css' +import './assets/custom.css' const app = createApp(App) app.use(router) +app.config.globalProperties.apiUrl= (process.env.VUE_APP_API_URL ? process.env.VUE_APP_API_URL : '') + app.mount('#app') -app.config.globalProperties.apiUrl="todo" \ No newline at end of file + + diff --git a/src/router/index.js b/src/router/index.js index f84586f..27267b6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,7 +9,17 @@ const routes = [ path: '/s', name: 's', component: { - template: "" + template: "", + }, + beforeEnter: (to, from, next) => { + console.log('test') + console.log('token', localStorage.getItem('token')) + if(localStorage.getItem('token') !== null){ + console.log('next') + next() + }else{ + next({path: '/', query: {url: to.fullPath, access: false}}) + } }, children: [ { @@ -18,12 +28,12 @@ const routes = [ component: Search }, { - path: '/profile/:member', + path: 'profile/:member', name: 'ProfileMember', component: View }, { - path: '/profile-edit', + path: 'profile-edit', name: 'ProfileEdit', component: Edit }, diff --git a/src/views/Index.vue b/src/views/Index.vue index 55fd864..25664d6 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -57,24 +57,28 @@ export default { async submitLogin() { this.showErrorMessage = false; try { + console.log(this.apiUrl) const loginResult = await axios.post( - `${process.env.VUE_APP_API_URL}/users/login`, + `${this.apiUrl}/users/login`, { username: this.username, password: this.password, } ); console.log(loginResult); + console.log(loginResult.status); if (loginResult.status === 200) { + console.log('if true') + this.showErrorMessage = false; //success login - localStorage.setItem("token", loginResult.token); - localStorage.setItem("user_id", loginResult.user_id); - this.router.push({ path: "s/search" }); + localStorage.setItem("token", loginResult.data.token); + localStorage.setItem("user_id", loginResult.data.user_id); + this.$router.push({ path: "/s/search" }); } else { this.showErrorMessage = true; } } catch (error) { - console.error(); + console.error(error); this.showErrorMessage = true; } }, diff --git a/src/views/Search.vue b/src/views/Search.vue index 95d24ad..8abc381 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -1,58 +1,66 @@ \ No newline at end of file diff --git a/src/views/profile/Edit.vue b/src/views/profile/Edit.vue index a3f5e42..d1b91e8 100644 --- a/src/views/profile/Edit.vue +++ b/src/views/profile/Edit.vue @@ -9,7 +9,7 @@ type="text" class="form-control" id="nickname" - v-model="nickname" + v-model="profile.nickname" required /> @@ -19,7 +19,7 @@ type="text" class="form-control" id="pronouns" - v-model="pronouns" + v-model="profile.pronouns" required />
@@ -34,7 +34,7 @@ class="form-control" id="freetext" rows="3" - v-model="freetext" + v-model="profile.freetext" >
@@ -45,14 +45,16 @@ class="form-control" id="volunteerwork" rows="3" - v-model="volunteerwork" + v-model="profile.volunteerwork" >
- +
    -
  • {{result.name}}
  • + @click="addSkill(result)" + > + {{ result.name }} +
@@ -84,6 +89,46 @@
+
+ + +
+
    +
  • + {{ result.name }} +
  • +
+
+
+ + {{ language.name }} + + +
+
item.id)); + if (this.profile.skills.map((item) => item.id).includes(skill.id)) + return false; + this.profile.skills.push(skill); + this.searchSkillsText = ""; + this.searchSkillResults = []; }, removeSkill(skillId) { - this.skills = this.skills.filter((skill) => { + this.profile.skills = this.profile.skills.filter((skill) => { if (skillId === skill.id) { return false; } else { @@ -153,7 +256,36 @@ export default { } }); }, - searchLanguages() {}, + async searchLanguages() { + try { + const languageResult = await axios.get( + `${process.env.VUE_APP_API_URL}/languages?search=${this.searchLanguagesText}` + ); + if (languageResult.status === 200) { + this.searchLanguagesResult = languageResult.data.languages; + } + } catch (error) { + console.error(); + this.showErrorMessage = true; + } + }, + + addLanguage(language) { + if (this.profile.languages.map((item) => item.id).includes(language.id)) + return false; + this.profile.languages.push(language); + this.searchLanguagesText = ""; + this.searchLanguagesResult = []; + }, + removeLanguage(languageId) { + this.profile.languages = this.profile.languages.filter((language) => { + if (languageId === language.id) { + return false; + } else { + return true; + } + }); + }, }, }; \ No newline at end of file