Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d68007fd
Commit
d68007fd
authored
Aug 31, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: redux
parent
cf58eea1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
28 deletions
+63
-28
public/app/features/server-stats/ServerStats.tsx
+37
-28
public/app/features/server-stats/api.ts
+26
-0
No files found.
public/app/features/server-stats/ServerStats.tsx
View file @
d68007fd
...
...
@@ -3,53 +3,61 @@ import { hot } from 'react-hot-loader';
import
{
connect
}
from
'react-redux'
;
import
{
initNav
}
from
'app/core/actions'
;
import
{
ContainerProps
}
from
'app/types'
;
import
{
getServerStats
,
ServerStat
}
from
'./api'
;
import
PageHeader
from
'app/core/components/PageHeader/PageHeader'
;
interface
Props
extends
ContainerProps
{}
interface
Props
extends
ContainerProps
{
getServerStats
:
()
=>
Promise
<
ServerStat
[]
>
;
}
interface
State
{
stats
:
ServerStat
[];
}
export
class
ServerStats
extends
React
.
Component
<
Props
,
any
>
{
export
class
ServerStats
extends
React
.
Component
<
Props
,
State
>
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
stats
:
[],
};
this
.
props
.
initNav
(
'cfg'
,
'admin'
,
'server-stats'
);
// const { nav, serverStats } = this.props;
//
// nav.load('cfg', 'admin', 'server-stats');
// serverStats.load();
//
// store.dispatch(setNav('new', { asd: 'tasd' }));
}
async
componentDidMount
()
{
try
{
const
stats
=
await
this
.
props
.
getServerStats
();
this
.
setState
({
stats
});
}
catch
(
error
)
{
console
.
error
(
error
);
}
}
render
()
{
const
{
navModel
}
=
this
.
props
;
console
.
log
(
'render'
,
navModel
);
const
{
stats
}
=
this
.
state
;
return
(
<
div
>
<
PageHeader
model=
{
navModel
}
/>
<
h2
>
aasd
</
h2
>
<
div
className=
"page-container page-body"
>
<
table
className=
"filter-table form-inline"
>
<
thead
>
<
tr
>
<
th
>
Name
</
th
>
<
th
>
Value
</
th
>
</
tr
>
</
thead
>
<
tbody
>
{
stats
.
map
(
StatItem
)
}
</
tbody
>
</
table
>
</
div
>
</
div
>
);
// const { nav, serverStats } = this.props;
// return (
// <div>
// <PageHeader model={nav as any} />
// <div className="page-container page-body">
// <table className="filter-table form-inline">
// <thead>
// <tr>
// <th>Name</th>
// <th>Value</th>
// </tr>
// </thead>
// <tbody>{serverStats.stats.map(StatItem)}</tbody>
// </table>
// </div>
// </div>
// );
}
}
function
StatItem
(
stat
)
{
function
StatItem
(
stat
:
ServerStat
)
{
return
(
<
tr
key=
{
stat
.
name
}
>
<
td
>
{
stat
.
name
}
</
td
>
...
...
@@ -60,6 +68,7 @@ function StatItem(stat) {
const
mapStateToProps
=
state
=>
({
navModel
:
state
.
navModel
,
getServerStats
:
getServerStats
,
});
const
mapDispatchToProps
=
{
...
...
public/app/features/server-stats/api.ts
0 → 100644
View file @
d68007fd
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
export
interface
ServerStat
{
name
:
string
;
value
:
string
;
}
export
const
getServerStats
=
async
():
Promise
<
ServerStat
[]
>
=>
{
try
{
const
res
=
await
getBackendSrv
().
get
(
'api/admin/stats'
);
return
[
{
name
:
'Total users'
,
value
:
res
.
users
},
{
name
:
'Total dashboards'
,
value
:
res
.
dashboards
},
{
name
:
'Active users (seen last 30 days)'
,
value
:
res
.
activeUsers
},
{
name
:
'Total orgs'
,
value
:
res
.
orgs
},
{
name
:
'Total playlists'
,
value
:
res
.
playlists
},
{
name
:
'Total snapshots'
,
value
:
res
.
snapshots
},
{
name
:
'Total dashboard tags'
,
value
:
res
.
tags
},
{
name
:
'Total starred dashboards'
,
value
:
res
.
stars
},
{
name
:
'Total alerts'
,
value
:
res
.
alerts
},
];
}
catch
(
error
)
{
console
.
error
(
error
);
throw
error
;
}
};
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