-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): implement server side search
- Loading branch information
1 parent
6fc72c4
commit 8344c17
Showing
13 changed files
with
179 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { | ||
GET_ATTRIBUTES_FOR_USER_MANAGEMENT, | ||
GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE | ||
} from './types' | ||
|
||
export const getAttributesRoot = (options) => ({ | ||
type: GET_ATTRIBUTES_FOR_USER_MANAGEMENT, | ||
payload: { options }, | ||
}) | ||
|
||
export const getAttributesResponseRoot = (data) => ({ | ||
type: GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE, | ||
payload: { data }, | ||
}) |
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,16 @@ | ||
import { handleResponse } from 'Utils/ApiUtils' | ||
|
||
export default class AttributeApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
|
||
// Get all attributes | ||
getAllAttributes = (opts) => { | ||
return new Promise((resolve, reject) => { | ||
this.api.getAttributes(opts, (error, data) => { | ||
handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
} |
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,39 @@ | ||
import { GET_ATTRIBUTES_FOR_USER_MANAGEMENT, GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE } from '../actions/types' | ||
import _ from 'lodash' | ||
import reducerRegistry from './ReducerRegistry' | ||
const INIT_STATE = { | ||
items:[], | ||
loading: false, | ||
} | ||
|
||
const reducerName = 'attributesReducerRoot' | ||
|
||
export default function attributesReducerRoot(state = INIT_STATE, action) { | ||
switch (action.type) { | ||
case GET_ATTRIBUTES_FOR_USER_MANAGEMENT: | ||
return { | ||
...state, | ||
loading: true, | ||
} | ||
case GET_ATTRIBUTES_FOR_USER_MANAGEMENT_RESPONSE: | ||
if (action.payload.data) { | ||
return { | ||
...state, | ||
loading: false, | ||
items: _.unionBy(action.payload.data.entries, state.items, 'displayName'), | ||
} | ||
} else { | ||
return handleDefault() | ||
} | ||
default: | ||
return handleDefault() | ||
} | ||
|
||
function handleDefault() { | ||
return { | ||
...state, | ||
loading: false, | ||
} | ||
} | ||
} | ||
reducerRegistry.register(reducerName, attributesReducerRoot) |
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,57 @@ | ||
import { call, all, put, fork, takeLatest, select } from 'redux-saga/effects' | ||
import { isFourZeroOneError, addAdditionalData } from 'Utils/TokenController' | ||
import { | ||
getAttributesResponseRoot | ||
} from '../actions/AttributesActions' | ||
import { getAPIAccessToken } from 'Redux/actions/AuthActions' | ||
import { postUserAction } from 'Redux/api/backend-api' | ||
import { | ||
GET_ATTRIBUTES_FOR_USER_MANAGEMENT, | ||
} from '../actions/types' | ||
import { | ||
FETCH, | ||
} from '../../audit/UserActionType' | ||
// } from '../../../../app/audit/UserActionType' | ||
import AttributeApi from '../api/AttributeApi' | ||
import { getClient } from 'Redux/api/base' | ||
import { initAudit } from 'Redux/sagas/SagaUtils' | ||
|
||
const PERSON_SCHEMA = 'person schema' | ||
|
||
const JansConfigApi = require('jans_config_api') | ||
|
||
function* newFunction() { | ||
const token = yield select((state) => state.authReducer.token.access_token) | ||
const issuer = yield select((state) => state.authReducer.issuer) | ||
const api = new JansConfigApi.AttributeApi( | ||
getClient(JansConfigApi, token, issuer), | ||
) | ||
return new AttributeApi(api) | ||
} | ||
|
||
export function* getAttributesRoot({ payload }) { | ||
const audit = yield* initAudit() | ||
try { | ||
addAdditionalData(audit, FETCH, PERSON_SCHEMA, payload) | ||
const attributeApi = yield* newFunction() | ||
const data = yield call(attributeApi.getAllAttributes, payload.options) | ||
yield put(getAttributesResponseRoot(data)) | ||
yield call(postUserAction, audit) | ||
} catch (e) { | ||
yield put(getAttributesResponseRoot([])) | ||
if (isFourZeroOneError(e)) { | ||
const jwt = yield select((state) => state.authReducer.userinfo_jwt) | ||
yield put(getAPIAccessToken(jwt)) | ||
} | ||
} | ||
} | ||
|
||
export function* watchGetAttributesRoot() { | ||
yield takeLatest(GET_ATTRIBUTES_FOR_USER_MANAGEMENT, getAttributesRoot) | ||
} | ||
|
||
export default function* rootSaga() { | ||
yield all([ | ||
fork(watchGetAttributesRoot), | ||
]) | ||
} |
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
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