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
dd19ec3b
Commit
dd19ec3b
authored
Feb 12, 2019
by
Dominik Prokop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move explore selectors to a separate file
parent
1693f083
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
28 deletions
+33
-28
public/app/features/explore/LogsContainer.tsx
+3
-28
public/app/features/explore/state/selectors.ts
+30
-0
No files found.
public/app/features/explore/LogsContainer.tsx
View file @
dd19ec3b
...
...
@@ -4,14 +4,14 @@ import { connect } from 'react-redux';
import
{
RawTimeRange
,
TimeRange
}
from
'@grafana/ui'
;
import
{
ExploreId
,
ExploreItemState
}
from
'app/types/explore'
;
import
{
LogsModel
,
LogsDedupStrategy
,
LogLevel
,
filterLogLevels
,
dedupLogRows
}
from
'app/core/logs_model'
;
import
{
LogsModel
,
LogsDedupStrategy
,
LogLevel
}
from
'app/core/logs_model'
;
import
{
StoreState
}
from
'app/types'
;
import
{
toggleLogs
,
changeDedupStrategy
}
from
'./state/actions'
;
import
Logs
from
'./Logs'
;
import
Panel
from
'./Panel'
;
import
{
toggleLogLevelAction
}
from
'app/features/explore/state/actionTypes'
;
import
{
createLodashMemoizedSelector
}
from
'app/core/utils/reselect
'
;
import
{
deduplicatedLogsSelector
,
exploreItemUIStateSelector
}
from
'app/features/explore/state/selectors
'
;
interface
LogsContainerProps
{
exploreId
:
ExploreId
;
...
...
@@ -98,37 +98,12 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
}
}
const
selectItemUIState
=
(
itemState
:
ExploreItemState
)
=>
{
const
{
showingGraph
,
showingLogs
,
showingTable
,
showingStartPage
,
dedupStrategy
}
=
itemState
;
return
{
showingGraph
,
showingLogs
,
showingTable
,
showingStartPage
,
dedupStrategy
,
};
};
const
logsSelector
=
(
state
:
ExploreItemState
)
=>
state
.
logsResult
;
const
hiddenLogLevelsSelector
=
(
state
:
ExploreItemState
)
=>
state
.
hiddenLogLevels
;
const
dedupStrategySelector
=
(
state
:
ExploreItemState
)
=>
state
.
dedupStrategy
;
const
deduplicatedLogsSelector
=
createLodashMemoizedSelector
(
logsSelector
,
hiddenLogLevelsSelector
,
dedupStrategySelector
,
(
logs
,
hiddenLogLevels
,
dedupStrategy
)
=>
{
if
(
!
logs
)
{
return
null
;
}
const
filteredData
=
filterLogLevels
(
logs
,
new
Set
(
hiddenLogLevels
));
return
dedupLogRows
(
filteredData
,
dedupStrategy
);
}
);
function
mapStateToProps
(
state
:
StoreState
,
{
exploreId
})
{
const
explore
=
state
.
explore
;
const
item
:
ExploreItemState
=
explore
[
exploreId
];
const
{
logsHighlighterExpressions
,
logsResult
,
queryTransactions
,
scanning
,
scanRange
,
range
}
=
item
;
const
loading
=
queryTransactions
.
some
(
qt
=>
qt
.
resultType
===
'Logs'
&&
!
qt
.
done
);
const
{
showingLogs
,
dedupStrategy
}
=
selectItemUIState
(
item
);
const
{
showingLogs
,
dedupStrategy
}
=
exploreItemUIStateSelector
(
item
);
const
hiddenLogLevels
=
new
Set
(
item
.
hiddenLogLevels
);
const
dedupedResult
=
deduplicatedLogsSelector
(
item
);
...
...
public/app/features/explore/state/selectors.ts
0 → 100644
View file @
dd19ec3b
import
{
createLodashMemoizedSelector
}
from
'app/core/utils/reselect'
;
import
{
ExploreItemState
}
from
'app/types'
;
import
{
filterLogLevels
,
dedupLogRows
}
from
'app/core/logs_model'
;
export
const
exploreItemUIStateSelector
=
(
itemState
:
ExploreItemState
)
=>
{
const
{
showingGraph
,
showingLogs
,
showingTable
,
showingStartPage
,
dedupStrategy
}
=
itemState
;
return
{
showingGraph
,
showingLogs
,
showingTable
,
showingStartPage
,
dedupStrategy
,
};
};
const
logsSelector
=
(
state
:
ExploreItemState
)
=>
state
.
logsResult
;
const
hiddenLogLevelsSelector
=
(
state
:
ExploreItemState
)
=>
state
.
hiddenLogLevels
;
const
dedupStrategySelector
=
(
state
:
ExploreItemState
)
=>
state
.
dedupStrategy
;
export
const
deduplicatedLogsSelector
=
createLodashMemoizedSelector
(
logsSelector
,
hiddenLogLevelsSelector
,
dedupStrategySelector
,
(
logs
,
hiddenLogLevels
,
dedupStrategy
)
=>
{
if
(
!
logs
)
{
return
null
;
}
const
filteredData
=
filterLogLevels
(
logs
,
new
Set
(
hiddenLogLevels
));
return
dedupLogRows
(
filteredData
,
dedupStrategy
);
}
);
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