aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/topbar
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@michaels-mbp-21.devices.brown.edu>2022-11-02 14:56:20 -0400
committerMichael Foiani <sotech117@michaels-mbp-21.devices.brown.edu>2022-11-02 14:56:20 -0400
commite9d5dbeef2bf1dab9dfb863d970b70b3074e3d0a (patch)
treee88de9ff3a05d094667a991cebf27006a0566d63 /src/client/views/topbar
parent770f546a38d7ec827bff55fd0dd64b873a112180 (diff)
add basic heartbeat functinality througha ping/pong api cycle
Diffstat (limited to 'src/client/views/topbar')
-rw-r--r--src/client/views/topbar/TopBar.tsx19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/client/views/topbar/TopBar.tsx b/src/client/views/topbar/TopBar.tsx
index 7e728306c..50a93ee92 100644
--- a/src/client/views/topbar/TopBar.tsx
+++ b/src/client/views/topbar/TopBar.tsx
@@ -1,6 +1,6 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Button, FontSize, IconButton, Size } from 'browndash-components';
-import { action, computed, observable } from 'mobx';
+import { action, computed, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { FaBug, FaCamera } from 'react-icons/fa';
@@ -8,6 +8,7 @@ import { AclAdmin, Doc, DocListCast } from '../../../fields/Doc';
import { StrCast } from '../../../fields/Types';
import { GetEffectiveAcl } from '../../../fields/util';
import { DocumentManager } from '../../util/DocumentManager';
+import { PingManager } from '../../util/PingManager';
import { ReportManager } from '../../util/ReportManager';
import { SettingsManager } from '../../util/SettingsManager';
import { SharingManager } from '../../util/SharingManager';
@@ -35,6 +36,12 @@ export class TopBar extends React.Component {
@observable textColor: string = Colors.LIGHT_GRAY;
@observable backgroundColor: string = Colors.DARK_GRAY;
+ @observable happyHeart: boolean = PingManager.Instance.isBeating;
+ setHappyHeart = action((status: boolean) => this.happyHeart = status);
+ dispose = reaction(() => PingManager.Instance.isBeating, isBeating => this.setHappyHeart(isBeating));
+
+
+
/**
* Returns the left hand side of the topbar.
* This side of the topbar contains the different modes.
@@ -176,6 +183,16 @@ export class TopBar extends React.Component {
onClick={() => SettingsManager.Instance.open()}
icon={<FontAwesomeIcon icon="cog" />}
/>
+ <IconButton
+ size={Size.SMALL}
+ isCircle={true}
+ color={this.happyHeart ? Colors.LIGHT_BLUE : Colors.ERROR_RED}
+ backgroundColor={Colors.DARK_GRAY}
+ hoverStyle="gray"
+ isActive={SettingsManager.Instance.isOpen}
+ onClick={() => SettingsManager.Instance.open()}
+ icon={<FontAwesomeIcon icon={this.happyHeart ? "heart" : "heart-broken"} />}
+ />
{/* <Button text={'Logout'} borderRadius={5} hoverStyle={'gray'} backgroundColor={Colors.DARK_GRAY} color={this.textColor} fontSize={FontSize.SECONDARY} onClick={() => window.location.assign(Utils.prepend('/logout'))} /> */}
</div>
);