Skip to content

Commit

Permalink
Merge pull request #71 from acmauth/consistencyTweaks
Browse files Browse the repository at this point in the history
Minor consistency tweaks for recent grades and also notifications
  • Loading branch information
neron-png authored Feb 27, 2024
2 parents 1c4c15a + 91f1aaf commit 3892c6d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 31 deletions.
2 changes: 0 additions & 2 deletions src/lib/components/grades/gradeCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ h2 {
.danger {
color: var(--app-color-orange-dark);
}
.examPeriod{
Expand Down
78 changes: 55 additions & 23 deletions src/lib/components/recentGrades/recentGradesCard.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script>
// @ts-nocheck
import { onMount } from "svelte";
import { createEventDispatcher } from 'svelte';
import AppCard from '$shared/AppCard.svelte';
export let subject;
let dispatch = createEventDispatcher();
Expand Down Expand Up @@ -70,39 +73,68 @@
</script>

<ion-card class="grade-card grade-card-{subject.courseExam.id}" href={`/courses/${subject.course.id}`} on:touchstart={handleTouchStart} on:touchmove={handleTouchMove} on:touchend={handleTouchEnd}>
<ion-card-content>
<div style="display:flex; flex-direction: row;justify-content: space-between;">

<ion-label class="ion-text-wrap">{subject.course.name}</ion-label>
<ion-card href={`/courses/${subject.course.id}`} class="grade-card grade-card-{subject.courseExam.id}" on:touchstart={handleTouchStart} on:touchmove={handleTouchMove} on:touchend={handleTouchEnd}>
<ion-item lines="none" class="ion-no-padding">
<div class="containerFlex">
<div class="titlesFlex">
<ion-label class="ion-text-wrap courseTitle">{subject.course.name}</ion-label>
<ion-label class="subjectID">{subject.course.id}</ion-label>
</div>
{#if subject.examGrade * 10 >= 5}
<ion-text class="ion-padding-left ion-padding-start" color="success">
<h2>{subject.formattedGrade}</h2>
</ion-text>
{:else}
<ion-text class="ion-padding-left ion-padding-start" color="danger">
<h2>{subject.formattedGrade}</h2>
</ion-text>
{/if}

</div>
<ion-label>{subject.course.id}</ion-label>
</ion-card-content>
<ion-text class="success gradeNumber">
<h2>{subject.formattedGrade}</h2>
</ion-text>
{:else}
<ion-text class="danger gradeNumber">
<h2>{subject.formattedGrade}</h2>
</ion-text>
{/if}
</div>
</ion-item>
</ion-card>



<style>
.gradeNumber h2{
margin: 0 !important;
}
.containerFlex {
display: flex;
align-items: center;
justify-content: space-between;
min-width: 100%;
}
h2 {
font-size: 1.5rem;
font-weight: bold;
}
.courseTitle {
font-size: 1rem;
}
.grade-card {
/* border-radius: 15px;
position: relative; */
margin: 0;
padding: 1rem;
transition: transform 0.3s ease;
/* touch-action: pan-x; */
}
/* .grade-card.swiping {
pointer-events: none;
} */
.success {
color: var(--app-color-green-dark);
}
.danger {
color: var(--app-color-orange-dark);
}
.subjectID{
font-size: 0.8rem;
color: grey
}
</style>
4 changes: 2 additions & 2 deletions src/lib/functions/degreeCalculator/fetchData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { universisGet } from "$lib/dataService";
import { neoUniversisGet } from "$lib/dataService";

/**
* @param {{title: any;id: any;semester: any;grade: any;input_grade: string;ects: any;}[]} unpassed_courses
Expand All @@ -8,7 +8,7 @@ export async function fetchData(unpassed_courses, sums)
{
let not_passed_all_courses = false;

let courses = (await universisGet("students/me/courses?$top=-1")).value;
let courses = (await neoUniversisGet("students/me/courses?$top=-1", {lifetime: 60 * 5})).value;


courses.sort((/** @type {{ semester: { id: number; }; }} */ a, /** @type {{ semester: { id: number; }; }} */ b) => a.semester.id - b.semester.id);
Expand Down
9 changes: 5 additions & 4 deletions src/routes/pages/notifications/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ async function getElearningNotifications(refresh: boolean = false) {
}
}
];

const response_Read = await neoElearningGet(body_Read, {forceFresh: refresh});
const response_Unread = await neoElearningGet(body_Unread, {forceFresh: refresh});
const options = {forceFresh: refresh, lifetime: 60 * 15}
const response_Read = await neoElearningGet(body_Read, options);
const response_Unread = await neoElearningGet(body_Unread, options);

let messages: elearningMessages;

Expand Down Expand Up @@ -93,7 +93,8 @@ async function getElearningNotifications(refresh: boolean = false) {
}

async function getUniversisNotifications(refresh: boolean = false) {
let messages: messages = await neoUniversisGet("students/me/messages?$top=3", {forceFresh: refresh});//&$filter=dateReceived eq null");
const options = {forceFresh: refresh, lifetime: 60 * 60 * 24}
let messages: messages = await neoUniversisGet("students/me/messages?$top=3", options);//&$filter=dateReceived eq null");


let cleanMessages = messages.value.map((message) => {
Expand Down

0 comments on commit 3892c6d

Please sign in to comment.