Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 2d6ae53

Browse files
Automatically build Docker image
1 parent c1ba012 commit 2d6ae53

File tree

11 files changed

+180
-56
lines changed

11 files changed

+180
-56
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.git
2+
/.github
3+
/.idea
4+
/dist
5+
/node_modules
6+
/out
7+
/.gitignore
8+
/main.js
9+
*.md
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Build Docker image
3+
on:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
push_to_dockerhub:
9+
name: Push to docker hub
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repo
13+
uses: actions/checkout@v2
14+
- uses: docker/setup-buildx-action@v1
15+
- name: Login to DockerHub
16+
uses: docker/login-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
- name: Push to Docker Hub
21+
uses: docker/build-push-action@v2
22+
with:
23+
push: true
24+
tags: alexandrevryghem/guido-desktop:latest

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:latest as build
2+
3+
WORKDIR /usr/local/app
4+
COPY . /usr/local/app/
5+
RUN npm install
6+
RUN npm run build
7+
8+
FROM nginx:latest
9+
10+
EXPOSE 80
11+
COPY --from=build /usr/local/app/dist /usr/share/nginx/html

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,54 @@
11
# Guido Desktop App
22

3-
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.3.
3+
[![Deploy on GitHub pages](https://github.com/ucll-ap-guide/guideApp-desktop/actions/workflows/deploy-to-github-pages.yml/badge.svg?branch=main)](https://github.com/ucll-ap-guide/guideApp-desktop/actions/workflows/deploy-to-github-pages.yml)
4+
[![Build Docker image](https://github.com/ucll-ap-guide/guideApp-desktop/actions/workflows/build-docker-image.yml/badge.svg?branch=main)](https://github.com/ucll-ap-guide/guideApp-desktop/actions/workflows/build-docker-image.yml)
45

5-
## Development server
6+
## Requirements
67

7-
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change
8-
any of the source files.
8+
- npm 8.5 and higher (probably also lower versions)
99

10-
## Build
10+
## How to run
11+
12+
⚠ Don't forget to first edit the apiUrl in the `environment.prod.ts` & `environment.ts` file.
13+
14+
### Build
1115

1216
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
17+
18+
### For development
19+
20+
Run `ng serve` for a development server. Navigate to `http://localhost:4200/`. The app will automatically reload if you
21+
change any of the source files.
22+
23+
### Build Docker image
24+
25+
(⚠ Don't forget to start Docker Desktop on Windows)
26+
27+
Use the `docker pull alexandrevryghem/guido-desktop:latest` command to get the latest version of the image (or build it
28+
yourself with the command `docker build -t guido-desktop .`).
29+
30+
To run the image run the command `docker run -d -p PORT:80 alexandrevryghem/guido-desktop:latest` and don't forget to
31+
change the `PORT`.
32+
33+
### Run docker-compose file
34+
35+
Use the `docker pull alexandrevryghem/guido-desktop:latest` command to get the latest version of the image (or build it
36+
yourself with the command `docker build -t guido-desktop .`).
37+
38+
To run the docker-compose file run the command `docker-compose up -d` and don't forget to change the `PORT`
39+
inside the `docker-compose.yml` file.
40+
41+
## How to use GitHub actions
42+
43+
### Deploy on GitHub pages
44+
45+
This action is automatically triggered when new code is pushed on `main` and will update the GitHub page, this doesn't
46+
require any additional setup.
47+
48+
### Build Docker image
49+
50+
This action is automatically triggered when new code is pushed on `main`, this will automatically build a Docker image
51+
and push it to your DockerHub repository. This image can be used to run the project on a production server.
52+
53+
⚠ Don't forget to create the `DOCKER_USERNAME` and `DOCKER_PASSWORD` secrets in the repository
54+
`Settings>Secrets>Actions`. The `DOCKER_PASSWORD` can also be an Access Token from DockerHub

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3.7'
2+
3+
services:
4+
website:
5+
image: alexandrevryghem/guido-desktop:latest
6+
container_name: guido-desktop
7+
networks:
8+
- guido
9+
ports:
10+
- PORT:80
11+
restart: always
12+
13+
networks:
14+
guido:
15+
name: guido

src/app/create-floor/create-floor.component.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ export class CreateFloorComponent implements AfterViewInit {
109109
}
110110

111111
/**
112-
* The **loadData()** function resets the whole map layer by removing all the D3 elements inside the
113-
* {@link SVGElement} and then reloading all the elements with D3 floorplan.
112+
* The **loadData()** function resets the object layer of the {@link GuidoMap} and then redraws them accordingly.
114113
*
115-
* @param floor The {@link Floor} who needs to be reloaded.
114+
* @param floor The {@link Floor} which needs to be redrawn.
116115
*/
117116
loadData(floor: Floor): void {
118117
let svg = d3.select("#demo" + this.floorNumber).select("svg");
@@ -137,7 +136,7 @@ export class CreateFloorComponent implements AfterViewInit {
137136

138137
/**
139138
* The **setEventListeners()** function adds {@link EventListener}s to update and remove {@link Polygon}s and
140-
* {@link GuidoNode}s.
139+
* {@link GuidoNode}s. The {@link MutationObserver} is also setup here.
141140
*
142141
* @param floor The {@link Floor} for which the {@link EventListener}s need to be added.
143142
*/
@@ -329,8 +328,8 @@ export class CreateFloorComponent implements AfterViewInit {
329328
}
330329

331330
/**
332-
* The **removeElement()** function removes the {@link Polygon}, {@link GuidoNode} or {@link Label} from the
333-
* {@link jsonData} and then reloads the floorplan again with the new {@link Overlays}.
331+
* The **removeElement()** function removes the {@link Polygon}, {@link GuidoNode} (points of interests, doors and
332+
* nodes) or {@link Label} from the {@link jsonData} and then reloads the floorplan again with the new {@link Overlays}.
334333
*
335334
* @param event The {@link Event} that triggered the delete action.
336335
*/
@@ -479,7 +478,8 @@ export class CreateFloorComponent implements AfterViewInit {
479478

480479
/**
481480
* The **changeVerticeCountOfPolygon()** function adds an extra vertice between the nearest {@link Polygon} point
482-
* and the neighboring point that is the closest to the {@link MouseEvent} click OR removes the clicked vertice.
481+
* and the neighboring point that is the closest to the {@link MouseEvent} click OR removes the nearest vertice of
482+
* the {@link Polygon} that has been clicked.
483483
*
484484
* @param event The {@link MouseEvent} that triggered this function.
485485
* @param isAdding The `boolean` indicating if a vertice needs to be added or removed.
@@ -629,7 +629,7 @@ export class CreateFloorComponent implements AfterViewInit {
629629
}
630630

631631
/**
632-
* The **getDoorDimensions()** function returns the door dimensions given his corners.
632+
* The **getDoorDimensions()** function returns the door dimensions given its corners.
633633
*
634634
* @param doorCoords The {@link Array} containing the {@link Point}s of the door.
635635
* @return A map containing the length and width of the door.
@@ -651,7 +651,6 @@ export class CreateFloorComponent implements AfterViewInit {
651651
* @param neighbors The {@link Array} of id's of all the neighbors.
652652
* @param self The instance of the {@link CreateFloorComponent}.
653653
*/
654-
655654
setNeighbors(id: number, neighbors: [string, boolean][], self: CreateFloorComponent = this): void {
656655
let newNeighbors: number[] = [];
657656
for (const neighbor of neighbors) {
@@ -764,8 +763,8 @@ export class CreateFloorComponent implements AfterViewInit {
764763
* @param name The name of the {@link Polygon}.
765764
* @param amountOfVertices The amount of vertices of the {@link Polygon}.
766765
* @param description The description of {@link Polygon}s purpose.
767-
* @param color The color of the {@link Polygon}, it is represented as an {@link Array} of `integers` between 0 and
768-
* 255.
766+
* @param color The color of the {@link Polygon}, it is represented as an {@link Array} of `integers` between
767+
* `0-255`.
769768
* @param self The instance of the {@link CreateFloorComponent}.
770769
*/
771770
createPolygon(id: number | null = null, name: string, amountOfVertices: number, description: string, color: [number, number, number] = [204, 204, 204], self: CreateFloorComponent = this): void {
@@ -880,7 +879,7 @@ export class CreateFloorComponent implements AfterViewInit {
880879
* {@link setNeighborMode}.
881880
*
882881
* @param id The unique identifier of the {@link Point} that needs to be found.
883-
* @return The point to which the line needs to be connected.
882+
* @return The {@link Point} to which the line needs to be connected.
884883
*/
885884
getConnectablePoint(id: number): Point {
886885
let elem = d3.select(`[id='${id}']`);

src/app/create-map/create-map.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare var d3: any;
1818
styleUrls: ['create-map.component.css']
1919
})
2020
/**
21-
* A component that can be used to create a {@link Map} using a {@link CreateFloorComponent} to represent each
21+
* A component that can be used to create a {@link Map} using {@link CreateFloorComponent}s to represent each
2222
* {@link Floor}.
2323
*/
2424
export class CreateMapComponent implements AfterViewInit {
@@ -65,7 +65,7 @@ export class CreateMapComponent implements AfterViewInit {
6565

6666
/**
6767
* The **moveFileInputField()** function moves the file {@link HTMLInputElement} from the first page to the taskbar
68-
* on the map editor screen (this way there is one {@link EventListener} less).
68+
* on the map editor screen (this way there is one less {@link EventListener}).
6969
*/
7070
moveFileInputField(): void {
7171
let toBeMoved = document.getElementById("uploadedMapFromComputer");
@@ -169,7 +169,7 @@ export class CreateMapComponent implements AfterViewInit {
169169

170170
/**
171171
* The **saveMapLocally()** function downloads the current state of the {@link jsonData} by downloading it as a
172-
* JSON file.
172+
* {@link JSON} file.
173173
*/
174174
saveMapLocally(): void {
175175
let downloadLink = document.createElement("a");
@@ -192,7 +192,7 @@ export class CreateMapComponent implements AfterViewInit {
192192
}
193193

194194
/**
195-
* The **saveMapRemotely()** function saves the {@link Map} {@link jsonData} on the server.
195+
* The **saveMapRemotely()** function saves the {@link GuidoMap}'s {@link jsonData} on the server.
196196
*/
197197
saveMapRemotely(): void {
198198
let copy = GuidoMap.copy(this.jsonData);
@@ -249,7 +249,7 @@ export class CreateMapComponent implements AfterViewInit {
249249
}
250250

251251
/**
252-
* The **deleteMap()** function deletes the {@link GuidoMap} with the given.
252+
* The **deleteMap()** function deletes the {@link GuidoMap} with the given {@link name}.
253253
*
254254
* @param name The name of the {@link GuidoMap} on the server that needs to be deleted.
255255
* @param self The instance of the {@link CreateMapComponent}.
@@ -272,7 +272,7 @@ export class CreateMapComponent implements AfterViewInit {
272272

273273
/**
274274
* The **toggleDeleteMode()** function switches the {@link deleteMode} to `true` when it was `false` and the other
275-
* way around, and it displays a warning message.
275+
* way around, and it also displays the necessary warning messages for the users.
276276
*/
277277
toggleDeleteMode(): void {
278278
this.jsonData.deleteMode = !this.jsonData.deleteMode;
@@ -386,7 +386,7 @@ export class CreateMapComponent implements AfterViewInit {
386386

387387
/**
388388
* The **toggleEditMode()** function switches the {@link editMode} to `true` when it was `false` and the other way
389-
* around, and it displays a warning message.
389+
* around, and it also displays the necessary warning messages for the users.
390390
*/
391391
toggleEditMode() {
392392
if (!this.jsonData.editMode) {

src/app/d3/floorplan.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import {Overlays} from "./overlays";
33

44
declare var d3: any
55

6+
/**
7+
* A class that manages and scales the different layers.
8+
*
9+
* Code partially from {@link https://dciarletta.github.io/d3-floorplan/}, completely refactored to TypeScript and
10+
* fitted to project.
11+
*/
612
export class Floorplan {
713
layers: any = [];
814
panZoomEnabled = true;
@@ -18,7 +24,7 @@ export class Floorplan {
1824
groups.each(function(data: any){
1925
if(!data) return;
2026

21-
// @ts-ignore
27+
// @ts-ignore
2228
let svg = d3.select(this);
2329

2430
// define common graphical elements
@@ -54,25 +60,25 @@ export class Floorplan {
5460

5561
// render and reorder layer controls
5662
let layerControls = controls.select("g.layer-controls").selectAll("g").data(self.layers, function (l: any) {
57-
return l.getId();
58-
});
63+
return l.getId();
64+
});
5965
let layerControlsEnter = layerControls.enter()
60-
.append("g").attr("class", "ui-active")
61-
.style("cursor", "pointer")
62-
.on("click", function (l: any) {
63-
// @ts-ignore
64-
let button = d3.select(this);
65-
let layer = svg.selectAll("g." + l.getId());
66-
if (button.classed("ui-active")) {
67-
layer.style("display", "none");
68-
button.classed("ui-active", false)
69-
.classed("ui-default", true);
70-
} else {
71-
layer.style("display", "inherit");
72-
button.classed("ui-active", true)
73-
.classed("ui-default", false);
74-
}
75-
});
66+
.append("g").attr("class", "ui-active")
67+
.style("cursor", "pointer")
68+
.on("click", function (l: any) {
69+
// @ts-ignore
70+
let button = d3.select(this);
71+
let layer = svg.selectAll("g." + l.getId());
72+
if (button.classed("ui-active")) {
73+
layer.style("display", "none");
74+
button.classed("ui-active", false)
75+
.classed("ui-default", true);
76+
} else {
77+
layer.style("display", "inherit");
78+
button.classed("ui-active", true)
79+
.classed("ui-default", false);
80+
}
81+
});
7682

7783
layerControlsEnter.append("rect")
7884
.attr("x", 0)

src/app/d3/imagelayer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
declare var d3: any;
22

3+
/**
4+
* A class that is used to display the background images of the {@link Floor}s.
5+
*
6+
* Code partially from {@link https://dciarletta.github.io/d3-floorplan/}, completely refactored to TypeScript and
7+
* fitted to project.
8+
*/
39
export class Imagelayer {
410
x = d3.scale.linear()
511
y = d3.scale.linear();
@@ -13,7 +19,7 @@ export class Imagelayer {
1319
// @ts-ignore
1420
let g = d3.select(this);
1521

16-
let imgs = g.selectAll("image").data(data, function(img: any) {
22+
let imgs = g.selectAll("image").data(data, function (img: any) {
1723
return img.url;
1824
})
1925

0 commit comments

Comments
 (0)