Loading src/configs/apiService.js +11 −0 Original line number Diff line number Diff line import axiosInstance from './axiosInstance' import axiosMockAdapter from 'axios-mock-adapter' import axios from 'axios' export const getInvokers = async () => { return axiosInstance.get(`/resources/invokers`) Loading @@ -19,3 +22,11 @@ export const getProviderServices = async providerId => { export const getEvents = async id => { return axiosInstance.get(`/resources/events/${id}`) } export const getUsers = async id => { return axiosInstance1.get(`/users`) } export const getUser = async id => { return axiosInstance.get(`/users/${id}`) } src/configs/axiosInstance.js +12 −1 Original line number Diff line number Diff line Loading @@ -4,10 +4,12 @@ import authConfig from 'src/configs/auth' const DEBUG_SHOW_DATA = true // Create axios instance const axiosInstance = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_BASE_URL }) // RESPONSE interceptor for API calls axiosInstance.interceptors.request.use( req => { if (process.env.NODE_ENV === 'development') { Loading @@ -20,6 +22,8 @@ axiosInstance.interceptors.request.use( const accessToken = getAccessToken() const refreshToken = getRefreshToken() // if token existe and request is not refresh, add token to headers if (accessToken && req.url !== '/refresh') { req.headers['Authorization'] = `Bearer ${accessToken}` } Loading @@ -28,7 +32,7 @@ axiosInstance.interceptors.request.use( req.headers['Authorization'] = `Bearer ${refreshToken}` } return req return req // return request }, error => { console.error('🔴 REQUEST ERROR: ', error.message) Loading @@ -37,8 +41,11 @@ axiosInstance.interceptors.request.use( } ) // RESPONSE interceptor for API calls axiosInstance.interceptors.response.use( res => { // if env is development, show log if (process.env.NODE_ENV === 'development') { if (DEBUG_SHOW_DATA) { console.log(`🟢 ${res.status} ${res.config.url}`, res.data) Loading @@ -49,6 +56,8 @@ axiosInstance.interceptors.response.use( return res }, // try to refresh token if 401 error async error => { console.error('🔴 RESPONSE ERROR: ', error.message) Loading @@ -58,9 +67,11 @@ axiosInstance.interceptors.response.use( error.response.config.url !== '/auth/me' && error.response.config.url !== '/refresh' ) { // try to refresh token const refreshToken = getRefreshToken() if (refreshToken) { try { // Post request to refresh token const response = await axiosInstance.post(authConfig.refreshEndpoint) setAccessToken(response.data.access_token) Loading src/configs/cookies.js +4 −3 Original line number Diff line number Diff line Loading @@ -15,10 +15,11 @@ export const setAccessToken = accessToken => { }) } // getAccessToken() se utiliza para obtener el token de acceso almacenado en las cookies export const getAccessToken = () => { return Cookies.get(ACCESS_TOKEN_KEY) ? decryptString(Cookies.get(ACCESS_TOKEN_KEY), ACCESS_TOKEN_ENCRYPTION_KEY) : null return Cookies.get(ACCESS_TOKEN_KEY) // comprueba si la cookie existe ? decryptString(Cookies.get(ACCESS_TOKEN_KEY), ACCESS_TOKEN_ENCRYPTION_KEY) // si existe, desencripta el token de acceso uitlizando la clave de cifrado : null // si no existe, devuelve null } export const setRefreshToken = refreshToken => { Loading src/pages/dashboard/index.js +17 −1 Original line number Diff line number Diff line Loading @@ -6,8 +6,12 @@ const Dashboard = () => { return ( <Grid container spacing={6}> {/* Card Runing containers*/} <Grid item xs={12} sm={4}> <iframe // src = url del panel de grafana a incrustar // NEXT_PUBLIC_GRAFANA_BASE_URL="http://10.95.235.20:3001" src={`${ process.env.NEXT_PUBLIC_GRAFANA_BASE_URL }/d-solo/f66dea48-ca2f-46fb-a6f0-50bf50502d74/docker-monitoring?orgId=1&refresh=10s&theme=${ Loading @@ -15,9 +19,11 @@ const Dashboard = () => { }&panelId=7`} width='100%' height='105' style={{ border: 0 }} style={{ border: 0 }} // delete border of iframe /> </Grid> {/* Card Total Memory Usage */} <Grid item xs={12} sm={4}> <iframe src={`${ Loading @@ -30,6 +36,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Total CPU Usage */} <Grid item xs={12} sm={4}> <iframe src={`${ Loading @@ -42,6 +50,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Car graph CPU Usage*/} <Grid item xs={12}> <iframe src={`${ Loading @@ -54,6 +64,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card graph Memory Usage */} <Grid item xs={12}> <iframe src={`${ Loading @@ -66,6 +78,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Network Rx */} <Grid item xs={12} sm={6}> <iframe src={`${ Loading @@ -78,6 +92,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Network Tx */} <Grid item xs={12} sm={6}> <iframe src={`${ Loading src/pages/invokers/[id].js +14 −38 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import { styled } from '@mui/material/styles' import Typography from '@mui/material/Typography' import CardHeader from '@mui/material/CardHeader' import PageHeader from 'src/@core/components/page-header' import Button from '@mui/material/Button' import Paper from '@mui/material/Paper' import Table from '@mui/material/Table' import TableRow from '@mui/material/TableRow' Loading Loading @@ -49,7 +50,7 @@ const Invokers = () => { <CardHeader title='Info' /> <CardContent> {!invokerEvents && <CircularProgress />} {invokerEvents && invokerEvents.length === 0 && <strong>Algo de la información del usuario al que pertenece. API para la que se ha creado el invoker. API para hacer X.</strong>} {invokerEvents && invokerEvents.length === 0 && <strong>Some of the information about the user that it belongs.API for which the invoker has been created. API to do something.</strong>} {invokerEvents && invokerEvents.length > 0 && ( <TableContainer> <Table sx={{ minWidth: 650 }} aria-label='Card Actions'> Loading Loading @@ -85,10 +86,11 @@ const Invokers = () => { <> <TableHead> <TableRow> <TableCell>Nombre API</TableCell> <TableCell>Método Autenticación</TableCell> <TableCell>Fecha alta</TableCell> <TableCell>Validez</TableCell> <TableCell>API name</TableCell> <TableCell>Athentication method</TableCell> <TableCell>Started date</TableCell> <TableCell>Validity</TableCell> <TableCell>Delete</TableCell> </TableRow> </TableHead> <TableBody> Loading @@ -105,6 +107,10 @@ const Invokers = () => { </TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>limit date</TableCell> <TableCell> <Button variant='contained'>Delete</Button> </TableCell> </TableRow> ))} </TableBody> Loading @@ -117,7 +123,7 @@ const Invokers = () => { <Grid item xs={12}> <Card> <CardHeader title='Events 2' /> <CardHeader title='Events' /> <TableContainer component={Paper}> <Table sx={{ minWidth: 650 }} aria-label='Invokers table'> {!invokerSecurityData && <CircularProgress />} Loading @@ -143,8 +149,8 @@ const Invokers = () => { > <TableCell component='th' scope='row'> </TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>For example</TableCell> <TableCell>for example</TableCell> </TableRow> ))} </TableBody> Loading @@ -154,36 +160,6 @@ const Invokers = () => { </TableContainer> </Card> </Grid> <Grid item xs={12}> <Card> <CardHeader title='Events' /> <CardContent> {!invokerEvents && <CircularProgress />} {invokerEvents && invokerEvents.length === 0 && <strong>No info</strong>} {invokerEvents && invokerEvents.length > 0 && ( <TableContainer> <Table sx={{ minWidth: 650 }} aria-label='Card Actions'> <TableHead> <TableRow> <TableCell>Identificador</TableCell> <TableCell>TimeStamp</TableCell> <TableCell>Descripción</TableCell> </TableRow> </TableHead> <TableBody> <TableRow> <TableCell>{invokerEvents[0].subscriber_id}</TableCell> <TableCell>{invokerEvents[0].subscription_id}</TableCell> <TableCell>{invokerEvents[0].notificationDestination}</TableCell> </TableRow> </TableBody> </Table> </TableContainer> )} </CardContent> </Card> </Grid> </Grid> ) } Loading Loading
src/configs/apiService.js +11 −0 Original line number Diff line number Diff line import axiosInstance from './axiosInstance' import axiosMockAdapter from 'axios-mock-adapter' import axios from 'axios' export const getInvokers = async () => { return axiosInstance.get(`/resources/invokers`) Loading @@ -19,3 +22,11 @@ export const getProviderServices = async providerId => { export const getEvents = async id => { return axiosInstance.get(`/resources/events/${id}`) } export const getUsers = async id => { return axiosInstance1.get(`/users`) } export const getUser = async id => { return axiosInstance.get(`/users/${id}`) }
src/configs/axiosInstance.js +12 −1 Original line number Diff line number Diff line Loading @@ -4,10 +4,12 @@ import authConfig from 'src/configs/auth' const DEBUG_SHOW_DATA = true // Create axios instance const axiosInstance = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_BASE_URL }) // RESPONSE interceptor for API calls axiosInstance.interceptors.request.use( req => { if (process.env.NODE_ENV === 'development') { Loading @@ -20,6 +22,8 @@ axiosInstance.interceptors.request.use( const accessToken = getAccessToken() const refreshToken = getRefreshToken() // if token existe and request is not refresh, add token to headers if (accessToken && req.url !== '/refresh') { req.headers['Authorization'] = `Bearer ${accessToken}` } Loading @@ -28,7 +32,7 @@ axiosInstance.interceptors.request.use( req.headers['Authorization'] = `Bearer ${refreshToken}` } return req return req // return request }, error => { console.error('🔴 REQUEST ERROR: ', error.message) Loading @@ -37,8 +41,11 @@ axiosInstance.interceptors.request.use( } ) // RESPONSE interceptor for API calls axiosInstance.interceptors.response.use( res => { // if env is development, show log if (process.env.NODE_ENV === 'development') { if (DEBUG_SHOW_DATA) { console.log(`🟢 ${res.status} ${res.config.url}`, res.data) Loading @@ -49,6 +56,8 @@ axiosInstance.interceptors.response.use( return res }, // try to refresh token if 401 error async error => { console.error('🔴 RESPONSE ERROR: ', error.message) Loading @@ -58,9 +67,11 @@ axiosInstance.interceptors.response.use( error.response.config.url !== '/auth/me' && error.response.config.url !== '/refresh' ) { // try to refresh token const refreshToken = getRefreshToken() if (refreshToken) { try { // Post request to refresh token const response = await axiosInstance.post(authConfig.refreshEndpoint) setAccessToken(response.data.access_token) Loading
src/configs/cookies.js +4 −3 Original line number Diff line number Diff line Loading @@ -15,10 +15,11 @@ export const setAccessToken = accessToken => { }) } // getAccessToken() se utiliza para obtener el token de acceso almacenado en las cookies export const getAccessToken = () => { return Cookies.get(ACCESS_TOKEN_KEY) ? decryptString(Cookies.get(ACCESS_TOKEN_KEY), ACCESS_TOKEN_ENCRYPTION_KEY) : null return Cookies.get(ACCESS_TOKEN_KEY) // comprueba si la cookie existe ? decryptString(Cookies.get(ACCESS_TOKEN_KEY), ACCESS_TOKEN_ENCRYPTION_KEY) // si existe, desencripta el token de acceso uitlizando la clave de cifrado : null // si no existe, devuelve null } export const setRefreshToken = refreshToken => { Loading
src/pages/dashboard/index.js +17 −1 Original line number Diff line number Diff line Loading @@ -6,8 +6,12 @@ const Dashboard = () => { return ( <Grid container spacing={6}> {/* Card Runing containers*/} <Grid item xs={12} sm={4}> <iframe // src = url del panel de grafana a incrustar // NEXT_PUBLIC_GRAFANA_BASE_URL="http://10.95.235.20:3001" src={`${ process.env.NEXT_PUBLIC_GRAFANA_BASE_URL }/d-solo/f66dea48-ca2f-46fb-a6f0-50bf50502d74/docker-monitoring?orgId=1&refresh=10s&theme=${ Loading @@ -15,9 +19,11 @@ const Dashboard = () => { }&panelId=7`} width='100%' height='105' style={{ border: 0 }} style={{ border: 0 }} // delete border of iframe /> </Grid> {/* Card Total Memory Usage */} <Grid item xs={12} sm={4}> <iframe src={`${ Loading @@ -30,6 +36,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Total CPU Usage */} <Grid item xs={12} sm={4}> <iframe src={`${ Loading @@ -42,6 +50,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Car graph CPU Usage*/} <Grid item xs={12}> <iframe src={`${ Loading @@ -54,6 +64,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card graph Memory Usage */} <Grid item xs={12}> <iframe src={`${ Loading @@ -66,6 +78,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Network Rx */} <Grid item xs={12} sm={6}> <iframe src={`${ Loading @@ -78,6 +92,8 @@ const Dashboard = () => { style={{ border: 0 }} /> </Grid> {/* Card Network Tx */} <Grid item xs={12} sm={6}> <iframe src={`${ Loading
src/pages/invokers/[id].js +14 −38 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import { styled } from '@mui/material/styles' import Typography from '@mui/material/Typography' import CardHeader from '@mui/material/CardHeader' import PageHeader from 'src/@core/components/page-header' import Button from '@mui/material/Button' import Paper from '@mui/material/Paper' import Table from '@mui/material/Table' import TableRow from '@mui/material/TableRow' Loading Loading @@ -49,7 +50,7 @@ const Invokers = () => { <CardHeader title='Info' /> <CardContent> {!invokerEvents && <CircularProgress />} {invokerEvents && invokerEvents.length === 0 && <strong>Algo de la información del usuario al que pertenece. API para la que se ha creado el invoker. API para hacer X.</strong>} {invokerEvents && invokerEvents.length === 0 && <strong>Some of the information about the user that it belongs.API for which the invoker has been created. API to do something.</strong>} {invokerEvents && invokerEvents.length > 0 && ( <TableContainer> <Table sx={{ minWidth: 650 }} aria-label='Card Actions'> Loading Loading @@ -85,10 +86,11 @@ const Invokers = () => { <> <TableHead> <TableRow> <TableCell>Nombre API</TableCell> <TableCell>Método Autenticación</TableCell> <TableCell>Fecha alta</TableCell> <TableCell>Validez</TableCell> <TableCell>API name</TableCell> <TableCell>Athentication method</TableCell> <TableCell>Started date</TableCell> <TableCell>Validity</TableCell> <TableCell>Delete</TableCell> </TableRow> </TableHead> <TableBody> Loading @@ -105,6 +107,10 @@ const Invokers = () => { </TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>limit date</TableCell> <TableCell> <Button variant='contained'>Delete</Button> </TableCell> </TableRow> ))} </TableBody> Loading @@ -117,7 +123,7 @@ const Invokers = () => { <Grid item xs={12}> <Card> <CardHeader title='Events 2' /> <CardHeader title='Events' /> <TableContainer component={Paper}> <Table sx={{ minWidth: 650 }} aria-label='Invokers table'> {!invokerSecurityData && <CircularProgress />} Loading @@ -143,8 +149,8 @@ const Invokers = () => { > <TableCell component='th' scope='row'> </TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>{invokerSecurityData[0].notification_destination}</TableCell> <TableCell>For example</TableCell> <TableCell>for example</TableCell> </TableRow> ))} </TableBody> Loading @@ -154,36 +160,6 @@ const Invokers = () => { </TableContainer> </Card> </Grid> <Grid item xs={12}> <Card> <CardHeader title='Events' /> <CardContent> {!invokerEvents && <CircularProgress />} {invokerEvents && invokerEvents.length === 0 && <strong>No info</strong>} {invokerEvents && invokerEvents.length > 0 && ( <TableContainer> <Table sx={{ minWidth: 650 }} aria-label='Card Actions'> <TableHead> <TableRow> <TableCell>Identificador</TableCell> <TableCell>TimeStamp</TableCell> <TableCell>Descripción</TableCell> </TableRow> </TableHead> <TableBody> <TableRow> <TableCell>{invokerEvents[0].subscriber_id}</TableCell> <TableCell>{invokerEvents[0].subscription_id}</TableCell> <TableCell>{invokerEvents[0].notificationDestination}</TableCell> </TableRow> </TableBody> </Table> </TableContainer> )} </CardContent> </Card> </Grid> </Grid> ) } Loading