I'm trying to create a nice admin dashboard with react-admin
.
As using spring
in my backend and this is how am sending data to react-admin
:
@GetMapping("admin/user")
ResponseEntity<List<User>> getAll()
{
System.out.println(new Date());;
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Content-Range", "posts 0-"+userRepository.findAll().size() + "/" + userRepository.findAll().size());
responseHeaders.set("Origin", "http://localhost:3001");
return ResponseEntity.ok()
.headers(responseHeaders)
.body(userRepository.findAll());
}
First of all this is not working and secondly, this is not even close to correct solution.
Unfortunately, my client renders the last thing over and over again.
As you can see below, element with id 129
is rendered over and over again!
At the frontend, within react.js
:
// Within main/parent component
class App extends Component {
render() {
return (
<Admin dataProvider={restProvider('http://localhost:8080/admin')}>
<Resource name="user" list={UserList}/>
</Admin>
);
}
};
// child component
const UserList = (props) => (
<List {...props}>
<Datagrid>
<TextField source="userID" />
<TextField source="username" />
<TextField source="firstName" />
<TextField source="middleName" />
<TextField source="lastName" />
<TextField source="profileImageURL" />
<DateField source="joiningTime" />
<EditButton basePath="/posts" />
</Datagrid>
</List>
);
I think I need a method that sort of configures every controller response with a Content-Range
header.
Please note that my returned data works fine in postman
: