Commit 38f9ff2d authored by Lasse Overgaard Møldrup's avatar Lasse Overgaard Møldrup
Browse files

Merge feature/persistence with develop

parents 9ef6d797 b6654587
Pipeline #51930 passed with stage
in 42 seconds
.DS_Store .DS_Store
\ No newline at end of file .vscode
\ No newline at end of file
stages: stages:
- test - test
- create-vue-build - create-vue-build
- build-docker-container - build-docker-server-container
- build-docker-web-container
test: test:
stage: test stage: test
...@@ -16,7 +17,6 @@ test: ...@@ -16,7 +17,6 @@ test:
create-vue-build: create-vue-build:
only: only:
# - master
- develop - develop
stage: create-vue-build stage: create-vue-build
image: node image: node
...@@ -34,11 +34,24 @@ create-vue-build: ...@@ -34,11 +34,24 @@ create-vue-build:
paths: paths:
- website/studerende-dk/node_modules/ - website/studerende-dk/node_modules/
build-docker-container: build-docker-server-container:
only: only:
# - master
- develop - develop
stage: build-docker-container stage: build-docker-server-container
image: docker:latest
services:
- name: docker:19.03.8-dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- cd backend
- docker build . -t "$CI_REGISTRY_IMAGE""-server"
- docker push "$CI_REGISTRY_IMAGE""-server"
build-docker-web-container:
only:
- develop
stage: build-docker-web-container
image: docker:latest image: docker:latest
services: services:
- name: docker:19.03.8-dind - name: docker:19.03.8-dind
...@@ -46,5 +59,5 @@ build-docker-container: ...@@ -46,5 +59,5 @@ build-docker-container:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: script:
- cd website/studerende-dk - cd website/studerende-dk
- docker build . -t "$CI_REGISTRY_IMAGE" - docker build . -t "$CI_REGISTRY_IMAGE""-web"
- docker push "$CI_REGISTRY_IMAGE" - docker push "$CI_REGISTRY_IMAGE""-web"
{
"python.formatting.provider": "black"
}
\ No newline at end of file
FROM python:3.8
COPY server/* .
ENV PYTHONUNBUFFERED=1
EXPOSE 1337
CMD ["python", "server.py"]
\ No newline at end of file
# Inspired by https://pythonbasics.org/webserver/
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
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}]}]}'
}
class MyServer(BaseHTTPRequestHandler):
def _set_ok_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def _set_err_headers(self):
self.send_response(500)
self.send_header('Content-type', 'text/html')
self.end_headers()
def handle_load_layout(self, id):
if id in db:
self._set_ok_headers()
self.wfile.write(bytes(db[id], 'utf-8'))
else:
self._set_err_headers()
self.wfile.write(bytes('Error: Could not find id ' + str(id), 'utf-8'))
def handle_save_layout(self, id, data):
db[id] = data.replace('%22', '"')
self._set_ok_headers()
def do_GET(self):
# remove '/?' from path
query = self.path[2:]
fields = dict(f.split("=") for f in query.split("&"))
if fields['type'] == "load":
self.handle_load_layout(fields['id'])
elif fields['type'] == "save":
self.handle_save_layout(fields['id'], fields['data'])
else:
self._set_err_headers()
self.wfile.write(bytes('Request type not supported', 'utf-8'))
if __name__ == '__main__':
webServer = HTTPServer((hostName, serverPort), MyServer)
print('Server started http://%s:%s' % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print('Server stopped.')
\ No newline at end of file
# From https://docs.docker.com/compose/
version: "3.9"
services:
web:
build: website/studerende-dk/
ports:
- "80:80"
server:
build: backend/
ports:
- "1337:1337"
\ No newline at end of file
FROM nginx:latest FROM nginx:latest
COPY ./dist /usr/share/nginx/html COPY ./dist /usr/share/nginx/html
COPY nginx-conf/ /etc/nginx/conf.d/
\ No newline at end of file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /usr/share/nginx/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location /persistence/ {
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://server:1337/;
proxy_redirect off;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
\ No newline at end of file
...@@ -15,4 +15,4 @@ $white-bg-color: #fbfbfb; ...@@ -15,4 +15,4 @@ $white-bg-color: #fbfbfb;
$default-margin: 40px; $default-margin: 40px;
$mobile-width-cutoff: 992px; $mobile-width-cutoff: 992px;
\ No newline at end of file
...@@ -20,6 +20,16 @@ import Feed from "@/components/blocks/Feed"; ...@@ -20,6 +20,16 @@ import Feed from "@/components/blocks/Feed";
import Mail from "@/components/blocks/Mail"; import Mail from "@/components/blocks/Mail";
import Calendar from "@/components/blocks/Calendar"; import Calendar from "@/components/blocks/Calendar";
const sendServerRequest = (type, payload) => {
const xhr = new XMLHttpRequest();
const url = "/persistence";
xhr.open("GET", url + "?type=" + type + "&" + payload);
xhr.send();
return xhr;
}
export default { export default {
name: 'Home', name: 'Home',
...@@ -53,7 +63,7 @@ export default { ...@@ -53,7 +63,7 @@ export default {
}); });
}, },
resizeHorizontalMouseMove(event){ resizeHorizontalMouseMove(event) {
const deltaX = this.mouseDragPos.x - event.x; const deltaX = this.mouseDragPos.x - event.x;
this.mouseDragPos.x = event.x; this.mouseDragPos.x = event.x;
const row = this.horizontalResizeObject.row; const row = this.horizontalResizeObject.row;
...@@ -123,7 +133,35 @@ export default { ...@@ -123,7 +133,35 @@ export default {
document.removeEventListener("mousemove", this.resizeVerticalMouseMove, false); document.removeEventListener("mousemove", this.resizeVerticalMouseMove, false);
document.removeEventListener("mouseup", this.eventRemover, false); document.removeEventListener("mouseup", this.eventRemover, false);
document.getElementsByTagName("html")[0].classList.remove("no-select"); document.getElementsByTagName("html")[0].classList.remove("no-select");
} },
removeBlock(side, row, col) {
this[side][row].blocks.splice(col, 1);
if (this[side][row].blocks.length === 0)
this[side].splice(row, 1);
},
saveLayout(id) {
const type = "save"
const payload = "id=" + id + "&" + "data=" + JSON.stringify(this.$data);
const request = sendServerRequest(type, payload);
request.onload = () => {
const response = request.response;
console.log(response);
}
},
loadLayout(id) {
const type = "load"
const payload = "id=" + id;
const request = sendServerRequest(type, payload);
request.onload = () => {
const response = request.response;
Object.assign(this.$data, JSON.parse(response));
}
},
}, },
components: { components: {
...@@ -152,13 +190,13 @@ export default { ...@@ -152,13 +190,13 @@ export default {
// Must be outside ".row" or else after affect children // Must be outside ".row" or else after affect children
.row::after{ .row::after{
content: " "; content: " ";
background-color: rgba(0, 0, 0, 0); background-color: rgba(0, 0, 0, 0);
position: absolute; position: absolute;
bottom: - $gap; bottom: - $gap;
width: 100%; width: 100%;
height: $gap; height: $gap;
cursor: n-resize; cursor: n-resize;
} }
.col { .col {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment