2017-05-17 23:21:02 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const React = require('react');
|
|
|
|
|
const AddAppDialog = require('../dialogs/AddAppDialog');
|
2017-05-22 12:34:27 +01:00
|
|
|
const AppTile = require('../elements/AppTile');
|
|
|
|
|
const Modal = require("../../../Modal");
|
2017-05-17 23:21:02 +01:00
|
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
|
displayName: 'AppsDrawer',
|
|
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
2017-05-22 12:34:27 +01:00
|
|
|
const as = this.state.apps;
|
|
|
|
|
as.push({
|
|
|
|
|
id: "bbcApp",
|
|
|
|
|
url: "http://news.bbc.co.uk",
|
|
|
|
|
name: "BBC News",
|
|
|
|
|
});
|
|
|
|
|
this.setState({apps: as});
|
2017-05-17 23:21:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
|
return {
|
2017-05-22 12:34:27 +01:00
|
|
|
apps: [{
|
|
|
|
|
id: "googleApp",
|
|
|
|
|
url: "http://matrix.org/grafana/dashboard/db/golang-metrics?panelId=2&fullscreen&edit&var-bucket_size=1m&var-job=riot-bot&var-handler=All&from=1495188444653&to=1495210044654",
|
|
|
|
|
name: "Google",
|
|
|
|
|
}],
|
2017-05-17 23:21:02 +01:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onClickAddWidget: function() {
|
2017-05-22 12:34:27 +01:00
|
|
|
Modal.createDialog(AddAppDialog, {
|
|
|
|
|
onFinished: (proceed, reason) => {
|
|
|
|
|
if (!proceed) return;
|
|
|
|
|
|
|
|
|
|
this.state.apps.push();
|
|
|
|
|
},
|
2017-05-17 23:21:02 +01:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
render: function() {
|
2017-05-22 12:34:27 +01:00
|
|
|
const apps = this.state.apps.map(
|
|
|
|
|
(app) => <AppTile key={app.id} url={app.url} name={app.name}/>);
|
|
|
|
|
|
2017-05-17 23:21:02 +01:00
|
|
|
return (
|
|
|
|
|
<div className="mx_AppsDrawer">
|
2017-05-22 12:34:27 +01:00
|
|
|
<div id="apps" className="mx_AppsContainer">
|
|
|
|
|
{apps}
|
|
|
|
|
</div>
|
|
|
|
|
<div onClick={this.onClickAddWidget}
|
|
|
|
|
role="button"
|
|
|
|
|
tabIndex="0"
|
|
|
|
|
className="mx_AddWidget_button"
|
|
|
|
|
title="Add a widget">
|
|
|
|
|
[+] Add a widget
|
|
|
|
|
</div>
|
2017-05-17 23:21:02 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
});
|