Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Genesys Website
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Website
Commits
f8d85bf1
Commit
f8d85bf1
authored
Mar 09, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added KPI charts to Admin dashboard
parent
7388af50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
7 deletions
+94
-7
src/kpi/ui/admin/c/RunsSection.tsx
src/kpi/ui/admin/c/RunsSection.tsx
+2
-2
src/model/kpi/ExecutionRun.ts
src/model/kpi/ExecutionRun.ts
+1
-1
src/ui/pages/admin/DashboardPage.tsx
src/ui/pages/admin/DashboardPage.tsx
+91
-4
No files found.
src/kpi/ui/admin/c/RunsSection.tsx
View file @
f8d85bf1
...
...
@@ -49,7 +49,7 @@ interface IRunsSectionProps extends React.ClassAttributes<any> {
classes
:
any
;
}
const
chartOptions
=
{
const
DEFAULT_CHART_OPTIONS
=
{
elements
:
{
line
:
{
tension
:
0
,
// disables bezier curves
...
...
@@ -101,7 +101,7 @@ class RunsSection extends React.Component<IRunsSectionProps> {
this
.
setState
({
...
this
.
state
,
totalCountChart
:
{
data
:
series
.
data
,
library
:
{
...
chartOptions
,
scales
:
{
...
DEFAULT_CHART_OPTIONS
,
scales
:
{
yAxes
:
[{
ticks
:
{
beginAtZero
:
false
,
...
...
src/model/kpi/ExecutionRun.ts
View file @
f8d85bf1
...
...
@@ -7,7 +7,7 @@ class ExecutionRun {
public
id
:
number
;
public
observations
:
Observation
[];
public
timestamp
:
Date
;
public
totalValue
:
number
;
}
...
...
src/ui/pages/admin/DashboardPage.tsx
View file @
f8d85bf1
...
...
@@ -6,24 +6,111 @@ import { bindActionCreators } from 'redux';
import
ContentHeaderWithButton
from
'
ui/common/heading/ContentHeaderWithButton
'
;
import
PageTitle
from
'
ui/common/PageTitle
'
;
import
Grid
from
'
@material-ui/core/Grid/Grid
'
;
import
{
PageContents
,
PageSection
}
from
'
ui/layout/PageLayout
'
;
import
{
LineChart
}
from
'
react-chartkick
'
;
import
*
as
moment
from
'
moment
'
;
import
KpiService
from
'
service/genesys/KpiService
'
;
import
ExecutionRun
from
'
model/kpi/ExecutionRun
'
;
require
(
'
chart.js
'
);
interface
IAdminDashProps
extends
React
.
ClassAttributes
<
any
>
{
title
:
string
;
}
class
AdministrationDashboard
extends
React
.
Component
<
IAdminDashProps
,
void
>
{
const
DEFAULT_CHART_OPTIONS
=
{
elements
:
{
line
:
{
tension
:
0
,
// disables bezier curves
},
},
};
constructor
(
props
)
{
super
(
props
);
const
makeKpiChart
=
(
runs
:
ExecutionRun
[])
=>
{
if
(
!
runs
)
{
return
;
}
// console.log(`Updating chart`, runs);
const
series
=
{
name
:
'
Total count
'
,
data
:
{}
};
let
minVal
=
null
;
let
maxVal
=
null
;
runs
.
forEach
((
element
)
=>
{
series
.
data
[
moment
(
element
.
timestamp
).
format
(
'
YYYY-MM-DD
'
)]
=
element
.
totalValue
;
minVal
=
minVal
===
null
?
element
.
totalValue
:
Math
.
min
(
minVal
,
element
.
totalValue
);
maxVal
=
maxVal
===
null
?
element
.
totalValue
:
Math
.
max
(
maxVal
,
element
.
totalValue
);
});
const
diff
=
(
maxVal
-
minVal
);
if
(
diff
!==
0
)
{
maxVal
+=
diff
*
0.1
;
minVal
-=
diff
*
0.1
;
}
else
{
maxVal
=
maxVal
+
1
;
minVal
=
minVal
-
1
;
}
// console.log(`Chart series min=${minVal} max=${maxVal}`, series);
return
{
data
:
series
.
data
,
library
:
{
...
DEFAULT_CHART_OPTIONS
,
scales
:
{
yAxes
:
[{
ticks
:
{
beginAtZero
:
false
,
autoSkip
:
false
,
min
:
Math
.
floor
(
minVal
),
max
:
Math
.
ceil
(
maxVal
),
},
}],
},
},
};
};
class
AdministrationDashboard
extends
React
.
Component
<
IAdminDashProps
>
{
public
state
=
{
kpiCharts
:
[],
};
public
componentWillMount
()
{
// load charts
const
kpiCharts
=
[];
KpiService
.
listExecutions
({
size
:
20
}).
then
((
paged
)
=>
paged
.
content
)
.
then
((
executions
)
=>
{
executions
.
forEach
((
execution
)
=>
{
console
.
log
(
`Loading
${
execution
.
name
}
`
);
KpiService
.
executionRuns
(
execution
.
name
,
{
size
:
20
}).
then
((
runs
)
=>
{
kpiCharts
.
push
({
title
:
execution
.
title
,
chart
:
makeKpiChart
(
runs
.
content
),
});
kpiCharts
.
sort
((
a
,
b
)
=>
a
.
title
.
localeCompare
(
b
.
title
));
this
.
setState
({
kpiCharts
});
}).
catch
((
err
)
=>
{
console
.
log
(
`Error loading
${
execution
.
name
}
runs`
,
err
);
});
});
}).
catch
((
err
)
=>
{
console
.
log
(
`Error loading KPIs`
,
err
);
});
}
public
render
()
{
console
.
log
(
'
Rendering admin??
'
);
return
(
<
div
>
<
PageTitle
title
=
"You're root, have fun!"
/>
<
ContentHeaderWithButton
title
=
"You're root, have fun!"
/>
<
PageContents
className
=
"pt-1rem"
>
<
Grid
container
spacing
=
{
8
}
>
{
this
.
state
.
kpiCharts
.
map
((
kpiChart
)
=>
(
<
Grid
item
sm
=
{
12
}
md
=
{
6
}
>
<
PageSection
title
=
{
kpiChart
.
title
}
>
<
LineChart
download
height
=
"200px"
thousands
=
","
{
...
kpiChart
.
chart
}
/>
</
PageSection
>
</
Grid
>
))
}
</
Grid
>
</
PageContents
>
</
div
>
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment