Add inbox indicator (RRS-2)
diff --git a/scripts/core.js b/scripts/core.js
index 116b21e..3fbf9d7 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -1,7 +1,7 @@
/**
* @file DTPS Core functions and module loader
* @author jottocraft
- * @version v3.6.0
+ * @version v3.7.0
*
* @copyright Copyright (c) 2018-2022 jottocraft
* @license MIT
@@ -38,8 +38,8 @@
* @property {string} cblSpec A URL to the CBL specification document used by dangerous Power+ CBL features
*/
var dtps = {
- ver: 360,
- readableVer: "v3.6.0",
+ ver: 370,
+ readableVer: "v3.7.0",
env: new URL(window.dtpsBaseURL || "https://powerplus.app").hostname == "localhost" ? "dev" : window.jottocraftSatEnv || "prod",
classes: [],
baseURL: window.dtpsBaseURL || "https://powerplus.app",
@@ -759,6 +759,19 @@
//Changelog will only show if the release notes are on GitHub
dtps.changelog(Number(window.localStorage.dtps));
}
+
+ //Render inbox
+ if (dtpsLMS.fetchUnreadMessageCount) {
+ dtpsLMS.fetchUnreadMessageCount().then(count => {
+ jQuery("#dtpsUnreadCount span").text(count);
+
+ if (Number(count) > 0) {
+ jQuery("#dtpsUnreadCount").addClass("active");
+ }
+
+ jQuery("#dtpsUnreadCount").show();
+ });
+ }
}).catch(function (err) {
//Web request error
console.error("[DTPS] Error fetching user and classes at dtps.init", err);
@@ -1594,6 +1607,10 @@
</div>
<div class="items" style="float: right;">
+ <a style="display: none;" id="dtpsUnreadCount" target="_blank" href="/conversations" class="navitem">
+ <i class="fluid-icon">inbox</i>
+ <span></span>
+ </a>
<div class="navitem" onclick="dtps.settings();">
<i class="fluid-icon">settings</i>
<span>Settings</span>
@@ -2220,6 +2237,7 @@
* @property {string} logo LMS logo image URL
* @property {string} url URL to the LMS' website
* @property {string} source URL to the LMS integration's source code
+ * @property {string} [inboxURL] URL to the LMS inbox. Required only if dtpsLMS.fetchUnreadMessageCount count is implemented
* @property {boolean} [dtech] True if this LMS is d.tech
* @property {boolean} [institutionSpecific] True if the LMS is designed for a specific institution instead of a broader LMS
* @property {boolean|string[]} [useRubricGrades] True if DTPS should use rubric grades for assignments. If an array is provided, only assignments whose class ID is in the array will use rubric grades.
@@ -2236,6 +2254,13 @@
*/
/**
+ * @name dtpsLMS.fetchUnreadMessageCount
+ * @description [OPTIONAL] Fetches the unread message count for the current user
+ * @kind function
+ * @return {Promise<string>} A promise which resolves to a string depicting the count of unread messages
+ */
+
+/**
* @name dtpsLMS.fetchClasses
* @description [REQUIRED] Fetches class data from the LMS
* @kind function
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index d3b40fe..a06a443 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -15,6 +15,7 @@
legalName: "Canvas LMS or Instructure Inc.",
description: "Power+ integration for Canvas LMS",
url: "https://www.instructure.com/canvas/",
+ inboxURL: "/conversations",
logo: "https://i.imgur.com/rGjNVoc.png",
source: "https://bitbucket.org/jottocraft/dtps/src/main/scripts/lms/canvas.js",
genericGradebook: true
@@ -96,6 +97,15 @@
})
}
+//Fetch unread message count from Canvas
+dtpsLMS.fetchUnreadMessageCount = function () {
+ return new Promise(function (resolve, reject) {
+ dtpsLMS.fetchWrapper("/api/v1/conversations/unread_count", { headers: dtpsLMS.commonHeaders }).then(response => response.json()).then(data => {
+ resolve(data.unread_count);
+ }).catch(reject);
+ });
+}
+
//Fetch class data from Canvas
dtpsLMS.fetchClasses = function (userID) {
return new Promise(function (resolve, reject) {
diff --git a/ui/dtps.css b/ui/dtps.css
index f6607a8..a98ae7b 100644
--- a/ui/dtps.css
+++ b/ui/dtps.css
@@ -32,13 +32,13 @@
}
[data-theme-type=light] {
- --theme: #cc9e54 !important;
- --themeText: #261900 !important;
+ --theme: #af9018 !important;
+ --themeText: #fdf8f2 !important;
}
[data-theme-type=dark] {
- --theme: #cc9e54 !important;
- --themeText: #261900 !important;
+ --theme: #d8ae44 !important;
+ --themeText: #22201a !important;
}
body:not(.ugShow) .assessmentWrapper.ungraded {
diff --git a/ui/fluid.css b/ui/fluid.css
index f6a4444..67fd39f 100644
--- a/ui/fluid.css
+++ b/ui/fluid.css
@@ -1539,28 +1539,29 @@
.navbar .navitem {
display: inline-block;
cursor: pointer;
- padding: 0px 10px;
+ padding: 0px 8px;
height: 32px;
line-height: 32px;
- margin: 2px 4px;
- color: var(--secText);
+ margin: 2px;
+ color: var(--lightText);
transition: color 0.2s;
user-select: none;
+ border-radius: 4px;
}
.navbar .navitem.active {
- color: var(--text);
+ color: var(--themeText);
+ background-color: var(--theme);
}
.navbar .navitem.active span, .navbar .navitem.active i {
font-weight: bold;
- text-shadow: var(--lightShadow);
}
.navbar .navitem i {
vertical-align: middle;
margin-right: 2px;
- font-size: 24px;
+ font-size: 20px;
}
.navbar .navitem span {