-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from ConsumerDataStandardsAustralia/feature/a…
…emo-status-and-outages AEMO Status and Outages
- Loading branch information
Showing
12 changed files
with
243 additions
and
66 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React from 'react' | ||
import Accordion from '@material-ui/core/Accordion' | ||
import AccordionSummary from '@material-ui/core/AccordionSummary' | ||
import AccordionActions from '@material-ui/core/AccordionActions' | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore' | ||
import SubjectIcon from '@material-ui/icons/Subject' | ||
import Typography from '@material-ui/core/Typography' | ||
import Divider from '@material-ui/core/Divider' | ||
import RefreshIcon from '@material-ui/icons/Refresh' | ||
import Fab from '@material-ui/core/Fab' | ||
import Tooltip from '@material-ui/core/Tooltip' | ||
import { makeStyles } from '@material-ui/core/styles' | ||
import { fade } from '@material-ui/core/styles/colorManipulator' | ||
import StatusOutages from './StatusOutages' | ||
import { connect } from 'react-redux' | ||
import { retrieveStatus, retrieveOutages } from '../../../store/aemo_discovery' | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
container: { | ||
marginLeft: theme.typography.pxToRem(20), | ||
marginRight: theme.typography.pxToRem(20) | ||
}, | ||
panel: { | ||
backgroundColor: fade('#fff', 0.9) | ||
}, | ||
heading: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
fontSize: theme.typography.pxToRem(20), | ||
}, | ||
details: { | ||
maxWidth:'95%', | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
marginBottom: 20 | ||
} | ||
})) | ||
|
||
const AEMODiscoveryInfo = (props) => { | ||
|
||
const classes = useStyles() | ||
const [expanded, setExpanded] = React.useState(true) | ||
const {statusDetails, outagesDetails} = props.data | ||
|
||
const toggleExpansion = (event, newExpanded) => { | ||
setExpanded(newExpanded) | ||
} | ||
|
||
const refreshStatusOutages = () => { | ||
props.retrieveStatus() | ||
props.retrieveOutages() | ||
} | ||
|
||
React.useEffect(() => { | ||
refreshStatusOutages() | ||
// eslint-disable-next-line | ||
}, []) | ||
|
||
return ( | ||
<Accordion defaultExpanded className={classes.panel} expanded={expanded} onChange={toggleExpansion}> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon/>} | ||
aria-controls='panel1c-content' | ||
> | ||
<div className={classes.heading}> | ||
<SubjectIcon/><Typography style={{paddingLeft: 8}}>Status & Outages</Typography> | ||
</div> | ||
</AccordionSummary> | ||
<div className={classes.details}> | ||
<p>Secondary Data Holders provide data to Data Holders via CDR requests, who in turn provide the data to ADRs. Such data is called Shared Responsibility Data (SR data).</p> | ||
<p>Currently, only the energy sector has a designated secondary data holder: AEMO. This page lists the status and outages for AEMO.</p> | ||
|
||
<div className="title"><span><img src="https://www.aemo.com.au/-/media/project/aemo/global/logos/aemo-logo.svg" alt="AEMO"/></span></div> | ||
<StatusOutages statusDetails={statusDetails} outagesDetails={outagesDetails} /> | ||
</div> | ||
|
||
<Divider/> | ||
|
||
<AccordionActions> | ||
<Tooltip title='Refresh'> | ||
<Fab size='medium' color='primary' onClick={refreshStatusOutages}> | ||
<RefreshIcon/> | ||
</Fab> | ||
</Tooltip> | ||
</AccordionActions> | ||
</Accordion> | ||
) | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
data: state.aemoDiscovery | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
retrieveStatus, | ||
retrieveOutages | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(AEMODiscoveryInfo) |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {conoutInfo} from '../conout/actions' | ||
import {createConoutError, checkExposedHeaders} from '../../utils/cors' | ||
|
||
const AEMO_URL = 'https://api.aemo.com.au/NEMRetail/cds-au/v1' | ||
|
||
export const RETRIEVE_AEMO_STATUS = 'RETRIEVE_AEMO_STATUS' | ||
export const RETRIEVE_AEMO_OUTAGES = 'RETRIEVE_AEMO_OUTAGES' | ||
|
||
const headers = { | ||
'Accept': 'application/json', | ||
'x-v': 1 | ||
} | ||
|
||
export const retrieveStatus = () => dispatch => { | ||
const fullUrl = AEMO_URL + '/discovery/status' | ||
const request = new Request(fullUrl, {headers}) | ||
dispatch(conoutInfo('Requesting retrieveStatus(): ' + fullUrl)) | ||
dispatch({ | ||
type: RETRIEVE_AEMO_STATUS, | ||
payload: fetch(request) | ||
.then(response => { | ||
if (response.ok) { | ||
checkExposedHeaders(response, fullUrl, dispatch) | ||
return response.json() | ||
} | ||
throw new Error(`Response not OK. Status: ${response.status} (${response.statusText})`) | ||
}) | ||
.then(obj => { | ||
dispatch(conoutInfo(`Received response for ${fullUrl}:`, obj)) | ||
return obj | ||
}) | ||
.catch(error => { | ||
dispatch(createConoutError(error, fullUrl)) | ||
}) | ||
}) | ||
} | ||
|
||
export const retrieveOutages = () => dispatch => { | ||
const fullUrl = AEMO_URL + '/discovery/outages' | ||
const request = new Request(fullUrl, {headers}) | ||
dispatch(conoutInfo('Requesting retrieveOutages(): ' + fullUrl)) | ||
dispatch({ | ||
type: RETRIEVE_AEMO_OUTAGES, | ||
payload: fetch(request) | ||
.then(response => { | ||
if (response.ok) { | ||
checkExposedHeaders(response, fullUrl, dispatch) | ||
return response.json() | ||
} | ||
throw new Error(`Response not OK. Status: ${response.status} (${response.statusText})`) | ||
}) | ||
.then(obj => { | ||
dispatch(conoutInfo(`Received response for ${fullUrl}:`, obj)) | ||
return obj | ||
}) | ||
.catch(error => { | ||
dispatch(createConoutError(error, fullUrl)) | ||
}) | ||
}) | ||
} |
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,2 @@ | ||
export * from './actions' | ||
export * from './reducer' |
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,28 @@ | ||
import { | ||
RETRIEVE_AEMO_STATUS, | ||
RETRIEVE_AEMO_OUTAGES | ||
} from './actions' | ||
import {fulfilled} from '../../utils/async-actions' | ||
|
||
export default function discovery(state = {}, action) { | ||
switch (action.type) { | ||
case fulfilled(RETRIEVE_AEMO_STATUS): { | ||
const s = {...state} | ||
if (action.payload) { | ||
const response = action.payload | ||
s.statusDetails = response ? response.data : null | ||
} | ||
return s | ||
} | ||
case fulfilled(RETRIEVE_AEMO_OUTAGES): { | ||
const s = {...state} | ||
if (action.payload) { | ||
const response = action.payload | ||
s.outagesDetails = response ? response.data : null | ||
} | ||
return s | ||
} | ||
default: | ||
return state | ||
} | ||
} |
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
Oops, something went wrong.