-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
appconfig: replace Angular.js based config with React
required for Grafana 8.0
- Loading branch information
1 parent
b514be9
commit e01824d
Showing
9 changed files
with
94 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { AppPluginMeta, PluginConfigPageProps } from '@grafana/data'; | ||
import { BackendSrv, getBackendSrv } from '@grafana/runtime'; | ||
import { Button, Icon } from '@grafana/ui'; | ||
import { css } from 'emotion'; | ||
import React, { PureComponent } from 'react'; | ||
import { AppSettings } from './types'; | ||
|
||
interface Props extends PluginConfigPageProps<AppPluginMeta<AppSettings>> {} | ||
|
||
export class AppConfig extends PureComponent<Props> { | ||
private backendSrv: BackendSrv; | ||
|
||
constructor(props: Props) { | ||
super(props); | ||
this.backendSrv = getBackendSrv(); | ||
this.onEnable = this.onEnable.bind(this); | ||
this.onDisable = this.onDisable.bind(this); | ||
} | ||
|
||
async updatePluginSettings(settings: { enabled: boolean; jsonData: any; pinned: boolean }) { | ||
return this.backendSrv.post(`/api/plugins/${this.props.plugin.meta.id}/settings`, settings); | ||
} | ||
|
||
async onEnable() { | ||
await this.updatePluginSettings({ enabled: true, jsonData: {}, pinned: true }); | ||
window.location.reload(); | ||
} | ||
|
||
async onDisable() { | ||
await this.updatePluginSettings({ enabled: false, jsonData: {}, pinned: false }); | ||
window.location.reload(); | ||
} | ||
|
||
render() { | ||
const isEnabled = this.props.plugin.meta.enabled; | ||
return ( | ||
<> | ||
<h2>Performance Co-Pilot App</h2> | ||
This app integrates metrics from Performance Co-Pilot. | ||
<br /> | ||
<br /> | ||
It includes the following datasources: | ||
<ul | ||
className={css` | ||
margin-left: 2em; | ||
`} | ||
> | ||
<li> | ||
<strong>PCP Redis</strong> for fast, scalable time series aggregation across multiple hosts | ||
</li> | ||
<li> | ||
<strong>PCP Vector</strong> for live, on-host metrics analysis, with container support | ||
</li> | ||
<li> | ||
<strong>PCP bpftrace</strong> for system introspection using bpftrace scripts | ||
</li> | ||
</ul> | ||
{isEnabled && ( | ||
<div | ||
className={css` | ||
margin-top: 1.5em; | ||
`} | ||
> | ||
<Icon | ||
name="check" | ||
className={css` | ||
color: #10a345; | ||
`} | ||
/>{' '} | ||
Plugin enabled. Please configure the datasources now. | ||
</div> | ||
)} | ||
<div className="gf-form gf-form-button-row"> | ||
{isEnabled ? ( | ||
<Button variant="destructive" onClick={this.onDisable}> | ||
Disable | ||
</Button> | ||
) : ( | ||
<Button onClick={this.onEnable}>Enable</Button> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface AppSettings {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { AppPlugin } from '@grafana/data'; | ||
import { PCPAppConfigCtrl } from './components/appconfig/config'; | ||
import { AppConfig } from './components/appconfig/config'; | ||
import { AppSettings } from './components/appconfig/types'; | ||
import { Search } from './components/search/Search'; | ||
|
||
export { PCPAppConfigCtrl as ConfigCtrl }; | ||
|
||
class CustomApp extends AppPlugin<{}> {} | ||
|
||
export const plugin = new CustomApp().setRootPage(Search); | ||
export const plugin = new AppPlugin<AppSettings>() | ||
.addConfigPage({ id: 'config', title: 'Config', icon: 'cog', body: AppConfig }) | ||
.setRootPage(Search); |