mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-16 06:18:27 +00:00
Format UI code.
This commit is contained in:
@ -2,7 +2,7 @@ import React, { Component } from "react";
|
||||
|
||||
import { notification, Input, Select, Button, Space, Form, Dropdown, Menu } from "antd";
|
||||
import { ReloadOutlined, CopyOutlined } from "@ant-design/icons";
|
||||
import {Buffer} from "buffer";
|
||||
import { Buffer } from "buffer";
|
||||
|
||||
interface IProps {
|
||||
formRef: React.RefObject<any>;
|
||||
@ -108,13 +108,15 @@ class AesKeyInput extends Component<IProps, IState> {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join("").toUpperCase())
|
||||
navigator.clipboard
|
||||
.writeText(bytes.join("").toUpperCase())
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -122,19 +124,26 @@ class AesKeyInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
copyToClipboardHexArray = () => {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join(", ").toUpperCase().replace(/[A-Fa-f0-9]{2}/g, "0x$&"))
|
||||
navigator.clipboard
|
||||
.writeText(
|
||||
bytes
|
||||
.join(", ")
|
||||
.toUpperCase()
|
||||
.replace(/[A-Fa-f0-9]{2}/g, "0x$&"),
|
||||
)
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -142,19 +151,31 @@ class AesKeyInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const copyMenu = <Menu items={[
|
||||
{
|
||||
key: "1",
|
||||
label: <Button type="text" onClick={this.copyToClipboard}>HEX string</Button>,
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: <Button type="text" onClick={this.copyToClipboardHexArray}>HEX array</Button>,
|
||||
},
|
||||
]} />;
|
||||
const copyMenu = (
|
||||
<Menu
|
||||
items={[
|
||||
{
|
||||
key: "1",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboard}>
|
||||
HEX string
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboardHexArray}>
|
||||
HEX array
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
const addon = (
|
||||
<Space size="large">
|
||||
|
@ -107,18 +107,19 @@ class DevAddrInput extends Component<IProps, IState> {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
copyToClipboard = () => {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join("").toUpperCase())
|
||||
navigator.clipboard
|
||||
.writeText(bytes.join("").toUpperCase())
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -126,19 +127,26 @@ class DevAddrInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
copyToClipboardHexArray = () => {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join(", ").toUpperCase().replace(/[A-Fa-f0-9]{2}/g, "0x$&"))
|
||||
navigator.clipboard
|
||||
.writeText(
|
||||
bytes
|
||||
.join(", ")
|
||||
.toUpperCase()
|
||||
.replace(/[A-Fa-f0-9]{2}/g, "0x$&"),
|
||||
)
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -146,20 +154,31 @@ class DevAddrInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
render() {
|
||||
const copyMenu = <Menu items={[
|
||||
{
|
||||
key: "1",
|
||||
label: <Button type="text" onClick={this.copyToClipboard}>HEX string</Button>,
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: <Button type="text" onClick={this.copyToClipboardHexArray}>HEX array</Button>,
|
||||
},
|
||||
]} />;
|
||||
const copyMenu = (
|
||||
<Menu
|
||||
items={[
|
||||
{
|
||||
key: "1",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboard}>
|
||||
HEX string
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboardHexArray}>
|
||||
HEX array
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
const addon = (
|
||||
<Space size="large">
|
||||
|
@ -2,7 +2,7 @@ import React, { Component } from "react";
|
||||
|
||||
import { notification, Input, Select, Button, Space, Form, Dropdown, Menu } from "antd";
|
||||
import { ReloadOutlined, CopyOutlined } from "@ant-design/icons";
|
||||
import {Buffer} from "buffer";
|
||||
import { Buffer } from "buffer";
|
||||
|
||||
interface IProps {
|
||||
formRef: React.RefObject<any>;
|
||||
@ -107,13 +107,15 @@ class EuiInput extends Component<IProps, IState> {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join("").toUpperCase())
|
||||
navigator.clipboard
|
||||
.writeText(bytes.join("").toUpperCase())
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -121,19 +123,26 @@ class EuiInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
copyToClipboardHexArray = () => {
|
||||
const bytes = this.state.value.match(/[A-Fa-f0-9]{2}/g);
|
||||
|
||||
if (bytes !== null && navigator.clipboard !== undefined) {
|
||||
navigator.clipboard.writeText(bytes.join(", ").toUpperCase().replace(/[A-Fa-f0-9]{2}/g, "0x$&"))
|
||||
navigator.clipboard
|
||||
.writeText(
|
||||
bytes
|
||||
.join(", ")
|
||||
.toUpperCase()
|
||||
.replace(/[A-Fa-f0-9]{2}/g, "0x$&"),
|
||||
)
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: "Copied to clipboard",
|
||||
duration: 3,
|
||||
});
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch(e => {
|
||||
notification.error({
|
||||
message: "Error",
|
||||
description: e,
|
||||
@ -141,19 +150,31 @@ class EuiInput extends Component<IProps, IState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const copyMenu = <Menu items={[
|
||||
{
|
||||
key: "1",
|
||||
label: <Button type="text" onClick={this.copyToClipboard}>HEX string</Button>,
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: <Button type="text" onClick={this.copyToClipboardHexArray}>HEX array</Button>,
|
||||
},
|
||||
]} />;
|
||||
const copyMenu = (
|
||||
<Menu
|
||||
items={[
|
||||
{
|
||||
key: "1",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboard}>
|
||||
HEX string
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
label: (
|
||||
<Button type="text" onClick={this.copyToClipboardHexArray}>
|
||||
HEX array
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
const addon = (
|
||||
<Space size="large">
|
||||
|
Reference in New Issue
Block a user