Add SSSD config

This commit is contained in:
Kyrylo Gliebov 2018-07-26 13:59:47 +02:00
parent a20e3c5a81
commit 471d2c160b
3 changed files with 127 additions and 7 deletions

View file

@ -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(<Config />, 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 (
<form onSubmit={this.handleSubmit}>
<table className="info-table-ct col-md-12">
<tbody>
<tr>
<td><label htmlFor="scope">Scope</label></td>
<td>
<select name="scope" id="scope" className="form-control"
value={this.state.config.session_recording.scope}
onChange={this.handleInputChange} >
<option value="none">None</option>
<option value="some">Some</option>
<option value="all">All</option>
</select>
</td>
</tr>
<tr>
<td><label htmlFor="users">Users</label></td>
<td>
<input type="text" id="users" name="users"
value={this.state.config.session_recording.users}
className="form-control" />
</td>
</tr>
<tr>
<td><label htmlFor="groups">Groups</label></td>
<td>
<input type="text" id="groups" name="groups"
value={this.state.config.session_recording.groups}
className="form-control" onChange={this.handleInputChange} />
</td>
</tr>
<tr>
<td>
</td>
<td>
<button className="btn btn-default" type="submit">Save</button>
</td>
</tr>
</tbody>
</table>
</form>
);
}
};
React.render(<Config />, document.getElementById('sr_config'));
React.render(<SssdConfig />, document.getElementById('sssd_config'));
}());