feat(front): cleaned hanling of whiteboard info
* Created an InfoService to centralized the logic * Added an info icon
This commit is contained in:
parent
5b4eeb7a98
commit
6475fdd5db
@ -1,3 +1,7 @@
|
|||||||
|
:root {
|
||||||
|
--selected-icon-bg-color: #dfdfdf;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
@ -78,7 +82,7 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.whiteboard-tool.active:not(:disabled) {
|
.whiteboard-tool.active:not(:disabled) {
|
||||||
background: #dfdfdf;
|
background: var(--selected-icon-bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#whiteboardThicknessSlider {
|
#whiteboardThicknessSlider {
|
||||||
@ -114,3 +118,17 @@ button {
|
|||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#displayWhiteboardInfoBtn.active {
|
||||||
|
background: var(--selected-icon-bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
#whiteboardInfoContainer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.displayNone {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
@ -224,6 +224,10 @@
|
|||||||
<button id="shareWhiteboardBtn" title="share whiteboard" type="button">
|
<button id="shareWhiteboardBtn" title="share whiteboard" type="button">
|
||||||
<i class="fas fa-share-square"></i>
|
<i class="fas fa-share-square"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button id="displayWhiteboardInfoBtn" title="Show whiteboard info" type="button">
|
||||||
|
<i class="fas fa-info-circle"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group minGroup">
|
<div class="btn-group minGroup">
|
||||||
@ -247,7 +251,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="position: absolute; bottom: 10px; right: 10px; display: none;">
|
<div id="whiteboardInfoContainer">
|
||||||
|
<p><b>Whiteboard information:</b></p>
|
||||||
<p># msg. sent to server: <i id="messageSentCount">0</i></p>
|
<p># msg. sent to server: <i id="messageSentCount">0</i></p>
|
||||||
<p># msg. received from server: <i id="messageReceivedCount">0</i></p>
|
<p># msg. received from server: <i id="messageReceivedCount">0</i></p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export const POINTER_EVENT_THRESHOLD_MIN_DIST_DELTA = 1; // 1px
|
export const POINTER_EVENT_THRESHOLD_MIN_DIST_DELTA = 1; // 1px
|
||||||
export const POINTER_EVENT_THRESHOLD_MIN_TIME_DELTA = 10; // 1ms
|
export const POINTER_EVENT_THRESHOLD_MIN_TIME_DELTA = 10; // 1ms
|
||||||
|
export const REFRESH_INFO_FREQUENCY = 5; // 5 times per second
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
faExpandArrowsAlt,
|
faExpandArrowsAlt,
|
||||||
faLock,
|
faLock,
|
||||||
faLockOpen,
|
faLockOpen,
|
||||||
|
faInfoCircle,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import {
|
import {
|
||||||
faSquare,
|
faSquare,
|
||||||
@ -50,7 +51,8 @@ library.add(
|
|||||||
faFileAlt,
|
faFileAlt,
|
||||||
faPlusSquare,
|
faPlusSquare,
|
||||||
faLock,
|
faLock,
|
||||||
faLockOpen
|
faLockOpen,
|
||||||
|
faInfoCircle
|
||||||
);
|
);
|
||||||
|
|
||||||
dom.i2svg();
|
dom.i2svg();
|
||||||
|
@ -7,6 +7,7 @@ import { dom } from "@fortawesome/fontawesome-svg-core";
|
|||||||
import pdfjsLib from "pdfjs-dist/webpack";
|
import pdfjsLib from "pdfjs-dist/webpack";
|
||||||
import shortcutFunctions from "./shortcutFunctions";
|
import shortcutFunctions from "./shortcutFunctions";
|
||||||
import ReadOnlyService from "./services/ReadOnlyService";
|
import ReadOnlyService from "./services/ReadOnlyService";
|
||||||
|
import InfoService from "./services/InfoService";
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
var whiteboardId = getQueryVariable("whiteboardid");
|
var whiteboardId = getQueryVariable("whiteboardid");
|
||||||
@ -48,10 +49,9 @@ function main() {
|
|||||||
signaling_socket.on("connect", function () {
|
signaling_socket.on("connect", function () {
|
||||||
console.log("Websocket connected!");
|
console.log("Websocket connected!");
|
||||||
|
|
||||||
let messageReceivedCount = 0;
|
|
||||||
signaling_socket.on("drawToWhiteboard", function (content) {
|
signaling_socket.on("drawToWhiteboard", function (content) {
|
||||||
whiteboard.handleEventsAndData(content, true);
|
whiteboard.handleEventsAndData(content, true);
|
||||||
$("#messageReceivedCount")[0].innerText = String(messageReceivedCount++);
|
InfoService.incrementNbMessagesReceived();
|
||||||
});
|
});
|
||||||
|
|
||||||
signaling_socket.on("refreshUserBadges", function () {
|
signaling_socket.on("refreshUserBadges", function () {
|
||||||
@ -84,7 +84,6 @@ function main() {
|
|||||||
$("#uploadWebDavBtn").show();
|
$("#uploadWebDavBtn").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
let messageSentCount = 0;
|
|
||||||
whiteboard.loadWhiteboard("#whiteboardContainer", {
|
whiteboard.loadWhiteboard("#whiteboardContainer", {
|
||||||
//Load the whiteboard
|
//Load the whiteboard
|
||||||
whiteboardId: whiteboardId,
|
whiteboardId: whiteboardId,
|
||||||
@ -97,7 +96,7 @@ function main() {
|
|||||||
// }
|
// }
|
||||||
content["at"] = accessToken;
|
content["at"] = accessToken;
|
||||||
signaling_socket.emit("drawToWhiteboard", content);
|
signaling_socket.emit("drawToWhiteboard", content);
|
||||||
$("#messageSentCount")[0].innerText = String(messageSentCount++);
|
InfoService.incrementNbMessagesSent();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -382,6 +381,10 @@ function main() {
|
|||||||
showBasicAlert("Copied Whiteboard-URL to clipboard.", { hideAfter: 2 });
|
showBasicAlert("Copied Whiteboard-URL to clipboard.", { hideAfter: 2 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#displayWhiteboardInfoBtn").click(() => {
|
||||||
|
InfoService.toggleDisplayInfo();
|
||||||
|
});
|
||||||
|
|
||||||
var btnsMini = false;
|
var btnsMini = false;
|
||||||
$("#minMaxBtn").click(function () {
|
$("#minMaxBtn").click(function () {
|
||||||
if (!btnsMini) {
|
if (!btnsMini) {
|
||||||
@ -597,8 +600,10 @@ function main() {
|
|||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
ReadOnlyService.activateReadOnlyMode();
|
ReadOnlyService.activateReadOnlyMode();
|
||||||
|
InfoService.hideInfo();
|
||||||
} else {
|
} else {
|
||||||
ReadOnlyService.deactivateReadOnlyMode();
|
ReadOnlyService.deactivateReadOnlyMode();
|
||||||
|
InfoService.displayInfo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
79
src/js/services/InfoService.js
Normal file
79
src/js/services/InfoService.js
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import { REFRESH_INFO_FREQUENCY } from "../const";
|
||||||
|
|
||||||
|
const REFRESH_INTERVAL = 1000 / REFRESH_INFO_FREQUENCY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class the handle the information about the whiteboard
|
||||||
|
*/
|
||||||
|
class InfoService {
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_infoAreDisplayed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_nbMessagesSent = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_nbMessagesReceived = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the interval Id
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_refreshInfoIntervalId = undefined;
|
||||||
|
|
||||||
|
incrementNbMessagesReceived() {
|
||||||
|
this._nbMessagesReceived++;
|
||||||
|
}
|
||||||
|
|
||||||
|
incrementNbMessagesSent() {
|
||||||
|
this._nbMessagesSent++;
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshDisplayedInfo() {
|
||||||
|
$("#messageReceivedCount")[0].innerText = String(this._nbMessagesReceived);
|
||||||
|
$("#messageSentCount")[0].innerText = String(this._nbMessagesSent);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayInfo() {
|
||||||
|
$("#whiteboardInfoContainer").toggleClass("displayNone", false);
|
||||||
|
$("#displayWhiteboardInfoBtn").toggleClass("active", true);
|
||||||
|
this._infoAreDisplayed = true;
|
||||||
|
|
||||||
|
this.refreshDisplayedInfo();
|
||||||
|
this._refreshInfoIntervalId = setInterval(() => {
|
||||||
|
// refresh only on a specific interval to reduce
|
||||||
|
// refreshing cost
|
||||||
|
this.refreshDisplayedInfo();
|
||||||
|
}, REFRESH_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
hideInfo() {
|
||||||
|
$("#whiteboardInfoContainer").toggleClass("displayNone", true);
|
||||||
|
$("#displayWhiteboardInfoBtn").toggleClass("active", false);
|
||||||
|
this._infoAreDisplayed = false;
|
||||||
|
if (this._refreshInfoIntervalId) {
|
||||||
|
clearInterval(this._refreshInfoIntervalId);
|
||||||
|
this._refreshInfoIntervalId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleDisplayInfo() {
|
||||||
|
if (this._infoAreDisplayed) {
|
||||||
|
this.hideInfo();
|
||||||
|
} else {
|
||||||
|
this.displayInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new InfoService();
|
Loading…
Reference in New Issue
Block a user