diff --git a/admin-ui/app/locales/en/translation.json b/admin-ui/app/locales/en/translation.json index dbf91eba7..f9f8146ae 100644 --- a/admin-ui/app/locales/en/translation.json +++ b/admin-ui/app/locales/en/translation.json @@ -505,7 +505,8 @@ "access_token": "Access token", "userinfo": "Userinfo", "JARM": "JARM", - "request_object": "Request Object" + "request_object": "Request Object", + "agama":"Agama" }, "links": { "support": "https://support.gluu.org/" diff --git a/admin-ui/plugins/auth-server/components/Agama/AgamaListPage.js b/admin-ui/plugins/auth-server/components/Agama/AgamaListPage.js index 681ba7bb1..0d203841c 100644 --- a/admin-ui/plugins/auth-server/components/Agama/AgamaListPage.js +++ b/admin-ui/plugins/auth-server/components/Agama/AgamaListPage.js @@ -1,5 +1,4 @@ import React, { useState, useEffect, useContext, useCallback } from 'react' -import { useNavigate, useLocation } from 'react-router-dom' import { useSelector, useDispatch } from 'react-redux' import { Card, CardBody, Badge, Input } from 'Components' import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle' @@ -8,17 +7,20 @@ import SetTitle from 'Utils/SetTitle' import { ThemeContext } from 'Context/theme/themeContext' import getThemeColor from 'Context/theme/config' import { Paper, TablePagination } from '@material-ui/core' -import { getAgama , postAgama} from '../../redux/actions/AgamaActions' +import { getAgama } from '../../redux/actions/AgamaActions' import { hasPermission, AGAMA_READ, AGAMA_WRITE } from 'Utils/PermChecker' +import axios from 'axios' import GluuViewWrapper from '../../../../app/routes/Apps/Gluu/GluuViewWrapper' import MaterialTable from '@material-table/core' import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap' import { useDropzone } from 'react-dropzone' import JSZip from 'jszip' +const JansConfigApi = require('jans_config_api') +import { getClient } from '../../../../app/redux/api/base' function AgamaListPage() { const { t } = useTranslation() @@ -35,11 +37,16 @@ function AgamaListPage() { const [projectName, setProjectName] = useState('') const [getProjectName, setGetProjectName] = useState(false) + + const token = useSelector((state) => state.authReducer.token.access_token) + const issuer = useSelector((state) => state.authReducer.issuer) + + const BASE_PATH = getClient(JansConfigApi, token, issuer) + const theme = useContext(ThemeContext) const selectedTheme = theme.state.theme const themeColors = getThemeColor(selectedTheme) const bgThemeColor = { background: themeColors.background } - function convertFileToByteArray(file) { return new Promise((resolve, reject) => { const reader = new FileReader() @@ -54,11 +61,27 @@ function AgamaListPage() { }) } - const submitData = async () => { let file = await convertFileToByteArray(selectedFile); - let obj = {file, name:projectName} - dispatch(postAgama(obj)) + var config = { + method: 'post', + url: BASE_PATH.basePath+'/api/v1/agama-deployment?name='+projectName, + headers: { + 'Authorization': 'Bearer '+token, + 'Content-Type': 'application/zip' + }, + data : file + } + axios(config) + .then(function (response) { + dispatch(getAgama()) + setProjectName('') + setShowAddModal(false) + }) + .catch(function (error) { + console.log(error); + }); + // dispatch(postAgama(obj)) } const onDrop = useCallback((acceptedFiles) => { // Do something with the files @@ -71,11 +94,9 @@ function AgamaListPage() { zip.forEach(function (relativePath, zipEntry) { if (zipEntry.name.endsWith('.json')) { foundJson = true - console.log(zipEntry.name) if (!foundProjectName) { zipEntry.async('string').then(function (jsonStr) { const jsonData = JSON.parse(jsonStr) // Parse the JSON data - console.log(jsonData) // Do something with the JSON data if (jsonData?.projectName) { foundProjectName = true setGetProjectName(false) @@ -96,13 +117,12 @@ function AgamaListPage() { setGetProjectName(true) } }) - // console.log(acceptedFiles[0]); }, []) const { acceptedFiles, getRootProps, getInputProps } = useDropzone({ onDrop, multiple: false, accept: { - 'application/*': ['.zip'], + 'application/x-zip-compressed': ['.zip'], }, }) @@ -111,11 +131,10 @@ function AgamaListPage() { ) const agamaList = useSelector((state) => state.agamaReducer.agamaList) const permissions = useSelector((state) => state.authReducer.permissions) - SetTitle(t('titles.oidc_clients')) + SetTitle(t('titles.agama')) let memoLimit = limit useEffect(() => { - console.log('GET AGAMA') dispatch(getAgama()) }, []) diff --git a/admin-ui/plugins/auth-server/redux/actions/AgamaActions.js b/admin-ui/plugins/auth-server/redux/actions/AgamaActions.js index 294111795..578e595d0 100644 --- a/admin-ui/plugins/auth-server/redux/actions/AgamaActions.js +++ b/admin-ui/plugins/auth-server/redux/actions/AgamaActions.js @@ -9,8 +9,4 @@ import { type: GET_AGAMA_RESPONSE, payload: data }) - - export const postAgama = (data) => ({ - type:POST_AGAMA, - payload:data - }) \ No newline at end of file + \ No newline at end of file diff --git a/admin-ui/plugins/auth-server/redux/actions/types.js b/admin-ui/plugins/auth-server/redux/actions/types.js index 8d6c7f0ed..5ad3acbf9 100644 --- a/admin-ui/plugins/auth-server/redux/actions/types.js +++ b/admin-ui/plugins/auth-server/redux/actions/types.js @@ -97,5 +97,3 @@ export const REVOKE_SESSION_RESPONSE = 'REVOKE_SESSION_RESPONSE' export const GET_AGAMA = "GET_AGAMA" export const GET_AGAMA_RESPONSE = "GET_AGAMA_RESPONSE" -export const POST_AGAMA = "POST_AGAMA" -export const POST_AGAMA_RESPONSE = "POST_AGAMA_RESPONSE" diff --git a/admin-ui/plugins/auth-server/redux/api/AgamaApi.js b/admin-ui/plugins/auth-server/redux/api/AgamaApi.js index 066dea915..1a04ed15d 100644 --- a/admin-ui/plugins/auth-server/redux/api/AgamaApi.js +++ b/admin-ui/plugins/auth-server/redux/api/AgamaApi.js @@ -13,16 +13,4 @@ export default class AgamaApi { }) }) } - // Post Agama - postAgama = ({payload}) => { - console.log('abcd',payload) - let opts = {} - opts['requestBody'] = payload.file - opts['name'] = payload.name - return new Promise((resolve, reject) => { - this.api.postAgamaDevStudioPrj(payload, (error, data) => { - handleResponse(error, reject, resolve, data) - }) - }) - } } diff --git a/admin-ui/plugins/auth-server/redux/sagas/AgamaSaga.js b/admin-ui/plugins/auth-server/redux/sagas/AgamaSaga.js index fb8b956da..57f7c7c79 100644 --- a/admin-ui/plugins/auth-server/redux/sagas/AgamaSaga.js +++ b/admin-ui/plugins/auth-server/redux/sagas/AgamaSaga.js @@ -1,8 +1,7 @@ import { call, all, put, fork, takeLatest, select } from 'redux-saga/effects' import { isFourZeroOneError } from 'Utils/TokenController' -import { getAcrsResponse, editAcrsResponse } from '../actions/AcrsActions' import { getAPIAccessToken } from 'Redux/actions/AuthActions' -import { GET_AGAMA, POST_AGAMA } from '../actions/types' +import { GET_AGAMA } from '../actions/types' import AgamaApi from '../api/AgamaApi' import { getClient } from 'Redux/api/base' import { getAgamaResponse } from '../actions/AgamaActions' @@ -29,20 +28,6 @@ export function* getAgamas() { } } } -export function* postAgamaSaga(payload) { - console.log("POST AGAMA") - try { - const api = yield* newFunction() - const data = yield call(api.postAgama, payload) - console.log(data); - // yield put(getAgamaResponse(data)) - } catch (e) { - if (isFourZeroOneError(e)) { - const jwt = yield select((state) => state.authReducer.userinfo_jwt) - yield put(getAPIAccessToken(jwt)) - } - } -} @@ -50,11 +35,8 @@ export function* postAgamaSaga(payload) { export function* watchGetAgama() { yield takeLatest(GET_AGAMA, getAgamas) } -export function* watchPostAgama() { - yield takeLatest(POST_AGAMA, postAgamaSaga) -} export default function* rootSaga() { - yield all([fork(watchGetAgama), fork(watchPostAgama)]) + yield all([fork(watchGetAgama)]) }