Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
heinzef committed Mar 22, 2020
2 parents f435946 + 5e8899d commit 47ede68
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 92 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 Digitales Klassenzimmer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions frontend/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ export default {
},
register(user) {
return post("/users/register", user);
},
tracks() {
return get("/tracks/");
},
track(id) {
return get("/track/" + id);
}
};
Binary file added frontend/src/assets/defaultRoom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 9 additions & 14 deletions frontend/src/components/SideBar.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="side-bar">
<SidebarList
:heading="tracks.heading"
:list="tracks.list"
:type="tracks.type"
:heading="'Meine Kurse'"
:list="tracks"
:type="'kurs'"
></SidebarList>
<SidebarList
:heading="rooms.heading"
Expand All @@ -20,25 +20,20 @@

<script>
import SidebarList from "./SidebarList";
import { mapGetters } from "@/store";
export default {
components: {
SidebarList
},
asyncComputed: {
...mapGetters(["tracks"])
},
data() {
return {
tracks: {
heading: "Meine Kurse",
type: "kurs",
list: [
"Nachhaltiger Konsum",
"Nachhaltigkeit einfach erklärt",
"Digitale Werkstatt - Kunststudio",
"Mathekurs Stufe 4"
]
},
rooms: {
heading: "Meine Räume",
type: "raum",
type: "room",
list: ["Klasse 5a", "Nachhilfe Mathe", "Random"]
},
chat: {
Expand Down
69 changes: 51 additions & 18 deletions frontend/src/components/SidebarList.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
<template>
<div class="collabsable-list">
<ul>
<li class="list-heading" :class="{ rotate: collapsed }" @click="collapsed = !collapsed">
<li
class="list-heading"
:class="{ rotate: collapsed }"
@click="collapsed = !collapsed"
>
{{ heading }}
</li>
<div class="list-container" :class="{'collapsed': collapsed}">
<div class="list-container" :class="{ collapsed: collapsed }">
<template v-if="type == 'kurs'">
<li v-for="item of list" v-bind:key="item.ID" :class="type">
<router-link
:to="{
name: type,
params: {
routeName: item.ID + '-' + getRouterString(item.Name),
trackName: item
}
}"
>
{{ item.Name }}
</router-link>
</li>
</template>
<template v-else-if="type == 'room'">
<li v-for="item of list" v-bind:key="item" :class="type">
<template v-if="type == 'kurs'">
<router-link :to="{name: type, params: {routeName: getRouterString(item), trackName: item}}">
{{ item }}
</router-link>
</template>
<template v-else>{{ item }}</template>
<router-link
:to="{
name: type,
params: {
routeName: getRouterString(item),
trackName: item
}
}"
>
{{ item }}
</router-link>
</li>
</template>
<template v-else>
<li v-for="item of list" v-bind:key="item.ID" :class="type">
<template>{{ item }}</template>
</li>
</div>
</template>
</div>
</ul>
</div>
</template>
Expand All @@ -32,10 +63,13 @@ export default {
},
methods: {
getRouterString(item) {
return item.toString().toLowerCase().trim()
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[\s\W-]+/g, '-')
.replace(/-$/, '') // Remove last floating dash if exists
return item
.toString()
.toLowerCase()
.trim()
.replace(/&/g, "-and-")
.replace(/[\s\W-]+/g, "-")
.replace(/-$/, "");
}
}
};
Expand All @@ -56,14 +90,14 @@ ul {
&:hover {
background: $color-sidebar-background;
}
}
}
}
.list-heading {
border-bottom: 1px solid $color-sidebar-border;
padding: 10px 15px 10px 0;
font-weight: 500;
color: #5881F9;
color: #5881f9;
cursor: pointer;
&:before {
font-icon: url("@/assets/icons/arrow-down-block.svg");
Expand All @@ -74,13 +108,12 @@ ul {
display: inline-block;
transition: 0.2s ease-in-out;
}
&.rotate{
border: none;
&.rotate {
border: none;
&:before {
transform: rotate(-90deg);
}
}
}
li.chat {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/TrackCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/>
<img v-else src="../assets/defaultTrack.jpg" :alt="track.name" /> -->
<div class="track-info">
<h5>{{ track.name }}</h5>
<p>{{ track.description }}</p>
<h5>{{ track.Name }}</h5>
<p>{{ track.Description }}</p>
</div>
</div>
</template>
Expand Down Expand Up @@ -43,7 +43,13 @@ export default {
}
.track-info {
width: 300px;
padding-top: 0;
padding: 20px;
margin-bottom: 5px;
overflow: hidden;
padding-top: 0;
text-overflow: ellipsis;
h5 {
font-weight: 900;
font-size: 1.6rem;
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ const routes = [
meta: {
requiresAuth: true
}
},
{
path: "/room/:routeName",
name: "room",
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () =>
import(/* webpackChunkName: "tracks" */ "@/views/Room.vue"),
meta: {
requiresAuth: true
}
}
];

Expand Down
27 changes: 27 additions & 0 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from "vue";
import AsyncComputed from "vue-async-computed";
import api from "@/api";
import deepmerge from "deepmerge";
Vue.use(AsyncComputed);

export const store = Vue.observable({
Expand All @@ -26,6 +27,32 @@ const getters = {
return store.user;
});
}
},
async tracks() {
if (store.tracks) {
return store.tracks;
} else {
return api.tracks().then(tracks => {
if (!tracks.error) {
Vue.set(store, "tracks", tracks);
}
return store.tracks;
});
}
},
async track(id) {
if (store.tracks && store.tracks.length > 0) {
const track = store.tracks.find(track => track.ID == id);
if (track) {
return track;
}
}
return api.track(id).then(track => {
if (!track.error) {
Vue.set(store, "tracks", deepmerge([track], store.tracks));
}
return track;
});
}
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export default {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
padding: 10px;
// justify-content: space-evenly;
padding: 20px;
}
.latest-course {
Expand Down
Loading

0 comments on commit 47ede68

Please sign in to comment.