Skip to content

Commit

Permalink
fix(admin-ui): fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Jul 11, 2022
1 parent 1e26952 commit 4bfc471
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 45 deletions.
16 changes: 4 additions & 12 deletions admin-ui/app/redux/actions/UserActions.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import {
UM_GET_USERS,
UM_UPDATE_USERS_RESPONSE,
UM_UPDATE_LOADING,
} from './types'
import { GET_USERS, GET_USERS_RESPONSE } from './types'

export const getUsers = (action) => ({
type: UM_GET_USERS,
type: GET_USERS,
payload: { action },
})

export const updateUserResponse = (action) => ({
type: UM_UPDATE_USERS_RESPONSE,
export const getUserResponse = (action) => ({
type: GET_USERS_RESPONSE,
payload: { action },
})
export const UMupdateUserLoading = (action) => ({
type: UM_UPDATE_LOADING,
payload: action,
})
5 changes: 2 additions & 3 deletions admin-ui/app/redux/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,5 @@ export const UPDATE_LICENSE_DETAILS = 'UPDATE_LICENSE_DETAILS'
export const UPDATE_LICENSE_DETAILS_RESPONSE = 'UPDATE_LICENSE_DETAILS_RESPONSE'

//User Management
export const UM_GET_USERS = 'UM_GET_USERS'
export const UM_UPDATE_USERS_RESPONSE = 'UM_UPDATE_USERS_RESPONSE'
export const UM_UPDATE_LOADING = 'UM_UPDATE_LOADING'
export const GET_USERS = 'GET_USERS'
export const GET_USERS_RESPONSE = 'GET_USERS_RESPONSE'
9 changes: 5 additions & 4 deletions admin-ui/app/redux/reducers/UserReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UM_UPDATE_LOADING, UM_GET_USERS } from '../actions/types'
import { GET_USERS, GET_USERS_RESPONSE } from '../actions/types'
import reducerRegistry from './ReducerRegistry'

const INIT_STATE = {
Expand All @@ -11,15 +11,16 @@ const reducerName = 'userReducer'

export default function userReducer(state = INIT_STATE, action) {
switch (action.type) {
case UM_GET_USERS:
case GET_USERS:
return {
...state,
loading: true,
}
case UM_UPDATE_LOADING:
case GET_USERS_RESPONSE:
return {
...state,
loading: action.payload,
loading: false,
items: action.payload ? action.payload : [],
}
default:
return handleDefault()
Expand Down
10 changes: 4 additions & 6 deletions admin-ui/app/redux/sagas/UserSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
isFourZeroOneError,
addAdditionalData,
} from '../../utils/TokenController'
import { UM_GET_USERS } from '../actions/types'
import { GET_USERS } from '../actions/types'
import UserApi from '../api/UserApi'
import { getClient } from '../api/base'
const JansConfigApi = require('jans_config_api')
import { initAudit } from './SagaUtils'
import { updateUserResponse, UMupdateUserLoading } from '../actions/UserActions'
import { getUserResponse } from '../actions/UserActions'
import { postUserAction } from '../api/backend-api'
import { getAPIAccessToken } from '../actions'
const API_USERS = 'api-users'
Expand All @@ -29,11 +29,9 @@ export function* getUsersSaga({ payload }) {
addAdditionalData(audit, FETCH, API_USERS, payload)
const userApi = yield* newFunction()
const data = yield call(userApi.getUsers, payload.action)
yield put(updateUserResponse(data))
yield put(UMupdateUserLoading(false))
yield put(getUserResponse(data))
yield call(postUserAction, audit)
} catch (e) {
yield put(UMupdateUserLoading(false))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
Expand All @@ -42,7 +40,7 @@ export function* getUsersSaga({ payload }) {
}

export function* watchGetUsers() {
yield takeEvery(UM_GET_USERS, getUsersSaga)
yield takeEvery(GET_USERS, getUsersSaga)
}

export default function* rootSaga() {
Expand Down
42 changes: 22 additions & 20 deletions admin-ui/app/routes/Dashboards/DashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,29 +310,31 @@ function DashboardPage({
dispatch(getUsers(userOptions))
}, 1000)
}, [])
useEffect(() => {
console.log('abcd', users)
}, [users])

useEffect(() => {
let count = 0
const interval = setInterval(() => {
if (statData.length === 0 && count < 2) {
search()
}
if (clients.length === 0 && count < 2) {
buildPayload(userAction, 'Fetch openid connect clients', {})
dispatch(getClients(userAction))
}
if (Object.keys(license).length === 0 && count < 2) {
getLicense()
}
if (count < 2) {
getServerStatus()
}
count++
}, 1000)
return () => clearInterval(interval)
const interval = () => {
console.log(count)
setTimeout(() => {
if (statData.length === 0 && count < 2) {
search()
}
if (clients.length === 0 && count < 2) {
buildPayload(userAction, 'Fetch openid connect clients', {})
dispatch(getClients(userAction))
}
if (Object.keys(license).length === 0 && count < 2) {
getLicense()
}
if (count < 2) {
getServerStatus()
interval()
}
count++
}, 1000)
}
interval()
return () => {}
}, [1000])

function search() {
Expand Down

0 comments on commit 4bfc471

Please sign in to comment.