Skip to content

Commit

Permalink
Merge pull request #533 from Krishanx92/main
Browse files Browse the repository at this point in the history
Add APK implementation to APIM
  • Loading branch information
Krishanx92 authored Feb 7, 2024
2 parents 7a7e83e + 5a01b4f commit fa77060
Show file tree
Hide file tree
Showing 27 changed files with 739 additions and 256 deletions.
6 changes: 6 additions & 0 deletions portals/admin/src/main/webapp/site/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Admin.KeyManager.label.allow.exchange.token": "Token Exchange",
"Admin.KeyManager.label.message.allow.direct.token": "Direct Token",
"Admin.KeyManager.label.token.audience": "Allowed Token Audience ",
"Admin.KeyManager.permission.type": "Key Manager Permission",
"Admin.Throttling.Advanced.Throttling.policy.table.header.name": "Name",
"Admin.Throttling.Advanced.Throttling.policy.table.header.quota": "Quota",
"Admin.Throttling.Advanced.Throttling.policy.table.header.quota.policy": "Quota Policy",
Expand Down Expand Up @@ -77,6 +78,7 @@
"AdminPages.Gateways.List.title": "Gateway Environments",
"AdminPages.Gateways.table.header.description": "Description",
"AdminPages.Gateways.table.header.displayName": "Name",
"AdminPages.Gateways.table.header.gatewayType": "Gateway Type",
"AdminPages.Gateways.table.header.vhosts": "Virtual Host(s)",
"AdminPages.KeyManager.Delete.form.delete.confirmation.message": "Are you sure you want to delete this KeyManager ?",
"AdminPages.KeyManagers.Delete.form.delete.successful": "KeyManager deleted successfully",
Expand Down Expand Up @@ -190,6 +192,7 @@
"GatewayEnvironments.AddEditVhost.httpsPort": "HTTPS Port",
"GatewayEnvironments.AddEditVhost.wsPort": "WS Port",
"GatewayEnvironments.AddEditVhost.wssPort": "WSS Port",
"KeyManager.AddEditKeyManager.permissions.add.description": "Permissions for the Key Manager",
"KeyManager.Claim.Helper.text": "Add Claim Mappings",
"KeyManager.Connector.Configuration.Helper.text": "Add Key Manager Connector Configurations",
"KeyManager.KeyValidation.CUSTOM": "CUSTOM",
Expand All @@ -199,6 +202,9 @@
"KeyManager.add.success": "Key Manager added successfully.",
"KeyManager.add.success.msg": " - Key Manager added successfully.",
"KeyManager.edit.success": " - Key Manager edited successfully.",
"KeyManager.enter.permission.allowed": "Use of this Key-Manager is\n \"Allowed\" for above roles.",
"KeyManager.enter.permission.denied": "Use of this Key-Manager is\n \"Denied\" for above roles.",
"KeyManager.permissions": "Permissions",
"KeyManagers.AddEditKeyManager.\n form.scopeManagementEndpoint": "Scope Management Endpoint",
"KeyManagers.AddEditKeyManager.\n form.displayRevokeEndpoint": "Display Revoke Endpoint",
"KeyManagers.AddEditKeyManager.External.KeyManager\n .general.details.description": "Identity Provider vendor and the token usage mode",
Expand Down
10 changes: 10 additions & 0 deletions portals/admin/src/main/webapp/site/public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
"Admin.KeyManager.label.allow.exchange.token": "",
"Admin.KeyManager.label.message.allow.direct.token": "",
"Admin.KeyManager.label.token.audience": "",
"Admin.KeyManager.permission.type": "",
"Admin.Throttling.Advanced.Throttling.policy.table.header.name": "",
"Admin.Throttling.Advanced.Throttling.policy.table.header.quota": "",
"Admin.Throttling.Advanced.Throttling.policy.table.header.quota.policy": "",
"Admin.Throttling.Advanced.Throttling.policy.table.header.unit.time": "",
"Admin.Throttling.Application.AddEdit.burst.control.add.description": "",
"Admin.Throttling.Application.Throttling.Policy.add.burst.limits.details": "",
"Admin.Throttling.Application.Throttling.Policy.add.data.amount.helper.text": "",
"Admin.Throttling.Application.Throttling.Policy.add.description.helper.text": "",
"Admin.Throttling.Application.Throttling.Policy.add.general.details": "",
Expand Down Expand Up @@ -75,6 +78,7 @@
"AdminPages.Gateways.List.title": "",
"AdminPages.Gateways.table.header.description": "",
"AdminPages.Gateways.table.header.displayName": "",
"AdminPages.Gateways.table.header.gatewayType": "",
"AdminPages.Gateways.table.header.vhosts": "",
"AdminPages.KeyManager.Delete.form.delete.confirmation.message": "",
"AdminPages.KeyManagers.Delete.form.delete.successful": "",
Expand Down Expand Up @@ -188,6 +192,7 @@
"GatewayEnvironments.AddEditVhost.httpsPort": "",
"GatewayEnvironments.AddEditVhost.wsPort": "",
"GatewayEnvironments.AddEditVhost.wssPort": "",
"KeyManager.AddEditKeyManager.permissions.add.description": "",
"KeyManager.Claim.Helper.text": "",
"KeyManager.Connector.Configuration.Helper.text": "",
"KeyManager.KeyValidation.CUSTOM": "",
Expand All @@ -197,6 +202,9 @@
"KeyManager.add.success": "",
"KeyManager.add.success.msg": "",
"KeyManager.edit.success": "",
"KeyManager.enter.permission.allowed": "",
"KeyManager.enter.permission.denied": "",
"KeyManager.permissions": "",
"KeyManagers.AddEditKeyManager.\n form.scopeManagementEndpoint": "",
"KeyManagers.AddEditKeyManager.\n form.displayRevokeEndpoint": "",
"KeyManagers.AddEditKeyManager.External.KeyManager\n .general.details.description": "",
Expand Down Expand Up @@ -457,6 +465,8 @@
"Throttling.Advanced.List.help.link.two": "",
"Throttling.Advanced.List.search.default": "",
"Throttling.Advanced.List.title.main": "",
"Throttling.Application.AddEdit.burst.control.limit": "",
"Throttling.Application.AddEdit.form.request.rate": "",
"Throttling.Application.Policy..List.search.default": "",
"Throttling.Application.Policy.List.addButtonProps.title": "",
"Throttling.Application.Policy.List.addButtonProps.triggerButtonText": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ import React, { useEffect, useReducer, useState } from 'react';
import API from 'AppData/api';
import PropTypes from 'prop-types';
import TextField from '@material-ui/core/TextField';
import { useAppContext } from 'AppComponents/Shared/AppContext';
import { FormattedMessage, useIntl } from 'react-intl';
import FormControl from '@material-ui/core/FormControl';
import { makeStyles } from '@material-ui/core/styles';
import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
import Alert from 'AppComponents/Shared/Alert';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import Typography from '@material-ui/core/Typography';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormLabel from '@material-ui/core/FormLabel';
import AddEditVhost from 'AppComponents/GatewayEnvironments/AddEditVhost';

const useStyles = makeStyles((theme) => ({
Expand All @@ -40,6 +46,39 @@ const useStyles = makeStyles((theme) => ({
padding: theme.spacing(1),
marginBottom: theme.spacing(1),
},
radioOutline: {
display: 'flex',
alignItems: 'center',
width: '200px', // Set your desired width
height: '125px', // Set your desired height
padding: '4px', // Adjust the padding for the desired outline size
marginRight: '30px',
marginLeft: '10px',
marginTop: '10px',
marginBottom: '10px',
border: '2px solid gray', // Initial border color
borderRadius: '8px', // Adjust the border-radius for a square outline
transition: 'border 0.3s', // Add transition for a smooth color change
'&:hover': {
border: '2px solid gray', // Keep the gray color on hover
},
'&.Mui-checked': {
border: `2px solid ${theme.palette.primary.main}`, // Change to blue when selected
},
},
label: {
marginLeft: '10px', // Adjust as needed for spacing between the radio button and label
},
newLabel: {
backgroundColor: 'green', // Blue color
color: 'white',
fontWeight: 'bold',
fontSize: '0.6rem',
padding: '2px 4px', // Adjust padding as needed
borderRadius: '4px', // Adjust border-radius for rounded corners
marginLeft: '10px', // Adjust margin as needed
display: 'inline-block', // Ensure inline display
},
}));

/**
Expand All @@ -53,6 +92,7 @@ function reducer(state, { field, value }) {
switch (field) {
case 'name':
case 'displayName':
case 'gatewayType':
case 'description':
case 'vhosts':
return { ...state, [field]: value };
Expand All @@ -74,7 +114,6 @@ function AddEditGWEnvironment(props) {
updateList, dataRow, icon, triggerButtonText, title,
} = props;
const classes = useStyles();

const defaultVhost = {
host: '', httpContext: '', httpsPort: 8243, httpPort: 8280, wssPort: 8099, wsPort: 9099, isNew: true,
};
Expand All @@ -93,12 +132,30 @@ function AddEditGWEnvironment(props) {
const onChange = (e) => {
dispatch({ field: e.target.name, value: e.target.value });
};

const [selectedGatewayType, setValue] = React.useState('');
const { settings } = useAppContext();
const { gatewayTypes } = settings;
const getBorderColor = (gatewayType) => {
return selectedGatewayType === gatewayType
? '2px solid #1976D2'
: '2px solid gray';
};

const handleChange = (event) => {
setValue(event.target.value);
};

useEffect(() => {
setInitialState({
displayName: '',
description: '',
selectedGatewayType: '',
vhosts: [defaultVhost],
});
if (gatewayTypes.length === 1) {
setValue(gatewayTypes[0]);
}
}, []);

const handleHostValidation = (vhost) => {
Expand Down Expand Up @@ -252,27 +309,39 @@ function AddEditGWEnvironment(props) {
return false;
}
const vhostDto = [];
vhosts.forEach((vhost) => {
vhostDto.push({
host: vhost.host,
httpContext: vhost.httpContext,
httpPort: vhost.httpPort,
httpsPort: vhost.httpsPort,
wsPort: vhost.wsPort,
wssPort: vhost.wssPort,
if (selectedGatewayType === 'Regular') {
vhosts.forEach((vhost) => {
vhostDto.push({
host: vhost.host,
httpContext: vhost.httpContext,
httpPort: vhost.httpPort,
httpsPort: vhost.httpsPort,
wsPort: vhost.wsPort,
wssPort: vhost.wssPort,
});
});
});
} else if (selectedGatewayType === 'APK') {
vhosts.forEach((vhost) => {
vhostDto.push({
host: vhost.host,
httpContext: vhost.httpContext,
httpPort: vhost.httpPort,
httpsPort: vhost.httpsPort,
});
});
}

const restApi = new API();
let promiseAPICall;
if (dataRow) {
// assign the update promise to the promiseAPICall
promiseAPICall = restApi.updateGatewayEnvironment(
dataRow.id, name.trim(), displayName, description, vhostDto,
dataRow.id, name.trim(), displayName, description, selectedGatewayType, vhostDto,
);
} else {
// assign the create promise to the promiseAPICall
promiseAPICall = restApi.addGatewayEnvironment(name.trim(), displayName, description, vhostDto);
promiseAPICall = restApi.addGatewayEnvironment(name.trim(), displayName, description,
selectedGatewayType, vhostDto);
}

return promiseAPICall.then(() => {
Expand Down Expand Up @@ -399,9 +468,56 @@ function AddEditGWEnvironment(props) {
)}
variant='outlined'
/>
{gatewayTypes && gatewayTypes.length > 1 && (
<FormControl component='fieldset'>
<FormLabel style={{ marginTop: '10px' }}>Select Gateway type</FormLabel>
<RadioGroup
row
aria-label='gateway-type'
name='gateway-type'
value={selectedGatewayType}
onChange={handleChange}
>
<FormControlLabel
value='Regular'
name='Regular'
className={classes.radioOutline}
control={<Radio />}
label={(
<div>
<span>Regular Gateway</span>
<Typography variant='body2' color='textSecondary'>
API gateway embedded in APIM runtime.
Connect directly to an existing APIManager.
</Typography>
</div>
)}
style={{ border: getBorderColor('Regular') }}
/>
<FormControlLabel
value='APK'
name='APK'
className={classes.radioOutline}
control={<Radio />}
label={(
<div>
<span>APK Gateway</span>
<span className={`${classes.label} ${classes.newLabel}`}>New</span>
<Typography variant='body2' color='textSecondary'>
Fast API gateway running on kubernetes designed to manage
and secure APIs.
</Typography>
</div>
)}
style={{ border: getBorderColor('APK') }}
/>
</RadioGroup>
</FormControl>
)}
<AddEditVhost
initialVhosts={vhosts}
onVhostChange={onChange}
selectedGatewayType={selectedGatewayType}
/>
</FormControl>
</FormDialogBase>
Expand Down
Loading

0 comments on commit fa77060

Please sign in to comment.