-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add events to application pages #602
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b123158
console: Add connection status constants
bafonins 76c160a
console: Add events subsription for application
bafonins 7a15d97
console: Move paused state to events
bafonins 0bef97c
console: Add redux primitives for events
bafonins 9f2aa12
console: Add redux primitives for app events
bafonins 04669bb
console: Add events subscription component
bafonins 41d4d15
console: Add application events component
bafonins 8b27c94
console: Add application data page
bafonins 826d1b0
console: Add events widget to app overview
bafonins 8c982de
console: Change events widget header text
bafonins 9bcd6e4
dev: Update locales
bafonins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ | |
min-height: 10rem | ||
|
||
.status-message | ||
font-weight: 600 | ||
margin-right: $cs.xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
export default Object.freeze({ | ||
CONNECTED: 'connected', | ||
DISCONNECTED: 'disconnected', | ||
CONNECTING: 'connecting', | ||
UNKNOWN: 'unknown', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
import bind from 'autobind-decorator' | ||
|
||
import PropTypes from '../../../lib/prop-types' | ||
import EventsSubscription from '../../containers/events-subscription' | ||
|
||
import { | ||
clearApplicationEventsStream, | ||
} from '../../store/actions/application' | ||
|
||
import { | ||
applicationEventsSelector, | ||
applicationEventsStatusSelector, | ||
} from '../../store/selectors/application' | ||
|
||
@connect( | ||
null, | ||
(dispatch, ownProps) => ({ | ||
onClear: () => dispatch(clearApplicationEventsStream(ownProps.appId)), | ||
})) | ||
@bind | ||
class ApplicationEvents extends React.Component { | ||
render () { | ||
const { | ||
appId, | ||
widget, | ||
onClear, | ||
} = this.props | ||
|
||
return ( | ||
<EventsSubscription | ||
id={appId} | ||
widget={widget} | ||
eventsSelector={applicationEventsSelector} | ||
statusSelector={applicationEventsStatusSelector} | ||
onClear={onClear} | ||
toAllUrl={`/console/applications/${appId}/data`} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
ApplicationEvents.propTypes = { | ||
appId: PropTypes.string.isRequired, | ||
widget: PropTypes.bool, | ||
} | ||
|
||
ApplicationEvents.defaultProps = { | ||
widget: false, | ||
} | ||
|
||
export default ApplicationEvents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import CONNECTION_STATUS from '../../constants/connection-status' | ||
import Events from '../../../components/events' | ||
import PropTypes from '../../../lib/prop-types' | ||
|
||
const { Widget } = Events | ||
|
||
const mapConnectionStatusToWidget = function (status) { | ||
switch (status) { | ||
case CONNECTION_STATUS.CONNECTED: | ||
return Widget.CONNECTION_STATUS.GOOD | ||
case CONNECTION_STATUS.CONNECTING: | ||
return Widget.CONNECTION_STATUS.MEDIOCRE | ||
case CONNECTION_STATUS.DISCONNECTED: | ||
return Widget.CONNECTION_STATUS.BAD | ||
case CONNECTION_STATUS.UNKNOWN: | ||
default: | ||
return Widget.CONNECTION_STATUS.UNKNOWN | ||
} | ||
} | ||
|
||
@connect(function (state, props) { | ||
const { | ||
eventsSelector, | ||
statusSelector, | ||
} = props | ||
|
||
return { | ||
events: eventsSelector(state, props), | ||
connectionStatus: statusSelector(state, props), | ||
} | ||
}) | ||
class EventsSubscription extends React.Component { | ||
render () { | ||
const { | ||
id, | ||
widget, | ||
events, | ||
connectionStatus, | ||
onClear, | ||
toAllUrl, | ||
} = this.props | ||
|
||
if (widget) { | ||
return ( | ||
<Widget | ||
emitterId={id} | ||
events={events} | ||
connectionStatus={mapConnectionStatusToWidget(connectionStatus)} | ||
toAllUrl={toAllUrl} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<Events | ||
emitterId={id} | ||
events={events} | ||
onClear={onClear} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
EventsSubscription.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
eventsSelector: PropTypes.func.isRequired, | ||
statusSelector: PropTypes.func, | ||
onClear: PropTypes.func, | ||
widget: PropTypes.bool, | ||
toAllUrl: PropTypes.string, | ||
} | ||
|
||
EventsSubscription.defaultProps = { | ||
widget: false, | ||
onClear: () => null, | ||
statusSelector: () => 'unknown', | ||
toAllUrl: null, | ||
} | ||
|
||
export default EventsSubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we do ourselves a favor with this if statement. We would need to update this for every prop/state structure change we do. Wouldn't it be better to assume rerenders by default and only rule out cases (like below with the paused state)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone changes the internals of the component then the person should also check the
shouldComponentUpdate
logic. This does influence the api of the component only the logic within the component.