mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-09 19:13:03 +00:00
Use data.items to display users
This commit is contained in:
@@ -4,7 +4,6 @@ import { Provider } from "react-redux";
|
|||||||
import { createStore } from "redux";
|
import { createStore } from "redux";
|
||||||
import { compose } from "recompose";
|
import { compose } from "recompose";
|
||||||
import { initialState, reducers } from "./Store";
|
import { initialState, reducers } from "./Store";
|
||||||
import { jhapiRequest } from "./util/jhapiUtil";
|
|
||||||
import withAPI from "./util/withAPI";
|
import withAPI from "./util/withAPI";
|
||||||
import { HashRouter, Switch, Route } from "react-router-dom";
|
import { HashRouter, Switch, Route } from "react-router-dom";
|
||||||
|
|
||||||
@@ -25,16 +24,28 @@ const App = () => {
|
|||||||
let api = withAPI()().props;
|
let api = withAPI()().props;
|
||||||
api
|
api
|
||||||
.updateUsers(user_page * limit, limit)
|
.updateUsers(user_page * limit, limit)
|
||||||
.then((data) =>
|
.then((data) => {
|
||||||
store.dispatch({ type: "USER_PAGE", value: { data: data, page: 0 } })
|
console.log(data);
|
||||||
)
|
let { _pagination, items } = data,
|
||||||
|
{ offset, limit } = _pagination;
|
||||||
|
store.dispatch({
|
||||||
|
type: "USER_PAGE",
|
||||||
|
value: { data: items, page: Math.floor(offset / limit) },
|
||||||
|
});
|
||||||
|
})
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
|
|
||||||
api
|
api
|
||||||
.updateGroups(groups_page * limit, limit)
|
.updateGroups(groups_page * limit, limit)
|
||||||
.then((data) =>
|
.then((data) => {
|
||||||
store.dispatch({ type: "GROUPS_PAGE", value: { data: data, page: 0 } })
|
console.log(data);
|
||||||
)
|
let { _pagination, items } = data,
|
||||||
|
{ offset, limit } = _pagination;
|
||||||
|
store.dispatch({
|
||||||
|
type: "GROUPS_PAGE",
|
||||||
|
value: { data: items, page: Math.floor(offset / limit) },
|
||||||
|
});
|
||||||
|
})
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import regeneratorRuntime from "regenerator-runtime";
|
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ const ServerDashboard = (props) => {
|
|||||||
|
|
||||||
if (page != user_page) {
|
if (page != user_page) {
|
||||||
updateUsers(...slice).then((data) =>
|
updateUsers(...slice).then((data) =>
|
||||||
dispatchPageUpdate(data, page, name_filter)
|
dispatchPageUpdate(data.items, page, name_filter)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ const ServerDashboard = (props) => {
|
|||||||
const handleSearch = debounce(async (event) => {
|
const handleSearch = debounce(async (event) => {
|
||||||
// setNameFilter(event.target.value);
|
// setNameFilter(event.target.value);
|
||||||
updateUsers(page * limit, limit, event.target.value).then((data) =>
|
updateUsers(page * limit, limit, event.target.value).then((data) =>
|
||||||
dispatchPageUpdate(data, page, name_filter)
|
dispatchPageUpdate(data.items, page, name_filter)
|
||||||
);
|
);
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
@@ -119,7 +118,7 @@ const ServerDashboard = (props) => {
|
|||||||
if (res.status < 300) {
|
if (res.status < 300) {
|
||||||
updateUsers(...slice)
|
updateUsers(...slice)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatchPageUpdate(data, page, name_filter);
|
dispatchPageUpdate(data.items, page, name_filter);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setIsDisabled(false);
|
setIsDisabled(false);
|
||||||
@@ -155,7 +154,7 @@ const ServerDashboard = (props) => {
|
|||||||
if (res.status < 300) {
|
if (res.status < 300) {
|
||||||
updateUsers(...slice)
|
updateUsers(...slice)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatchPageUpdate(data, page, name_filter);
|
dispatchPageUpdate(data.items, page, name_filter);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setErrorAlert(`Failed to update users list.`);
|
setErrorAlert(`Failed to update users list.`);
|
||||||
@@ -457,7 +456,7 @@ const ServerDashboard = (props) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
updateUsers(...slice)
|
updateUsers(...slice)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatchPageUpdate(data, page, name_filter);
|
dispatchPageUpdate(data.items, page, name_filter);
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Failed to update users list.`)
|
setErrorAlert(`Failed to update users list.`)
|
||||||
@@ -493,7 +492,7 @@ const ServerDashboard = (props) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
updateUsers(...slice)
|
updateUsers(...slice)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatchPageUpdate(data, page, name_filter);
|
dispatchPageUpdate(data.items, page, name_filter);
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Failed to update users list.`)
|
setErrorAlert(`Failed to update users list.`)
|
||||||
|
@@ -6,6 +6,7 @@ export const jhapiRequest = (endpoint, method, data) => {
|
|||||||
json: true,
|
json: true,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/jupyterhub-pagination+json",
|
||||||
},
|
},
|
||||||
body: data ? JSON.stringify(data) : null,
|
body: data ? JSON.stringify(data) : null,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user