Skip to content

Commit

Permalink
feat: sql- add/edit/delete of sql configuration not working #283
Browse files Browse the repository at this point in the history
  • Loading branch information
duttarnab committed Oct 26, 2021
1 parent 744f6a4 commit 15da0a6
Show file tree
Hide file tree
Showing 16 changed files with 432 additions and 398 deletions.
43 changes: 33 additions & 10 deletions app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
},
"fields": {
"access_token_signing_alg": "Access Token Signing Algorithm",
"activate": "activate",
"activate": "Activate",
"active": "Active",
"application_type": "Application Type",
"attributes": "Attributes",
"attribute_edit_type": "Attribute Edit Type",
"attribute_view_type": "Attribute View Type",
"authentication_method": "Authentication method for the Token Endpoint",
"authorization_code_access_token": "Authorization Code Access Token",
"average_of_mau": "Average of MAU",
"base_dns": "Base DNs",
"bind_dn": "Bind DN",
"bind_password": "Bind Password",
Expand All @@ -41,7 +39,6 @@
"cache_configuration": "Cache Configuration",
"cache_provider_type": "Cache Provider Type",
"claims": "Claims",
"client_credentials_access_token": "Client Credentials Access Token",
"client_expiration_date": "Client Expiration Date",
"client_id": "Client Id",
"client_name": "Client Name",
Expand Down Expand Up @@ -107,8 +104,6 @@
"memcached_configuration": "memcachedConfiguration",
"maximum_length": "Maximum length",
"minimum_length": "Minimum length",
"month": "Month",
"monthly_active_users": "Monthly Active Users",
"multivalued": "Multivalued?",
"name": "Name",
"native_persistence_configuration": "nativePersistenceConfiguration",
Expand Down Expand Up @@ -221,7 +216,14 @@
"companyName": "Company Name",
"customerEmail": "Customer Email",
"customerName": "Customer Name",
"licenseDetails": "License Details"
"licenseDetails": "License Details",
"username": "Username",
"connectionUris": "Connection URIs",
"schemaName": "Schema Name",
"passwordEncryptionMethod": "Password Encryption Method",
"serverTimezone": "Server Timezone",
"binaryAttributes": "Binary Attributes",
"certificateAttributes": "Certificate Attributes"
},
"languages": {
"french": "Français",
Expand Down Expand Up @@ -295,7 +297,9 @@
"edit_ldap": "Edit Ldap",
"edit_attribute": "Edit Attribute",
"refresh_data": "Refresh Data",
"view_attribute": "View attribute"
"view_attribute": "View attribute",
"edit_sql": "Edit SQL",
"add_sql": "Add SQL"
},
"placeholders": {
"action_commit_message": "Provide the reason of this change",
Expand Down Expand Up @@ -332,7 +336,14 @@
"smtp_user_name": "Enter the SMTP user name",
"smtp_user_password": "Enter the SMTP user password",
"spontaneous_client_id": "Enter the spontaneous client id",
"typeahead_holder_message": "Enter multiple items by selecting from appeared dropdown after entering each item."
"typeahead_holder_message": "Enter multiple items by selecting from appeared dropdown after entering each item.",
"sql_config_name": "Enter the sql configuration name.",
"sql_username": "Enter the Username.",
"sql_password": "Enter the Password.",
"sql_schemaname": "Enter the schema name.",
"sql_passwordEncryptionMethod": "Add password encryption method.",
"sql_serverTimezone": "Enter server timezone.",
"activate_sql_configuration": "Activate SQL configuration."
},
"titles": {
"acrs": "ACRs",
Expand Down Expand Up @@ -793,14 +804,26 @@
"buckets": "The couchbase buckets to store data.",
"defaultBucket": "The default bucket for the Gluu Server.",
"connectTimeout": "Connection time out.",
"computationPoolSize": "Computation pool size.",
"computationPoolSize": "",
"useSSL":"Use this feature if the backend server allows SSL connectivity.",
"sslTrustStoreFile": "SSL truststore file.",
"sslTrustStoreFormat": "SSL truststore format.",
"sslTrustStorePin": "Encoded truststore pin.",
"userName": "Database username.",
"userPassword": "Database password."

},
"sql": {
"config_name": "Enter the sql configuration name.",
"username": "Enter the database username.",
"password": "Enter the database password.",
"schemaname": "Enter the schema name.",
"passwordEncryptionMethod": "Add password encryption method.",
"serverTimezone": "Enter server timezone.",
"binaryAttributes": "Binary attributes.",
"certificateAttributes": "Certificate attributes.",
"activate": "Activate SQL configuration.",
"connectionUri": "Connection URI of database."
}
}
}
1 change: 1 addition & 0 deletions app/utils/ApiResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export const JSON_CONFIG = 'json_properties'
export const SETTINGS = 'settings'
export const LICENSE = 'license'
export const LDAP = 'ldap'
export const SQL = 'sql'
export const COUCHBASE = 'couchbase'
export const CACHE = 'cache'
27 changes: 11 additions & 16 deletions plugins/services-plugin/Components/Configuration/SqlAddPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,29 @@ import React from 'react'
import { connect } from 'react-redux'
import { useHistory } from 'react-router-dom'
import { Container, CardBody, Card } from '../../../../app/components'
import LdapForm from './LdapForm'
import { addLdap } from '../../redux/actions/LdapActions'
import SqlForm from './SqlForm'
import { addSql } from '../../redux/actions/SqlActions'
import { buildPayload } from '../../../../app/utils/PermChecker'

function LdapAddPage({ dispatch }) {
function SqlAddPage({ dispatch }) {
const userAction = {}
const history = useHistory()
function handleSubmit(data) {
if (data) {
let message = data.ldap.action_message
delete data.ldap.action_message
let message = data.sql.action_message
delete data.sql.action_message
buildPayload(userAction, message, data)
dispatch(addLdap(userAction))
history.push('/config/ldap')
dispatch(addSql(userAction))
history.push('/config/sql')
}
}
const defautConfigurations = {
maxConnections: 2,
useSSL: false,
useAnonymousBind: false,
enabled: false
}
const defautConfigurations = {}
return (
<React.Fragment>
<Container>
<Card className="mb-3">
<CardBody>
<LdapForm
<SqlForm
item={defautConfigurations}
handleSubmit={handleSubmit}
/>
Expand All @@ -41,8 +36,8 @@ function LdapAddPage({ dispatch }) {
}
const mapStateToProps = (state) => {
return {
loading: state.ldapReducer.loading,
loading: state.sqlReducer.loading,
permissions: state.authReducer.permissions,
}
}
export default connect(mapStateToProps)(LdapAddPage)
export default connect(mapStateToProps)(SqlAddPage)
86 changes: 24 additions & 62 deletions plugins/services-plugin/Components/Configuration/SqlDetailPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../../../app/components'
import { useTranslation } from 'react-i18next'

const LdapDetailPage = ({ row, testLdapConnection }) => {
const SqlDetailPage = ({ row, testSqlConnection }) => {
const { t } = useTranslation()

function getBadgeTheme(status) {
Expand All @@ -20,8 +20,8 @@ const LdapDetailPage = ({ row, testLdapConnection }) => {
}
}

function checkLdapConnection() {
testLdapConnection(row)
function checkSqlConnection() {
testSqlConnection(row)
}

return (
Expand All @@ -31,7 +31,7 @@ const LdapDetailPage = ({ row, testLdapConnection }) => {
<Col sm={6}>
<FormGroup row>
<Label for="input" sm={6}>
{t('fields.configuration_id')}:
{t('fields.name')}:
</Label>
<Label for="input" sm={6}>
{row.configId}
Expand All @@ -41,35 +41,36 @@ const LdapDetailPage = ({ row, testLdapConnection }) => {
<Col sm={6}>
<FormGroup row>
<Label for="input" sm={6}>
{t('fields.bind_dn')}:
{t('fields.username')}:
</Label>
<Label for="input" sm={6}>
{row.bindDN}
{row.userName}
</Label>
</FormGroup>
</Col>
</Row>
<Row>
<Col sm={6}>
<FormGroup row>
<Label sm={6}>{t('fields.status')}:</Label>
<Label sm={6}>{t('fields.connectionUris')}:</Label>
<Label sm={6}>
<Badge color={getBadgeTheme(row.enabled)}>
{row.enabled
? `${t('options.enabled')}`
: `${t('options.disable')}`}
</Badge>
{row.connectionUri &&
row.connectionUri.map((ele, index) => (
<Badge key={index} color="primary">
{ele}
</Badge>
))}
</Label>
</FormGroup>
</Col>
<Col sm={6}>
<FormGroup row>
<Label sm={6}>{t('fields.servers')}:</Label>
<Label sm={6}>{t('fields.binaryAttributes')}:</Label>
<Label sm={6}>
{row.servers &&
row.servers.map((server, index) => (
{row.binaryAttributes &&
row.binaryAttributes.map((attr, index) => (
<Badge key={index} color="primary">
{server}
{attr}
</Badge>
))}
</Label>
Expand All @@ -79,68 +80,29 @@ const LdapDetailPage = ({ row, testLdapConnection }) => {
<Row>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.max_connections')}:</Label>
<Label sm={6}>{row.maxConnections}</Label>
<Label sm={6}>{t('fields.schemaName')}:</Label>
<Label sm={6}>{row.schemaName}</Label>
</FormGroup>
</Col>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.use_ssl')}:</Label>
<Label sm={6}>{t('fields.passwordEncryptionMethod')}:</Label>
<Label sm={6}>
{row.useSSL}
<Badge color={getBadgeTheme(row.useSSL)}>
{row.useSSL ? t('options.true') : t('options.false')}
</Badge>
{row.passwordEncryptionMethod}
</Label>
</FormGroup>
</Col>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.base_dns')}:</Label>
<Label sm={6}>{t('fields.serverTimezone')}:</Label>
<Label sm={6}>
{row.baseDNs &&
row.baseDNs.map((baseDN, index) => (
<Badge key={baseDN} color="primary">
{baseDN}
</Badge>
))}
{row.serverTimezone}
</Label>
</FormGroup>
</Col>
</Row>
<Row>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.primary_key')}:</Label>
<Label sm={6}>{row.primaryKey}</Label>
</FormGroup>
</Col>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.local_primary_key')}:</Label>
<Label sm={6}>{row.localPrimaryKey}</Label>
</FormGroup>
</Col>
<Col sm={4}>
<FormGroup row>
<Label sm={6}>{t('fields.use_anonymous_bind')}:</Label>
<Label sm={6}>{row.useAnonymousBind}</Label>
</FormGroup>
</Col>
</Row>
<Row>
<Col sm={4}>
<button
onClick={checkLdapConnection}
type="button"
className="btn btn-primary text-center"
>
{t('fields.test_connection')}
</button>
</Col>
</Row>
</Container>
</React.Fragment>
)
}
export default LdapDetailPage
export default SqlDetailPage
29 changes: 12 additions & 17 deletions plugins/services-plugin/Components/Configuration/SqlEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,29 @@ import React from 'react'
import { connect } from 'react-redux'
import { useHistory } from 'react-router-dom'
import { Container, CardBody, Card } from '../../../../app/components'
import LdapForm from './LdapForm'
import { editLdap } from '../../redux/actions/LdapActions'
import SqlForm from './SqlForm'
import { editSql } from '../../redux/actions/SqlActions'
import { buildPayload } from '../../../../app/utils/PermChecker'

function LdapEditPage({ item, dispatch }) {
function SqlEditPage({ item, dispatch }) {
const userAction = {}
const history = useHistory()
function handleSubmit(data) {
if (data) {
let message = data.ldap.action_message
delete data.ldap.action_message
let message = data.sql.action_message
delete data.sql.action_message
buildPayload(userAction, message, data)
dispatch(editLdap(userAction))
history.push('/config/ldap')
dispatch(editSql(userAction))
history.push('/config/sql')
}
}
const defautConfigurations = {
maxConnections: 2,
useSSL: false,
useAnonymousBind: false,
enabled: false
}

return (
<React.Fragment>
<Container>
<Card className="mb-3">
<CardBody>
<LdapForm item={item} handleSubmit={handleSubmit} />
<SqlForm item={item} handleSubmit={handleSubmit} />
</CardBody>
</Card>
</Container>
Expand All @@ -38,9 +33,9 @@ function LdapEditPage({ item, dispatch }) {
}
const mapStateToProps = (state) => {
return {
item: state.ldapReducer.item,
loading: state.ldapReducer.loading,
item: state.sqlReducer.item,
loading: state.sqlReducer.loading,
permissions: state.authReducer.permissions,
}
}
export default connect(mapStateToProps)(LdapEditPage)
export default connect(mapStateToProps)(SqlEditPage)
Loading

0 comments on commit 15da0a6

Please sign in to comment.