Skip to content

Commit 2d1133c

Browse files
committed
Upgrade to Grafana 7.2
1 parent c5576cc commit 2d1133c

13 files changed

+1618
-1625
lines changed

dist/module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module.js.LICENSE.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,18 @@ object-assign
5252
* Copyright (c) 2014-2015, Jon Schlinkert.
5353
* Licensed under the MIT License.
5454
*/
55+
56+
/*! *****************************************************************************
57+
Copyright (c) Microsoft Corporation. All rights reserved.
58+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
59+
this file except in compliance with the License. You may obtain a copy of the
60+
License at http://www.apache.org/licenses/LICENSE-2.0
61+
62+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
63+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
64+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
65+
MERCHANTABLITY OR NON-INFRINGEMENT.
66+
67+
See the Apache Version 2.0 License for specific language governing permissions
68+
and limitations under the License.
69+
***************************************************************************** */

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
{"name": "Editor", "path": "img/editor.png"},
2121
{"name": "Panel", "path": "img/panel.png"}
2222
],
23-
"version": "0.2.1",
24-
"updated": "2020-09-01"
23+
"version": "0.3.0",
24+
"updated": "2020-10-09"
2525
},
2626

2727
"dependencies": {
2828
"grafanaDependency": ">=7.1.1",
29+
"grafanaVersion": "7.x",
2930
"plugins": []
3031
}
3132
}

package-lock.json

Lines changed: 1422 additions & 1451 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ae3e-plotly-panel",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Grafana Plotly Panel",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",
@@ -11,15 +11,15 @@
1111
"license": "Apache-2.0",
1212
"devDependencies": {
1313
"@babel/preset-env": "7.5.5",
14-
"@grafana/data": "7.1.1",
15-
"@grafana/runtime": "7.1.1",
16-
"@grafana/toolkit": "7.1.1",
17-
"@grafana/ui": "7.1.1"
14+
"@grafana/data": "7.2.0",
15+
"@grafana/runtime": "7.2.0",
16+
"@grafana/toolkit": "7.2.0",
17+
"@grafana/ui": "7.2.0"
1818
},
1919
"dependencies": {
2020
"deepmerge": "^4.2.2",
2121
"plotly.js": "1.52.1",
22-
"react-ace": "6.2.2",
22+
"@monaco-editor/react": "^3.6.3",
2323
"react-chart-editor": "0.41.0",
2424
"react-plotly.js": "2.4.0"
2525
},

src/PanelOptionCode.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//Code from https://github.com/gapitio/gapit-htmlgraphics-panel
2+
import React from 'react';
3+
import { StandardEditorProps } from '@grafana/data';
4+
import { TextPanelEditor } from 'TextPanelEditor';
5+
import { EditorLanguageType, EditorCodeType } from 'types';
6+
7+
interface Settings {
8+
language: EditorLanguageType;
9+
}
10+
11+
interface Props extends StandardEditorProps<EditorCodeType, Settings> {}
12+
13+
export const PanelOptionCode: React.FC<Props> = ({ value, item, onChange }) => {
14+
if(typeof value!=="string"){
15+
value=JSON.stringify(value, null, 2)
16+
}
17+
return <TextPanelEditor language={item.settings?.language} value={value} onChange={code => {
18+
if(item.settings?.language==='json' && code){
19+
code=JSON.parse(code);
20+
}
21+
onChange(code)}} />;
22+
};

src/SimpleEditor.tsx

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/SimplePanel.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ interface Props extends PanelProps<SimpleOptions> {}
2525

2626
export class SimplePanel extends PureComponent<Props> {
2727
render() {
28-
console.log(this);
29-
console.log(this.props.replaceVariables('$distance'));
30-
//console.log(this.props.replaceVariables('$__to'+' '+'$__from'));
31-
32-
console.log(templateSrv.getVariables())
3328
//Get all variables
3429
const context = {
35-
interval: templateSrv.getBuiltInIntervalValue(),//dataSource.templateSrv.builtIns.__interval.value,
30+
//interval: templateSrv.getBuiltInIntervalValue(),//dataSource.templateSrv.builtIns.__interval.value,
31+
__from:this.props.replaceVariables('$__from'),
32+
__to:this.props.replaceVariables('$__to'),
33+
__interval:this.props.replaceVariables('$__interval'),
34+
__interval_ms:this.props.replaceVariables('$__interval_ms')
3635
} as any;
3736
templateSrv.getVariables().forEach((elt: any)=>{
3837
context[elt.name]=elt.current.text;
@@ -77,7 +76,7 @@ export class SimplePanel extends PureComponent<Props> {
7776
});
7877
}*/
7978

80-
console.log(merge(this.props.options.data,parameters.data,{ arrayMerge: combineMerge }));
79+
//console.log(merge(this.props.options.data,parameters.data,{ arrayMerge: combineMerge }));
8180
//let layout = { ...this.props.options.layout, autosize: true, paper_bgcolor: 'rgba(0,0,0,0)', plot_bgcolor: 'transparent', height: this.props.height, title: this.props.options.title }
8281
let layout = { ...this.props.options.layout, autosize: true, height: this.props.height };
8382

src/TextPanelEditor.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//Code from https://github.com/gapitio/gapit-htmlgraphics-panel
2+
import React, { PureComponent } from 'react';
3+
import MonacoEditor, { monaco, EditorDidMount } from '@monaco-editor/react';
4+
import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
5+
import { EditorLanguageType } from 'types';
6+
import { config } from '@grafana/runtime';
7+
//import textEditorDeclarations from './text-editor-declarations';
8+
9+
interface MonacoEditorProps {
10+
language: EditorLanguageType;
11+
value: string | undefined;
12+
onChange: (value?: string) => void;
13+
}
14+
15+
let keyCtrlCmd = 2048;
16+
let keyS = 49;
17+
18+
monaco.init().then(monaco => {
19+
// Add autocompletion for panel definitions (htmlNode, codeData, data, options, and theme)
20+
//monaco.languages.typescript.javascriptDefaults.addExtraLib(textEditorDeclarations);
21+
22+
// Override the key values (should be the same)
23+
keyCtrlCmd = monaco.KeyMod.CtrlCmd;
24+
keyS = monaco.KeyCode.KEY_S;
25+
});
26+
27+
class TextPanelEditor extends PureComponent<MonacoEditorProps> {
28+
getEditorValue: (() => string) | undefined;
29+
editorInstance: editor.IStandaloneCodeEditor | undefined;
30+
31+
onSourceChange = () => {
32+
if (this.getEditorValue) {
33+
this.props.onChange(this.getEditorValue());
34+
}
35+
};
36+
37+
onEditorDidMount: EditorDidMount = (getEditorValue, editorInstance) => {
38+
this.getEditorValue = getEditorValue;
39+
this.editorInstance = editorInstance;
40+
editorInstance.addCommand(keyCtrlCmd | keyS, () => {
41+
this.onSourceChange();
42+
this.render();
43+
});
44+
};
45+
46+
updateDimensions = () => {
47+
this.editorInstance?.layout();
48+
};
49+
50+
render = () => {
51+
// Updates the layout (width) of the text editor
52+
if (this.editorInstance) {
53+
this.editorInstance.layout();
54+
}
55+
56+
return (
57+
<div onBlur={this.onSourceChange}>
58+
<MonacoEditor
59+
height={'33vh'}
60+
language={this.props.language}
61+
theme={config.theme.isDark ? 'vs-dark' : 'vs-light'}
62+
value={this.props.value}
63+
editorDidMount={this.onEditorDidMount}
64+
options={{ fontSize: 12 }}
65+
/>
66+
</div>
67+
);
68+
};
69+
}
70+
71+
export { TextPanelEditor };

0 commit comments

Comments
 (0)