aboutsummaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/js/actions/MenuActions.js4
-rw-r--r--src/web/js/actions/MiddlePanelActions.js3
-rw-r--r--src/web/js/components/MiddlePanel.react.js29
-rw-r--r--src/web/js/stores/MiddlePanelStore.js17
-rw-r--r--src/web/templates/home2.html2
-rw-r--r--src/web/templates/layout.html5
-rw-r--r--src/web/views/views.py3
7 files changed, 34 insertions, 29 deletions
diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js
index ce3a1030..f02ea5a0 100644
--- a/src/web/js/actions/MenuActions.js
+++ b/src/web/js/actions/MenuActions.js
@@ -1,11 +1,13 @@
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes;
+var jquery = require('jquery');
+
var MenuActions = {
// PARENT FILTERS
reload: function() {
- $.getJSON('/menu', function(payload) {
+ jquery.getJSON('/menu', function(payload) {
JarrDispatcher.dispatch({
type: MenuActionTypes.RELOAD_MENU,
categories: payload.categories,
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js
index 9877d0d5..42c18b58 100644
--- a/src/web/js/actions/MiddlePanelActions.js
+++ b/src/web/js/actions/MiddlePanelActions.js
@@ -1,10 +1,11 @@
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
var MiddlePanelActionTypes = require('../constants/JarrConstants').MiddlePanelActionTypes;
+var jquery = require('jquery');
var MiddlePanelActions = {
reload: function() {
- $.getJSON('/middle_panel', function(payload) {
+ jquery.getJSON('/middle_panel', function(payload) {
JarrDispatcher.dispatch({
type: MiddlePanelActionTypes.RELOAD_MIDDLE_PANEL,
articles: payload.articles,
diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js
index 51d582c0..c5a9c3f9 100644
--- a/src/web/js/components/MiddlePanel.react.js
+++ b/src/web/js/components/MiddlePanel.react.js
@@ -50,10 +50,8 @@ var TableLine = React.createClass({
});
var TableBody = React.createClass({
- propTypes: {articles: React.PropTypes.array.isRequired,
- },
getInitialState: function() {
- return {articles: this.props.articles,
+ return {articles: [],
};
},
render: function() {
@@ -73,19 +71,6 @@ var TableBody = React.createClass({
</table>
</div>
);
- }
-});
-
-var MiddlePanel = React.createClass({
- getInitialState: function() {
- return {articles: []};
- },
- render: function() {
- var body = null;
- if(this.state.articles.length) {
- body = (<TableBody articles={this.state.articles} />);
- }
- return (<div className="col-md-offset-2 col-md-10 main">{body}</div>);
},
componentDidMount: function() {
MiddlePanelActions.reload();
@@ -95,8 +80,16 @@ var MiddlePanel = React.createClass({
MiddlePanelStore.removeChangeListener(this._onChange);
},
_onChange: function() {
- var datas = MiddlePanelStore.getAll();
- this.setState({articles: datas.articles});
+ this.setState({articles: MiddlePanelStore.getArticles()});
+ },
+});
+
+var MiddlePanel = React.createClass({
+ render: function() {
+ return (<div className="col-md-offset-2 col-md-10 main">
+ <TableBody />
+ </div>
+ );
},
});
diff --git a/src/web/js/stores/MiddlePanelStore.js b/src/web/js/stores/MiddlePanelStore.js
index d5744e20..4e6e04c4 100644
--- a/src/web/js/stores/MiddlePanelStore.js
+++ b/src/web/js/stores/MiddlePanelStore.js
@@ -11,6 +11,21 @@ var MiddlePanelStore = assign({}, EventEmitter.prototype, {
getAll: function() {
return this._datas;
},
+ getArticles: function() {
+ var articles = [];
+ var key = null;
+ var id = null;
+ if (this._datas.parent_filter_type) {
+ key = this._datas.parent_filter_type + '_id';
+ id = this._datas.parent_filter_id;
+ }
+ this._datas.articles.map(function(article) {
+ if(!key || article[key] == id) {
+ articles.push(article);
+ }
+ });
+ return articles;
+ },
setFilter: function(value) {
if(this._datas.filter != value) {
this._datas.filter = value;
@@ -46,7 +61,7 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) {
// PARENT FILTER
case MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER:
MiddlePanelStore.setParentFilter(action.parent_type,
- action.filter_id);
+ action.parent_id);
break;
// FILTER
case MiddlePanelActionTypes.MIDDLE_PANEL_FILTER_ALL:
diff --git a/src/web/templates/home2.html b/src/web/templates/home2.html
index 54413b35..3e9d4a6f 100644
--- a/src/web/templates/home2.html
+++ b/src/web/templates/home2.html
@@ -1,8 +1,6 @@
{% extends "layout.html" %}
{% block content %}
<section id="jarrapp"></section>
-<script type="text/javascript" src="{{ url_for("static", filename="js/jquery.js") }}"></script>
-<script type="text/javascript" src="{{ url_for("static", filename="js/bootstrap.min.js") }}"></script>
<script type="text/javascript" src="{{ url_for("static", filename="js/bundle.min.js") }}"></script>
{% endblock %}
diff --git a/src/web/templates/layout.html b/src/web/templates/layout.html
index db5b6589..0b2f371d 100644
--- a/src/web/templates/layout.html
+++ b/src/web/templates/layout.html
@@ -140,10 +140,5 @@
</div>
{% block content %}{% endblock %}
-
- <!-- Bootstrap core JavaScript -->
- <!-- Placed at the end of the document so the pages load faster -->
- <script type="text/javascript" src="{{ url_for("static", filename="js/jquery.js") }}"></script>
- <script type="text/javascript" src="{{ url_for("static", filename="js/bootstrap.min.js") }}"></script>
</body>
</html>
diff --git a/src/web/views/views.py b/src/web/views/views.py
index b29ef645..ae3d9b01 100644
--- a/src/web/views/views.py
+++ b/src/web/views/views.py
@@ -263,9 +263,10 @@ def get_menu():
@login_required
def get_middle_panel():
fd_hash = {fd.id: fd for fd in FeedController(g.user.id).read()}
- articles = ArticleController(g.user.id).read(readed=False)
+ articles = ArticleController(g.user.id).read(readed=False).order_by('date')
return jsonify(**{'articles': [{'title': art.title, 'liked': art.like,
'read': art.readed, 'article_id': art.id,
+ 'feed_id': art.feed_id, 'category_id': art.category_id or 0,
'feed_title': fd_hash[art.feed_id].title,
'icon_url': url_for('icon.icon', url=fd_hash[art.feed_id].icon_url)
if fd_hash[art.feed_id].icon_url else None,
bgstack15