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
682c792d
Commit
682c792d
authored
Jun 26, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: react panels editor mode, tabs working
parent
2f5bcd37
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
43 deletions
+113
-43
public/app/features/dashboard/dashgrid/PanelEditor.tsx
+52
-36
public/app/features/dashboard/dashgrid/PanelHeader.tsx
+8
-5
public/app/features/dashboard/dashgrid/QueriesTab.tsx
+49
-0
public/app/stores/ViewStore/ViewStore.ts
+4
-2
No files found.
public/app/features/dashboard/dashgrid/PanelEditor.tsx
View file @
682c792d
import
React
from
'react'
;
import
React
from
'react'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
getAngularLoader
,
AngularComponent
}
from
'app/core/services/angular_loader'
;
import
{
store
}
from
'app/stores/store'
;
import
{
observer
}
from
'mobx-react'
;
import
{
QueriesTab
}
from
'./QueriesTab'
;
import
classNames
from
'classnames'
;
interface
PanelEditorProps
{
interface
PanelEditorProps
{
panel
:
PanelModel
;
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
}
}
export
class
PanelEditor
extends
React
.
Component
<
PanelEditorProps
,
any
>
{
interface
PanelEditorTab
{
queryElement
:
any
;
id
:
string
;
queryComp
:
AngularComponent
;
text
:
string
;
tabs
:
any
[];
icon
:
string
;
}
@
observer
export
class
PanelEditor
extends
React
.
Component
<
PanelEditorProps
,
any
>
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
tabs
=
[
{
id
:
'queries'
,
text
:
'Queries'
,
icon
:
'fa fa-database'
},
{
id
:
'viz'
,
text
:
'Visualization'
,
icon
:
'fa fa-line-chart'
},
];
}
}
componentDidMount
()
{
renderQueriesTab
()
{
if
(
!
this
.
queryElement
)
{
return
<
QueriesTab
panel=
{
this
.
props
.
panel
}
dashboard=
{
this
.
props
.
dashboard
}
/>;
return
;
}
}
let
loader
=
getAngularLoader
();
var
template
=
'<metrics-tab />'
;
let
scopeProps
=
{
ctrl
:
{
panel
:
this
.
props
.
panel
,
dashboard
:
this
.
props
.
dashboard
,
panelCtrl
:
{
panel
:
this
.
props
.
panel
,
dashboard
:
this
.
props
.
dashboard
,
},
},
};
this
.
queryComp
=
loader
.
load
(
this
.
queryElement
,
scopeProps
,
template
);
renderVizTab
()
{
return
<
h2
>
Visualizations
</
h2
>;
}
}
onChangeTab
=
tabName
=>
{};
onChangeTab
=
(
tab
:
PanelEditorTab
)
=>
{
store
.
view
.
updateQuery
({
tab
:
tab
.
id
},
false
);
};
render
()
{
render
()
{
const
activeTab
:
string
=
store
.
view
.
query
.
get
(
'tab'
)
||
'queries'
;
const
tabs
:
PanelEditorTab
[]
=
[
{
id
:
'queries'
,
text
:
'Queries'
,
icon
:
'fa fa-database'
},
{
id
:
'viz'
,
text
:
'Visualization'
,
icon
:
'fa fa-line-chart'
},
];
return
(
return
(
<
div
className=
"tabbed-view tabbed-view--panel-edit-new"
>
<
div
className=
"tabbed-view tabbed-view--panel-edit-new"
>
<
div
className=
"tabbed-view-header"
>
<
div
className=
"tabbed-view-header"
>
<
ul
className=
"gf-tabs"
>
<
ul
className=
"gf-tabs"
>
<
li
className=
"gf-tabs-item"
>
{
tabs
.
map
(
tab
=>
{
<
a
className=
"gf-tabs-link active"
>
Queries
</
a
>
return
<
TabItem
tab=
{
tab
}
activeTab=
{
activeTab
}
onClick=
{
this
.
onChangeTab
}
key=
{
tab
.
id
}
/>;
</
li
>
})
}
<
li
className=
"gf-tabs-item"
>
<
a
className=
"gf-tabs-link"
>
Visualization
</
a
>
</
li
>
</
ul
>
</
ul
>
<
button
className=
"tabbed-view-close-btn"
ng
-
click=
"ctrl.exitFullscreen();"
>
<
button
className=
"tabbed-view-close-btn"
ng
-
click=
"ctrl.exitFullscreen();"
>
...
@@ -64,9 +57,32 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
...
@@ -64,9 +57,32 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
</
div
>
</
div
>
<
div
className=
"tabbed-view-body"
>
<
div
className=
"tabbed-view-body"
>
<
div
ref=
{
element
=>
(
this
.
queryElement
=
element
)
}
className=
"panel-height-helper"
/>
{
activeTab
===
'queries'
&&
this
.
renderQueriesTab
()
}
{
activeTab
===
'viz'
&&
this
.
renderVizTab
()
}
</
div
>
</
div
>
</
div
>
</
div
>
);
);
}
}
}
}
interface
TabItemParams
{
tab
:
PanelEditorTab
;
activeTab
:
string
;
onClick
:
(
tab
:
PanelEditorTab
)
=>
void
;
}
function
TabItem
({
tab
,
activeTab
,
onClick
}:
TabItemParams
)
{
const
tabClasses
=
classNames
({
'gf-tabs-link'
:
true
,
active
:
activeTab
===
tab
.
id
,
});
return
(
<
li
className=
"gf-tabs-item"
key=
{
tab
.
id
}
>
<
a
className=
{
tabClasses
}
onClick=
{
()
=>
onClick
(
tab
)
}
>
<
i
className=
{
tab
.
icon
}
/>
{
tab
.
text
}
</
a
>
</
li
>
);
}
public/app/features/dashboard/dashgrid/PanelHeader.tsx
View file @
682c792d
...
@@ -11,11 +11,14 @@ interface PanelHeaderProps {
...
@@ -11,11 +11,14 @@ interface PanelHeaderProps {
export
class
PanelHeader
extends
React
.
Component
<
PanelHeaderProps
,
any
>
{
export
class
PanelHeader
extends
React
.
Component
<
PanelHeaderProps
,
any
>
{
onEditPanel
=
()
=>
{
onEditPanel
=
()
=>
{
store
.
view
.
updateQuery
({
store
.
view
.
updateQuery
(
panelId
:
this
.
props
.
panel
.
id
,
{
edit
:
true
,
panelId
:
this
.
props
.
panel
.
id
,
fullscreen
:
true
,
edit
:
true
,
});
fullscreen
:
true
,
},
false
);
};
};
render
()
{
render
()
{
...
...
public/app/features/dashboard/dashgrid/QueriesTab.tsx
0 → 100644
View file @
682c792d
import
React
from
'react'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
getAngularLoader
,
AngularComponent
}
from
'app/core/services/angular_loader'
;
interface
Props
{
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
}
export
class
QueriesTab
extends
React
.
Component
<
Props
,
any
>
{
element
:
any
;
component
:
AngularComponent
;
constructor
(
props
)
{
super
(
props
);
}
componentDidMount
()
{
if
(
!
this
.
element
)
{
return
;
}
let
loader
=
getAngularLoader
();
var
template
=
'<metrics-tab />'
;
let
scopeProps
=
{
ctrl
:
{
panel
:
this
.
props
.
panel
,
dashboard
:
this
.
props
.
dashboard
,
panelCtrl
:
{
panel
:
this
.
props
.
panel
,
dashboard
:
this
.
props
.
dashboard
,
},
},
};
this
.
component
=
loader
.
load
(
this
.
element
,
scopeProps
,
template
);
}
componentWillUnmount
()
{
if
(
this
.
component
)
{
this
.
component
.
destroy
();
}
}
render
()
{
return
<
div
ref=
{
element
=>
(
this
.
element
=
element
)
}
className=
"panel-height-helper"
/>;
}
}
public/app/stores/ViewStore/ViewStore.ts
View file @
682c792d
...
@@ -23,8 +23,10 @@ export const ViewStore = types
...
@@ -23,8 +23,10 @@ export const ViewStore = types
}))
}))
.
actions
(
self
=>
{
.
actions
(
self
=>
{
// querystring only
// querystring only
function
updateQuery
(
query
:
any
)
{
function
updateQuery
(
query
:
any
,
clear
=
true
)
{
self
.
query
.
clear
();
if
(
clear
)
{
self
.
query
.
clear
();
}
for
(
let
key
of
Object
.
keys
(
query
))
{
for
(
let
key
of
Object
.
keys
(
query
))
{
if
(
query
[
key
])
{
if
(
query
[
key
])
{
self
.
query
.
set
(
key
,
query
[
key
]);
self
.
query
.
set
(
key
,
query
[
key
]);
...
...
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