diff --git a/client/admin/notificationUtils/notificationLookup/notificationLookup.jsx b/client/admin/notificationUtils/notificationLookup/notificationLookup.jsx new file mode 100644 index 000000000..3ed0410ee --- /dev/null +++ b/client/admin/notificationUtils/notificationLookup/notificationLookup.jsx @@ -0,0 +1,82 @@ +require('./notificationLookup.less'); +const React = require('react'); +const createClass = require('create-react-class'); +const cx = require('classnames'); + +const request = require('superagent'); +const Moment = require('moment'); + + +const NotificationLookup = createClass({ + getDefaultProps() { + return {}; + }, + getInitialState() { + return { + query : '', + foundNotification : null, + searching : false, + error : null + }; + }, + handleChange(e){ + this.setState({ query: e.target.value }); + }, + lookup(){ + this.setState({ searching: true, error: null }); + + request.get(`/admin/notification/lookup/${this.state.query}`) + .then((res)=>this.setState({ foundNotification: res.body })) + .catch((err)=>this.setState({ error: err })) + .finally(()=>this.setState({ searching: false })); + }, + + renderFoundNotification(){ + const notification = this.state.foundnotification; + return
+
+
Key
+
{notification.dismissKey}
+ +
Title
+
{notification.title || 'No Title'}
+ +
Text
+
{notification.text || 'No Text'}
+ +
Created
+
{Moment(notification.createdAt).fromNow()}
+ +
Start
+
{Moment(notification.startAt).fromNow() || 'No Start Time'}
+ +
Created
+
{Moment(notification.stopAt).fromNow() || 'No End Time'}
+
+
; + }, + + render(){ + return
+

Notification Lookup

+ + + + {this.state.error + &&
{this.state.error.toString()}
+ } + + {this.state.foundNotification + ? this.renderFoundNotification() + :
No notification found.
+ } +
; + } +}); + +module.exports = NotificationLookup; diff --git a/client/admin/notificationUtils/notificationLookup/notificationLookup.less b/client/admin/notificationUtils/notificationLookup/notificationLookup.less new file mode 100644 index 000000000..720b4e044 --- /dev/null +++ b/client/admin/notificationUtils/notificationLookup/notificationLookup.less @@ -0,0 +1,30 @@ + +.notificationLookup{ + input{ + height : 33px; + margin-bottom : 20px; + padding : 0px 10px; + font-family : monospace; + } + button{ + vertical-align : middle; + height : 37px; + } + dl{ + @maxItemWidth : 132px; + dt{ + float : left; + clear : left; + width : @maxItemWidth; + text-align : right; + &::after { + content: " : "; + } + } + dd{ + height : 1em; + margin-left : @maxItemWidth + 6px; + padding : 0 0 0.5em 0; + } + } +} \ No newline at end of file diff --git a/client/admin/notificationUtils/notificationUtils.jsx b/client/admin/notificationUtils/notificationUtils.jsx index 9c7b4cbe3..f68462377 100644 --- a/client/admin/notificationUtils/notificationUtils.jsx +++ b/client/admin/notificationUtils/notificationUtils.jsx @@ -1,10 +1,12 @@ const React = require('react'); const createClass = require('create-react-class'); +const NotificationLookup = require('./notificationLookup/notificationLookup.jsx'); + const NotificationUtils = createClass({ render : function(){ return <> -
Notifications
+ ; } });