diff options
author | Emiliano Ciavatta | 2020-10-16 13:26:55 +0000 |
---|---|---|
committer | Emiliano Ciavatta | 2020-10-16 13:26:55 +0000 |
commit | d429a344ef34bb9289616dc7ca11c161fabce5d7 (patch) | |
tree | 664d56822eac93568f44c40ca25be725d1dd81c8 /frontend | |
parent | 5534413b3a3e6e783310be8147ac8340d3098a7e (diff) |
Refactor js arrow functions
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/src/components/App.js | 2 | ||||
-rw-r--r-- | frontend/src/components/Notifications.js | 2 | ||||
-rw-r--r-- | frontend/src/components/Timeline.js | 2 | ||||
-rw-r--r-- | frontend/src/components/filters/AdvancedFilters.js | 4 | ||||
-rw-r--r-- | frontend/src/components/filters/ExitSearchFilter.js | 2 | ||||
-rw-r--r-- | frontend/src/components/filters/RulesConnectionsFilter.js | 2 | ||||
-rw-r--r-- | frontend/src/components/objects/Connection.js | 4 | ||||
-rw-r--r-- | frontend/src/components/objects/ConnectionMatchedRules.js | 4 | ||||
-rw-r--r-- | frontend/src/components/panels/ConnectionsPane.js | 10 | ||||
-rw-r--r-- | frontend/src/components/panels/PcapsPane.js | 6 | ||||
-rw-r--r-- | frontend/src/components/panels/RulesPane.js | 16 | ||||
-rw-r--r-- | frontend/src/components/panels/SearchPane.js | 22 | ||||
-rw-r--r-- | frontend/src/components/panels/ServicesPane.js | 10 | ||||
-rw-r--r-- | frontend/src/components/panels/StreamsPane.js | 6 | ||||
-rw-r--r-- | frontend/src/dispatcher.js | 8 | ||||
-rw-r--r-- | frontend/src/log.js | 2 |
16 files changed, 51 insertions, 51 deletions
diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index 888ff86..e12a99d 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -27,7 +27,7 @@ class App extends Component { state = {}; componentDidMount() { - dispatcher.register("notifications", payload => { + dispatcher.register("notifications", (payload) => { if (payload.event === "connected") { this.setState({ connected: true, diff --git a/frontend/src/components/Notifications.js b/frontend/src/components/Notifications.js index a81eba1..0b47b43 100644 --- a/frontend/src/components/Notifications.js +++ b/frontend/src/components/Notifications.js @@ -107,7 +107,7 @@ class Notifications extends Component { <div className="notifications"> <div className="notifications-list"> { - this.state.closedNotifications.concat(this.state.notifications).map(n => { + this.state.closedNotifications.concat(this.state.notifications).map((n) => { const notificationClassnames = { "notification": true, "notification-closed": n.closed, diff --git a/frontend/src/components/Timeline.js b/frontend/src/components/Timeline.js index 94fa4d0..9ecbd80 100644 --- a/frontend/src/components/Timeline.js +++ b/frontend/src/components/Timeline.js @@ -127,7 +127,7 @@ class Timeline extends Component { const series = new TimeSeries({ name: "statistics", columns: ["time"].concat(columns), - points: zeroFilledMetrics.map((m) => [m["range_start"]].concat(columns.map(c => + points: zeroFilledMetrics.map((m) => [m["range_start"]].concat(columns.map((c) => ((metric in m) && (m[metric] != null)) ? (m[metric][c] || 0) : 0 ))) }); diff --git a/frontend/src/components/filters/AdvancedFilters.js b/frontend/src/components/filters/AdvancedFilters.js index 15667a5..8598185 100644 --- a/frontend/src/components/filters/AdvancedFilters.js +++ b/frontend/src/components/filters/AdvancedFilters.js @@ -28,10 +28,10 @@ class AdvancedFilters extends Component { componentDidMount() { this.urlParams = new URLSearchParams(this.props.location.search); - this.connectionsFiltersCallback = payload => { + this.connectionsFiltersCallback = (payload) => { this.urlParams = updateParams(this.urlParams, payload); const active = ["client_address", "client_port", "min_duration", "max_duration", "min_bytes", "max_bytes"] - .some(f => this.urlParams.has(f)); + .some((f) => this.urlParams.has(f)); if (this.state.active !== active) { this.setState({active}); } diff --git a/frontend/src/components/filters/ExitSearchFilter.js b/frontend/src/components/filters/ExitSearchFilter.js index 72cfb0c..0aacfd6 100644 --- a/frontend/src/components/filters/ExitSearchFilter.js +++ b/frontend/src/components/filters/ExitSearchFilter.js @@ -28,7 +28,7 @@ class ExitSearchFilter extends Component { let params = new URLSearchParams(this.props.location.search); this.setState({performedSearch: params.get("performed_search")}); - this.connectionsFiltersCallback = payload => { + this.connectionsFiltersCallback = (payload) => { if (this.state.performedSearch !== payload["performed_search"]) { this.setState({performedSearch: payload["performed_search"]}); } diff --git a/frontend/src/components/filters/RulesConnectionsFilter.js b/frontend/src/components/filters/RulesConnectionsFilter.js index 37d36b7..210ee36 100644 --- a/frontend/src/components/filters/RulesConnectionsFilter.js +++ b/frontend/src/components/filters/RulesConnectionsFilter.js @@ -37,7 +37,7 @@ class RulesConnectionsFilter extends Component { backend.get("/api/rules").then((res) => { let rules = res.json.flatMap((rule) => rule.enabled ? [{id: rule.id, name: rule.name}] : []); - activeRules = rules.filter((rule) => activeRules.some(id => rule.id === id)); + activeRules = rules.filter((rule) => activeRules.some((id) => rule.id === id)); this.setState({rules, activeRules}); }); diff --git a/frontend/src/components/objects/Connection.js b/frontend/src/components/objects/Connection.js index e5896e9..b70b7f7 100644 --- a/frontend/src/components/objects/Connection.js +++ b/frontend/src/components/objects/Connection.js @@ -37,7 +37,7 @@ class Connection extends Component { if (name === "hide") { const enabled = !this.props.data.hidden; backend.post(`/api/connections/${this.props.data.id}/${enabled ? "hide" : "show"}`) - .then(_ => { + .then((_) => { this.props.onEnabled(!enabled); this.setState({update: true}); }); @@ -45,7 +45,7 @@ class Connection extends Component { if (name === "mark") { const marked = this.props.data.marked; backend.post(`/api/connections/${this.props.data.id}/${marked ? "unmark" : "mark"}`) - .then(_ => { + .then((_) => { this.props.onMarked(!marked); this.setState({update: true}); }); diff --git a/frontend/src/components/objects/ConnectionMatchedRules.js b/frontend/src/components/objects/ConnectionMatchedRules.js index cfd1254..a69cad8 100644 --- a/frontend/src/components/objects/ConnectionMatchedRules.js +++ b/frontend/src/components/objects/ConnectionMatchedRules.js @@ -33,8 +33,8 @@ class ConnectionMatchedRules extends Component { }; render() { - const matchedRules = this.props.matchedRules.map(mr => { - const rule = this.props.rules.find(r => r.id === mr); + const matchedRules = this.props.matchedRules.map((mr) => { + const rule = this.props.rules.find((r) => r.id === mr); return <ButtonField key={mr} onClick={() => this.onMatchedRulesSelected(rule.id)} name={rule.name} color={rule.color} small/>; }); diff --git a/frontend/src/components/panels/ConnectionsPane.js b/frontend/src/components/panels/ConnectionsPane.js index 9418fad..457c249 100644 --- a/frontend/src/components/panels/ConnectionsPane.js +++ b/frontend/src/components/panels/ConnectionsPane.js @@ -61,8 +61,8 @@ class ConnectionsPane extends Component { const id = match[1]; additionalParams.from = id; backend.get(`/api/connections/${id}`) - .then(res => this.connectionSelected(res.json)) - .catch(error => log.error("Error loading initial connection", error)); + .then((res) => this.connectionSelected(res.json)) + .catch((error) => log.error("Error loading initial connection", error)); } this.loadConnections(additionalParams, urlParams, true).then(() => log.debug("Connections loaded")); @@ -283,11 +283,11 @@ class ConnectionsPane extends Component { </thead> <tbody> { - this.state.connections.flatMap(c => { + this.state.connections.flatMap((c) => { return [<Connection key={c.id} data={c} onSelected={() => this.connectionSelected(c)} selected={this.state.selected === c.id} - onMarked={marked => c.marked = marked} - onEnabled={enabled => c.hidden = !enabled} + onMarked={(marked) => c.marked = marked} + onEnabled={(enabled) => c.hidden = !enabled} services={this.state.services}/>, c.matched_rules.length > 0 && <ConnectionMatchedRules key={c.id + "_m"} matchedRules={c.matched_rules} diff --git a/frontend/src/components/panels/PcapsPane.js b/frontend/src/components/panels/PcapsPane.js index ddc5948..b7d5ce9 100644 --- a/frontend/src/components/panels/PcapsPane.js +++ b/frontend/src/components/panels/PcapsPane.js @@ -98,9 +98,9 @@ class PcapsPane extends Component { } backend.post("/api/pcap/file", { - file: this.state.fileValue, - flush_all: this.state.processFlushAll, - delete_original_file: this.state.deleteOriginalFile + "file": this.state.fileValue, + "flush_all": this.state.processFlushAll, + "delete_original_file": this.state.deleteOriginalFile }).then((res) => { this.setState({ processStatusCode: res.status, diff --git a/frontend/src/components/panels/RulesPane.js b/frontend/src/components/panels/RulesPane.js index 0bbd407..cdfe185 100644 --- a/frontend/src/components/panels/RulesPane.js +++ b/frontend/src/components/panels/RulesPane.js @@ -103,17 +103,17 @@ class RulesPane extends Component { }; loadRules = () => { - backend.get("/api/rules").then(res => this.setState({rules: res.json, rulesStatusCode: res.status})) - .catch(res => this.setState({rulesStatusCode: res.status, rulesResponse: JSON.stringify(res.json)})); + backend.get("/api/rules").then((res) => this.setState({rules: res.json, rulesStatusCode: res.status})) + .catch((res) => this.setState({rulesStatusCode: res.status, rulesResponse: JSON.stringify(res.json)})); }; addRule = () => { if (this.validateRule(this.state.newRule)) { - backend.post("/api/rules", this.state.newRule).then(res => { + backend.post("/api/rules", this.state.newRule).then((res) => { this.reset(); this.setState({ruleStatusCode: res.status}); this.loadRules(); - }).catch(res => { + }).catch((res) => { this.setState({ruleStatusCode: res.status, ruleResponse: JSON.stringify(res.json)}); }); } @@ -122,11 +122,11 @@ class RulesPane extends Component { updateRule = () => { const rule = this.state.selectedRule; if (this.validateRule(rule)) { - backend.put(`/api/rules/${rule.id}`, rule).then(res => { + backend.put(`/api/rules/${rule.id}`, rule).then((res) => { this.reset(); this.setState({ruleStatusCode: res.status}); this.loadRules(); - }).catch(res => { + }).catch((res) => { this.setState({ruleStatusCode: res.status, ruleResponse: JSON.stringify(res.json)}); }); } @@ -247,7 +247,7 @@ class RulesPane extends Component { const rule = this.currentRule(); const pattern = this.state.selectedPattern || this.state.newPattern; - let rules = this.state.rules.map(r => + let rules = this.state.rules.map((r) => <tr key={r.id} onClick={() => { this.reset(); this.setState({selectedRule: _.cloneDeep(r)}); @@ -262,7 +262,7 @@ class RulesPane extends Component { let patterns = (this.state.selectedPattern == null && !isUpdate ? rule.patterns.concat(this.state.newPattern) : rule.patterns - ).map(p => p === pattern ? + ).map((p) => p === pattern ? <tr key={"new_pattern"}> <td style={{"width": "500px"}}> <InputField small active={this.state.patternRegexFocused} value={pattern.regex} diff --git a/frontend/src/components/panels/SearchPane.js b/frontend/src/components/panels/SearchPane.js index 776ebd0..4c9f229 100644 --- a/frontend/src/components/panels/SearchPane.js +++ b/frontend/src/components/panels/SearchPane.js @@ -231,29 +231,29 @@ class SearchPane extends Component { <div className="content-row"> <div className="text-search"> - <TagField tags={(options["text_search"].terms || []).map(t => { + <TagField tags={(options["text_search"].terms || []).map((t) => { return {name: t}; })} name="terms" min={3} inline allowNew={true} readonly={regexOptionsModified || options["text_search"]["exact_phrase"]} - onChange={(tags) => this.updateParam(s => s["text_search"].terms = tags.map(t => t.name))}/> + onChange={(tags) => this.updateParam((s) => s["text_search"].terms = tags.map(t => t.name))}/> <TagField tags={(options["text_search"]["excluded_terms"] || []).map(t => { return {name: t}; })} name="excluded_terms" min={3} inline allowNew={true} readonly={regexOptionsModified || options["text_search"]["exact_phrase"]} - onChange={(tags) => this.updateParam(s => s["text_search"]["excluded_terms"] = tags.map(t => t.name))}/> + onChange={(tags) => this.updateParam((s) => s["text_search"]["excluded_terms"] = tags.map(t => t.name))}/> <span className="exclusive-separator">or</span> <InputField name="exact_phrase" value={options["text_search"]["exact_phrase"]} inline error={this.state.exactPhraseError} - onChange={v => this.updateParam(s => s["text_search"]["exact_phrase"] = v)} + onChange={(v) => this.updateParam((s) => s["text_search"]["exact_phrase"] = v)} readonly={regexOptionsModified || (Array.isArray(options["text_search"].terms) && options["text_search"].terms.length > 0)}/> <CheckField checked={options["text_search"]["case_sensitive"]} name="case_sensitive" readonly={regexOptionsModified} small - onChange={(v) => this.updateParam(s => s["text_search"]["case_sensitive"] = v)}/> + onChange={(v) => this.updateParam((s) => s["text_search"]["case_sensitive"] = v)}/> </div> <div className="separator"> @@ -264,28 +264,28 @@ class SearchPane extends Component { <InputField name="pattern" value={options["regex_search"].pattern} inline error={this.state.patternError} readonly={textOptionsModified || options["regex_search"]["not_pattern"]} - onChange={v => this.updateParam(s => s["regex_search"].pattern = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"].pattern = v)}/> <span className="exclusive-separator">or</span> <InputField name="not_pattern" value={options["regex_search"]["not_pattern"]} inline error={this.state.notPatternError} readonly={textOptionsModified || options["regex_search"].pattern} - onChange={v => this.updateParam(s => s["regex_search"]["not_pattern"] = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"]["not_pattern"] = v)}/> <div className="checkbox-line"> <CheckField checked={options["regex_search"]["case_insensitive"]} name="case_insensitive" readonly={textOptionsModified} small - onChange={(v) => this.updateParam(s => s["regex_search"]["case_insensitive"] = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"]["case_insensitive"] = v)}/> <CheckField checked={options["regex_search"]["multi_line"]} name="multi_line" readonly={textOptionsModified} small - onChange={(v) => this.updateParam(s => s["regex_search"]["multi_line"] = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"]["multi_line"] = v)}/> <CheckField checked={options["regex_search"]["ignore_whitespaces"]} name="ignore_whitespaces" readonly={textOptionsModified} small - onChange={(v) => this.updateParam(s => s["regex_search"]["ignore_whitespaces"] = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"]["ignore_whitespaces"] = v)}/> <CheckField checked={options["regex_search"]["dot_character"]} name="dot_character" readonly={textOptionsModified} small - onChange={(v) => this.updateParam(s => s["regex_search"]["dot_character"] = v)}/> + onChange={(v) => this.updateParam((s) => s["regex_search"]["dot_character"] = v)}/> </div> </div> </div> diff --git a/frontend/src/components/panels/ServicesPane.js b/frontend/src/components/panels/ServicesPane.js index 48d9e29..5986804 100644 --- a/frontend/src/components/panels/ServicesPane.js +++ b/frontend/src/components/panels/ServicesPane.js @@ -68,18 +68,18 @@ class ServicesPane extends Component { loadServices = () => { backend.get("/api/services") - .then(res => this.setState({services: Object.values(res.json), servicesStatusCode: res.status})) - .catch(res => this.setState({servicesStatusCode: res.status, servicesResponse: JSON.stringify(res.json)})); + .then((res) => this.setState({services: Object.values(res.json), servicesStatusCode: res.status})) + .catch((res) => this.setState({servicesStatusCode: res.status, servicesResponse: JSON.stringify(res.json)})); }; updateService = () => { const service = this.state.currentService; if (this.validateService(service)) { - backend.put("/api/services", service).then(res => { + backend.put("/api/services", service).then((res) => { this.reset(); this.setState({serviceStatusCode: res.status}); this.loadServices(); - }).catch(res => { + }).catch((res) => { this.setState({serviceStatusCode: res.status, serviceResponse: JSON.stringify(res.json)}); }); } @@ -126,7 +126,7 @@ class ServicesPane extends Component { const isUpdate = this.state.isUpdate; const service = this.state.currentService; - let services = this.state.services.map(s => + let services = this.state.services.map((s) => <tr key={s.port} onClick={() => { this.reset(); this.setState({isUpdate: true, currentService: _.cloneDeep(s)}); diff --git a/frontend/src/components/panels/StreamsPane.js b/frontend/src/components/panels/StreamsPane.js index 1819fec..9470d7d 100644 --- a/frontend/src/components/panels/StreamsPane.js +++ b/frontend/src/components/panels/StreamsPane.js @@ -67,7 +67,7 @@ class StreamsPane extends Component { loadStream = (connectionId) => { this.setState({messages: [], currentId: connectionId}); backend.get(`/api/streams/${connectionId}?format=${this.state.format}`) - .then(res => this.setState({messages: res.json})); + .then((res) => this.setState({messages: res.json})); }; setFormat = (format) => { @@ -166,8 +166,8 @@ class StreamsPane extends Component { downloadStreamRaw = (value) => { if (this.state.currentId) { backend.download(`/api/streams/${this.props.connection.id}/download?format=${this.state.format}&type=${value}`) - .then(res => downloadBlob(res.blob, `${this.state.currentId}-${value}-${this.state.format}.txt`)) - .catch(_ => log.error("Failed to download stream messages")); + .then((res) => downloadBlob(res.blob, `${this.state.currentId}-${value}-${this.state.format}.txt`)) + .catch((_) => log.error("Failed to download stream messages")); } }; diff --git a/frontend/src/dispatcher.js b/frontend/src/dispatcher.js index ef5dbde..32f3f33 100644 --- a/frontend/src/dispatcher.js +++ b/frontend/src/dispatcher.js @@ -24,7 +24,7 @@ class Dispatcher { } dispatch = (topic, payload) => { - this.listeners.filter(l => l.topic === topic).forEach(l => l.callback(payload)); + this.listeners.filter((l) => l.topic === topic).forEach((l) => l.callback(payload)); }; register = (topic, callback) => { @@ -34,20 +34,20 @@ class Dispatcher { if (typeof topic === "string") { this.listeners.push({topic, callback}); } else if (typeof topic === "object" && Array.isArray(topic)) { - topic.forEach(e => { + topic.forEach((e) => { if (typeof e !== "string") { throw new Error("all topics must be strings"); } }); - topic.forEach(e => this.listeners.push({e, callback})); + topic.forEach((e) => this.listeners.push({e, callback})); } else { throw new Error("topic must be a string or an array of strings"); } }; unregister = (callback) => { - _.remove(this.listeners, l => l.callback === callback); + _.remove(this.listeners, (l) => l.callback === callback); }; } diff --git a/frontend/src/log.js b/frontend/src/log.js index 0afac47..9a75fbc 100644 --- a/frontend/src/log.js +++ b/frontend/src/log.js @@ -23,7 +23,7 @@ const log = { }; function isDevelopment() { - return !process.env.NODE_ENV || process.env.NODE_ENV === 'development'; + return !process.env.NODE_ENV || process.env.NODE_ENV === "development"; } export default log; |