diff options
Diffstat (limited to 'contents/ui/main.qml')
-rw-r--r-- | contents/ui/main.qml | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 4872c3c..bc49207 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -47,22 +47,41 @@ Item { ) announcementsModel.clear() + assignmentsModel.clear() for (let course of courses) { callApi(`/courses/${course[0]}/activity_stream`, 10, activityStream => { // Get activity stream for each course - activityStream.forEach((activity, index) => { + let announcementCount = 0 + let assignmentCount = 0 + activityStream.forEach(activity => { if (activity.type == "Announcement") { announcementsModel.append({ - index: index, + type: "announcement", + activityId: activity.id, + index: announcementCount, course: course[1], title: activity.title, url: activity.html_url, - important: plasmoid.configuration.importantAnnouncements.includes( - activity.announcement_id.toString() + important: plasmoid.configuration.importantActivities.includes( + activity.id.toString() ), - announcementId: activity.announcement_id }) + announcementCount++ + } else if (activity.type == "Submission") { + assignmentsModel.append({ + type: "assignment", + activityId: activity.id, + index: assignmentCount, + course: course[1], + title: activity.title, + due: activity.assignment.due_at, + url: activity.html_url, + important: plasmoid.configuration.importantActivities.includes( + activity.id.toString() + ), + }) + assignmentCount++ } }) }) @@ -93,11 +112,13 @@ Item { ListModel { id: announcementsModel ListElement { + type: "announcement" + index: 0 course: "CS101" - title: "Title of the announcement" + title: "Title" url: "https://xkcd.com" important: true - announcementId: 0 + activityId: 0 } } @@ -106,16 +127,48 @@ Item { Layout.margins: PlasmaCore.Units.smallSpacing Layout.fillWidth: true Layout.fillHeight: true - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ListView { Layout.fillWidth: true - delegate: AnnouncementView {} + delegate: ActivityView {} model: announcementsModel } } + PlasmaExtras.Heading { + level: 2 + text: "Assignments" + } + + ListModel { + id: assignmentsModel + ListElement { + type: "assignment" + index: 0 + course: "EE210" + title: "Title" + due: "2022-12-31T23:59:59Z" + url: "https://xkcd.com" + important: true + activityId: 1 + } + } + + ScrollView { + implicitHeight: PlasmaCore.Units.gridUnit * 20 + Layout.margins: PlasmaCore.Units.smallSpacing + Layout.fillWidth: true + Layout.fillHeight: true + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + + ListView { + Layout.fillWidth: true + delegate: ActivityView {} + model: assignmentsModel + } + } + PlasmaComponents3.Button { icon.name: "view-refresh" text: i18n("Refresh") |