diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a50b3b132633e6dddaf8a8c26664adf4f4d16277..e757a909259f83ab7a49cbed5dac6b15ab115061 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,41 +1,43 @@ image: node:16 stages: - - setup +# - setup - test -variables: - npm_config_cache: "$CI_PROJECT_DIR/.npm" +#variables: +# npm_config_cache: "$CI_PROJECT_DIR/.npm" # Define a hidden job to be used with extends # Better than default to avoid activating cache for all jobs -.dependencies_cache: - cache: - key: - files: - - package-lock.json - paths: - - .npm - policy: pull +#.dependencies_cache: +# cache: +# key: +# files: +# - package-lock.json +# paths: +# - .npm +# policy: pull -setup: - stage: setup - script: - - npm ci - extends: .dependencies_cache - cache: - policy: pull-push - artifacts: - expire_in: 3 days #delete cache after 3 days to conserve space - paths: - - node_modules +#setup: +# stage: setup +# script: +# - npm ci +# extends: .dependencies_cache +# cache: +# policy: pull-push +# artifacts: +# expire_in: 3 days #delete cache after 3 days to conserve space +# paths: +# - node_modules -lint_test: +test: stage: test script: + - npm ci - npm run lint - -unit_test: - stage: test - script: - npm run test:unit + +#unit_test: +# stage: test +# script: +# - npm run test:unit diff --git a/src/assets/members.png b/src/assets/members.png new file mode 100644 index 0000000000000000000000000000000000000000..51775f6bead51014d3143631c292421752d024b6 Binary files /dev/null and b/src/assets/members.png differ diff --git a/src/assets/newCommunity.png b/src/assets/newCommunity.png new file mode 100644 index 0000000000000000000000000000000000000000..73bfba9f8000cecabb461394d7fe2f6b90c02b56 Binary files /dev/null and b/src/assets/newCommunity.png differ diff --git a/src/components/GroupComponents/GroupHome.vue b/src/components/CommunityComponents/CommunityHome.vue similarity index 85% rename from src/components/GroupComponents/GroupHome.vue rename to src/components/CommunityComponents/CommunityHome.vue index 4d18e19535e351c355a18a3778ed2532e99f9ef4..08a1468f9527895c878bf65e634ed4166362cd3a 100644 --- a/src/components/GroupComponents/GroupHome.vue +++ b/src/components/CommunityComponents/CommunityHome.vue @@ -1,5 +1,14 @@ <template> <section class="relative w-full max-w-md px-5 py-4 mx-auto rounded-md"> + <div> + <img + class="cursor-pointer h-8 float-right" + v-if="isLoggedIn" + src="@/assets/members.png" + alt="Medlemmer" + @click="$router.push('/group/:id/memberlist')" + /> + </div> <div class="mb-5 mt-5 border-b-2 border-blue-900"> <label class="text-xl font-bold">Tøyenhus borettslag</label> </div> @@ -34,14 +43,13 @@ </template> <script> -import ItemCard from "@/components/GroupComponents/ItemCard"; +import ItemCard from "@/components/CommunityComponents/ItemCard"; export default { name: "SearchItemListComponent", components: { ItemCard, }, - computed: { searchedItems() { let filteredItems = []; @@ -56,6 +64,11 @@ export default { return filteredItems; }, }, + created() { + if(this.$store.state.user.token !== null){ + this.isLoggedIn = true + } + }, /** * Her må det lages en metode som henter alle items (i en gruppe) fra databasen. @@ -65,6 +78,7 @@ export default { data() { return { + isLoggedIn: false, items: [ { img: "", adresse: "Oslo", title: "Dyson", price: 1000 }, diff --git a/src/components/GroupComponents/GroupList.vue b/src/components/CommunityComponents/CommunityList.vue similarity index 77% rename from src/components/GroupComponents/GroupList.vue rename to src/components/CommunityComponents/CommunityList.vue index 58d6a170c583d3fd773862b35458e880ae5dcd65..045eeadf16730ecd725b4e0c9990fbad0ee3d9ca 100644 --- a/src/components/GroupComponents/GroupList.vue +++ b/src/components/CommunityComponents/CommunityList.vue @@ -7,7 +7,7 @@ </template> <script> -import GroupListItem from "@/components/GroupComponents/GroupListItem.vue"; +import GroupListItem from "@/components/CommunityComponents/CommunityListItem.vue"; export default { name: "GroupList", diff --git a/src/components/GroupComponents/GroupListItem.vue b/src/components/CommunityComponents/CommunityListItem.vue similarity index 100% rename from src/components/GroupComponents/GroupListItem.vue rename to src/components/CommunityComponents/CommunityListItem.vue diff --git a/src/components/GroupComponents/ItemCard.vue b/src/components/CommunityComponents/ItemCard.vue similarity index 100% rename from src/components/GroupComponents/ItemCard.vue rename to src/components/CommunityComponents/ItemCard.vue diff --git a/src/components/GroupComponents/MemberList.vue b/src/components/CommunityComponents/MemberList.vue similarity index 100% rename from src/components/GroupComponents/MemberList.vue rename to src/components/CommunityComponents/MemberList.vue diff --git a/src/components/FormComponents/NewGroupForm.vue b/src/components/CommunityComponents/NewCommunityForm.vue similarity index 78% rename from src/components/FormComponents/NewGroupForm.vue rename to src/components/CommunityComponents/NewCommunityForm.vue index e322ce2c043a9a1349d7fa0e9cb7757150ea6595..bb3a4d8edfd877b35648111b8b9a28d4ab2c9575 100644 --- a/src/components/FormComponents/NewGroupForm.vue +++ b/src/components/CommunityComponents/NewCommunityForm.vue @@ -101,42 +101,6 @@ </div> </div> - <!-- Select category --> - <div class="mt-6"> - <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" - id="selectCategoryLabel" - >Kategori</label - > - <select - v-model="v$.group.select.$model" - id="categories" - class="bg-gray-200 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - > - <option class="text-gray-400" value="" disabled selected> - Select a category - </option> - <option - v-for="category in group.categories" - :key="category" - class="text-gray-900 text-sm" - > - {{ category }} - </option> - </select> - - <!-- error message for select box --> - <div - class="text-red" - v-for="(error, index) of v$.group.select.$errors" - :key="index" - > - <div class="text-red-600 text-sm"> - {{ error.$message }} - </div> - </div> - </div> - <!-- Description --> <div class="mt-6" :class="{ error: v$.group.description.$errors.length }"> <label @@ -184,13 +148,16 @@ <!-- Button for adding an image --> <div class="inline-flex rounded-md shadow-sm"> - <button + <div class="text-red-500 uppercase text-center"> + midlertidig fjernet + </div> + <!-- <button @click="$refs.file.click()" - class="text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50 cursor-not-allowed" + class="text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50" :disabled="imageAdded" > Velg bilde - </button> + </button> --> <!-- Button for removing an image --> <button @@ -266,9 +233,6 @@ export default { maxLength(200) ), }, - select: { - required: helpers.withMessage(() => `Velg en kategori`, required), - }, }, }; }, @@ -276,10 +240,8 @@ export default { return { group: { name: "", - select: null, description: "", images: [], - categories: ["Borettslag", "Idrettsklubb", "Fritidsklubb"], radio: null, place: "", visibility: 1, @@ -300,45 +262,26 @@ export default { removeImage: function () { this.group.images.pop(); this.imageThere = false; - console.log("Bilder nå: " + this.group.images.length); }, checkRadioButton: function (event) { this.group.radio = event.target.value; - console.log(this.group.radio); if (this.group.radio == null || this.group.radio == "Åpen") { this.group.visibility = 1; } else { this.group.visibility = 0; } - - console.log("visibility: " + this.group.visibility); }, checkValidation: function () { - console.log("sjekker validering"); - this.v$.group.$touch(); if (this.v$.group.$invalid) { - console.log("Invalid, avslutter..."); return false; } - - console.log("validert!"); return true; }, async saveClicked() { - console.log("Attempting to save item"); - if (this.checkValidation()) { - console.log("validert, videre..."); - console.log("Navn: " + this.group.name); - console.log("Sted: " + this.group.place); - console.log("Synlighet: " + this.group.radio); - console.log("Kategori: " + this.group.select); - console.log("Beskrivelse: " + this.group.description); - console.log("bilder: " + this.group.images); - const groupInfo = { name: this.group.name, description: this.group.description, @@ -347,18 +290,13 @@ export default { picture: "", }; - console.log(groupInfo); - const postCreatedGroup = await postNewgroup(groupInfo); - console.log(postCreatedGroup); + await postNewgroup(groupInfo); } }, addImage: function (event) { - console.log(event.target.files); this.group.images.push(URL.createObjectURL(event.target.files[0])); - console.log("antall bilder: " + this.group.images.length); this.imageThere = true; - console.log("image: " + this.imageThere); }, }, }; diff --git a/src/components/FormComponents/NewItemForm.vue b/src/components/CommunityComponents/NewItemForm.vue similarity index 100% rename from src/components/FormComponents/NewItemForm.vue rename to src/components/CommunityComponents/NewItemForm.vue diff --git a/src/components/GroupComponents/SearchItemList.vue b/src/components/CommunityComponents/SearchItemList.vue similarity index 97% rename from src/components/GroupComponents/SearchItemList.vue rename to src/components/CommunityComponents/SearchItemList.vue index d7c05f7e84a77c419a56aa513628741090a26baa..51f51ac4ead6c2e8468c88d52d6c48a3a1e13467 100644 --- a/src/components/GroupComponents/SearchItemList.vue +++ b/src/components/CommunityComponents/SearchItemList.vue @@ -31,7 +31,7 @@ </template> <script> -import ItemCard from "@/components/GroupComponents/ItemCard"; +import ItemCard from "@/components/CommunityComponents/ItemCard"; export default { name: "SearchItemListComponent", diff --git a/src/components/FormComponents/NotificationsForm.vue b/src/components/NavigationComponents/NotificationsForm.vue similarity index 100% rename from src/components/FormComponents/NotificationsForm.vue rename to src/components/NavigationComponents/NotificationsForm.vue diff --git a/src/router/index.js b/src/router/index.js index f323577815fc196cb68d832c3f5246828b9ecf35..f78c5c3db73981e799e1ce8cdd4c296ae081317e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,6 @@ import store from "@/store"; import { createRouter, createWebHistory } from "vue-router"; -import HomeView from "../views/GroupViews/HomeView.vue"; +import HomeView from "../views/CommunityViews/CommunityView.vue"; import LoginView from "../views/FormViews/LoginView.vue"; import NewPasswordView from "../views/FormViews/NewPasswordView"; @@ -38,7 +38,9 @@ const routes = [ path: "/messages", name: "messages", component: () => - import(/* webpackChunkName: "register" */ "../views/ChatViews/ChatView.vue"), + import( + /* webpackChunkName: "register" */ "../views/ChatViews/ChatView.vue" + ), beforeEnter: guardRoute, }, { @@ -55,7 +57,7 @@ const routes = [ { path: "/searchItemList", name: "searchItemList", - component: () => import("../views/GroupViews/SearchItemListView.vue"), + component: () => import("../views/CommunityViews/SearchItemListView.vue"), }, { path: "/resetPassword", @@ -65,36 +67,35 @@ const routes = [ { path: "/createNewGroup", name: "createNewGroup", - component: () => import("../views/FormViews/CreateNewGroupView.vue"), + component: () => import("../views/CommunityViews/NewCommunityView.vue"), }, { path: "/group/:id/memberlist", name: "memberlist", - component: () => import("../views/GroupViews/MemberListView.vue"), + component: () => import("../views/CommunityViews/MemberListView.vue"), beforeEnter: guardRoute, }, { path: "/addNewItem", name: "addNewItem", - component: () => import("../views/FormViews/AddNewItemView.vue"), + component: () => import("../views/CommunityViews/NewItemView.vue"), beforeEnter: guardRoute, }, { path: "/notifications", name: "notifications", - component: () => import("../views/FormViews/NotificationView.vue"), + component: () => import("../views/NavigationViews/NotificationView.vue"), beforeEnter: guardRoute, }, { path: "/user/:id/groups", name: "myGroups", - component: () => import("../views/GroupViews/MyGroupsView.vue"), + component: () => import("../views/CommunityViews/MyCommunitiesView.vue"), }, { - path: "/groupHomePage", + path: "/community/:id", name: "GroupHome", - component: () => import("../views/GroupViews/GroupHomeView.vue"), - beforeEnter: guardRoute, + component: () => import("../views/CommunityViews/CommunityHomeView.vue"), }, ]; diff --git a/src/views/GroupViews/GroupHomeView.vue b/src/views/CommunityViews/CommunityHomeView.vue similarity index 71% rename from src/views/GroupViews/GroupHomeView.vue rename to src/views/CommunityViews/CommunityHomeView.vue index 70826927bddd5e5c7f5087d6542c7ffce3c5ad3b..cabfd1b6ed2ea1e5775868f160484ddd9fa99b06 100644 --- a/src/views/GroupViews/GroupHomeView.vue +++ b/src/views/CommunityViews/CommunityHomeView.vue @@ -3,7 +3,7 @@ </template> <script> -import GroupHome from "@/components/GroupComponents/GroupHome"; +import GroupHome from "@/components/CommunityComponents/CommunityHome"; export default { name: "GroupHomeView.vue", components: { diff --git a/src/views/GroupViews/HomeView.vue b/src/views/CommunityViews/CommunityView.vue similarity index 55% rename from src/views/GroupViews/HomeView.vue rename to src/views/CommunityViews/CommunityView.vue index 47f81aac3c36cf8924acf4371369e770ac840df6..a2279054ac63749bd62f790783e9adefb23edaa7 100644 --- a/src/views/GroupViews/HomeView.vue +++ b/src/views/CommunityViews/CommunityView.vue @@ -1,24 +1,35 @@ <template> <div> - <div id="myGroups"> - <div>Mine grupper:</div> + <img + class="cursor-pointer h-8 mr-4 mt-4 float-right" + v-if="isLoggedIn" + src="@/assets/newCommunity.png" + alt="Legg til gruppe" + @click="$router.push('/createNewGroup')" + /> + </div> + <div> + <div id="myGroups" v-if="isLoggedIn"> + <div class="m-4" >Mine grupper:</div> <group-list :groupList="myGroups" /> </div> <div id="localGroups"> - <div>Offentlige grupper:</div> + <div class="m-4">Offentlige grupper:</div> <group-list :groupList="localGroups" /> </div> </div> + </template> <script> -import GroupList from "@/components/GroupComponents/GroupList.vue"; +import GroupList from "@/components/CommunityComponents/CommunityList.vue"; import { getMyGroups, getVisibleGroups } from "@/utils/apiutil"; export default { name: "HomeView", data() { return { + isLoggedIn: false, myGroups: [], localGroups: [], }; @@ -37,6 +48,9 @@ export default { async created() { await this.getMyGroups(); await this.getPotentialGroups(); - }, + if(this.$store.state.user.token !== null){ + this.isLoggedIn = true + } + }, }; </script> diff --git a/src/views/GroupViews/MemberListView.vue b/src/views/CommunityViews/MemberListView.vue similarity index 96% rename from src/views/GroupViews/MemberListView.vue rename to src/views/CommunityViews/MemberListView.vue index 4352d97bcfb80b23efeece2506e4754ec125b8b3..d250c0d86d6909e6813594be74e75f2616f29fec 100644 --- a/src/views/GroupViews/MemberListView.vue +++ b/src/views/CommunityViews/MemberListView.vue @@ -58,7 +58,7 @@ </template> <script> -import MemberList from "@/components/GroupComponents/MemberList.vue"; +import MemberList from "@/components/CommunityComponents/MemberList.vue"; export default { data() { diff --git a/src/views/GroupViews/MyGroupsView.vue b/src/views/CommunityViews/MyCommunitiesView.vue similarity index 86% rename from src/views/GroupViews/MyGroupsView.vue rename to src/views/CommunityViews/MyCommunitiesView.vue index ff0015601103a9e67fce8f3ea0b3356f2818b7f6..b2abf6c58e23ed50f27c12a94fbe80c1cbc9aad8 100644 --- a/src/views/GroupViews/MyGroupsView.vue +++ b/src/views/CommunityViews/MyCommunitiesView.vue @@ -8,7 +8,7 @@ </template> <script> -import GroupList from "@/components/GroupComponents/GroupList.vue"; +import GroupList from "@/components/CommunityComponents/CommunityList.vue"; import { getMyGroups } from "@/utils/apiutil"; export default { diff --git a/src/views/FormViews/CreateNewGroupView.vue b/src/views/CommunityViews/NewCommunityView.vue similarity index 52% rename from src/views/FormViews/CreateNewGroupView.vue rename to src/views/CommunityViews/NewCommunityView.vue index 9fcf12fbf0738a897ae01d5babcf941b1e6cbec8..38eacf3ba70f4df9c97093d2e5712fb961dc4c4d 100644 --- a/src/views/FormViews/CreateNewGroupView.vue +++ b/src/views/CommunityViews/NewCommunityView.vue @@ -1,13 +1,13 @@ <template> - <CreateNewGroup></CreateNewGroup> + <NewCommunity /> </template> <script> -import CreateNewGroup from "@/components/FormComponents/NewGroupForm"; +import NewCommunity from "@/components/CommunityComponents/NewCommunityForm"; export default { name: "CreateNewGroupView.vue", components: { - CreateNewGroup, + NewCommunity, }, }; </script> diff --git a/src/views/FormViews/AddNewItemView.vue b/src/views/CommunityViews/NewItemView.vue similarity index 72% rename from src/views/FormViews/AddNewItemView.vue rename to src/views/CommunityViews/NewItemView.vue index 243c054dc2c74179d892f2d28b31ad7bfd0ca371..8bbca71dd407668fe3de9abd0720d41eeea1c508 100644 --- a/src/views/FormViews/AddNewItemView.vue +++ b/src/views/CommunityViews/NewItemView.vue @@ -3,7 +3,7 @@ </template> <script> -import AddNewItem from "@/components/FormComponents/NewItemForm"; +import AddNewItem from "@/components/CommunityComponents/NewItemForm"; export default { name: "AddNewItemView.vue", diff --git a/src/views/GroupViews/SearchItemListView.vue b/src/views/CommunityViews/SearchItemListView.vue similarity index 71% rename from src/views/GroupViews/SearchItemListView.vue rename to src/views/CommunityViews/SearchItemListView.vue index 553a3388b514bccde4dbec5cd04dae602c5afc4f..1725bf8e672f75b7fe3e2600f6ae9bffaf4c063c 100644 --- a/src/views/GroupViews/SearchItemListView.vue +++ b/src/views/CommunityViews/SearchItemListView.vue @@ -3,7 +3,7 @@ </template> <script> -import SearchItemListComponent from "@/components/GroupComponents/SearchItemList"; +import SearchItemListComponent from "@/components/CommunityComponents/SearchItemList"; export default { name: "SearchItemListView", components: { diff --git a/src/views/FormViews/NotificationView.vue b/src/views/NavigationViews/NotificationView.vue similarity index 70% rename from src/views/FormViews/NotificationView.vue rename to src/views/NavigationViews/NotificationView.vue index c04c33d78f92104cb38f2b70986f4052d5f006d9..91eda3ca2fcf81963a368d41e3a9f466c4ba48da 100644 --- a/src/views/FormViews/NotificationView.vue +++ b/src/views/NavigationViews/NotificationView.vue @@ -5,7 +5,7 @@ </template> <script> -import NotificationsForm from "@/components/FormComponents/NotificationsForm"; +import NotificationsForm from "@/components/NavigationComponents/NotificationsForm"; export default { name: "NotificationView.vue", diff --git a/tests/unit/add-new-item.spec.js b/tests/unit/add-new-item.spec.js index b7424021681dce29a1f52f02324b78f30115c553..417812b108f62b53c5762732a59d4e969b8e4c3c 100644 --- a/tests/unit/add-new-item.spec.js +++ b/tests/unit/add-new-item.spec.js @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import AddNewItem from "@/components/FormComponents/NewItemForm.vue"; +import AddNewItem from "@/components/CommunityComponents/NewItemForm.vue"; describe("addNewItem elements rendering", () => { it("renders all labels", () => { diff --git a/tests/unit/create-new-group.spec.js b/tests/unit/create-new-group.spec.js index c96a64b00055bbb2ac6abe90ec7472aaf7cecedc..9ff1f2f8c528a002ee52b053533cf8df7ac78150 100644 --- a/tests/unit/create-new-group.spec.js +++ b/tests/unit/create-new-group.spec.js @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import CreateNewGroup from "@/components/FormComponents/NewGroupForm.vue"; +import CreateNewGroup from "@/components/CommunityComponents/NewCommunityForm.vue"; describe("CreateNewGroup elements rendering", () => { it("renders all labels", () => { @@ -9,7 +9,6 @@ describe("CreateNewGroup elements rendering", () => { expect(wrapper.find("#radioBoxOpenLabel").text()).toMatch("Åpen"); expect(wrapper.find("#radioBoxPrivateLabel").text()).toMatch("Privat"); expect(wrapper.find("#titleLabel").text()).toMatch("Gruppenavn"); - expect(wrapper.find("#selectCategoryLabel").text()).toMatch("Kategori"); expect(wrapper.find("#descriptionLabel").text()).toMatch("Beskrivelse"); expect(wrapper.find("#imageLabel").text()).toMatch("Bilde"); }); @@ -21,10 +20,6 @@ describe("CreateNewGroup elements rendering", () => { await titleInput.setValue("Fjellgata"); expect(titleInput.element.value).toBe("Fjellgata"); - const selectedCategory = wrapper.find("#categories"); - await selectedCategory.setValue("Borettslag"); - expect(selectedCategory.element.value).toBe("Borettslag"); - const descriptionInput = wrapper.find("#description"); await descriptionInput.setValue("Dette er et borettslag"); expect(descriptionInput.element.value).toBe("Dette er et borettslag"); diff --git a/tests/unit/search-item-list.spec.js b/tests/unit/search-item-list.spec.js index 05eca1b38fc6d70e7bb80af1e07f12fb8702f4f8..1ad4cff4313ee641059e386856a18e79fa2f7a0f 100644 --- a/tests/unit/search-item-list.spec.js +++ b/tests/unit/search-item-list.spec.js @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import SearchItemListComponent from "@/components/GroupComponents/SearchItemList.vue"; +import SearchItemListComponent from "@/components/CommunityComponents/SearchItemList.vue"; describe("CreateNewGroup elements rendering", () => { it("Tests setting values of input field", async () => {