Commit 9c0cc972 authored by Johan Degn's avatar Johan Degn
Browse files

Merge branch 'develop' into feature/add-block

merge develop into feature/add-block and resolve conflicts in Home.vue
parents 701ae074 378f3791
......@@ -6,8 +6,8 @@ hostName = '0.0.0.0'
serverPort = 1337
db = {
'katrine-marie' : '{"left":[],"right":[{"height":400,"blocks":[{"type":"Calendar","width":100}]}]}',
'isaac' : '{"left":[],"right":[{"height":400,"blocks":[{"type":"Feed","width":100}]}]}'
'katrine-marie' : '[{"height":400,"blocks":[{"type":"Calendar","width":75},{"type":"ActiveCourses","width":25}]},{"height":250,"blocks":[{"type":"Deadlines","width":100}]},{"height":300,"blocks":[{"type":"Feed","width":50},{"type":"Mail","width":25},{"type":"Mail","width":25}]}]',
'isaac' : '[{"height":400,"blocks":[{"type":"Calendar","width":75},{"type":"ActiveCourses","width":25}]},{"height":250,"blocks":[{"type":"Deadlines","width":100}]},{"height":300,"blocks":[{"type":"Feed","width":50},{"type":"Mail","width":25},{"type":"Mail","width":25}]}]'
}
class MyServer(BaseHTTPRequestHandler):
......
#!/bin/bash
# this script pulls the docker images and
# deploys them respectively if they are
# newer than the ones running.
# this script can be run at any time,
# and will only change the running
# containers if newer ones are available.
function deploy {
local url=$1
local service_name=$2
local run_arguments=$3
old_digest=$(docker inspect -f '{{.RepoDigests}}' ${url}:active | grep -o 'sha256:[0-9A-Fa-f]*')
# probably no existing image
if [ $? -ne 0 ]; then
echo "No existing image! Abort."
exit 1;
fi
new_digest=$(docker pull ${url}:latest | grep Digest | sed 's/Digest: //')
# network error or authentication might go wrong
if [ $? -ne 0 ]; then
echo "Auth or network err! Abort."
exit 2;
fi
# sanity check that new digest is formatted correctly and is same length as old.
# if it aint, it could be the result of a gitlab server error or such.
local check=$(echo $new_digest | grep -o 'sha256:[0-9A-Fa-f]*')
if [ "${#check}" -eq "0" ] || [ ${#old_digest} -ne 71 ]; then
echo "Damnit, something went bad! Crash and burn.."
exit 3;
fi
echo "Old digest: $old_digest"
echo "New digest: $new_digest"
if [ "$old_digest" != "$new_digest" ]; then
echo "Deploying new docker instance: $service_name."
docker stop $service_name
docker rm $service_name
docker rmi ${url}:active
docker tag ${url}:latest ${url}:active
docker run --network persist-net $run_arguments --name $service_name -d ${url}:active
result=0
else
echo "Already up to date."
fi
# remove/untag file. silence output
docker rmi ${url}:latest >/dev/null 2>&1
}
base_url="registry.gitlab.au.dk/exsys2021/da6/hold-afstand/"
# deploy new server if available
result=1
deploy ${base_url}server "server" "--network-alias server"
server_deployed=$result
echo
# deploy new web if available
result=1
deploy ${base_url}web "web" "-p 80:80"
web_deployed=$result
# if anything has been deployed, notify the devs
if [ $server_deployed -eq 0 ] || [ $web_deployed -eq 0 ]; then
[ $server_deployed -eq 0 ] && msg="backend"
[ $web_deployed -eq 0 ] && [ $server_deployed -eq 0 ] && msg=${msg}" and "
[ $web_deployed -eq 0 ] && msg=${msg}"frontend"
slack_msg="A new version of the ${msg} has been deployed! Check it out: https://vm34.exsys2021.cs.au.dk/"
echo $slack_msg
# notify slack channel
/home/auuser/slack-notifier.sh $slack_msg
fi
echo "Done."
#!/bin/bash
# ----- CAUTION!!! -----
# This script stops and removes the running web and server
# containers, removes their images and the persist-net
# docker network.
#
# It then reconfigures the network, download
# the images and redeploys them again.
base_url="registry.gitlab.au.dk/exsys2021/da6/hold-afstand/"
# stops docker containers
echo -n "Stopping containers..."
docker stop server >/dev/null 2>&1
docker stop web >/dev/null 2>&1
echo " Done."
# removes docker containers
echo -n "Removing containers..."
docker rm server >/dev/null 2>&1
docker rm web >/dev/null 2>&1
echo " Done."
# removes docker images
echo -n "Removing images..."
docker rmi ${base_url}server:active >/dev/null 2>&1
docker rmi ${base_url}web:active >/dev/null 2>&1
echo " Done."
# removes unused docker networks
echo -n "Removing docker network..."
docker network rm persist-net >/dev/null 2>&1
echo " Done."
# pulling the images
echo -n "Pulling latest sever image..."
docker pull ${base_url}server:latest >/dev/null 2>&1
echo " Done."
echo -n "Pulling latest web image..."
docker pull ${base_url}web:latest >/dev/null 2>&1
echo " Done."
# changes tags from latest to active
echo -n "Tagging..."
docker tag ${base_url}server:latest ${base_url}server:active >/dev/null 2>&1
docker tag ${base_url}web:latest ${base_url}web:active >/dev/null 2>&1
docker rmi ${base_url}server:latest >/dev/null 2>&1
docker rmi ${base_url}web:latest >/dev/null 2>&1
echo " Done."
# crates network
echo -n "Creates docker network..."
docker network create -d bridge persist-net --attachable >/dev/null 2>&1
echo " Done."
# spins up containers
echo -n "Spinning up containers..."
docker run --network persist-net --network-alias server --name server -d ${base_url}server:active >/dev/null 2>&1
docker run --network persist-net -p 80:80 --name web -d ${base_url}web:active >/dev/null 2>&1
echo " Done."
echo "All done!"
#!/bin/bash
# INFO: This script should be placed in auuser 's homefolder!
# sanity check
if [ "$#" == "0" ]; then
echo "The message should be passed as an argument!"
exit 1
fi
data='{"text":"'"$@"'"}'
url=$(head -n 1 slack-url)
curl -X POST -H 'Content-type: application/json' --data "$data" $url
......@@ -32,6 +32,7 @@
text-align: center;
color: $darker-theme-color;
background-color: $lightest-green-theme-color;
min-width: 320px;
}
* {
......@@ -61,7 +62,6 @@
#site {
display: flex;
flex-direction: column;
height: 100%;
}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
width="2.35556in" height="1.72222in"
viewBox="0 0 212 155">
<path id="Imported Path"
fill="currentColor" stroke="none" stroke-width="0"
d="M 43.49,132.51
C 44.58,131.09 45.59,129.60 46.76,128.24
51.75,122.43 57.04,116.90 62.21,111.24
66.13,106.96 69.86,102.47 74.04,98.43
84.34,88.46 97.45,78.30 108.53,69.35
125.47,56.59 142.97,44.60 161.03,33.48
165.70,30.60 179.97,22.38 175.17,25.04
168.64,28.65 149.41,40.09 155.86,36.34
169.65,28.32 183.43,20.26 197.21,12.23
199.79,10.51 202.36,8.80 204.93,7.08
204.93,7.08 169.66,20.89 169.66,20.89
169.66,20.89 169.66,20.89 169.66,20.89
167.25,22.48 164.83,24.08 162.42,25.67
169.75,21.51 191.65,8.91 184.40,13.20
170.18,21.63 155.75,29.68 141.50,38.06
118.99,51.29 97.60,66.38 76.78,82.13
64.29,92.24 52.81,101.13 41.13,112.18
29.21,123.48 18.52,136.14 7.07,147.92
7.07,147.92 43.49,132.51 43.49,132.51
43.49,132.51 43.49,132.51 43.49,132.51 Z
M 54.11,17.91
C 76.39,46.94 97.28,77.00 116.78,107.97
125.20,121.83 133.24,135.91 141.37,149.93
141.37,149.93 173.22,131.38 173.22,131.38
173.22,131.38 173.22,131.38 173.22,131.38
164.26,117.83 155.42,104.20 146.72,90.48
126.69,59.66 105.30,29.60 87.69,-2.70
87.69,-2.70 54.11,17.91 54.11,17.91
54.11,17.91 54.11,17.91 54.11,17.91 Z" />
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
width="2.51111in" height="1.75556in"
viewBox="0 0 226 158">
<path id="path867"
fill="currentColor" stroke="none" stroke-width="0"
d="M 7.09,103.51
C 20.55,116.87 34.35,129.87 48.16,142.87
50.02,144.54 55.31,149.90 58.40,150.57
60.39,151.00 62.68,151.01 64.50,150.08
74.83,144.77 84.97,138.95 94.35,132.09
97.80,129.57 99.88,125.56 102.57,122.22
106.50,117.35 110.32,112.39 114.20,107.47
142.71,74.31 175.09,44.71 208.20,16.26
211.77,13.21 215.34,10.16 218.91,7.10
218.91,7.10 195.73,16.54 195.73,16.54
195.73,16.54 195.73,16.54 195.73,16.54
192.43,19.48 189.12,22.43 185.82,25.37
153.30,54.31 121.31,84.04 92.49,116.73
88.13,121.81 83.89,127.01 79.40,131.98
76.35,135.36 65.47,140.65 69.87,141.79
75.69,143.30 80.73,136.59 86.00,133.69
87.56,132.83 82.81,135.68 81.02,135.67
77.70,135.63 72.31,130.55 70.41,129.05
56.34,116.72 42.38,104.08 30.74,89.34
30.74,89.34 7.09,103.51 7.09,103.51
7.09,103.51 7.09,103.51 7.09,103.51 Z" />
</svg>
<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 122.88" style="enable-background:new 0 0 122.88 122.88" xml:space="preserve"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;}</style><g><path class="st0" d="M14.1,0h94.67c7.76,0,14.1,6.35,14.1,14.1v94.67c0,7.75-6.35,14.1-14.1,14.1H14.1c-7.75,0-14.1-6.34-14.1-14.1 V14.1C0,6.34,6.34,0,14.1,0L14.1,0z M81.35,28.38L94.1,41.14c1.68,1.68,1.68,4.44,0,6.11l-7.06,7.06L68.17,35.44l7.06-7.06 C76.91,26.7,79.66,26.7,81.35,28.38L81.35,28.38z M52.34,88.98c-5.1,1.58-10.21,3.15-15.32,4.74c-12.01,3.71-11.95,6.18-8.68-5.37 l5.16-18.2l0,0l-0.02-0.02L64.6,39.01l18.87,18.87l-31.1,31.11L52.34,88.98L52.34,88.98z M36.73,73.36l12.39,12.39 c-3.35,1.03-6.71,2.06-10.07,3.11c-7.88,2.42-7.84,4.05-5.7-3.54L36.73,73.36L36.73,73.36z"/></g></svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
width="3.93333in" height="3.93333in"
viewBox="0 0 354 354">
<path id="Imported Path"
fill="none" stroke="currentColor" stroke-width="10"
d="M 177.00,125.25
C 177.00,321.69 177.00,321.69 177.00,321.69M 231.46,125.25
C 231.46,321.69 231.46,321.69 231.46,321.69M 122.54,125.25
C 122.54,321.69 122.54,321.69 122.54,321.69M 177.00,125.25
C 177.00,321.69 177.00,321.69 177.00,321.69M 296.23,341.69 296.23,341.69 296.23,341.69 296.23,341.69
M 177.00,12.31
C 156.43,12.31 139.31,27.06 135.64,46.56
135.64,46.56 218.36,46.60 218.36,46.60
214.71,27.08 197.58,12.31 177.00,12.31
177.00,12.31 177.00,12.31 177.00,12.31 Z
M 313.37,48.73
C 313.37,48.73 313.37,91.83 313.37,91.83
313.37,91.83 40.63,91.83 40.63,91.83
40.63,91.83 40.63,48.73 40.63,48.73
40.63,48.73 313.37,48.73 313.37,48.73 Z
M 57.77,92.85
C 57.77,92.85 296.23,92.85 296.23,92.85
296.23,92.85 296.23,341.69 296.23,341.69
296.23,341.69 57.77,341.69 57.77,341.69
57.77,341.69 57.77,92.85 57.77,92.85 Z" />
</svg>
......@@ -57,14 +57,14 @@
#version-tag {
color: $light-theme-color;
font-weight: bold;
font-size: 0.8em;
float: right;
margin-top: -5px;
}
header {
width: 100%;
padding: 15px $default-margin;
padding: 15px 15px;
z-index: 1;
background-color: $theme-color;
......@@ -83,7 +83,7 @@
label {
cursor: pointer;
font-size: 50px;
font-size: 2em;
}
@include no-select;
......@@ -110,6 +110,7 @@
margin: 0;
line-height: 1em;
margin-bottom: 2px;
font-size: 1.3em;
}
}
......@@ -127,6 +128,28 @@
cursor: pointer;
}
@media only screen and (min-width: $small-mobile-width-cutoff) {
#logo{
h1{
font-size: 2em;
}
}
#version-tag {
font-size: 1em;
}
header{
padding: 15px $default-margin/2;
}
#hamburger-menu{
label{
font-size: 50px;
}
}
}
@media only screen and (min-width: $mobile-width-cutoff) {
#hamburger-menu {
display: none;
......@@ -139,5 +162,9 @@
#hamburger-content {
display: none;
}
header{
padding: 15px $default-margin;
}
}
</style>
\ No newline at end of file
<template>
<BlockTemplate heading="Aktive kurser">
<BlockTemplate heading="Aktive kurser" :row="row" :col="col">
<ul>
<li v-for="(course, index) in courses" :key="index"><a href="/about">{{ course }}</a></li>
</ul>
......@@ -9,10 +9,19 @@
<script>
export default {
name: 'ActiveCourses',
props: ['row', 'col'],
data() {
return {
courses: ['Calculus Beta', 'Databaser', 'etc.']
}
}
}
</script>
\ No newline at end of file
</script>
<style scoped lang="scss">
.block{
min-width: 250px;
}
</style>
\ No newline at end of file
<template>
<div class="block">
<div class="heading">
<div class="heading" :draggable="dragEnabled.value" @dragstart="startDrag($event, row, col)" @dragend.prevent="stopDrag()">
<h2>{{ heading }}</h2>
</div>
<div class="content">
......@@ -11,7 +11,9 @@
<script>
export default {
props: [ 'heading' ]
props: [ 'heading', 'row', 'col' ],
inject: [ 'dragEnabled', 'startDrag', 'stopDrag' ]
}
</script>
......@@ -21,6 +23,7 @@ export default {
.block {
width: 100%;
height: 100%;
min-width: 150px;
text-align: left;
display: flex;
flex-direction: column;
......@@ -29,6 +32,7 @@ export default {
.heading {
color: $lightest-theme-color;
background-color: $theme-color;
pointer-events: none;
h2 {
padding: 10px $padding;
......@@ -61,4 +65,11 @@ export default {
margin-right: -$padding;
margin-bottom: 0;
}
@media only screen and (min-width: $mobile-width-cutoff) {
.heading {
cursor: move;
pointer-events: auto;
}
}
</style>
\ No newline at end of file
<template>
<div id="calendar">
<table>
<thead>
<table id="calendarTable">
<thead :draggable="dragEnabled.value" @dragstart="startDrag($event, row, col)" @dragend.prevent="stopDrag()">
<!-- Generating first header of schema -->
<tr>
<th>
<div>
<button id="offSizeButton" @click="prevWeek()"> &larr; </button>
</div>
</th>
<th colspan="4">Uge: {{getWeek(today)}} - {{getMonthName(today.getMonth())}}</th>
<th>
<div>
<button @click="nextWeek()"> &rarr; </button>
<th id="calendarHead" colspan="6">
<div id="headerDiv">
<div>
<button id="leftButton" @click="prevWeek()"> &larr; </button>
</div>
<div v-if="schedule.length == 5">
Uge: {{getWeek(today)}} - {{getMonthName(today.getMonth())}}
</div>
<div>
<button id="rightButton" @click="nextWeek()"> &rarr; </button>
</div>
</div>
</th>
</tr>
<!-- Empty cell to make monday move 1 cell left -->
<th></th>
<!-- Generating weekday names and month number-->
<th v-for="(day,i) in weekDays" :key="day">
{{day}} - {{getDateOfISOWeek(getWeek(today), today.getFullYear(), i).getDate()}}
</th>
<tr>
<!-- Empty cell to make monday move 1 cell left -->
<th></th>
<!-- Generating weekday names and month number-->
<template v-if="schedule.length == 1">
<th :colspan="colSpanValue" v-for="(n,i) in schedule" :key="i">
{{getMonthName(today.getMonth())}} uge {{getWeek(today)}} - {{weekDays[today.getDay()-1]}} {{today.getDate()}}.
</th>
</template>
<!-- Generate a single day, if size is too small -->
<template v-else>
<th :colspan="colSpanValue" v-for="(n,i) in schedule" :key="i">
{{weekDays[i]}} - {{getDateOfISOWeek(getWeek(today), today.getFullYear(), i).getDate()}}
</th>
</template>
</tr>
</thead>
<tbody>
<!-- Generating time rows -->
<tr v-for="(time,i) in time" :key="time" :style="{height: halfHourSpace*2 + 'px'}">
<tr v-for="(time,i) in time" :key="time" >
<td>{{time}}</td>
<!-- Generating schema based on first row-->
<template v-if="firstIndex(i)">
<td id="skematd" v-for="day in schedule" :key="day">
<td :colspan="colSpanValue" id="skematd" v-for="day in schedule" :key="day">
<!-- Adding and calculatings divs for each task, offset form the first row -->
<a href="/about">
<div v-for="task in day" :key="task"
......@@ -41,7 +53,7 @@
</template>
<!-- All other rows than the first are empty, but full of cells -->
<template v-else>
<td v-for="n in 5" :key="n"></td>
<td :colspan="colSpanValue" v-for="n in schedule" :key="n"></td>
</template>
</tr>
</tbody>
......@@ -52,6 +64,11 @@
<script>
export default {
name: 'Cal',
props: ['row', 'col'],
inject: [ 'dragEnabled', 'startDrag', 'stopDrag' ],
data() {
return {
// Currently showing schema data
......@@ -62,6 +79,9 @@ export default {
{a: {name: "CompArk", start: 2*2, stop: 2*4}, b:{name: "Numla", start: 2*4, stop: 2*6}, c:{name: "Exsys TØ", start: 2*6, stop: 2*9}},
{a: {name: "CompArk TØ", start: 0, stop: 2*3}}
],
scheduleDay:[
{a: {name: "Exsys", start: 2*6, stop: 2*8}}
],
// Dummy data for week 12
scheduleWeek12: [
......@@ -91,6 +111,8 @@ export default {
// the size of an half hour of time in the schema
halfHourSpace: [19],
colSpanValue: [1],
calendarDayWidth: [400],
// Names of all month, used in the schema header
monthName: ["January", "Februar", "Marts", "April", "Maj", "Juni",
......@@ -105,16 +127,43 @@ export default {
}
},
methods: {
// Move the date 7 days back
// Calculate how many days a movement in the calendar should be
// forward: boolean - whether the move is forward or not, changes
// the calculate on friday and monday
daysToAdd (forward){
// If in week view, move 7 days
if(this.schedule.length != 1){
return 7;
}
// If in day view and at friday or monday
// The calendar should move 3 days
if((this.today.getDay() == 5 && forward) || (this.today.getDay() == 1 && !forward)){
return 3;
}
// Neither week view nor friday or monday
return 1;
},
// Move the date back based on calendar view
prevWeek(){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() - 7);
const currentYear = this.today.getFullYear();
const currentMonth = this.today.getMonth();
const dayToMoveCalendarBackTo = this.today.getDate() - this.daysToAdd(false);
this.today = new Date(currentYear, currentMonth, dayToMoveCalendarBackTo);
this.changeSchedule();
this.updateDaysInDisplay();
},
// Move the date 7 days forward
// Move the date forward based on calendar view
nextWeek(){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() + 7);
const currentYear = this.today.getFullYear();
const currentMonth = this.today.getMonth();
const dayToMoveCalendarForwardTo = this.today.getDate() + this.daysToAdd(true);
this.today = new Date(currentYear, currentMonth, dayToMoveCalendarForwardTo);
this.changeSchedule();
this.updateDaysInDisplay();
},
// Changes the schedule to the current week, is invoked each time the date is changed
......@@ -135,7 +184,7 @@ export default {
// Check for first index in a loop
firstIndex(index){
return index === 0
return index === 0;
},
// Source: https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php
......@@ -162,31 +211,91 @@ export default {