Add SSSD config
This commit is contained in:
parent
a20e3c5a81
commit
471d2c160b
3 changed files with 127 additions and 7 deletions
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
|||
<div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="/cockpit/@localhost/session_recording/index.html">Session Recording</a></li>
|
||||
<li class="active">Configuration</li>
|
||||
|
|
@ -40,10 +40,18 @@ along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><span>Configuration</span></div>
|
||||
<div class="panel-body" id="view"></div>
|
||||
<div class="panel-heading"><span>General Configuration</span></div>
|
||||
<div class="panel-body" id="sr_config"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><span>SSSD Configuration</span></div>
|
||||
<div class="panel-body" id="sssd_config"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
113
src/config.jsx
113
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 @@
|
|||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
React.render(<Config />, document.getElementById('view'));
|
||||
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'));
|
||||
}());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue