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/>.
|
||||
*/
|
||||
|
||||
import 'cockpit';
|
||||
import React from 'react';
|
||||
import { StarterKit } from './starter-kit-view.jsx';
|
||||
import { StarterKit } from './starter-kit.jsx';
|
||||
|
||||
function render() {
|
||||
React.render(
|
||||
React.createElement(
|
||||
StarterKit,
|
||||
{title: "Sample Page"}
|
||||
),
|
||||
document.getElementById('app')
|
||||
);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", render);
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
React.render(React.createElement(StarterKit, {}), document.getElementById('app'));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,21 +17,25 @@
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'cockpit';
|
||||
import React from 'react';
|
||||
|
||||
export class StarterKit extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
// a good place to initialize this.state
|
||||
|
||||
cockpit.file('/etc/hostname').read().done((content) => {
|
||||
this.setState({ 'hostname': content.trim() });
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
let title = this.props.title?(<a href="#">{this.props.title}</a>):"Empty title";
|
||||
return (
|
||||
<div class="container-fluid">
|
||||
<h3>{title}</h3>
|
||||
<div className="container-fluid">
|
||||
<h2>Starter Kit</h2>
|
||||
<div>
|
||||
<span>Some content</span>
|
||||
<span>Running on {this.state.hostname}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue