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
bbd02dd6
Commit
bbd02dd6
authored
Oct 23, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renaming things
parent
b7d821b5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
95 additions
and
39 deletions
+95
-39
public/app/core/angular_wrappers.ts
+2
-2
public/app/core/components/Alerts/state/actions.ts
+0
-23
public/app/core/components/AppNotifications/AppNotificationList.tsx
+56
-5
public/app/core/components/AppNotifications/state/actions.ts
+28
-0
public/app/core/components/AppNotifications/state/reducers.test.ts
+1
-1
public/app/core/components/AppNotifications/state/reducers.ts
+4
-4
public/app/types/alerts.ts
+2
-2
public/app/types/index.ts
+2
-2
No files found.
public/app/core/angular_wrappers.ts
View file @
bbd02dd6
...
...
@@ -5,12 +5,12 @@ import EmptyListCTA from './components/EmptyListCTA/EmptyListCTA';
import
{
SearchResult
}
from
'./components/search/SearchResult'
;
import
{
TagFilter
}
from
'./components/TagFilter/TagFilter'
;
import
{
SideMenu
}
from
'./components/sidemenu/SideMenu'
;
import
A
lertList
from
'./components/Alerts/Alert
List'
;
import
A
ppNotificationList
from
'./components/AppNotifications/AppNotification
List'
;
export
function
registerAngularDirectives
()
{
react2AngularDirective
(
'passwordStrength'
,
PasswordStrength
,
[
'password'
]);
react2AngularDirective
(
'sidemenu'
,
SideMenu
,
[]);
react2AngularDirective
(
'pageAlertList'
,
A
lert
List
,
[]);
react2AngularDirective
(
'pageAlertList'
,
A
ppNotification
List
,
[]);
react2AngularDirective
(
'pageHeader'
,
PageHeader
,
[
'model'
,
'noTabs'
]);
react2AngularDirective
(
'emptyListCta'
,
EmptyListCTA
,
[
'model'
]);
react2AngularDirective
(
'searchResult'
,
SearchResult
,
[]);
...
...
public/app/core/components/Alerts/state/actions.ts
deleted
100644 → 0
View file @
b7d821b5
import
{
Alert
}
from
'app/types'
;
export
enum
ActionTypes
{
AddAlert
=
'ADD_ALERT'
,
ClearAlert
=
'CLEAR_ALERT'
,
}
interface
AddAlertAction
{
type
:
ActionTypes
.
AddAlert
;
payload
:
Alert
;
}
interface
ClearAlertAction
{
type
:
ActionTypes
.
ClearAlert
;
payload
:
Alert
;
}
export
type
Action
=
AddAlertAction
|
ClearAlertAction
;
export
const
clearAlert
=
(
alert
:
Alert
)
=>
({
type
:
ActionTypes
.
ClearAlert
,
payload
:
alert
,
});
public/app/core/components/A
lerts/Alert
List.tsx
→
public/app/core/components/A
ppNotifications/AppNotification
List.tsx
View file @
bbd02dd6
import
React
,
{
PureComponent
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
appEvents
from
'app/core/app_events'
;
import
{
addAppNotification
,
clearAppNotification
}
from
'./state/actions'
;
export
interface
Props
{
alerts
:
any
[];
addAppNotification
:
typeof
addAppNotification
;
clearAppNotification
:
typeof
clearAppNotification
;
}
export
class
AlertList
extends
PureComponent
<
Props
>
{
onClearAlert
=
alert
=>
{
console
.
log
(
'clear alert'
,
alert
);
enum
AppNotificationSeverity
{
Success
=
'success'
,
Warning
=
'warning'
,
Error
=
'error'
,
Info
=
'info'
,
}
export
class
AppNotificationList
extends
PureComponent
<
Props
>
{
componentDidMount
()
{
appEvents
.
on
(
'alert-warning'
,
options
=>
this
.
addAppNotification
(
options
[
0
],
options
[
1
],
'warning'
,
5000
));
appEvents
.
on
(
'alert-success'
,
options
=>
this
.
addAppNotification
(
options
[
0
],
options
[
1
],
'success'
,
3000
));
appEvents
.
on
(
'alert-error'
,
options
=>
this
.
addAppNotification
(
options
[
0
],
options
[
1
],
'error'
,
7000
));
}
addAppNotification
(
title
,
text
,
severity
,
timeout
)
{
const
newAlert
=
{
title
:
title
||
''
,
text
:
text
||
''
,
severity
:
severity
||
AppNotificationSeverity
.
Info
,
icon
:
this
.
getIconForSeverity
(
severity
),
remove
:
this
.
clearAutomatically
(
this
,
timeout
),
};
this
.
props
.
addAppNotification
(
newAlert
);
}
getIconForSeverity
(
severity
)
{
switch
(
severity
)
{
case
AppNotificationSeverity
.
Success
:
return
'fa fa-check'
;
case
AppNotificationSeverity
.
Error
:
return
'fa fa-exclamation-triangle'
;
default
:
return
'fa fa-exclamation'
;
}
}
clearAutomatically
=
(
alert
,
timeout
)
=>
{
setTimeout
(()
=>
{
this
.
props
.
clearAppNotification
(
alert
);
},
timeout
);
};
onClearAppNotification
=
alert
=>
{
this
.
props
.
clearAppNotification
(
alert
);
};
render
()
{
...
...
@@ -25,7 +71,7 @@ export class AlertList extends PureComponent<Props> {
<
div
className=
"alert-title"
>
{
alert
.
title
}
</
div
>
<
div
className=
"alert-text"
>
{
alert
.
text
}
</
div
>
</
div
>
<
button
type=
"button"
className=
"alert-close"
onClick=
{
()
=>
this
.
onClearA
lert
(
alert
)
}
>
<
button
type=
"button"
className=
"alert-close"
onClick=
{
()
=>
this
.
onClearA
ppNotification
(
alert
)
}
>
<
i
className=
"fa fa fa-remove"
/>
</
button
>
</
div
>
...
...
@@ -42,4 +88,9 @@ function mapStateToProps(state) {
};
}
export
default
connect
(
mapStateToProps
)(
AlertList
);
const
mapDispatchToProps
=
{
addAppNotification
,
clearAppNotification
,
};
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
AppNotificationList
);
public/app/core/components/AppNotifications/state/actions.ts
0 → 100644
View file @
bbd02dd6
import
{
AppNotification
}
from
'app/types'
;
export
enum
ActionTypes
{
AddAppNotification
=
'ADD_APP_NOTIFICATION'
,
ClearAppNotification
=
'CLEAR_APP_NOTIFICATION'
,
}
interface
AddAppNotificationAction
{
type
:
ActionTypes
.
AddAppNotification
;
payload
:
AppNotification
;
}
interface
ClearAppNotificationAction
{
type
:
ActionTypes
.
ClearAppNotification
;
payload
:
AppNotification
;
}
export
type
Action
=
AddAppNotificationAction
|
ClearAppNotificationAction
;
export
const
clearAppNotification
=
(
alert
:
AppNotification
)
=>
({
type
:
ActionTypes
.
ClearAppNotification
,
payload
:
alert
,
});
export
const
addAppNotification
=
(
alert
:
AppNotification
)
=>
({
type
:
ActionTypes
.
AddAppNotification
,
payload
:
alert
,
});
public/app/core/components/A
lert
s/state/reducers.test.ts
→
public/app/core/components/A
ppNotification
s/state/reducers.test.ts
View file @
bbd02dd6
...
...
@@ -21,7 +21,7 @@ describe('clear alert', () => {
};
const
result
=
alertsReducer
(
initialState
,
{
type
:
ActionTypes
.
ClearA
lert
,
type
:
ActionTypes
.
ClearA
ppNotification
,
payload
:
initialState
.
alerts
[
1
],
});
...
...
public/app/core/components/A
lert
s/state/reducers.ts
→
public/app/core/components/A
ppNotification
s/state/reducers.ts
View file @
bbd02dd6
import
{
A
lert
,
AlertsState
}
from
'app/types'
;
import
{
A
ppNotification
,
AlertsState
}
from
'app/types'
;
import
{
Action
,
ActionTypes
}
from
'./actions'
;
export
const
initialState
:
AlertsState
=
{
alerts
:
[]
as
A
lert
[],
alerts
:
[]
as
A
ppNotification
[],
};
export
const
alertsReducer
=
(
state
=
initialState
,
action
:
Action
):
AlertsState
=>
{
switch
(
action
.
type
)
{
case
ActionTypes
.
AddA
lert
:
case
ActionTypes
.
AddA
ppNotification
:
return
{
...
state
,
alerts
:
state
.
alerts
.
concat
([
action
.
payload
])
};
case
ActionTypes
.
ClearA
lert
:
case
ActionTypes
.
ClearA
ppNotification
:
return
{
...
state
,
alerts
:
state
.
alerts
.
filter
(
alert
=>
alert
!==
action
.
payload
),
...
...
public/app/types/alerts.ts
View file @
bbd02dd6
export
interface
A
lert
{
export
interface
A
ppNotification
{
severity
:
string
;
icon
:
string
;
title
:
string
;
...
...
@@ -6,5 +6,5 @@ export interface Alert {
}
export
interface
AlertsState
{
alerts
:
A
lert
[];
alerts
:
A
ppNotification
[];
}
public/app/types/index.ts
View file @
bbd02dd6
...
...
@@ -9,7 +9,7 @@ import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys';
import
{
Invitee
,
OrgUser
,
User
,
UsersState
}
from
'./user'
;
import
{
DataSource
,
DataSourcesState
}
from
'./datasources'
;
import
{
PluginDashboard
,
PluginMeta
,
Plugin
,
PluginsState
}
from
'./plugins'
;
import
{
A
lert
,
AlertsState
}
from
'./alerts'
;
import
{
A
ppNotification
,
AlertsState
}
from
'./alerts'
;
export
{
Team
,
...
...
@@ -47,7 +47,7 @@ export {
User
,
UsersState
,
PluginDashboard
,
A
lert
,
A
ppNotification
,
AlertsState
,
};
...
...
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