Skip to content

Commit

Permalink
Merge pull request #89 from ucsb-cs148-f21/classLOGO
Browse files Browse the repository at this point in the history
polish
  • Loading branch information
ZiyueWang675 authored Dec 3, 2021
2 parents 02e4509 + f12b118 commit 4339164
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 276 deletions.
70 changes: 28 additions & 42 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,32 @@
<template>
<div>
<b-navbar
toggleable="md"
type="dark"
variant="dark"
>
<b-navbar toggleable="md" type="dark" variant="dark">
<b-navbar-brand>UCSB Study Group</b-navbar-brand>

<b-navbar-toggle target="nav-collapse" />
<b-collapse
id="nav-collapse"
is-nav
>
<b-collapse id="nav-collapse" is-nav>
<b-navbar-nav v-if="isLoggedIn">
<b-nav-item to="/home">
Home
</b-nav-item>
<b-nav-item to="/AdminPanel">
AdminPanel
</b-nav-item>
<b-nav-item>
<b-nav-item-dropdown
text="My classes"
right
>
<li
v-for="classes in getClasses"
:key="classes._id"
>
<b-dropdown-item :to="`/class/${classes._id}`">
{{ classes.courseID }}
</b-dropdown-item>
</li>
</b-nav-item-dropdown>
</b-nav-item>
<b-nav-item to="/home"> Home </b-nav-item>
<b-nav-item to="/AdminPanel"> AdminPanel </b-nav-item>

<b-nav-item-dropdown text="My classes" right>
<li v-for="classes in getClasses" :key="classes._id">
<b-dropdown-item :to="`/class/${classes._id}`">
{{ classes.courseID }}
</b-dropdown-item>
</li>
</b-nav-item-dropdown>
</b-navbar-nav>
<!-- Right aligned nav items -->
<b-navbar-nav
v-if="isLoggedIn"
class="ms-auto"
>
<b-button size="sm" @click="signout" class="my-2 my-sm-0" variant="outline-primary">Signout</b-button>
<b-navbar-nav v-if="isLoggedIn" class="ms-auto">
<b-button
size="sm"
class="my-2 my-sm-0"
variant="outline-primary"
@click="signout"
>
Signout
</b-button>
<b-nav-item to="/UserProfile">
<b-img
:src="`${photoURL}`"
Expand All @@ -58,13 +44,13 @@
</template>

<script>
import { firebase } from '@/firestore';
import { axiosInstance } from './utils/axiosInstance';
import { firebase } from "@/firestore";
import { axiosInstance } from "./utils/axiosInstance";
export default {
data() {
return {
photoURL: '',
photoURL: "",
isLoggedIn: false,
myClasses: [],
gotClasses: false,
Expand All @@ -82,10 +68,10 @@ export default {
console.log(user);
if (user !== null) {
if (!this.gotClasses) {
const classArray = (await axiosInstance.get('users/getClasses'))
const classArray = (await axiosInstance.get("users/getClasses"))
.data;
classArray.forEach((el) => {
this.$store.commit('insertClass', el);
this.$store.commit("insertClass", el);
});
this.gotClasses = true;
}
Expand All @@ -102,9 +88,9 @@ export default {
this.isLoggedIn = true;
this.photoURL = user.photoURL;
if (!this.gotClasses) {
const classArray = (await axiosInstance.get('users/getClasses')).data;
const classArray = (await axiosInstance.get("users/getClasses")).data;
classArray.forEach((el) => {
this.$store.commit('insertClass', el);
this.$store.commit("insertClass", el);
console.log(this.getClasses);
});
Expand Down
92 changes: 19 additions & 73 deletions frontend/src/ChatContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<template>
<div class="window-container" :class="{ 'window-mobile': isDevice }">
<chat-window
:show-audio="false"
:height="screenHeight"
:theme="theme"
:styles="styles"
Expand Down Expand Up @@ -113,31 +114,14 @@ export default {
removeEnrollCode: null,
removeUserId: "",
removeUsers: [],
roomActions: [
{ name: "inviteUser", title: "Invite User" },
{ name: "removeUser", title: "Remove User" },
{ name: "deleteRoom", title: "Delete Room" },
{ name: "leaveRoom", title: "Leave Room" },
],
menuActions: [
{ name: "inviteUser", title: "Invite User" },
{ name: "removeUser", title: "Remove User" },
{ name: "deleteRoom", title: "Delete Room" },
],
roomActions: [{ name: "leaveRoom", title: "Leave Room" }],
menuActions: [{ name: "leaveRoom", title: "Leave Room" }],
styles: { container: { borderRadius: "4px" } },
templatesText: [
{
tag: "help",
text: "This is the help",
},
{
tag: "action",
text: "This is the action",
},
{
tag: "action 2",
text: "This is the second action",
},
],
// ,dbRequestCount: 0
};
Expand Down Expand Up @@ -575,12 +559,6 @@ export default {

menuActionHandler({ action, roomId }) {
switch (action.name) {
case "inviteUser":
return this.inviteUser(roomId);
case "removeUser":
return this.removeUser(roomId);
case "deleteRoom":
return this.deleteRoom(roomId);
case "leaveRoom":
return this.leaveRoom(roomId);
default:
Expand Down Expand Up @@ -669,12 +647,6 @@ export default {
this.$emit("leftRooms");
},

// change needed
inviteUser(roomId) {
this.resetForms();
this.inviteEnrollCode = roomId;
},

async addRoomUser() {
this.disableForm = true;

Expand All @@ -690,46 +662,26 @@ export default {
this.fetchRooms();
},

removeUser(roomId) {
this.resetForms();
this.removeEnrollCode = roomId;
this.removeUsers = this.rooms.find(
(room) => room.roomId === roomId
).users;
},

async deleteRoomUser() {
this.disableForm = true;

await roomsRef.doc(this.removeEnrollCode).update({
users: firebase.firestore.FieldValue.arrayRemove(this.removeUserId),
});

this.removeEnrollCode = null;
this.removeUserId = "";
this.fetchRooms();
},

async deleteRoom(roomId) {
const room = this.rooms.find((r) => r.roomId === roomId);
if (
room.users.find((user) => user._id === "SGmFnBZB4xxMv9V4CVlW") ||
room.users.find((user) => user._id === "6jMsIXUrBHBj7o2cRlau")
) {
return alert("Nope, for demo purposes you cannot delete this room");
}
// async deleteRoom(roomId) {
// const room = this.rooms.find((r) => r.roomId === roomId);
// if (
// room.users.find((user) => user._id === "SGmFnBZB4xxMv9V4CVlW") ||
// room.users.find((user) => user._id === "6jMsIXUrBHBj7o2cRlau")
// ) {
// return alert("Nope, for demo purposes you cannot delete this room");
// }

const ref = messagesRef(roomId);
// const ref = messagesRef(roomId);

ref.get().then((res) => {
if (res.empty) return;
res.docs.map((doc) => ref.doc(doc.id).delete());
});
// ref.get().then((res) => {
// if (res.empty) return;
// res.docs.map((doc) => ref.doc(doc.id).delete());
// });

await roomsRef.doc(roomId).delete();
// await roomsRef.doc(roomId).delete();

this.fetchRooms();
},
// this.fetchRooms();
// },

resetForms() {
this.disableForm = false;
Expand All @@ -740,12 +692,6 @@ export default {
this.removeEnrollCode = null;
this.removeUserId = "";
},

// ,incrementDbCounter(type, size) {
// size = size || 1
// this.dbRequestCount += size
// console.log(type, size)
// }
},
};
</script>
Binary file added frontend/src/assets/lagoon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/sea.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4339164

Please sign in to comment.