aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-01-18 12:10:47 -0500
committerbobzel <zzzman@gmail.com>2022-01-18 12:10:47 -0500
commit66fb0e4bbf88a5e9bcb5869dd7c8b8a7714de024 (patch)
treea73266808167bdfc057cee44bb8d40c31b993edb /src
parent4cdfa6c29701d372064eb4dc612807a27cb19857 (diff)
fixed warnings. display last user to edit db. fixed /activity to show only users with a connected socket. fixed toggle "Overlay" button to toggle its background based on overlay state.
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/util/CurrentUserUtils.ts2
-rw-r--r--src/client/views/InkStrokeProperties.ts2
-rw-r--r--src/client/views/MainView.tsx10
-rw-r--r--src/client/views/PropertiesView.tsx6
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx6
-rw-r--r--src/client/views/nodes/MapBox/MapBox.tsx34
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx2
-rw-r--r--src/fields/Doc.ts2
-rw-r--r--src/server/ApiManagers/UserManager.ts10
-rw-r--r--src/server/websocket.ts13
11 files changed, 52 insertions, 37 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 80c3f9168..df573a377 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1426,7 +1426,7 @@ export namespace DocUtils {
function ConvertDMSToDD(degrees: number, minutes: number, seconds: number, direction: string) {
var dd = degrees + minutes / 60 + seconds / (60 * 60);
- if (direction == "S" || direction == "W") {
+ if (direction === "S" || direction === "W") {
dd = dd * -1;
} // Don't do anything for N or E
return dd;
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 90b43c415..a8b0da369 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -1164,7 +1164,7 @@ export class CurrentUserUtils {
dontUndo: true,
title,
color: Colors.WHITE,
- backgroundColor: "transparent",
+ backgroundColor: checkResult ? ComputedField.MakeFunction(checkResult) as any : "transparent",
_dropAction: "alias",
hidden: hidden ? ComputedField.MakeFunction(hidden) as any : undefined,
_removeDropProperties: new List<string>(["dropAction", "_stayInCollection"]),
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index cab4e1216..41cace1e3 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -251,7 +251,7 @@ export class InkStrokeProperties {
samplesLeft.push(new Point(pt.x, pt.y));
}
}
- var { finalCtrls, error } = FitOneCurve(samplesLeft, { X: startDir.x, Y: startDir.y }, { X: endDir.x, Y: endDir.y });
+ var { finalCtrls } = FitOneCurve(samplesLeft, { X: startDir.x, Y: startDir.y }, { X: endDir.x, Y: endDir.y });
for (var i = nearestSeg / 4; i < splicedPoints.length / 4; i++) {
const bez = new Bezier(splicedPoints.slice(i * 4, i * 4 + 4).map(p => ({ x: p.X, y: p.Y })));
if (i === nearestSeg / 4) startDir = bez.derivative(nearestT);
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 0bd6c9166..1478da1f7 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -166,7 +166,7 @@ export class MainView extends React.Component {
}
library.add(fa.faEdit, fa.faTrash, fa.faTrashAlt, fa.faShare, fa.faDownload, fa.faExpandArrowsAlt, fa.faLayerGroup, fa.faExternalLinkAlt, fa.faCalendar,
- fa.faSquare, far.faSquare, fa.faConciergeBell, fa.faWindowRestore, fa.faFolder, fa.faMapPin, fa.faMapMarker, fa.faFingerprint, fa.faCrosshairs, fa.faDesktop, fa.faUnlock,
+ fa.faSquare, far.faSquare as any, fa.faConciergeBell, fa.faWindowRestore, fa.faFolder, fa.faMapPin, fa.faMapMarker, fa.faFingerprint, fa.faCrosshairs, fa.faDesktop, fa.faUnlock,
fa.faLock, fa.faLaptopCode, fa.faMale, fa.faCopy, fa.faHandPointLeft, fa.faHandPointRight, fa.faCompass, fa.faSnowflake, fa.faMicrophone, fa.faKeyboard,
fa.faQuestion, fa.faTasks, fa.faPalette, fa.faAngleLeft, fa.faAngleRight, fa.faBell, fa.faCamera, fa.faExpand, fa.faCaretDown, fa.faCaretLeft, fa.faCaretRight,
fa.faCaretSquareDown, fa.faCaretSquareRight, fa.faArrowsAltH, fa.faPlus, fa.faMinus, fa.faTerminal, fa.faToggleOn, fa.faFile, fa.faLocationArrow,
@@ -178,10 +178,10 @@ export class MainView extends React.Component {
fa.faTimesCircle, fa.faThumbtack, fa.faTree, fa.faTv, fa.faUndoAlt, fa.faVideo, fa.faAsterisk, fa.faBrain, fa.faImage, fa.faPaintBrush, fa.faTimes,
fa.faEye, fa.faArrowsAlt, fa.faQuoteLeft, fa.faSortAmountDown, fa.faAlignLeft, fa.faAlignCenter, fa.faAlignRight, fa.faHeading, fa.faRulerCombined,
fa.faFillDrip, fa.faLink, fa.faUnlink, fa.faBold, fa.faItalic, fa.faClipboard, fa.faUnderline, fa.faStrikethrough, fa.faSuperscript, fa.faSubscript,
- fa.faIndent, fa.faEyeDropper, fa.faPaintRoller, fa.faBars, fa.faBrush, fa.faShapes, fa.faEllipsisH, fa.faHandPaper, fa.faMap, fa.faUser, faHireAHelper,
- fa.faTrashRestore, fa.faUsers, fa.faWrench, fa.faCog, fa.faMap, fa.faBellSlash, fa.faExpandAlt, fa.faArchive, fa.faBezierCurve, fa.faCircle, far.faCircle,
- fa.faLongArrowAltRight, fa.faPenFancy, fa.faAngleDoubleRight, faBuffer, fa.faExpand, fa.faUndo, fa.faSlidersH, fa.faAngleDoubleLeft, fa.faAngleUp,
- fa.faAngleDown, fa.faPlayCircle, fa.faClock, fa.faRocket, fa.faExchangeAlt, faBuffer, fa.faHashtag, fa.faAlignJustify, fa.faCheckSquare, fa.faListUl,
+ fa.faIndent, fa.faEyeDropper, fa.faPaintRoller, fa.faBars, fa.faBrush, fa.faShapes, fa.faEllipsisH, fa.faHandPaper, fa.faMap, fa.faUser, faHireAHelper as any,
+ fa.faTrashRestore, fa.faUsers, fa.faWrench, fa.faCog, fa.faMap, fa.faBellSlash, fa.faExpandAlt, fa.faArchive, fa.faBezierCurve, fa.faCircle, far.faCircle as any,
+ fa.faLongArrowAltRight, fa.faPenFancy, fa.faAngleDoubleRight, faBuffer as any, fa.faExpand, fa.faUndo, fa.faSlidersH, fa.faAngleDoubleLeft, fa.faAngleUp,
+ fa.faAngleDown, fa.faPlayCircle, fa.faClock, fa.faRocket, fa.faExchangeAlt, fa.faHashtag, fa.faAlignJustify, fa.faCheckSquare, fa.faListUl,
fa.faWindowMinimize, fa.faWindowRestore, fa.faTextWidth, fa.faTextHeight, fa.faClosedCaptioning, fa.faInfoCircle, fa.faTag, fa.faSyncAlt, fa.faPhotoVideo,
fa.faArrowAltCircleDown, fa.faArrowAltCircleUp, fa.faArrowAltCircleLeft, fa.faArrowAltCircleRight, fa.faStopCircle, fa.faCheckCircle, fa.faGripVertical,
fa.faSortUp, fa.faSortDown, fa.faTable, fa.faTh, fa.faThList, fa.faProjectDiagram, fa.faSignature, fa.faColumns, fa.faChevronCircleUp, fa.faUpload, fa.faBorderAll,
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index f38341603..3e7b0bd0f 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -1,6 +1,6 @@
import React = require("react");
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { faAnchor, faArrowRight } from '@fortawesome/free-solid-svg-icons'
+import { faAnchor, faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { Checkbox, Tooltip } from "@material-ui/core";
import { intersection } from "lodash";
import { action, autorun, computed, Lambda, observable } from "mobx";
@@ -1218,7 +1218,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
onChange={e => this.handleLinkRelationshipChange(e.currentTarget.value)}
className="text"
type="text"
- />
+ />;
}
@computed
@@ -1232,7 +1232,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
onChange={e => this.handleDescriptionChange(e.currentTarget.value)}
className="text"
type="text"
- />
+ />;
}
/**
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
index c35bb3581..f5a5492e3 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
@@ -150,8 +150,8 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
}
onClickLine = () => {
- SelectionManager.SelectSchemaViewDoc(this.props.LinkDocs[0], true)
- this.toggleProperties()
+ SelectionManager.SelectSchemaViewDoc(this.props.LinkDocs[0], true);
+ this.toggleProperties();
}
// componentToHex = (c: number) => {
@@ -249,7 +249,7 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
//thickness varies linearly from 3px to 12px for increasing link count
const strokeWidth = linkSize === -1 ? "3px" : Math.floor(2 + 10 * (linkSize / Math.max(...linkRelationshipSizes))) + "px";
- if (this.props.LinkDocs[0].displayArrow == undefined) {
+ if (this.props.LinkDocs[0].displayArrow === undefined) {
this.props.LinkDocs[0].displayArrow = false;
}
diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx
index e80ad8acd..50444c73a 100644
--- a/src/client/views/nodes/MapBox/MapBox.tsx
+++ b/src/client/views/nodes/MapBox/MapBox.tsx
@@ -57,9 +57,9 @@ const defaultCenter = {
const mapOptions = {
fullscreenControl: false,
-}
+};
-dotenv.config({ path: __dirname + '/.env' })
+dotenv.config({ path: __dirname + '/.env' });
const apiKey = process.env.GOOGLE_MAPS;
const script = document.createElement('script');
@@ -115,8 +115,8 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
@observable private searchMarkers: google.maps.Marker[] = [];
@observable private searchBox = new window.google.maps.places.Autocomplete(this.inputRef.current!, options);
@observable private _savedAnnotations = new ObservableMap<number, HTMLDivElement[]>();
- @computed get allSidebarDocs() { return DocListCast(this.dataDoc[this.SidebarKey]); };
- @computed get allMapMarkers() { return DocListCast(this.dataDoc[this.annotationKey]); };
+ @computed get allSidebarDocs() { return DocListCast(this.dataDoc[this.SidebarKey]); }
+ @computed get allMapMarkers() { return DocListCast(this.dataDoc[this.annotationKey]); }
@observable private toggleAddMarker = false;
private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
@@ -155,7 +155,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
*/
private CenterControl = () => {
const controlDiv = document.createElement("div");
- controlDiv.className = "mapBox-addMarker"
+ controlDiv.className = "mapBox-addMarker";
// Set CSS for the control border.
const controlUI = document.createElement("div");
controlUI.style.backgroundColor = "#fff";
@@ -201,7 +201,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
// Setup the click event listeners
controlUI.addEventListener("click", () => {
- if (this.toggleAddMarker == true) {
+ if (this.toggleAddMarker === true) {
this.toggleAddMarker = false;
console.log("add marker button status:" + this.toggleAddMarker);
controlUI.style.backgroundColor = "#fff";
@@ -211,7 +211,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
console.log("add marker button status:" + this.toggleAddMarker);
controlUI.style.backgroundColor = "#4476f7";
markerIcon.style.color = "rgb(255,255,255)";
- };
+ }
});
controlDiv.appendChild(controlUI);
return controlDiv;
@@ -271,10 +271,10 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}, 250);
// listener to addmarker event
this._map.addListener('click', (e: MouseEvent) => {
- if (this.toggleAddMarker == true) {
+ if (this.toggleAddMarker === true) {
this.placeMarker((e as any).latLng, map);
}
- })
+ });
}
@action
@@ -328,10 +328,10 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
console.log("print all sidebar Docs");
console.log(this.allSidebarDocs);
if (!this.layoutDoc._showSidebar) this.toggleSidebar();
- const docs = doc instanceof Doc ? [doc] : doc
+ const docs = doc instanceof Doc ? [doc] : doc;
docs.forEach(doc => {
if (doc.lat !== undefined && doc.lng !== undefined) {
- const existingMarker = this.allMapMarkers.find(marker => marker.lat === doc.lat && marker.lng == doc.lng);
+ const existingMarker = this.allMapMarkers.find(marker => marker.lat === doc.lat && marker.lng === doc.lng);
doc.onClickBehavior = "enterPortal";
if (existingMarker) {
Doc.AddDocToList(existingMarker, "data", doc);
@@ -340,7 +340,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
this.addDocument(marker, this.annotationKey);
}
}
- }) //add to annotation list
+ }); //add to annotation list
console.log("sidebaraddDocument");
console.log(doc);
@@ -359,7 +359,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
docs.forEach(doc => {
console.log(this.allMapMarkers);
console.log(this.allSidebarDocs);
- })
+ });
return this.removeDocument(doc, sidebarKey);
}
@@ -432,7 +432,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
title: place.name,
position: place.geometry.location,
})
- )
+ );
}
/**
@@ -498,7 +498,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
@computed get annotationLayer() {
const pe = this.props.isContentActive() && this.props.pointerEvents !== "none" && !MarqueeOptionsMenu.Instance.isShown() ? "all" :
- SnappingManager.GetIsDragging() ? undefined : "none"
+ SnappingManager.GetIsDragging() ? undefined : "none";
return <div className="mapBox-annotationLayer" style={{ height: Doc.NativeHeight(this.Document) || undefined }} ref={this._annotationLayer}>
{this.inlineTextAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y)).map(anno =>
<Annotation key={`${anno[Id]}-annotation`} {...this.props}
@@ -509,7 +509,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
getAnchor = () => {
const anchor =
AnchorMenu.Instance?.GetAnchor(this._savedAnnotations) ??
- this.rootDoc
+ this.rootDoc;
return anchor;
}
@@ -525,7 +525,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
onLoad={marker => this.markerLoadHandler(marker, place)}
onClick={(e: google.maps.MapMouseEvent) => this.markerClickHandler(e, place)}
/>
- ))
+ ));
}
// TODO: auto center on select a document in the sidebar
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 4a6af86c1..311d52afa 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -120,7 +120,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
public ProseRef?: HTMLDivElement;
public get EditorView() { return this._editorView; }
public get SidebarKey() { return this.fieldKey + "-sidebar"; }
- @computed get allSidebarDocs() { return DocListCast(this.dataDoc[this.SidebarKey]); };
+ @computed get allSidebarDocs() { return DocListCast(this.dataDoc[this.SidebarKey]); }
@computed get sidebarWidthPercent() { return this._showSidebar ? "20%" : StrCast(this.layoutDoc._sidebarWidthPercent, "0%"); }
@computed get sidebarColor() { return StrCast(this.layoutDoc.sidebarColor, StrCast(this.layoutDoc[this.props.fieldKey + "-backgroundColor"], "#e4e4e4")); }
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 328385fda..8a5491b4b 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1241,7 +1241,7 @@ export namespace Doc {
case DocumentType.INK: return "pen-nib";
case DocumentType.PDF: return "file-pdf";
case DocumentType.LINK: return "link";
- case DocumentType.MAP: return "map-marker-alt"
+ case DocumentType.MAP: return "map-marker-alt";
default: return "question";
}
}
diff --git a/src/server/ApiManagers/UserManager.ts b/src/server/ApiManagers/UserManager.ts
index f36506b14..fe80c6a7c 100644
--- a/src/server/ApiManagers/UserManager.ts
+++ b/src/server/ApiManagers/UserManager.ts
@@ -4,6 +4,7 @@ import { Database } from "../database";
import { msToTime } from "../ActionUtilities";
import * as bcrypt from "bcrypt-nodejs";
import { Opt } from "../../fields/Doc";
+import { WebSocket } from "../websocket";
export const timeMap: { [id: string]: number } = {};
interface ActivityUnit {
@@ -131,9 +132,12 @@ export default class UserManager extends ApiManager {
for (const user in timeMap) {
const time = timeMap[user];
- const duration = now - time;
- const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes;
- target.push({ user, duration });
+ const socketPair = Array.from(WebSocket.socketMap).find(pair => pair[1] === user);
+ if (socketPair && !socketPair[0].disconnected) {
+ const duration = now - time;
+ const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes;
+ target.push({ user, duration });
+ }
}
const process = (target: { user: string, duration: number }[]) => {
diff --git a/src/server/websocket.ts b/src/server/websocket.ts
index 13d7237f6..0c79c1bbb 100644
--- a/src/server/websocket.ts
+++ b/src/server/websocket.ts
@@ -187,7 +187,7 @@ export namespace WebSocket {
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
console.log(blue(`user ${userEmail} has connected to the web socket at: ${datetime}`));
- socketMap.set(socket, userEmail);
+ socketMap.set(socket, userEmail + " at " + datetime);
}
function getField([id, callback]: [string, (result?: Transferable) => void]) {
@@ -338,7 +338,18 @@ export namespace WebSocket {
if (!pendingOps.get(id)!.length) pendingOps.delete(id);
}
+ function printActiveUsers() {
+ socketMap.forEach((user, socket) => {
+ !socket.disconnected && console.log(user);
+ });
+ }
+ var CurUser: string | undefined = undefined;
+
function UpdateField(socket: Socket, diff: Diff) {
+ if (CurUser !== socketMap.get(socket)) {
+ CurUser = socketMap.get(socket);
+ console.log("Switch User: " + CurUser);
+ }
if (pendingOps.has(diff.id)) {
pendingOps.get(diff.id)!.push({ diff, socket });
return true;