summaryrefslogtreecommitdiff
path: root/contents/ui/configGeneral.qml
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-04-09 15:22:17 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-04-09 15:22:17 +0800
commit0a2bf162712d3c5d468b8b93815e6e2f161d555f (patch)
tree018c704e40d6bae89dc3ac95c1342dd01ca47558 /contents/ui/configGeneral.qml
parent136be4b97cb759d8dc5f63b519fcb09a0fd8638b (diff)
Rename General config group to Canvas, allow hiding submitted assignments
Diffstat (limited to 'contents/ui/configGeneral.qml')
-rw-r--r--contents/ui/configGeneral.qml67
1 files changed, 4 insertions, 63 deletions
diff --git a/contents/ui/configGeneral.qml b/contents/ui/configGeneral.qml
index fc64389..479b9e6 100644
--- a/contents/ui/configGeneral.qml
+++ b/contents/ui/configGeneral.qml
@@ -4,70 +4,11 @@ import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami
Kirigami.FormLayout {
- property alias cfg_canvasUrl: canvasUrl.text
- property alias cfg_oauth2Token: oauth2Token.text
- property alias cfg_courses: courses.text
+ property alias cfg_showSubmittedAssignments: showSubmittedAssignments.checked
- TextField {
- id: canvasUrl
- Kirigami.FormData.label: i18n("Canvas URL:")
- placeholderText: i18n("https://your.canvas.url")
- }
-
- TextField {
- id: oauth2Token
- Kirigami.FormData.label: i18n("OAuth2 Token:")
- placeholderText: i18n("Generate in Canvas web interface")
- }
-
- function fetchCourses() {
- courses.clear()
- fetchCoursesStatus.text = i18n("Fetching…")
- let xhr = new XMLHttpRequest()
- xhr.open("GET", `${canvasUrl.text.replace(/\/$/, "")}/api/v1/courses?per_page=100`)
- xhr.setRequestHeader("Authorization", `Bearer ${oauth2Token.text}`)
- xhr.onload = () => {
- if (xhr.status == 200) {
- try {
- let json = JSON.parse(xhr.responseText)
- for (let c of json) {
- courses.append(`${c.id} ${c.course_code}`)
- }
- fetchCoursesStatus.text = i18n(
- "Done! You can remove courses you don't wish to see on your desktop from the list."
- )
- } catch (e) {
- if (e instanceof SyntaxError) {
- console.error(`Cannot parse response for ${path} as JSON:\n${xhr.responseText}`)
- fetchgCoursesStatus.text = i18n("Cannot parse API response")
- } else { throw e }
- }
- } else {
- console.error(`XHR failed when retrieving /courses (status ${xhr.status}):\n${xhr.responseText}`)
- fetchCoursesStatus.text = i18n("API call failed (HTTP status %1)", xhr.status)
- }
- }
- xhr.send()
- }
-
- ScrollView {
- Layout.fillWidth: true
- Kirigami.FormData.label: i18n("Courses:")
- TextArea {
- Layout.fillWidth: true
- id: courses
- placeholderText: i18n("Click Fetch courses for a full list")
- }
- }
-
- Button {
- text: "Fetch courses"
- onClicked: fetchCourses()
- }
-
- Label {
- id: fetchCoursesStatus
- text: ""
+ CheckBox {
+ id: showSubmittedAssignments
+ text: i18n("Show submitted assignments")
}
}