blob: ee8bbdd17f1a48811dcaef52bcbe7fb69839a4d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
import org.kde.plasma.networkmanagement as PlasmaNM
import org.kde.kirigami as Kirigami
import "kanvas.js" as Kanvas
PlasmoidItem {
width: Kirigami.Units.gridUnit * 20
height: Kirigami.Units.gridUnit * 40
clip: true
readonly property string canvasUrl: plasmoid.configuration.canvasUrl
readonly property string apiEndpoint: `${canvasUrl.replace(/\/$/, "")}/api/v1`
readonly property string oauth2Token: plasmoid.configuration.oauth2Token
readonly property string authHeader: `Bearer ${oauth2Token}`
PlasmaNM.NetworkStatus {
id: networkStatus
}
// sync on initialization
Component.onCompleted: Kanvas.syncCanvas()
// update every refreshInterval minutes
Timer {
interval: plasmoid.configuration.refreshInterval * 60 * 1000
running: true
repeat: true
onTriggered: Kanvas.syncCanvas()
}
// top level layout
ColumnLayout {
id: main
anchors.fill: parent
PlasmaExtras.Heading {
level: 1
text: i18n("Kanvas")
}
PlasmaExtras.Heading {
level: 2
text: i18n("Announcements")
}
ListModel {
id: announcementsModel
/* Uncomment when debugging layout
ListElement {
type: "announcement"
course: "CS101"
title: "Code quality"
message: "Code may be a little messy…"
url: "https://xkcd.com/1513"
important: true
finished: false
activityId: 0
}
*/
}
ScrollView {
implicitHeight: Kirigami.Units.gridUnit * 20
Layout.margins: Kirigami.Units.smallSpacing
Layout.fillWidth: true
Layout.fillHeight: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ListView {
id: announcementsListView
Layout.fillWidth: true
spacing: 0
delegate: ActivityView {}
model: announcementsModel
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: announcementsModel.count == 0
iconName: "mail-read-symbolic"
text: i18n("No announcements")
}
}
}
PlasmaExtras.Heading {
level: 2
text: i18n("Assignments")
}
ListModel {
id: assignmentsModel
/* Uncomment when debugging layout
ListElement {
type: "assignment"
course: "EE201"
title: "Circuit diagram"
dueAt: "2022-04-10T15:59:59Z"
submitted: true
url: "https://xkcd.com/730"
important: true
finished: true
activityId: 1
}
*/
}
ScrollView {
implicitHeight: Kirigami.Units.gridUnit * 20
Layout.margins: Kirigami.Units.smallSpacing
Layout.fillWidth: true
Layout.fillHeight: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ListView {
id: assignmentsListView
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
delegate: ActivityView {}
model: assignmentsModel
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: assignmentsModel.count == 0
iconName: "mail-read-symbolic"
text: i18n("No assignments")
}
}
}
RowLayout {
PlasmaComponents3.Button {
icon.name: "view-refresh"
text: i18n("Refresh")
onClicked: Kanvas.syncCanvas()
}
// PlasmaComponents3.Label {
// id: offlineLabel
// visible: networkStatus.networkStatus != "Connected"
// text: i18n("Network disconnected")
// color: PlasmaCore.Theme.negativeTextColor
// }
}
}
}
|