diff --git a/src/config.html b/src/config.html index b0c78c0..1184fbd 100644 --- a/src/config.html +++ b/src/config.html @@ -30,34 +30,8 @@ along with Cockpit; If not, see . -
-
-
-
- -
-
-
-
-
-
General Configuration
-
-
-
-
-
-
-
-
SSSD Configuration
-
-
-
-
-
- +
+ diff --git a/src/config.jsx b/src/config.jsx index e3fbc6a..1b83328 100644 --- a/src/config.jsx +++ b/src/config.jsx @@ -16,442 +16,313 @@ * You should have received a copy of the GNU Lesser General Public License * along with Cockpit; If not, see . */ +"use strict"; -(function() { - "use strict"; +let cockpit = require("cockpit"); +let React = require("react"); +let ReactDOM = require("react-dom"); +let json = require('comment-json'); +let ini = require('ini'); - let cockpit = require("cockpit"); - let React = require("react"); - let ReactDOM = require("react-dom"); - let json = require('comment-json'); - let ini = require('ini'); - - class Config extends React.Component { - constructor(props) { - super(props); - this.handleInputChange = this.handleInputChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - this.setConfig = this.setConfig.bind(this); - this.fileReadFailed = this.fileReadFailed.bind(this); - this.readConfig = this.readConfig.bind(this); - this.file = null; - this.config = null; - this.state = { - config_loaded: false, - file_error: false, - submitting: "none", - shell: "", - notice: "", - latency: "", - payload: "", - log_input: false, - log_output: true, - log_window: true, - limit_rate: "", - limit_burst: "", - limit_action: "", - file_path: "", - syslog_facility: "", - syslog_priority: "", - journal_augment: "", - journal_priority: "", - writer: "", - }; - } - - handleInputChange(e) { - const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; - const name = e.target.name; - const state = {}; - state[name] = value; - this.setState(state); - } - - handleSubmit(event) { - this.setState({submitting:"block"}); - let config = { - shell: this.state.shell, - notice: this.state.notice, - latency: parseInt(this.state.latency), - payload: parseInt(this.state.payload), - log: { - input: this.state.log_input, - output: this.state.log_output, - window: this.state.log_window, - }, - limit: { - rate: parseInt(this.state.limit_rate), - burst: parseInt(this.state.limit_burst), - action: this.state.limit_action, - }, - file: { - path: this.state.file_path, - }, - syslog: { - facility: this.state.syslog_facility, - priority: this.state.syslog_priority, - }, - journal: { - priority: this.state.journal_priority, - augment: this.state.journal_augment - }, - writer: this.state.writer - }; - this.file.replace(config).done(() => { - this.setState({submitting:"none"}); - }) - .fail((error) => { - console.log(error); - }); - event.preventDefault(); - } - - setConfig(data) { - delete data.configuration; - delete data.args; - var flattenObject = function(ob) { - var toReturn = {}; - - for (var i in ob) { - if (!ob.hasOwnProperty(i)) continue; - - if ((typeof ob[i]) == 'object') { - var flatObject = flattenObject(ob[i]); - for (var x in flatObject) { - if (!flatObject.hasOwnProperty(x)) continue; - - toReturn[i + '_' + x] = flatObject[x]; - } - } else { - toReturn[i] = ob[i]; - } - } - return toReturn; - }; - let state = flattenObject(data); - state.config_loaded = true; - this.setState(state); - } - - getConfig() { - let proc = cockpit.spawn(["tlog-rec-session", "--configuration"]); - - proc.stream((data) => { - this.setConfig(json.parse(data, null, true)); - proc.close(); - }); - - proc.fail((fail) => { - console.log(fail); - this.readConfig(); - }); - } - - readConfig() { - let parseFunc = function(data) { - return json.parse(data, null, true); - }; - - let stringifyFunc = function(data) { - return json.stringify(data, null, true); - }; - // needed for cockpit.file usage - let syntax_object = { - parse: parseFunc, - stringify: stringifyFunc, - }; - - this.file = cockpit.file("/etc/tlog/tlog-rec-session.conf", { - syntax: syntax_object, - superuser: true, - }); - /* - let promise = this.file.read(); - - promise.done((data) => { - if (data === null) { - this.fileReadFailed(); - } - }).fail((data) => { - this.fileReadFailed(data); - }); - */ - } - - fileReadFailed(reason) { - console.log(reason); - this.setState({file_error: reason}); - } - - componentWillMount() { - this.getConfig(); - this.readConfig(); - } - - render() { - if (this.state.config_loaded === false && this.state.file_error === false) { - return ( -
Loading
- ); - } else if (this.state.config_loaded === true && this.state.file_error === false) { - return ( -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- - -
- - - Saving... -
-
- ); - } else { - return ( -
- -

There is no configuration file of tlog present in your system.

-

Please, check the /etc/tlog/tlog-rec-session.conf or if tlog is installed.

-

{this.state.file_error}

-
- ); - } - } +class Config extends React.Component { + constructor(props) { + super(props); + this.handleInputChange = this.handleInputChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + this.setConfig = this.setConfig.bind(this); + this.fileReadFailed = this.fileReadFailed.bind(this); + this.readConfig = this.readConfig.bind(this); + this.file = null; + this.config = null; + this.state = { + config_loaded: false, + file_error: false, + submitting: "none", + shell: "", + notice: "", + latency: "", + payload: "", + log_input: false, + log_output: true, + log_window: true, + limit_rate: "", + limit_burst: "", + limit_action: "", + file_path: "", + syslog_facility: "", + syslog_priority: "", + journal_augment: "", + journal_priority: "", + writer: "", + }; } - class SssdConfig extends React.Component { - constructor(props) { - super(props); - this.handleSubmit = this.handleSubmit.bind(this); - this.handleInputChange = this.handleInputChange.bind(this); - this.setConfig = this.setConfig.bind(this); - this.file = null; - this.state = { - scope: "", - users: "", - groups: "", - submitting: "none", - }; - } + handleInputChange(e) { + const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; + const name = e.target.name; + const state = {}; + state[name] = value; + this.setState(state); + } - handleInputChange(e) { - const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; - const name = e.target.name; - const state = {}; - state[name] = value; - this.setState(state); - } + handleSubmit(event) { + this.setState({submitting:"block"}); + let config = { + shell: this.state.shell, + notice: this.state.notice, + latency: parseInt(this.state.latency), + payload: parseInt(this.state.payload), + log: { + input: this.state.log_input, + output: this.state.log_output, + window: this.state.log_window, + }, + limit: { + rate: parseInt(this.state.limit_rate), + burst: parseInt(this.state.limit_burst), + action: this.state.limit_action, + }, + file: { + path: this.state.file_path, + }, + syslog: { + facility: this.state.syslog_facility, + priority: this.state.syslog_priority, + }, + journal: { + priority: this.state.journal_priority, + augment: this.state.journal_augment + }, + writer: this.state.writer + }; + this.file.replace(config).done(() => { + this.setState({submitting:"none"}); + }) + .fail((error) => { + console.log(error); + }); + event.preventDefault(); + } - setConfig(data) { - console.log(data); - const config = {...data['session_recording']}; - this.setState(config); - } + setConfig(data) { + delete data.configuration; + delete data.args; + var flattenObject = function(ob) { + var toReturn = {}; - componentWillMount() { - let syntax_object = { - parse: ini.parse, - stringify: ini.stringify - }; + for (var i in ob) { + if (!ob.hasOwnProperty(i)) continue; - this.file = cockpit.file("/etc/sssd/conf.d/sssd-session-recording.conf", { - syntax: syntax_object, - superuser: true, - }); + if ((typeof ob[i]) == 'object') { + var flatObject = flattenObject(ob[i]); + for (var x in flatObject) { + if (!flatObject.hasOwnProperty(x)) continue; - let promise = this.file.read(); + toReturn[i + '_' + x] = flatObject[x]; + } + } else { + toReturn[i] = ob[i]; + } + } + return toReturn; + }; + let state = flattenObject(data); + state.config_loaded = true; + this.setState(state); + } - promise.done(this.setConfig); + getConfig() { + let proc = cockpit.spawn(["tlog-rec-session", "--configuration"]); - promise.fail(function(error) { - console.log(error); - }); - } + proc.stream((data) => { + this.setConfig(json.parse(data, null, true)); + proc.close(); + }); - handleSubmit(e) { - this.setState({submitting:"block"}); - const obj = {}; - obj.session_recording = {}; - obj.session_recording.scope = this.state.scope; - obj.session_recording.users = this.state.users; - obj.session_recording.groups = this.state.groups; + proc.fail((fail) => { + console.log(fail); + this.readConfig(); + }); + } - let _this = this; - this.file.replace(obj).done(function() { - _this.setState({submitting:"none"}); - }) - .fail(function(error) { - console.log(error); - }); - e.preventDefault(); - } + readConfig() { + let parseFunc = function(data) { + return json.parse(data, null, true); + }; - render() { + let stringifyFunc = function(data) { + return json.stringify(data, null, true); + }; + // needed for cockpit.file usage + let syntax_object = { + parse: parseFunc, + stringify: stringifyFunc, + }; + + this.file = cockpit.file("/etc/tlog/tlog-rec-session.conf", { + syntax: syntax_object, + superuser: true, + }); + /* + let promise = this.file.read(); + + promise.done((data) => { + if (data === null) { + this.fileReadFailed(); + } + }).fail((data) => { + this.fileReadFailed(data); + }); + */ + } + + fileReadFailed(reason) { + console.log(reason); + this.setState({file_error: reason}); + } + + componentWillMount() { + this.getConfig(); + this.readConfig(); + } + + render() { + if (this.state.config_loaded === false && this.state.file_error === false) { + return ( +
Loading
+ ); + } else if (this.state.config_loaded === true && this.state.file_error === false) { return (
- +
- + - - {this.state.scope === "some" && - - - - } - {this.state.scope === "some" && - + - } - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -460,9 +331,175 @@
- -
-
- +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ + Saving...
); + } else { + return ( +
+ +

There is no configuration file of tlog present in your system.

+

Please, check the /etc/tlog/tlog-rec-session.conf or if tlog is installed.

+

{this.state.file_error}

+
+ ); } } +} - ReactDOM.render(, document.getElementById('sr_config')); - ReactDOM.render(, document.getElementById('sssd_config')); -}()); +class SssdConfig extends React.Component { + constructor(props) { + super(props); + this.handleSubmit = this.handleSubmit.bind(this); + this.handleInputChange = this.handleInputChange.bind(this); + this.setConfig = this.setConfig.bind(this); + this.file = null; + this.state = { + scope: "", + users: "", + groups: "", + submitting: "none", + }; + } + + handleInputChange(e) { + const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; + const name = e.target.name; + const state = {}; + state[name] = value; + this.setState(state); + } + + setConfig(data) { + const config = {...data['session_recording']}; + this.setState(config); + } + + componentWillMount() { + let syntax_object = { + parse: ini.parse, + stringify: ini.stringify + }; + + this.file = cockpit.file("/etc/sssd/conf.d/sssd-session-recording.conf", { + syntax: syntax_object, + superuser: true, + }); + + let promise = this.file.read(); + + promise.done(this.setConfig); + + promise.fail(function(error) { + console.log(error); + }); + } + + handleSubmit(e) { + this.setState({submitting:"block"}); + const obj = {}; + obj.session_recording = {}; + obj.session_recording.scope = this.state.scope; + obj.session_recording.users = this.state.users; + obj.session_recording.groups = this.state.groups; + + let _this = this; + this.file.replace(obj).done(function() { + _this.setState({submitting:"none"}); + }) + .fail(function(error) { + console.log(error); + }); + e.preventDefault(); + } + + render() { + return ( +
+ + + + + + + {this.state.scope === "some" && + + + + + } + {this.state.scope === "some" && + + + + + } + + + + + +
+ +
+ +
+ +
+ Saving... +
+
+ ); + } +} + +class ConfigView extends React.Component { + render() { + const goBack = () => { + cockpit.jump(['session-recording']); + }; + + return ( +
+
+
+
    +
  1. Session + Recording
  2. +
  3. Configuration
  4. +
+
+
+
+
+
+
General Configuration
+
+ +
+
+
+
+
+
+
+
SSSD Configuration
+
+ +
+
+
+
+
+ ); + } +} + +ReactDOM.render(, document.getElementById('view')); diff --git a/src/index.html b/src/index.html index e23d550..0e49141 100644 --- a/src/index.html +++ b/src/index.html @@ -30,7 +30,7 @@ along with Cockpit; If not, see . -
+
diff --git a/src/recordings.jsx b/src/recordings.jsx index b995614..8ef6d63 100644 --- a/src/recordings.jsx +++ b/src/recordings.jsx @@ -605,6 +605,7 @@ class View extends React.Component { this.handleTsChange = this.handleTsChange.bind(this); this.handleLogTsChange = this.handleLogTsChange.bind(this); this.handleDateSinceChange = this.handleDateSinceChange.bind(this); + this.openConfig = this.openConfig.bind(this); /* Journalctl instance */ this.journalctl = null; /* Recording ID journalctl instance is invoked with */ @@ -831,6 +832,10 @@ class View extends React.Component { this.setState({logsTs: ts}); } + openConfig() { + cockpit.jump(['session-recording/config']); + } + componentDidMount() { let proc = cockpit.spawn(["getent", "passwd", "tlog"]); @@ -929,8 +934,7 @@ class View extends React.Component { - -