Skip to content

Commit 567ff29

Browse files
authored
Merge branch 'main' into persistance
2 parents 46240ed + 2170541 commit 567ff29

32 files changed

Lines changed: 1653 additions & 428 deletions

.github/workflows/docker-build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docker CI Build
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Build and start services with Docker Compose (CI Mode)
21+
run: |
22+
CI=true COMMAND="npx serve -s build" docker compose up -d --build
23+
24+
- name: Check running containers
25+
run: docker ps -a
26+
27+
- name: Check for container failures
28+
run: |
29+
docker compose logs --tail=50
30+
if [ "$(docker compose ps --format '{{.State}}' | grep -c exited)" -gt 0 ]; then
31+
echo "A container has exited with an error. Failing the workflow."
32+
exit 1
33+
fi

.github/workflows/docker-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker CI
1+
name: Docker CI LINT
22

33
on:
44
push:
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Build and start services with Docker Compose (CI Mode)
2121
run: |
22-
CI=true COMMAND="npx serve -s build" docker compose up -d --build
22+
CI=true LINT=true COMMAND="npx serve -s build" docker compose up -d --build
2323
2424
- name: Check running containers
2525
run: docker ps -a

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ WORKDIR /app
33
COPY my-app .
44
RUN npm ci
55
ARG CI=false
6+
ARG LINT=false
67
RUN if [ "$CI" = "true" ]; then npm run build; fi
7-
RUN if [ "$CI" = "true" ]; then npm run lint; fi
8+
RUN if [ "$LINT" = "true" ]; then npm run lint; fi
89
EXPOSE 5173
910
CMD ["npm", "run", "dev"]

my-app/firebase.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,12 @@ export async function getReviewsForCourse(courseCode) {
215215
const reviewsRef = ref(db, `reviews/${courseCode}`);
216216
const snapshot = await get(reviewsRef);
217217
if (!snapshot.exists()) return [];
218-
219218
const reviews = [];
220-
snapshot.forEach((childSnapshot) => {
219+
snapshot.forEach(childSnapshot => {
221220
reviews.push({
222-
id: childSnapshot.key, // Firebase-generated unique key
223-
userName: childSnapshot.val().userName,
224-
text: childSnapshot.val().text,
221+
id: childSnapshot.key,
222+
...childSnapshot.val()
225223
});
226224
});
227225
return reviews;
228-
}
226+
}

my-app/src/model.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,32 @@ import { addCourse, addReviewForCourse, getReviewsForCourse } from "../firebase"
33

44
export const model = {
55
user: undefined,
6+
//add searchChange: false, //this is for reworking the searchbar presenter, so that it triggers as a model,
7+
//instead of passing searchcouses lambda function down into the searchbarview.
68
currentSearch: [],
79
currentSearchText: "",
810
scrollPosition: 0,
911
courses: [],
1012
favourites: [],
13+
isReady: false,
14+
filtersChange: false,
15+
filtersCalculated: false,
16+
filteredCourses: [],
17+
filterOptions: {
18+
applyTranscriptFilter: true,
19+
eligibility: "weak", //the possible values for the string are: "weak"/"moderate"/"strong"
20+
applyLevelFilter: true,
21+
level: [], //the possible values for the array are: "PREPARATORY", "BASIC", "ADVANCED", "RESEARCH"
22+
applyLanguageFilter: true,
23+
language: "none", //the possible values for the string are: "none"/"english"/"swedish"/"both"
24+
applyLocationFilter:true,
25+
location: [], //the possible values for the array are: 'KTH Campus', 'KTH Kista', 'AlbaNova', 'KTH Flemingsberg', 'KTH Solna', 'KTH Södertälje', 'Handelshögskolan', 'KI Solna', 'Stockholms universitet', 'KONSTFACK'
26+
applyCreditsFilter:true,
27+
creditMin: 0,
28+
creditMax: 45,
29+
applyDepartmentFilter:false,
30+
department: []
31+
},
1132

1233
setUser(user) {
1334
if (!this.user)
@@ -76,7 +97,6 @@ export const model = {
7697
this.addCourse(course);
7798
});
7899
},
79-
80100
//for reviews
81101
async addReview(courseCode, review) {
82102
try {
@@ -95,4 +115,53 @@ export const model = {
95115
return [];
96116
}
97117
},
118+
//for filters
119+
120+
setFiltersChange() {
121+
this.filtersChange = true;
122+
},
123+
124+
setFiltersCalculated() {
125+
this.filtersCalculated = true;
126+
},
127+
128+
updateLevelFilter(level) {
129+
this.filterOptions.level = level;
130+
},
131+
updateLanguageFilter(languages) {
132+
this.filterOptions.language = languages;
133+
},
134+
updateLocationFilter(location) {
135+
this.filterOptions.location = location;
136+
},
137+
updateCreditsFilter(creditLimits) {
138+
this.filterOptions.creditMin = creditLimits[0];
139+
this.filterOptions.creditMax = creditLimits[1];
140+
},
141+
updateTranscriptElegibilityFilter(eligibility) {
142+
this.filterOptions.eligibility = eligibility;
143+
},
144+
145+
//setters for the filter options
146+
setApplyTranscriptFilter(transcriptFilterState) {
147+
this.filterOptions.applyTranscriptFilter = transcriptFilterState;
148+
},
149+
setApplyLevelFilter(levelFilterState) {
150+
this.filterOptions.applyLevelFilter = levelFilterState;
151+
},
152+
setApplyLanguageFilter(languageFilterState) {
153+
this.filterOptions.applyLanguageFilter = languageFilterState;
154+
},
155+
setApplyLocationFilter(locationFilterState) {
156+
this.filterOptions.applyLocationFilter = locationFilterState;
157+
},
158+
setApplyCreditsFilter(creditsFilterState) {
159+
this.filterOptions.applyCreditsFilter = creditsFilterState;
160+
},
161+
// setApplyDepartmentFilter(departmentFilterState) {
162+
// this.filterOptions.applyDepartmentFilter = departmentFilterState;
163+
// },
164+
165+
166+
98167
};

my-app/src/pages/App.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import React from 'react';
22
import { SidebarPresenter } from '../presenters/SidebarPresenter.jsx';
33
import { SearchbarPresenter } from '../presenters/SearchbarPresenter.jsx';
44
import { ListViewPresenter } from '../presenters/ListViewPresenter.jsx';
5+
import { FilterPresenter } from "../presenters/FilterPresenter.jsx";
56
import { Routes, Route } from 'react-router-dom';
67
import SharedView from '../pages/SharedView.jsx';
78
import { model } from '/src/model.js';
89

910
function MainAppLayout({ model }) {
1011
return (
1112
<div className="flex h-screen w-screen overflow-hidden">
12-
<div className="w-1/4 h-full bg-gradient-to-t from-[#4f3646] to-[#6747c0]">
13+
<FilterPresenter model={model} />
14+
<div className="flex-auto w-40% h-full bg-gradient-to-t from-[#4f3646] to-[#6747c0]">
1315
<SidebarPresenter model={model} />
1416
</div>
1517
<div className="w-3/4 h-full flex flex-col">

0 commit comments

Comments
 (0)