Clean up StarterKit view
And show the contents of `/etc/hostname` to make sure cockpit.js is loaded correctly.
This commit is contained in:
parent
ce7a2d3870
commit
8ff4b33bb5
2 changed files with 13 additions and 18 deletions
|
|
@ -18,18 +18,9 @@
|
||||||
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'cockpit';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StarterKit } from './starter-kit-view.jsx';
|
import { StarterKit } from './starter-kit.jsx';
|
||||||
|
|
||||||
function render() {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
React.render(
|
React.render(React.createElement(StarterKit, {}), document.getElementById('app'));
|
||||||
React.createElement(
|
});
|
||||||
StarterKit,
|
|
||||||
{title: "Sample Page"}
|
|
||||||
),
|
|
||||||
document.getElementById('app')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", render);
|
|
||||||
|
|
|
||||||
|
|
@ -17,21 +17,25 @@
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import 'cockpit';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export class StarterKit extends React.Component {
|
export class StarterKit extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
// a good place to initialize this.state
|
|
||||||
|
cockpit.file('/etc/hostname').read().done((content) => {
|
||||||
|
this.setState({ 'hostname': content.trim() });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let title = this.props.title?(<a href="#">{this.props.title}</a>):"Empty title";
|
|
||||||
return (
|
return (
|
||||||
<div class="container-fluid">
|
<div className="container-fluid">
|
||||||
<h3>{title}</h3>
|
<h2>Starter Kit</h2>
|
||||||
<div>
|
<div>
|
||||||
<span>Some content</span>
|
<span>Running on {this.state.hostname}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue