1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
import {
faCheck,
faClipboard,
faSync,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { FunctionComponent, useState } from "react";
import { InputGroup } from "react-bootstrap";
import { copyToClipboard, Environment, toggleState } from "../../utilities";
import {
Button,
Check,
Chips,
CollapseBox,
Group,
Input,
Message,
Selector,
SettingsProvider,
Text,
} from "../components";
import { branchOptions, proxyOptions, securityOptions } from "./options";
const characters = "abcdef0123456789";
const settingApiKey = "settings-auth-apikey";
const generateApiKey = () => {
return Array(32)
.fill(null)
.map(() => characters.charAt(Math.floor(Math.random() * characters.length)))
.join("");
};
const baseUrlOverride = (settings: Settings) =>
settings.general.base_url?.slice(1) ?? "";
const SettingsGeneralView: FunctionComponent = () => {
const [copied, setCopy] = useState(false);
return (
<SettingsProvider title="General - Bazarr (Settings)">
<Group header="Host">
<Input name="Address">
<Text placeholder="0.0.0.0" settingKey="settings-general-ip"></Text>
<Message>Valid IPv4 address or '0.0.0.0' for all interfaces</Message>
</Input>
<Input name="Port">
<Text placeholder={6767} settingKey="settings-general-port"></Text>
</Input>
<Input name="Base URL">
<InputGroup>
<InputGroup.Prepend>
<InputGroup.Text>/</InputGroup.Text>
</InputGroup.Prepend>
<Text
settingKey="settings-general-base_url"
override={baseUrlOverride}
beforeStaged={(v) => "/" + v}
></Text>
</InputGroup>
<Message>Reverse proxy support</Message>
</Input>
</Group>
<Group header="Security">
<CollapseBox>
<CollapseBox.Control>
<Input name="Authentication">
<Selector
clearable
options={securityOptions}
settingKey="settings-auth-type"
beforeStaged={(v) => (v === null ? "None" : v)}
></Selector>
</Input>
</CollapseBox.Control>
<CollapseBox.Content on={(k) => k !== "" && k !== "None"}>
<Input name="Username">
<Text settingKey="settings-auth-username"></Text>
</Input>
<Input name="Password">
<Text password settingKey="settings-auth-password"></Text>
</Input>
</CollapseBox.Content>
</CollapseBox>
<Input name="API Key">
<InputGroup>
<Text disabled controlled settingKey={settingApiKey}></Text>
<InputGroup.Append>
<Button
variant={copied ? "success" : "light"}
settingKey={settingApiKey}
onClick={(update, key, value) => {
if (value) {
copyToClipboard(value);
toggleState(setCopy, 1500);
}
}}
>
<FontAwesomeIcon
icon={copied ? faCheck : faClipboard}
></FontAwesomeIcon>
</Button>
<Button
variant="danger"
settingKey={settingApiKey}
onClick={(update, key) => {
update(generateApiKey(), key);
}}
>
<FontAwesomeIcon icon={faSync}></FontAwesomeIcon>
</Button>
</InputGroup.Append>
</InputGroup>
</Input>
</Group>
<Group header="Proxy">
<CollapseBox>
<CollapseBox.Control>
<Input>
<Selector
clearable
settingKey="settings-proxy-type"
options={proxyOptions}
beforeStaged={(v) => (v === null ? "None" : v)}
></Selector>
</Input>
</CollapseBox.Control>
<CollapseBox.Content on={(k) => k !== "" && k !== "None"}>
<Input name="Host">
<Text settingKey="settings-proxy-url"></Text>
</Input>
<Input name="Port">
<Text settingKey="settings-proxy-port"></Text>
</Input>
<Input name="Username">
<Text settingKey="settings-proxy-username"></Text>
</Input>
<Input name="Password">
<Text password settingKey="settings-proxy-password"></Text>
<Message>
You only need to enter a username and password if one is
required. Leave them blank otherwise
</Message>
</Input>
<Input name="Ignored Addresses">
<Chips settingKey="settings-proxy-exclude"></Chips>
<Message>'*.' as a wildcard for subdomains</Message>
</Input>
</CollapseBox.Content>
</CollapseBox>
</Group>
<Group header="Updates" hidden={!Environment.canUpdate}>
<Input>
<Check
label="Automatic"
settingKey="settings-general-auto_update"
></Check>
<Message>Automatically download and install updates</Message>
</Input>
<Input>
<Selector
options={branchOptions}
settingKey="settings-general-branch"
></Selector>
<Message>Branch used by update mechanism</Message>
</Input>
</Group>
<Group header="Logging">
<Input>
<Check label="Debug" settingKey="settings-general-debug"></Check>
<Message>Debug logging should only be enabled temporarily</Message>
</Input>
</Group>
<Group header="Analytics">
<Input>
<Check label="Enable" settingKey="settings-analytics-enabled"></Check>
<Message>
Send anonymous usage information, nothing that can identify you.
This includes information on which providers you use, what languages
you search for, Bazarr, Python, Sonarr, Radarr and what OS version
you are using. We will use this information to prioritize features
and bug fixes. Please, keep this enabled as this is the only way we
have to better understand how you use Bazarr.
</Message>
</Input>
</Group>
</SettingsProvider>
);
};
export default SettingsGeneralView;
|