Skip to content
Snippets Groups Projects
Commit 5f9ed321 authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-915: Option to show and remeber latest logs in subtask status log dialog...

TMSS-915: Option to show and remeber latest logs in subtask status log dialog in task list and task view.
parent 863193ee
Branches
No related tags found
3 merge requests!634WIP: COBALT commissioning delta,!532Resolves TMSS-915,!481Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
...@@ -3,6 +3,8 @@ import _ from 'lodash'; ...@@ -3,6 +3,8 @@ import _ from 'lodash';
import TaskService from '../../services/task.service'; import TaskService from '../../services/task.service';
import ViewTable from '../../components/ViewTable'; import ViewTable from '../../components/ViewTable';
import AppLoader from '../../layout/components/AppLoader'; import AppLoader from '../../layout/components/AppLoader';
import { Button } from 'primereact/button';
import UtilService from '../../services/util.service';
/** /**
* Component that list down the status change logs of subtasks * Component that list down the status change logs of subtasks
...@@ -11,39 +13,66 @@ export class TaskStatusLogs extends Component { ...@@ -11,39 +13,66 @@ export class TaskStatusLogs extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.taskListAttribute = UtilService.localStore({ type: 'get', key: "TASK_LIST_ATTR" }) || {};
this.state = { this.state = {
isLoading: true, isLoading: true,
logs: [] logs: [],
showLatest: this.taskListAttribute["showLatestLogs"] || false
} }
this.setShowLatest = this.setShowLatest.bind(this);
} }
async componentDidMount() { async componentDidMount() {
let logs = await TaskService.getTaskStatusLogs(this.props.taskId); let logs = await TaskService.getTaskStatusLogs(this.props.taskId);
logs = _.sortBy(logs, ['subtask_id', 'updated_at']); // logs = _.sortBy(logs, ['subtask_id', 'updated_at']);
this.setState({logs: logs, isLoading: false}); this.setState({logs: logs, isLoading: false});
} }
/**
* Function to show latest or all logs and store the option selected for rendering the same when opened again.
*/
setShowLatest() {
let showLatest = !this.state.showLatest
this.taskListAttribute['showLatestLogs'] = showLatest;
this.setState({showLatest: showLatest});
UtilService.localStore({ type: 'set', key: 'TASK_LIST_ATTR', value: this.taskListAttribute });
}
render() { render() {
let logs = _.sortBy(this.state.logs, ['subtask_id', 'updated_at']);
if (this.state.showLatest) {
logs = _(logs).orderBy(['subtask_id', 'updated_at'], ['asc', 'desc']).uniqBy('subtask_id').value();
}
return( return(
<React.Fragment> <React.Fragment>
{ this.state.isLoading? <AppLoader /> : { this.state.isLoading? <AppLoader /> :
<ViewTable <div className="p-grid" style={{marginTop: "auto"}}>
data={this.state.logs} <div className="col-lg-12" style={{zIndex:"1"}}>
defaultcolumns={[{subtask_id: "Subtask Id", subtask_type: "Type", updated_at: "Updated At", <Button className="dialog-btn" label={this.state.showLatest?"Show All":"Show Latest Only"}
old_state_value: "From State", new_state_value: "To State", user: 'User'}]} style={{width:"150px"}}
optionalcolumns={[{}]} // icon={`pi ${this.state.showLatest?"pi-angle-left":"pi-angle-right"}`}
columnclassname={[{"Subtask Id": "filter-input-75", "Type": "filter-input-75", // iconPos={`${this.state.showLatest?"left":"right"}`}
"Updated At": "filter-input-75", "From State": "filter-input-75", onClick={(e) => this.setShowLatest()} />
"To State": "filter-input-75", "User": "filter-input-75"}]} </div>
defaultSortColumn={[{}]} <div className="col-lg-12" style={{marginTop:"-30px", zIndex:"0"}}>
showaction="false" <ViewTable
keyaccessor="id" data={logs}
paths={this.state.paths} defaultcolumns={[{subtask_id: "Subtask Id", subtask_type: "Type", updated_at: "Updated At",
defaultpagesize={this.state.logs.length} old_state_value: "From State", new_state_value: "To State", user: 'User'}]}
showTopTotal={false} optionalcolumns={[{}]}
showGlobalFilter={false} columnclassname={[{"Subtask Id": "filter-input-75", "Type": "filter-input-75",
allowColumnSelection={false} "Updated At": "filter-input-75", "From State": "filter-input-75",
/> "To State": "filter-input-75", "User": "filter-input-75"}]}
defaultSortColumn={[{}]}
showaction="false"
keyaccessor="id"
paths={this.state.paths}
showTopTotal={false}
showGlobalFilter={false}
allowColumnSelection={false}
/>
</div>
</div>
} }
</React.Fragment> </React.Fragment>
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment