Skip to content

Commit

Permalink
feat: build
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlysu committed Aug 16, 2023
1 parent 1542fed commit 31d38db
Show file tree
Hide file tree
Showing 21 changed files with 160 additions and 136 deletions.
42 changes: 21 additions & 21 deletions dist/MANIFEST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ Hash: SHA512
"signedByOrgName": "Tencent",
"rootUrls": [],
"plugin": "tencentcloud-monitor-app",
"version": "2.8.5",
"time": 1690859500414,
"version": "2.8.6",
"time": 1692173526048,
"keyId": "7e4d0c6a708866e7",
"files": {
"datasource/config-editor/config.html": "110380b35165fcfcffa797ab6841e9621bf5135881fa5e94f5f316a0600b5796",
"datasource/tencentcloud-monitor-app-backend_darwin_amd64": "050b6e8264edd7f6955ac0d8ca985b59e0f1bc322dec83ef0c7b6acdbcf54852",
"datasource/tencentcloud-monitor-app-backend_darwin_amd64": "014b102aadb81e4883d70160a97cf47d0bc8144278a572c5400e6562f44b764c",
"datasource/module.js.LICENSE.txt": "0d8f66cd4afb566cb5b7e1540c68f43b939d3eba12ace290f18abc4f4cb53ed0",
"datasource/tencentcloud-monitor-app-backend_linux_arm64": "e82f8111452c3e97a2bcddc50b373a296510fa3cfd3a9de8c5a340213dd8b492",
"datasource/module.js.map": "512174f65239b40c1ddf23239ba60ef3baa219e7612c66650c506022744df60a",
"datasource/tencentcloud-monitor-app-backend_linux_arm64": "b294c146e720b3b32c31a29f7f050289bbca4f5040a1ce82f3d4cb20171c312a",
"datasource/module.js.map": "00a4bb7b195676932d809bc380cc9f63d4b1655814c27390c0ca6967297a21fa",
"datasource/plugin.json": "674e6482bf2c91afe44591bcbee6341bdf7a90d795186f7d58140b4a40a44c48",
"datasource/img/tencent-cloud.svg": "572e1abf6d2a4be854845b55219e8d0661f79b325f0659b5439dddb37a304a8a",
"datasource/tencentcloud-monitor-app-backend_linux_arm": "79d9e0fa633c254634a10b8b33e7972a83d58ff4552411ce61509d44b1239e13",
"datasource/tencentcloud-monitor-app-backend_linux_arm": "d67866228c1dcdadbf537c5020579f95881f310ee48215e718925454fa773cdf",
"datasource/query-ctrl/partials/query.editor.html": "443d863f1d1c9295467da9a4290d16e9211699d034502b76605ebf41b61a4011",
"datasource/module.js": "1134392f98a7ac5079b8479dbb73f7b91d3a32c741ab8e5f8b059898dce75077",
"datasource/tencentcloud-monitor-app-backend_windows_amd64.exe": "8668218308b9eabb7290e87b1f46bb06d2f468cf5789bb83a4f63cf46d4a5b24",
"datasource/tencentcloud-monitor-app-backend_linux_amd64": "86c8fe18f95a70707dba508455369b104da16cf8698c4f66eb255c481245c5f9",
"datasource/tencentcloud-monitor-app-backend_darwin_arm64": "1fbafc2c3aaa7e97937acc469e1d7d7637e05503084e83e788ed897aaafb4a19",
"datasource/module.js": "aeeac3d0e129dae5cd13b881df63c23b02c9a86dcc78061112250ff40ba8a282",
"datasource/tencentcloud-monitor-app-backend_windows_amd64.exe": "73109bc2e2a20a5e4f00c1bd600310d86f866b25d306edb27c19290ec55ab82f",
"datasource/tencentcloud-monitor-app-backend_linux_amd64": "fca39eeca93cc713bf258acd8913d6294a14c520a7aa0d29b55575cf31f24d75",
"datasource/tencentcloud-monitor-app-backend_darwin_arm64": "436f0c75d79736b104007be1dce5b51707542518d079e4974b65c435c3b2071f",
"LICENSE": "7d90d87fbfbc9369eb627fd38811e01dfd955d72269d5039e7c6119372baa1e3",
"CHANGELOG.md": "0596a172e06ba90b28ef8887553a6e97320a3bd01f77d81e8b3face21c848163",
"module.js.map": "0783dfd005941a5256efa4917abfa8a65b6ef15fb246f3cc3e1ea2f0bb649aea",
"module.js.map": "d52f6db4e8d4f2fbb82ebf1cdeed76adef4ea6b20c26dbf978488f3bbbf6644b",
"image/datasource-config.png": "e31ceec33c6454f6335850791f9b35fc2be56a4e43dfc11a75435e16f025dc0f",
"image/variable-region-config.png": "d46215b565d2b851855fb48bf7ee73ef696e3b8cfc671a376743faa39b193f3c",
"image/variable-panel-query.png": "e17f91280df34695d7be10b3e355b6c91d4b43404243529dc7e75d1f9a8605fa",
"image/variable-cvm-dashboard.png": "f97220e1230b83b0110f7e11468538b44c48d8b70906509f5153f8895ed02653",
"plugin.json": "a50783b7b4fa6f86cbd9eb7a5f90ba4b6abf3f377e1040506337d46f6780a3fa",
"plugin.json": "530642075f5ddbc6f59c81e70ea5f9a0b3ffc1f6895710b6c16de54537f9f725",
"README.md": "6510f9156c1d9198895cb8dcce1f137ac88292d0ce922c5f31bbb19af76e78c6",
"img/tencent-cloud.svg": "572e1abf6d2a4be854845b55219e8d0661f79b325f0659b5439dddb37a304a8a",
"components/config.js": "901e71010aa61627fd40203c2f74e58b0ac2c41b64b29874c5925376f8329d5f",
"components/config.js.map": "67209cd61e285e6c800157e5720802057142da223ee7fc11ff374d5d80058a81",
"components/config.js": "9b7fa378e0e995486f5d1ee55ed108c412438f750a98ec82592df1e8d0177507",
"components/config.js.map": "b82ac49248b25a97ad9fb0d9e67856da5f5e6e430d7d7ef301fdd09a057955e9",
"components/config.html": "851e7cf915df590befbe6a56bf9bf4a17083de46ef93246a0bc6214d7be13464",
"module.js": "bd9c423ad647aef96407ca6c49f4566b3a24e4afabd7d1def1b9518c0c456919",
"module.js": "7f5fa045df7d48411a191e9a0a24a088595ca652897572635486df4c44e5c867",
"dashboards/example_redis_mem_en_dashboard.json": "66bde7943e04a3a42048535206d273c303e345a6bf5d57e6a1bc818e8799d360",
"dashboards/example_logService_clb_en_dashboard.json": "c6545c6b884ed84851d0e933badcd79a55fc85c2baf8487135f63b1105083fa2",
"dashboards/example_lb_dashboard.json": "9884b63f52a1564a57edf79626dfee97f0e0e80bcaa321cffcf747054204ca43",
Expand Down Expand Up @@ -80,10 +80,10 @@ Hash: SHA512
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wrkEARMKAAYFAmTId+wAIQkQfk0ManCIZucWIQTzOyW2kQdOhGNlcPN+TQxq
cIhm54N5AgkBLnTo9xJJoS5mD1eN4DpUaD9Yrc1KjGmyMTBbp2dNonEisVEo
61NxFu/1h/GMldTkZrbpmjkSYLO4KTiaaDxRjkgCCQFz6BijxfBkbvqtr85i
W4z46O+10DELFTTIc09TNP6WcIAhi6H6XRY3H6SIDJliuaVf17/MjD3p82tZ
wbyiIIOfsw==
=Bxjh
wrkEARMKAAYFAmTchNYAIQkQfk0ManCIZucWIQTzOyW2kQdOhGNlcPN+TQxq
cIhm5/4/AgkBEuoIpWKevOiLARbyrzLDa4eztImvglb9WNLJbnUhFmPrL40n
qijUSzoCoPwEyfb5xhVf5w9gq9k4YFP2tjmvq7ACCQHHY9ju7c1Y2JNLNc/+
nnqfX8lHyrll/1kX4ZUozf4pyz01fJe0mBC2J8wlYtHXsowThqYsNzuCeUIm
IS2zEV91xA==
=pH9Q
-----END PGP SIGNATURE-----
2 changes: 1 addition & 1 deletion dist/components/config.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/components/config.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/datasource/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/datasource/module.js.map

Large diffs are not rendered by default.

Binary file modified dist/datasource/tencentcloud-monitor-app-backend_darwin_amd64
Binary file not shown.
Binary file modified dist/datasource/tencentcloud-monitor-app-backend_darwin_arm64
Binary file not shown.
Binary file modified dist/datasource/tencentcloud-monitor-app-backend_linux_amd64
Binary file not shown.
Binary file modified dist/datasource/tencentcloud-monitor-app-backend_linux_arm
Binary file not shown.
Binary file modified dist/datasource/tencentcloud-monitor-app-backend_linux_arm64
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"small": "img/tencent-cloud.svg",
"large": "img/tencent-cloud.svg"
},
"version": "2.8.5",
"updated": "2023-08-01",
"version": "2.8.6",
"updated": "2023-08-16",
"links": [
{ "name": "GitHub", "url": "https://github.com/TencentCloud/tencentcloud-monitor-grafana-app" },
{ "name": "Docs", "url": "https://cloud.tencent.com/document/product/248/48529" },
Expand Down
28 changes: 16 additions & 12 deletions src/datasource/config-editor/ConfigEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { FormEvent, PureComponent } from 'react';
import {LegacyForms, InlineFieldRow, InlineField, Input, Switch, Select, Alert} from '@grafana/ui';
import { LegacyForms, InlineFieldRow, InlineField, Input, Switch, Select, Alert } from '@grafana/ui';
import { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';
import { MyDataSourceOptions, MySecureJsonData } from '../types';
import { SERVICES } from '../tc_monitor';
import { t, setLanguage, Language } from '../../locale'
import { t, setLanguage, Language } from '../../locale';
const { SecretFormField } = LegacyForms;

type Props = DataSourcePluginOptionsEditorProps<MyDataSourceOptions, MySecureJsonData>;

interface State {
monitorFilter: string;
isClsAlertVisiable: boolean,
isClsAlertVisiable: boolean;
}

export class ConfigEditor extends PureComponent<Props, State> {
Expand All @@ -20,7 +20,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
monitorFilter: '',
isClsAlertVisiable: false,
};
setLanguage(props.options.jsonData.language || Language.Chinese)
setLanguage(props.options.jsonData.language || Language.Chinese);
}

patchJsonData = (kv: Record<string, any>) => {
Expand Down Expand Up @@ -162,9 +162,12 @@ export class ConfigEditor extends PureComponent<Props, State> {
<Select
value={jsonData.language || Language.Chinese}
className="width-10"
options={[{ value: Language.English, label: 'English' }, { value: Language.Chinese, label: '简体中文' }]}
options={[
{ value: Language.English, label: 'English' },
{ value: Language.Chinese, label: '简体中文' },
]}
onChange={(option: SelectableValue<Language>) => {
setLanguage(option.value)
setLanguage(option.value);
this.patchJsonData({
language: option.value,
});
Expand Down Expand Up @@ -213,13 +216,13 @@ export class ConfigEditor extends PureComponent<Props, State> {
</InlineField>
</InlineFieldRow>
</div>
)
);
}

renderLogServiceConfig() {
const { options } = this.props;
const { jsonData } = options;
const { isClsAlertVisiable} = this.state
const { isClsAlertVisiable } = this.state;
return (
<div style={{ marginTop: 30 }}>
<h3 className="page-heading">Log Service</h3>
Expand All @@ -228,13 +231,14 @@ export class ConfigEditor extends PureComponent<Props, State> {
<InlineSwitch
value={jsonData.logServiceEnabled}
onChange={(e) => {
const logServiceEnabled = e.currentTarget.checked
const logServiceEnabled = e.currentTarget.checked;
this.patchJsonData({
logServiceEnabled,
});
if(logServiceEnabled) this.setState({
isClsAlertVisiable: true
})
if (logServiceEnabled)
this.setState({
isClsAlertVisiable: true,
});
}}
/>
</InlineField>
Expand Down
13 changes: 8 additions & 5 deletions src/datasource/log-service/LogServiceDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { RowContextOptions } from '@grafana/ui/components/Logs/LogRowContextProvider';
import moment from 'moment';
import { toTimeSeriesMany } from './common/format/prepareTimeSeries';
import {addQueryResultLimit, replaceClsQueryWithTemplateSrv} from './common/utils/query';
import { addQueryResultLimit, replaceClsQueryWithTemplateSrv } from './common/utils/query';

export class LogServiceDataSource extends DataSourceApi<QueryInfo, MyDataSourceOptions> {
private readonly instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>;
Expand All @@ -38,7 +38,10 @@ export class LogServiceDataSource extends DataSourceApi<QueryInfo, MyDataSourceO
const requestTargets = targets.map<QueryInfo>((target) => {
const region = target.logServiceParams?.region ? getTemplateSrv().replace(target.logServiceParams.region) : '';
const TopicId = target.logServiceParams?.TopicId ? getTemplateSrv().replace(target.logServiceParams.TopicId) : '';
const Query = addQueryResultLimit(replaceClsQueryWithTemplateSrv(target.logServiceParams?.Query || '', scopedVars),target.logServiceParams);
const Query = addQueryResultLimit(
replaceClsQueryWithTemplateSrv(target.logServiceParams?.Query || '', scopedVars),
target.logServiceParams
);

return {
...target,
Expand All @@ -61,7 +64,7 @@ export class LogServiceDataSource extends DataSourceApi<QueryInfo, MyDataSourceO
From: from,
To: to,
SyntaxRule: target.logServiceParams.SyntaxRule,
Limit: target.logServiceParams.MaxResultNum
Limit: target.logServiceParams.MaxResultNum,
},
target.logServiceParams.region,
{ instanceSettings: this.instanceSettings }
Expand Down Expand Up @@ -125,7 +128,7 @@ export class LogServiceDataSource extends DataSourceApi<QueryInfo, MyDataSourceO
const logServiceParams = query;
const region = logServiceParams?.region ? getTemplateSrv().replace(logServiceParams.region) : '';
const TopicId = logServiceParams?.TopicId ? getTemplateSrv().replace(logServiceParams.TopicId) : '';
const Query = addQueryResultLimit(replaceClsQueryWithTemplateSrv(logServiceParams.Query),logServiceParams);
const Query = addQueryResultLimit(replaceClsQueryWithTemplateSrv(logServiceParams.Query), logServiceParams);

if (!options.range) {
return [];
Expand All @@ -138,7 +141,7 @@ export class LogServiceDataSource extends DataSourceApi<QueryInfo, MyDataSourceO
Query: Query,
From: options.range!.from.valueOf(),
To: options.range!.to.valueOf(),
Limit: logServiceParams?.MaxResultNum
Limit: logServiceParams?.MaxResultNum,
},
region,
{
Expand Down
108 changes: 56 additions & 52 deletions src/datasource/log-service/LogServiceQueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { DataSourceApi, QueryEditorProps } from '@grafana/data';
import { defaultQueryInfo, MyDataSourceOptions, QueryInfo, queryInfoRuntime } from '../types';
import React, { FC, useCallback } from 'react';
import { useLatest } from 'react-use';
import {InlineField, InlineLabel, QueryField, Select, InlineFieldRow, Input} from '@grafana/ui';
import { InlineField, InlineLabel, QueryField, Select, InlineFieldRow, Input } from '@grafana/ui';
import { TopicSelector } from './components/TopicSelector';
import { TcDataSourceId } from '../common/constants';
import { t } from '../../locale';
import _ from 'lodash';
import './index.less';
import {SearchSyntaxRule} from "./common/constants";
import { SearchSyntaxRule } from './common/constants';

type Props = QueryEditorProps<DataSourceApi<any>, QueryInfo, MyDataSourceOptions>;

Expand All @@ -27,49 +27,47 @@ export const LogServiceQueryEditor: FC<Props> = React.memo((props: Props) => {
[propsRef]
);


return (
<div>
<InlineFieldRow>
<TopicSelector
value={{ region: logServiceParams.region, TopicId: logServiceParams.TopicId }}
onChange={(v) => {
partialOnChange({
logServiceParams: {
...(propsRef.current?.query?.logServiceParams || ({} as any)),
...v,
},
});
}}
datasource={datasource}
/>
<InlineField label={t('syntax_rule')} labelWidth={20}>
<Select
value={logServiceParams.SyntaxRule}
<TopicSelector
value={{ region: logServiceParams.region, TopicId: logServiceParams.TopicId }}
onChange={(v) => {
partialOnChange({
logServiceParams: {
...(propsRef.current?.query?.logServiceParams || ({} as any)),
SyntaxRule: v.value,
...v,
},
});
}
}
menuPlacement="bottom"
options={[
{
label: 'Lucene',
value: SearchSyntaxRule.LUCENE
},
{
label: 'CQL',
value: SearchSyntaxRule.CQL
},
]}
width={25}
className="log-service-monospaced-font-family"
}}
datasource={datasource}
/>
</InlineField>
<InlineField label={t('syntax_rule')} labelWidth={20}>
<Select
value={logServiceParams.SyntaxRule}
onChange={(v) => {
partialOnChange({
logServiceParams: {
...(propsRef.current?.query?.logServiceParams || ({} as any)),
SyntaxRule: v.value,
},
});
}}
menuPlacement="bottom"
options={[
{
label: 'Lucene',
value: SearchSyntaxRule.LUCENE,
},
{
label: 'CQL',
value: SearchSyntaxRule.CQL,
},
]}
width={25}
className="log-service-monospaced-font-family"
/>
</InlineField>
</InlineFieldRow>

<MaxResultNumInput
Expand All @@ -78,9 +76,9 @@ export const LogServiceQueryEditor: FC<Props> = React.memo((props: Props) => {
partialOnChange({
logServiceParams: {
...(propsRef.current?.query?.logServiceParams || ({} as any)),
MaxResultNum: val
MaxResultNum: val,
},
})
});
}}
/>

Expand Down Expand Up @@ -111,28 +109,34 @@ export const LogServiceQueryEditor: FC<Props> = React.memo((props: Props) => {

LogServiceQueryEditor.displayName = 'LogServiceQueryEditor';

interface MaxResultNumInputProps {
interface MaxResultNumInputProps {
value: string | number;
onChange: (value: number | undefined) => void
onChange: (value: number | undefined) => void;
}


const MaxResultNumInput: FC<MaxResultNumInputProps> = React.memo((props) => {
const min = 1
const max = 1000
const { value,onChange:onChangeFromProps } = props

const onInputChange = useCallback((e)=>{
const currVal = Number(e.currentTarget.value) || undefined
onChangeFromProps(currVal)
const min = 1;
const max = 1000;
const { value, onChange: onChangeFromProps } = props;

},[onChangeFromProps]);
const onInputChange = useCallback(
(e) => {
const currVal = Number(e.currentTarget.value) || undefined;
onChangeFromProps(currVal);
},
[onChangeFromProps]
);

return (
// @ts-ignore 这里报error属性不存在,但应该是存在的。
<InlineField label={t('max_result_num')} labelWidth={20} invalid={value < min || value > max} error='仅支持返回1~1000条日志'>
<InlineField
label={t('max_result_num')}
labelWidth={20}
invalid={value < min || value > max}
error="仅支持返回1~1000条日志"
>
<Input
type='number'
type="number"
min={min}
max={max}
value={value}
Expand All @@ -141,5 +145,5 @@ const MaxResultNumInput: FC<MaxResultNumInputProps> = React.memo((props) => {
className="log-service-monospaced-font-family"
/>
</InlineField>
)
})
);
});
2 changes: 0 additions & 2 deletions src/datasource/log-service/common/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

export enum SearchSyntaxRule {
Expand Down
Loading

0 comments on commit 31d38db

Please sign in to comment.