-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [OS-25] PSS feedback frontend (#341)
* Initial refactoring * Revert "Initial refactoring" This reverts commit dd38aa1. * Add new component * Add components for current status * Update * Init work for PSS Feedback * Updates to code
- Loading branch information
Showing
6 changed files
with
99 additions
and
6 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
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,80 @@ | ||
import React, { Component } from "react"; | ||
import { withRouter } from "react-router-dom"; | ||
import { action } from "mobx"; | ||
import { observer, inject } from "mobx-react"; | ||
import Moment from "moment/moment"; | ||
import { Card, CardBody, CardHeader, FormGroup, Input } from "reactstrap"; | ||
|
||
import myClient from "../../agents/client"; | ||
|
||
@inject("connsStore") | ||
@observer | ||
class DetailsStatus extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
componentWillMount() { | ||
this.refreshStatus(); | ||
} | ||
|
||
componentWillUnmount() { | ||
clearTimeout(this.refreshTimeout); | ||
} | ||
|
||
refreshStatus = () => { | ||
const conn = this.props.connsStore.store.current; | ||
const connectionId = conn.connectionId; | ||
|
||
if (connectionId !== undefined) { | ||
if (conn.phase === "RESERVED") { | ||
// In case of ASAP, handle the case | ||
const cur = new Moment().add(30, 's'); | ||
const beg = Moment(conn.reserved.schedule.beginning * 1000); | ||
if (cur.isAfter(beg)) { | ||
myClient.submitWithToken("GET", "/protected/pss/work_status/" + connectionId, "").then( | ||
action(response => { | ||
let explanation = JSON.parse(response)['explanation'] | ||
this.handleStatusChange(explanation); | ||
}) | ||
); | ||
this.refreshTimeout = setTimeout(this.refreshStatus, 3000); // update per 3 seconds | ||
} | ||
} else { | ||
this.handleStatusChange('Can only get PSS status for a RESERVED connection'); | ||
} | ||
} else { | ||
this.refreshTimeout = setTimeout(this.refreshStatus, 3000); // update per 3 seconds | ||
} | ||
} | ||
|
||
handleStatusChange(result) { | ||
let explanation = ''; | ||
if (result === null) { | ||
explanation = 'PSS is IDLE'; | ||
} else { | ||
explanation = result; | ||
} | ||
this.props.connsStore.setPssStatus(explanation); | ||
} | ||
|
||
render() { | ||
const store = this.props.connsStore.store; | ||
return ( | ||
<Card> | ||
<CardHeader> Current Status </CardHeader> | ||
<CardBody> | ||
<FormGroup> | ||
<Input | ||
type="text" | ||
disabled | ||
value={store.pssStatus} | ||
/> | ||
</FormGroup> | ||
</CardBody> | ||
</Card> | ||
); | ||
} | ||
} | ||
|
||
export default withRouter(DetailsStatus); |
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