Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">

<changeSet author="conductor\dijalma.silva" id="1">
<preConditions>
<tableExists tableName="PRIVILEGES"/>
</preConditions>
<sql>
INSERT INTO roles_privileges (role_id, privilege_id) select rol.id, priv.id from roles rol, (select PRIVILEGES.id from PRIVILEGES except select privilege_id from roles_privileges where role_id = 1) priv where rol.name = 'ADMIN'
</sql>
</changeSet>
</databaseChangeLog>
3 changes: 2 additions & 1 deletion heimdall-api/src/main/resources/liquibase/master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<include file="changelog/DATA_USERS_1.xml" relativeToChangelogFile="true"/>
<include file="changelog/DATA_USERS_ROLES_1.xml" relativeToChangelogFile="true"/>
<include file="changelog/20180521092430-insert-privileges-to-provider.xml" relativeToChangelogFile="true"/>
<include file="changelog/20180521101715-add-privileges-provider-to-role-admin.xml" relativeToChangelogFile="true"/>
<include file="changelog/20180918144230-insert-privileges-for-logtraces.xml" relativeToChangelogFile="true"/>
<include file="changelog/20180918144310-insert-privileges-for-metrics.xml" relativeToChangelogFile="true"/>
<include file="changelog/20180521101715-add-privileges-provider-to-role-admin.xml" relativeToChangelogFile="true"/>
<include file="changelog/20181018114923-add-privileges-metrics-to-role-admin.xml" relativeToChangelogFile="true"/>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ private Query<LogTrace> prepareRange(Query<LogTrace> query, Periods date) {
switch(date) {
case TODAY: {
query.field(insertedOnDate).containsIgnoreCase(LocalDate.now().format(DateTimeFormatter.ISO_DATE));
break;
}
case YESTERDAY: {
query.field(insertedOnDate).containsIgnoreCase(LocalDate.now().minusDays(1).format(DateTimeFormatter.ISO_DATE));
break;
}
case THIS_WEEK: {
Map<String, LocalDate> week = CalendarUtils.firstAndLastDaysOfWeek(LocalDate.now());
Expand Down
96 changes: 65 additions & 31 deletions heimdall-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions heimdall-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"cross-fetch": "^1.1.1",
"css-animation": "^1.4.1",
"dotenv": "^5.0.1",
"echarts": "^4.2.0-rc.2",
"echarts-for-react": "^2.0.15-beta.0",
"less": "2.7.3",
"lodash.flow": "^3.5.0",
"moment": "^2.22.1",
Expand Down
62 changes: 62 additions & 0 deletions heimdall-frontend/src/actions/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { AnalyticsConstants } from '../constants/actions-types'
import { analyticsService } from '../services/AnalyticsService'

export const initLoading = () => dispatch => {
dispatch({ type: AnalyticsConstants.ANALYTICS_LOADING })
}

export const finishLoading = () => dispatch => {
dispatch({ type: AnalyticsConstants.ANALYTICS_LOADING_FINISH })
}

export const sendNotification = notification => dispatch => {
dispatch({ type: AnalyticsConstants.ANALYTICS_NOTIFICATION, notification })
}

export const getTopApps = (limit, period) => dispatch => {
analyticsService.getAppsTop(limit, period)
.then(data => {
dispatch({ type: AnalyticsConstants.ANALYTICS_TOP_APPS, topApps: data })
dispatch(finishLoading())
})
.catch(error => {
console.log(error)
dispatch(finishLoading())
})
}

export const getTopApis = (limit, period) => dispatch => {
analyticsService.getApisTop(limit, period)
.then(data => {
dispatch({ type: AnalyticsConstants.ANALYTICS_TOP_APIS, topApis: data })
dispatch(finishLoading())
})
.catch(error => {
console.log(error)
dispatch(finishLoading())
})
}

export const getTopAccessTokens = (limit, period) => dispatch => {
analyticsService.getAccessTokensTop(limit, period)
.then(data => {
dispatch({ type: AnalyticsConstants.ANALYTICS_TOP_ACCESS_TOKENS, topAccessTokens: data })
dispatch(finishLoading())
})
.catch(error => {
console.log(error)
dispatch(finishLoading())
})
}

export const getTopResultStatus = (limit, period) => dispatch => {
analyticsService.getResultStatusTop(limit, period)
.then(data => {
dispatch({ type: AnalyticsConstants.ANALYTICS_TOP_RESULT_STATUS, topResultStatus: data })
dispatch(finishLoading())
})
.catch(error => {
console.log(error)
dispatch(finishLoading())
})
}
73 changes: 73 additions & 0 deletions heimdall-frontend/src/components/ui/Chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react'
import PropTypes from 'prop-types'
import ReactEcharts from 'echarts-for-react'

import Loading from "./Loading"

class Chart extends React.Component {

state = {
color: 'red'
}

componentDidMount() {
this.setState({...this.state, color: this.props.color})
}

getOption = () => {
const { metrics } = this.props

let dataMetrics = []
let dataMetricsValues = []

if (metrics && Array.isArray(metrics)) {

dataMetrics = metrics.map(metric => {
return metric.metric
})

dataMetricsValues = metrics.map(metric => {
return metric.value
})

}

return {
title: {
text: this.props.title,
},
tooltip: {},
xAxis: {
data: dataMetrics
},
yAxis: {},
series: [{
name: 'requests',
type: 'bar',
data: dataMetricsValues
}],
color: this.state.color

}
}

render() {

const { metrics } = this.props

if (!metrics) {
return <Loading />
}

return (
<ReactEcharts option={this.getOption()} style={{height: 350}}/>
)
}
}

Chart.propTypes = {
metrics: PropTypes.array,
title: PropTypes.string.isRequired,
}

export default Chart
Loading