From 471d2c160b8ace4a36bc1eba8070a57628e717df Mon Sep 17 00:00:00 2001 From: Kyrylo Gliebov Date: Thu, 26 Jul 2018 13:59:47 +0200 Subject: [PATCH] Add SSSD config --- package.json | 1 + src/config.html | 18 +++++--- src/config.jsx | 115 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fbb9665..93b49da 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "term.js-cockpit": "0.0.10", "fs.extra": "^1.3.2", "fs.realpath": "^1.0.0", + "ini": "^1.3.5", "node-sass": "^4.9.0", "raw-loader": "^0.5.1" } diff --git a/src/config.html b/src/config.html index 757a1ee..8799839 100644 --- a/src/config.html +++ b/src/config.html @@ -32,7 +32,7 @@ along with Cockpit; If not, see .
-
+
-
-
-
Configuration
-
+
+
+
General Configuration
+
+
+
+
+
+
+
+
SSSD Configuration
+
diff --git a/src/config.jsx b/src/config.jsx index 0277128..ae02053 100644 --- a/src/config.jsx +++ b/src/config.jsx @@ -23,6 +23,7 @@ let cockpit = require("cockpit"); let React = require("react"); let json = require('comment-json'); + let ini = require('ini'); let Config = class extends React.Component { constructor(props) { @@ -273,7 +274,117 @@ ); } } - } + }; - React.render(, document.getElementById('view')); + let SssdConfig = class 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 = { + config: { + session_recording: { + scope: null, + users: null, + groups: null, + }, + }, + }; + } + + handleInputChange(e){ + const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; + const name = e.target.name; + const config = this.state.config; + config.session_recording[name] = value; + + this.forceUpdate(); + } + + setConfig(data) { + this.setState({config: data}); + } + + componentDidMount() { + 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() { + this.file.replace(this.state.config).done( function() { + console.log('updated'); + }) + .fail( function(error) { + console.log(error); + }); + event.preventDefault(); + } + + render() { + return ( +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + +
+
+ ); + } + }; + + React.render(, document.getElementById('sr_config')); + React.render(, document.getElementById('sssd_config')); }());