Skip to content

Commit

Permalink
feat: show license details on GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
duttarnab committed Sep 15, 2021
1 parent e5c75f6 commit 6365b2a
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 3 deletions.
14 changes: 13 additions & 1 deletion app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,18 @@
"user_info_signed_response_alg": "JWS alg Algorithm for signing userinfo responses",
"user_name": "User Name",
"user_password": "User Password",
"view_type": "View Type"
"view_type": "View Type",
"productName": "Product Name",
"productCode": "Product Code",
"licenseType": "License Type",
"maxActivations": "Maximum Activations",
"licenseKey": "License Key",
"isLicenseActive": "Is License Active",
"validityPeriod": "License Valid Upto",
"companyName": "Company Name",
"customerEmail": "Customer Email",
"customerName": "Customer Name",
"licenseDetails": "License Details"
},
"languages": {
"french": "Français",
Expand All @@ -224,6 +235,7 @@
"keys": "Keys",
"ldap": "Ldap",
"license": "Licensing",
"licenseDetails": "License Details",
"my_profile": "My Profile",
"sql": "Sql",
"logging": "Logging",
Expand Down
14 changes: 13 additions & 1 deletion app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"keys": "Clés",
"ldap": "Ldap",
"license": "Licence",
"licenseDetails": "License Details",
"my_profile": "Mon profil",
"sql": "Sql",
"logging": "Enregistrement",
Expand Down Expand Up @@ -201,7 +202,18 @@
"user_info_signed_response_alg": "JWS alg Algorithm pour la signature des réponses userinfo",
"user_name": "Nom d'utilisateur",
"user_password": "Mot de passe de l'utilisateur",
"view_type": "Type de vue"
"view_type": "Type de vue",
"productName": "Product Name",
"productCode": "Product Code",
"licenseType": "License Type",
"maxActivations": "Maximum Activations",
"licenseKey": "License Key",
"isLicenseActive": "Is License Active",
"validityPeriod": "License Valid Upto",
"companyName": "Company Name",
"customerEmail": "Customer Email",
"customerName": "Customer Name",
"licenseDetails": "License Details"
},
"messages": {
"action_commit_question": "Journal d'audit : vous souhaitez appliquer les modifications apportées sur cette page ?",
Expand Down
14 changes: 13 additions & 1 deletion app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"keys": "Chaves",
"ldap": "Ldap",
"license": "Licenciamento",
"licenseDetails": "License Details",
"my_profile": "Meu perfil",
"sql": "Sql",
"logging": "Exploração madeireira",
Expand Down Expand Up @@ -200,7 +201,18 @@
"user_info_signed_response_alg": "Algoritmo JWS para assinar respostas userinfo",
"user_name": "Nome do usuário",
"user_password": "Senha do usuário",
"view_type": "Tipo de vista"
"view_type": "Tipo de vista",
"productName": "Product Name",
"productCode": "Product Code",
"licenseType": "License Type",
"maxActivations": "Maximum Activations",
"licenseKey": "License Key",
"isLicenseActive": "Is License Active",
"validityPeriod": "License Valid Upto",
"companyName": "Company Name",
"customerEmail": "Customer Email",
"customerName": "Customer Name",
"licenseDetails": "License Details"
},
"messages": {
"action_commit_question": "Registro de auditoria: deseja aplicar as alterações feitas nesta página?",
Expand Down
127 changes: 127 additions & 0 deletions plugins/admin/components/Configuration/LicenseDetailsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React, { useEffect, useState } from 'react'
import { useTranslation } from "react-i18next";
import { connect } from 'react-redux'
import GluuFormDetailRow from '../../../../app/routes/Apps/Gluu/GluuFormDetailRow'
import { HeaderMain } from '../../../../app/routes/components/HeaderMain'
import { getLicenseDetails } from '../../redux/actions/LicenseDetailsActions'
import { Container, Row, Col } from '../../../../app/components'

function LicenseDetailsPage({ item, loading, dispatch }) {
const { t } = useTranslation();

useEffect(() => {
dispatch(getLicenseDetails())
}, []);

return (
<React.Fragment>
{/* <Container> */}
<HeaderMain
title={t('fields.licenseDetails')}
className="mb-5 mt-4"
/>
<Container style={{ backgroundColor: '#F5F5F5' }}>
<Row>
<Col sm={3}>
<GluuFormDetailRow
label="fields.productName"
value={item.productName}
isBadge={true}
/>
</Col>
<Col sm={9}>
<GluuFormDetailRow
label="fields.productCode"
value={item.productCode}
isBadge={true}
lsize={3}
rsize={9}
/>
</Col>
</Row>
<Row>
<Col sm={3}>
<GluuFormDetailRow
label="fields.licenseType"
value={item.licenseType}
isBadge={true}
/>
</Col>
<Col sm={9}>
<GluuFormDetailRow
label="fields.maxActivations"
value={item.maxActivations}
isBadge={true}
lsize={3}
rsize={9}
/>
</Col>
</Row>
<Row>
<Col sm={3}>
<GluuFormDetailRow
label="fields.licenseKey"
value={item.licenseKey}
isBadge={true}
/>
</Col>
<Col sm={9}>
<GluuFormDetailRow
label="fields.isLicenseActive"
value={item.isLicenseActive}
isBadge={true}
lsize={3}
rsize={9}
/>
</Col>
</Row>
<Row>
<Col sm={3}>
<GluuFormDetailRow
label="fields.validityPeriod"
value={item.validityPeriod}
isBadge={true}
/>
</Col>
<Col sm={9}>
<GluuFormDetailRow
label="fields.companyName"
value={item.companyName}
isBadge={true}
lsize={3}
rsize={9}
/>
</Col>
</Row>
<Row>
<Col sm={3}>
<GluuFormDetailRow
label="fields.customerEmail"
value={item.customerEmail}
isBadge={true}
/>
</Col>
<Col sm={9}>
<GluuFormDetailRow
label="fields.companyName"
value={item.customerFirstName + " " + item.customerLastName}
isBadge={true}
lsize={3}
rsize={9}
/>
</Col>
</Row>
</Container>

</React.Fragment>
)
}

const mapStateToProps = (state) => {
alert(JSON.stringify(state.licenseDetailsReducer.item))
return {
item: state.licenseDetailsReducer.item,
loading: state.licenseDetailsReducer.loading,
}
}
export default connect(mapStateToProps)(LicenseDetailsPage)
15 changes: 15 additions & 0 deletions plugins/admin/plugin-metadata.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import HealthPage from './components/Health/HealthPage'
import ReportPage from './components/Reports/ReportPage'
import LicenseDetailsPage from './components/Configuration/LicenseDetailsPage'
import AdminUiRole from './components/Roles/AdminUiRole'
import MaximumActiveUsersPage from './components/MaximumActiveUsersPage'
import SettingsPage from './components/Settings/SettingsPage'
import scriptSaga from './redux/sagas/CustomScriptSaga'
import licenseDetailsSaga from './redux/sagas/LicenseDetailsSaga'

import ScriptListPage from './components/CustomScripts/ScriptListPage'
import CustomScriptAddPage from './components/CustomScripts/CustomScriptAddPage'
Expand All @@ -12,6 +14,7 @@ import CustomScriptEditPage from './components/CustomScripts/CustomScriptEditPag
import mauReducer from './redux/reducers/MauReducer'
import mauSaga from './redux/sagas/MauSaga'
import scriptReducer from './redux/reducers/CustomScriptReducer'
import licenseDetailsReducer from './redux/reducers/LicenseDetailsReducer'

const PLUGIN_BASE_APTH = '/adm'

Expand All @@ -31,6 +34,11 @@ const pluginMetadata = {
path: PLUGIN_BASE_APTH + '/mau',
permission: '/config/acrs.readonly',
},
{
title: 'menus.licenseDetails',
path: PLUGIN_BASE_APTH + '/licenseDetails',
permission: '/config/acrs.readonly',
},
{
title: 'menus.scripts',
path: PLUGIN_BASE_APTH + '/scripts',
Expand Down Expand Up @@ -102,14 +110,21 @@ const pluginMetadata = {
path: PLUGIN_BASE_APTH + '/settings',
permission: '/config/acrs.readonly',
},
{
component: LicenseDetailsPage,
path: PLUGIN_BASE_APTH + '/licenseDetails',
permission: '/config/acrs.readonly',
},
],
reducers: [
{ name: 'mauReducer', reducer: mauReducer },
{ name: 'scriptReducer', reducer: scriptReducer },
{ name: 'licenseDetailsReducer', reducer: licenseDetailsReducer },
],
sagas: [
mauSaga(),
scriptSaga(),
licenseDetailsSaga(),
],
}

Expand Down
10 changes: 10 additions & 0 deletions plugins/admin/redux/actions/LicenseDetailsActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { GET_LICENSE_DETAILS, GET_LICENSE_DETAILS_RESPONSE } from './types'

export const getLicenseDetails = () => ({
type: GET_LICENSE_DETAILS,
})

export const getLicenseDetailsResponse = (data) => ({
type: GET_LICENSE_DETAILS_RESPONSE,
payload: { data },
})
5 changes: 5 additions & 0 deletions plugins/admin/redux/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ export const GET_CUSTOM_SCRIPT_BY_TYPE_RESPONSE =
export const DELETE_CUSTOM_SCRIPT = 'DELETE_CUSTOM_SCRIPT'
export const DELETE_CUSTOM_SCRIPT_RESPONSE = 'DELETE_CUSTOM_SCRIPT_RESPONSE'
export const SET_SCRIPT_ITEM = 'SET_SCRIPT_ITEM'

//License Details

export const GET_LICENSE_DETAILS = 'GET_LICENSE_DETAILS'
export const GET_LICENSE_DETAILS_RESPONSE = 'GET_LICENSE_DETAILS_RESPONSE'
15 changes: 15 additions & 0 deletions plugins/admin/redux/api/LicenseDetailsApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from '../../../../app/redux/api/axios'

// Get License Details
export const getLicenseDetails = async () => {
return await axios
.get('/license/getLicenseDetails')
.then((response) => response.data)
.catch((error) => {
console.error(
'Problems getting license details in order to process authz code flow.',
error,
)
return -1
})
}
37 changes: 37 additions & 0 deletions plugins/admin/redux/reducers/LicenseDetailsReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { GET_LICENSE_DETAILS, GET_LICENSE_DETAILS_RESPONSE } from '../actions/types'
import reducerRegistry from '../../../../app/redux/reducers/ReducerRegistry'
const INIT_STATE = {
item: {},
loading: true,
}

const reducerName = 'licenseDetailsReducer'

export default function licenseDetailsReducer(state = INIT_STATE, action) {
switch (action.type) {
case GET_LICENSE_DETAILS:
alert('-------')
return {
...state,
loading: true,
}
case GET_LICENSE_DETAILS_RESPONSE:
if (action.payload.data) {
return {
...state,
item: action.payload.data,
loading: false,
}
} else {
return {
...state,
loading: false,
}
}
default:
return {
...state,
}
}
}
reducerRegistry.register(reducerName, licenseDetailsReducer)
42 changes: 42 additions & 0 deletions plugins/admin/redux/sagas/LicenseDetailsSaga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* License Sagas
*/
import { all, call, fork, put, takeEvery } from 'redux-saga/effects'
import { GET_LICENSE_DETAILS, GET_LICENSE_DETAILS_RESPONSE } from '../actions/types'
import {
getLicenseDetailsResponse,
} from '../actions/LicenseDetailsActions'

import {
getLicenseDetails,
} from '../api/LicenseDetailsApi'

function* getLicenseDetailsPresentWorker() {
try {
alert('Inside getLicenseDetailsPresentWorker')
const response = yield call(getLicenseDetails)
alert(response)
if (response) {
yield put(getLicenseDetailsResponse(response))
return
}
} catch (error) {
console.log('Error in fetching License Details.', error)
}
yield put(getLicenseDetailsResponse())
}

//watcher sagas
export function* getLicensePresentWatcher() {
yield takeEvery(GET_LICENSE_DETAILS, getLicenseDetailsPresentWorker)
}


/**
* License Root Saga
*/
export default function* rootSaga() {
yield all([
fork(getLicensePresentWatcher),
])
}

0 comments on commit 6365b2a

Please sign in to comment.