From 035496ea265e4f1db2d18e37db7be3a779e6a2d7 Mon Sep 17 00:00:00 2001 From: Kaleab Kindu Date: Fri, 12 Aug 2022 01:36:34 +0300 Subject: [PATCH 1/5] fix bug on default layout --- starter-project-web-vue2/layouts/default.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/starter-project-web-vue2/layouts/default.vue b/starter-project-web-vue2/layouts/default.vue index f25910e..ac530bf 100644 --- a/starter-project-web-vue2/layouts/default.vue +++ b/starter-project-web-vue2/layouts/default.vue @@ -40,6 +40,7 @@ mdi-menu + From 1469ca17ecaa1b108c60a7675bf8fada681c8d8f Mon Sep 17 00:00:00 2001 From: Kaleab Kindu Date: Fri, 12 Aug 2022 01:38:03 +0300 Subject: [PATCH 2/5] add link to my landing page --- starter-project-web-vue2/pages/index.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/starter-project-web-vue2/pages/index.vue b/starter-project-web-vue2/pages/index.vue index 642d815..b258557 100644 --- a/starter-project-web-vue2/pages/index.vue +++ b/starter-project-web-vue2/pages/index.vue @@ -81,6 +81,11 @@ export default { name: 'Bisrat Walle', description: 'Software Engineer', link: '/bisrat', + }, + { + name: 'Kaleab Kindu', + description: 'Software Engineer', + link: '/kaleab', } ], } From 8c1c963bbe562ab34e4e11f8d62f45e377e2f184 Mon Sep 17 00:00:00 2001 From: Kaleab Kindu Date: Fri, 12 Aug 2022 01:40:01 +0300 Subject: [PATCH 3/5] add components to my page --- .../components/kaleab/KaleabAddArticle.vue | 68 ++++++++ .../components/kaleab/KaleabArticles.vue | 152 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 starter-project-web-vue2/components/kaleab/KaleabAddArticle.vue create mode 100644 starter-project-web-vue2/components/kaleab/KaleabArticles.vue diff --git a/starter-project-web-vue2/components/kaleab/KaleabAddArticle.vue b/starter-project-web-vue2/components/kaleab/KaleabAddArticle.vue new file mode 100644 index 0000000..6af9ccb --- /dev/null +++ b/starter-project-web-vue2/components/kaleab/KaleabAddArticle.vue @@ -0,0 +1,68 @@ + + \ No newline at end of file diff --git a/starter-project-web-vue2/components/kaleab/KaleabArticles.vue b/starter-project-web-vue2/components/kaleab/KaleabArticles.vue new file mode 100644 index 0000000..4a34d98 --- /dev/null +++ b/starter-project-web-vue2/components/kaleab/KaleabArticles.vue @@ -0,0 +1,152 @@ + + + From 49290c435c71246bc504b3bc60fdbf40371f2319 Mon Sep 17 00:00:00 2001 From: Kaleab Kindu Date: Fri, 12 Aug 2022 01:43:46 +0300 Subject: [PATCH 4/5] create landing page and a page for a single blog --- starter-project-web-vue2/pages/kaleab/_id.vue | 69 +++++++++++++++++++ .../pages/kaleab/index.vue | 17 +++++ 2 files changed, 86 insertions(+) create mode 100644 starter-project-web-vue2/pages/kaleab/_id.vue create mode 100644 starter-project-web-vue2/pages/kaleab/index.vue diff --git a/starter-project-web-vue2/pages/kaleab/_id.vue b/starter-project-web-vue2/pages/kaleab/_id.vue new file mode 100644 index 0000000..7f4490c --- /dev/null +++ b/starter-project-web-vue2/pages/kaleab/_id.vue @@ -0,0 +1,69 @@ + + + diff --git a/starter-project-web-vue2/pages/kaleab/index.vue b/starter-project-web-vue2/pages/kaleab/index.vue new file mode 100644 index 0000000..c1f840f --- /dev/null +++ b/starter-project-web-vue2/pages/kaleab/index.vue @@ -0,0 +1,17 @@ + + + From f5d56117e4bb2624fe825626a0ebc38a6fbabfee Mon Sep 17 00:00:00 2001 From: Kaleab Kindu Date: Fri, 12 Aug 2022 01:45:53 +0300 Subject: [PATCH 5/5] add state management and backend integration --- starter-project-web-vue2/store/kaleab.js | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 starter-project-web-vue2/store/kaleab.js diff --git a/starter-project-web-vue2/store/kaleab.js b/starter-project-web-vue2/store/kaleab.js new file mode 100644 index 0000000..5443f73 --- /dev/null +++ b/starter-project-web-vue2/store/kaleab.js @@ -0,0 +1,51 @@ + +export const state = { + articles: [] +}; + + +export const getters = { + allArticles: (state) => state.articles +}; + +export const actions = { + async fetchArticles({ commit }){ + const response = await this.$axios.get("articles/all") + commit("setArticles", response.data) + }, + async addArticles({ commit }, article){ + const response = await this.$axios.post("articles", article) + commit("newArticles", response.data) + }, + + async deleteArticles({ commit }, id){ + await this.$axios.delete(`articles/${id}`) + commit("removeArticles", id) + }, + async updateArticles({ commit }, newArticle){ + + const response = await this.$axios.patch(`articles/${newArticle._id}`, newArticle) + commit("modifyArticles", response.data) + } +}; + +export const mutations = { + setArticles: (state, articles) => (state.articles = articles), + newArticles: (state, article) => (state.articles.unshift(article)), + removeArticles: (state, id) => (state.articles = state.articles.filter((article) => article._id !== id)), + modifyArticles: (state, updateArticle) => { + const index = state.articles.findIndex((article) => article._id === updateArticle._id) + if (index !== -1){ + state.articles.splice(index, 1, updateArticle) + } + } +}; + +export default { + state, + getters, + actions, + mutations +} + +