From a881023f128f0a0903cb46e298115083b4c427f9 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 2 Mar 2016 07:30:51 +0100 Subject: minor update to the navbar --- src/web/js/components/Navbar.react.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/web/js') diff --git a/src/web/js/components/Navbar.react.js b/src/web/js/components/Navbar.react.js index 08716977..a5dedcf9 100644 --- a/src/web/js/components/Navbar.react.js +++ b/src/web/js/components/Navbar.react.js @@ -70,7 +70,7 @@ JarrNavBar = React.createClass({ this.setState({showModal: true, modalType: 'addCategory'}); }, render: function() { - return ( + return ( {this.getModal()} @@ -78,6 +78,7 @@ JarrNavBar = React.createClass({ + + ); }, -- cgit From b32ca6c0f5968f5e9f59847db5012e3ef7f98631 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 2 Mar 2016 08:25:52 +0100 Subject: Code update. Some problems with CSRF token on Chromium... --- src/web/js/actions/RightPanelActions.js | 8 ++++++-- src/web/js/components/MainApp.react.js | 2 +- src/web/js/components/Menu.react.js | 8 +++++--- src/web/js/components/MiddlePanel.react.js | 8 ++------ src/web/js/components/RightPanel.react.js | 30 ++++++++++++++++++++++++------ src/web/js/stores/MenuStore.js | 6 ++++++ 6 files changed, 44 insertions(+), 18 deletions(-) (limited to 'src/web/js') diff --git a/src/web/js/actions/RightPanelActions.js b/src/web/js/actions/RightPanelActions.js index 47adad79..5d78e001 100644 --- a/src/web/js/actions/RightPanelActions.js +++ b/src/web/js/actions/RightPanelActions.js @@ -4,8 +4,12 @@ var ActionTypes = require('../constants/JarrConstants'); var MenuActions = require('../actions/MenuActions'); var RightPanelActions = { - loadArticle: function(article_id, was_read_before) { - jquery.getJSON('/getart/' + article_id, + loadArticle: function(article_id, was_read_before, to_parse) { + var suffix = ''; + if(to_parse) { + suffix = '/parse'; + } + jquery.getJSON('/getart/' + article_id + suffix, function(payload) { JarrDispatcher.dispatch({ type: ActionTypes.LOAD_ARTICLE, diff --git a/src/web/js/components/MainApp.react.js b/src/web/js/components/MainApp.react.js index cbdc5833..ffb14589 100644 --- a/src/web/js/components/MainApp.react.js +++ b/src/web/js/components/MainApp.react.js @@ -15,7 +15,7 @@ var MainApp = React.createClass({ + xs={12} sm={4} md={4} lg={4}> diff --git a/src/web/js/components/Menu.react.js b/src/web/js/components/Menu.react.js index 60578f8a..f4ad76d0 100644 --- a/src/web/js/components/Menu.react.js +++ b/src/web/js/components/Menu.react.js @@ -84,13 +84,15 @@ var CategoryGroup = React.createClass({ name: React.PropTypes.string.isRequired, feeds: React.PropTypes.array.isRequired, unread: React.PropTypes.number.isRequired, - folded: React.PropTypes.bool.isRequired, + folded: React.PropTypes.bool, }, getInitialState: function() { - return {folded: this.props.folded}; + return {folded: false}; }, componentWillReceiveProps: function(nextProps) { - this.setState({folded: nextProps.folded}); + if(nextProps.folded != null) { + this.setState({folded: nextProps.folded}); + } }, render: function() { // hidden the no category if empty diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js index dad33acc..cb5be92d 100644 --- a/src/web/js/components/MiddlePanel.react.js +++ b/src/web/js/components/MiddlePanel.react.js @@ -35,7 +35,7 @@ var TableLine = React.createClass({ icon = ; } var title = ( + onClick={this.openRedirectLink} target="_blank"> {icon} {this.props.feed_title} ); var read = (); icon = ; - var newTab = ( - {icon} - ); var clsses = "list-group-item"; if(this.props.selected) { clsses += " active"; @@ -57,7 +53,7 @@ var TableLine = React.createClass({
{title}
-
{read} {liked} {newTab} {this.props.title}
+
{read} {liked} {this.props.title}
); }, diff --git a/src/web/js/components/RightPanel.react.js b/src/web/js/components/RightPanel.react.js index 39b06f38..6005e954 100644 --- a/src/web/js/components/RightPanel.react.js +++ b/src/web/js/components/RightPanel.react.js @@ -35,6 +35,7 @@ var PanelMixin = { ); } btn_grp = ( + {this.getExtraButton()} {edit_button} {rem_button} ); @@ -169,13 +170,28 @@ var Article = React.createClass({ ], obj_type: 'article', getTitle: function() {return this.props.obj.title;}, + getExtraButton: function() { + if(!this.props.obj.readability_available) { + return null; + } + return (); + }, getBody: function() { return (
{this.getCore()} -
); }, + reloadParsed: function() { + if(this.props.obj.readability_available + && !this.props.obj.readability_parsed) { + RightPanelActions.loadArticle(this.props.obj.id, true, true); + } + }, }); var Feed = React.createClass({ @@ -188,10 +204,13 @@ var Feed = React.createClass({ {'title': 'Feed link', 'type': 'link', 'key': 'link'}, {'title': 'Site link', 'type': 'link', 'key': 'site_link'}, {'title': 'Enabled', 'type': 'bool', 'key': 'enabled'}, + {'title': 'Auto Readability', + 'type': 'bool', 'key': 'readability_auto_parse'}, {'title': 'Filters', 'type': 'ignore', 'key': 'filters'}, {'title': 'Category', 'type': 'ignore', 'key': 'category_id'}, ], getTitle: function() {return this.props.obj.title;}, + getExtraButton: function() {return null;}, getFilterRow: function(i, filter) { return (
@@ -317,8 +336,6 @@ var Feed = React.createClass({
-
Number of articles
-
{this.props.obj.nb_articles}
{this.getErrorFields()} {this.getCategorySelect()} @@ -353,6 +370,7 @@ var Category = React.createClass({ if(this.props.obj.id != 0) {return true;} else {return false;} }, + getExtraButton: function () {return null;}, isRemovable: function() {return this.isEditable();}, obj_type: 'category', fields: [{'title': 'Category name', 'type': 'string', 'key': 'name'}], @@ -423,9 +441,9 @@ var RightPanel = React.createClass({ key={this.state.category.id} />); } - return ( + return ( {breadcrum} {cntnt} diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index 49c61bc1..9686ff4a 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -17,6 +17,7 @@ var MenuStore = assign({}, EventEmitter.prototype, { setFilter: function(value) { if(this._datas.filter != value) { this._datas.filter = value; + this._datas.all_folded = null; this.emitChange(); } }, @@ -24,6 +25,7 @@ var MenuStore = assign({}, EventEmitter.prototype, { if(this._datas.active_id != value || this._datas.active_type != type) { this._datas.active_type = type; this._datas.active_id = value; + this._datas.all_folded = null; this.emitChange(); } }, @@ -53,6 +55,7 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas['error_threshold'] = action.error_threshold; MenuStore._datas['crawling_method'] = action.crawling_method; MenuStore._datas['all_unread_count'] = action.all_unread_count; + MenuStore._datas.all_folded = null; MenuStore.emitChange(); break; case ActionTypes.PARENT_FILTER: @@ -81,6 +84,7 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas.categories[cat_id].unread += new_unread[feed_id]; } if(changed) { + MenuStore._datas.all_folded = null; MenuStore.emitChange(); } } @@ -98,12 +102,14 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas.categories[article.category_id].unread += val; MenuStore._datas.feeds[article.feed_id].unread += val; }); + MenuStore._datas.all_folded = null; MenuStore.emitChange(); break; case ActionTypes.LOAD_ARTICLE: if(!action.was_read_before) { MenuStore._datas.categories[action.article.category_id].unread -= 1; MenuStore._datas.feeds[action.article.feed_id].unread -= 1; + MenuStore._datas.all_folded = null; MenuStore.emitChange(); } break; -- cgit From 49d7ed4f2bd61504ff77f8dd5e78df2a2ec42f83 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 22 Mar 2016 13:36:08 +0100 Subject: Removed extra info fo rreadability. --- src/web/js/components/RightPanel.react.js | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/web/js') diff --git a/src/web/js/components/RightPanel.react.js b/src/web/js/components/RightPanel.react.js index 6005e954..275bcfb3 100644 --- a/src/web/js/components/RightPanel.react.js +++ b/src/web/js/components/RightPanel.react.js @@ -35,7 +35,6 @@ var PanelMixin = { ); } btn_grp = ( - {this.getExtraButton()} {edit_button} {rem_button} ); @@ -170,15 +169,6 @@ var Article = React.createClass({ ], obj_type: 'article', getTitle: function() {return this.props.obj.title;}, - getExtraButton: function() { - if(!this.props.obj.readability_available) { - return null; - } - return (); - }, getBody: function() { return (
{this.getCore()} @@ -204,13 +194,10 @@ var Feed = React.createClass({ {'title': 'Feed link', 'type': 'link', 'key': 'link'}, {'title': 'Site link', 'type': 'link', 'key': 'site_link'}, {'title': 'Enabled', 'type': 'bool', 'key': 'enabled'}, - {'title': 'Auto Readability', - 'type': 'bool', 'key': 'readability_auto_parse'}, {'title': 'Filters', 'type': 'ignore', 'key': 'filters'}, {'title': 'Category', 'type': 'ignore', 'key': 'category_id'}, ], getTitle: function() {return this.props.obj.title;}, - getExtraButton: function() {return null;}, getFilterRow: function(i, filter) { return (
@@ -370,7 +357,6 @@ var Category = React.createClass({ if(this.props.obj.id != 0) {return true;} else {return false;} }, - getExtraButton: function () {return null;}, isRemovable: function() {return this.isEditable();}, obj_type: 'category', fields: [{'title': 'Category name', 'type': 'string', 'key': 'name'}], -- cgit From 3d199ce8955c035a5a1bc4569058e2f84ef9cfe0 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 22 Mar 2016 14:30:54 +0100 Subject: fixes --- src/web/js/actions/MenuActions.js | 5 +++- src/web/js/actions/MiddlePanelActions.js | 5 +--- src/web/js/components/Menu.react.js | 17 ++++++++++- src/web/js/components/MiddlePanel.react.js | 8 ++++-- src/web/js/components/RightPanel.react.js | 11 +++---- src/web/js/constants/JarrConstants.js | 22 ++++---------- src/web/js/stores/MenuStore.js | 19 +++++++++--- src/web/js/stores/MiddlePanelStore.js | 46 +++++++++++++----------------- 8 files changed, 72 insertions(+), 61 deletions(-) (limited to 'src/web/js') diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js index b9154581..824610d8 100644 --- a/src/web/js/actions/MenuActions.js +++ b/src/web/js/actions/MenuActions.js @@ -5,7 +5,7 @@ var jquery = require('jquery'); var MenuActions = { // PARENT FILTERS - reload: function() { + reload: function(setFilterFunc, id) { jquery.getJSON('/menu', function(payload) { JarrDispatcher.dispatch({ type: ActionTypes.RELOAD_MENU, @@ -18,6 +18,9 @@ var MenuActions = { crawling_method: payload.crawling_method, all_unread_count: payload.all_unread_count, }); + if(setFilterFunc && id) { + setFilterFunc(id); + } }); }, setFilter: function(filter) { diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js index f805b7b1..efae516a 100644 --- a/src/web/js/actions/MiddlePanelActions.js +++ b/src/web/js/actions/MiddlePanelActions.js @@ -141,10 +141,7 @@ var MiddlePanelActions = { url: "/mark_all_as_read", success: function (payload) { JarrDispatcher.dispatch({ - type: ActionTypes.CHANGE_ATTR, - attribute: 'read', - value_num: -1, - value_bool: true, + type: ActionTypes.MARK_ALL_AS_READ, articles: payload.articles, }); }, diff --git a/src/web/js/components/Menu.react.js b/src/web/js/components/Menu.react.js index f4ad76d0..4537ee81 100644 --- a/src/web/js/components/Menu.react.js +++ b/src/web/js/components/Menu.react.js @@ -267,7 +267,22 @@ var Menu = React.createClass({ ); }, componentDidMount: function() { - MenuActions.reload(); + var setFilterFunc = null; + var id = null; + if(window.location.search.substring(1)) { + var args = window.location.search.substring(1).split('&'); + args.map(function(arg) { + if (arg.split('=')[0] == 'at' && arg.split('=')[1] == 'c') { + setFilterFunc = MiddlePanelActions.setCategoryFilter; + } else if (arg.split('=')[0] == 'at' && arg.split('=')[1] == 'f') { + setFilterFunc = MiddlePanelActions.setFeedFilter; + + } else if (arg.split('=')[0] == 'ai') { + id = parseInt(arg.split('=')[1]); + } + }); + } + MenuActions.reload(setFilterFunc, id); MenuStore.addChangeListener(this._onChange); }, componentWillUnmount: function() { diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js index cb5be92d..561802aa 100644 --- a/src/web/js/components/MiddlePanel.react.js +++ b/src/web/js/components/MiddlePanel.react.js @@ -77,7 +77,7 @@ var TableLine = React.createClass({ evnt.stopPropagation(); }, loadArticle: function() { - this.setState({active: true, read: true}, function() { + this.setState({selected: true, read: true}, function() { RightPanelActions.loadArticle( this.props.article_id, this.props.read); }.bind(this)); @@ -228,7 +228,11 @@ var MiddlePanel = React.createClass({ return (
{this.state.articles.map(function(article){ - return (); } btn_grp = ( + {this.getExtraButton()} {edit_button} {rem_button} ); @@ -175,13 +176,7 @@ var Article = React.createClass({
); - }, - reloadParsed: function() { - if(this.props.obj.readability_available - && !this.props.obj.readability_parsed) { - RightPanelActions.loadArticle(this.props.obj.id, true, true); - } - }, + } }); var Feed = React.createClass({ @@ -198,6 +193,7 @@ var Feed = React.createClass({ {'title': 'Category', 'type': 'ignore', 'key': 'category_id'}, ], getTitle: function() {return this.props.obj.title;}, + getExtraButton: function() {return null;}, getFilterRow: function(i, filter) { return (
@@ -357,6 +353,7 @@ var Category = React.createClass({ if(this.props.obj.id != 0) {return true;} else {return false;} }, + getExtraButton: function () {return null;}, isRemovable: function() {return this.isEditable();}, obj_type: 'category', fields: [{'title': 'Category name', 'type': 'string', 'key': 'name'}], diff --git a/src/web/js/constants/JarrConstants.js b/src/web/js/constants/JarrConstants.js index 0ea42aad..78e8bf04 100644 --- a/src/web/js/constants/JarrConstants.js +++ b/src/web/js/constants/JarrConstants.js @@ -1,23 +1,13 @@ -/* - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * TodoConstants - */ - var keyMirror = require('keymirror'); module.exports = keyMirror({ TOGGLE_MENU_FOLD: null, RELOAD_MENU: null, - PARENT_FILTER: null, - MENU_FILTER: null, - CHANGE_ATTR: null, + PARENT_FILTER: null, // set a feed or a category as filter in menu + MENU_FILTER: null, // change displayed feed in the menu + CHANGE_ATTR: null, // edit an attr on an article (like / read) RELOAD_MIDDLE_PANEL: null, - MIDDLE_PANEL_FILTER: null, - LOAD_ARTICLE: null, + MIDDLE_PANEL_FILTER: null, // set a filter (read/like/all) + LOAD_ARTICLE: null, // load a single article in right panel + MARK_ALL_AS_READ: null, }); diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index 9686ff4a..1cbbbda7 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -29,9 +29,6 @@ var MenuStore = assign({}, EventEmitter.prototype, { this.emitChange(); } }, - readFeedArticle: function(feed_id) { - // TODO - }, emitChange: function() { this.emit(CHANGE_EVENT); }, @@ -88,7 +85,6 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore.emitChange(); } } - break; case ActionTypes.MENU_FILTER: MenuStore.setFilter(action.filter); @@ -116,6 +112,21 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { case ActionTypes.TOGGLE_MENU_FOLD: MenuStore._datas.all_folded = action.all_folded; MenuStore.emitChange(); + break; + case ActionTypes.MARK_ALL_AS_READ: + action.articles.map(function(art) { + if(!art.read) { + MenuStore._datas.feeds[art.feed_id].unread -= 1; + if(art.category_id) { + MenuStore._datas.categories[art.category_id].unread -= 1; + + } + } + }); + + MenuStore._datas.all_folded = null; + MenuStore.emitChange(); + break; default: // do nothing } diff --git a/src/web/js/stores/MiddlePanelStore.js b/src/web/js/stores/MiddlePanelStore.js index 4a5efd00..c554f929 100644 --- a/src/web/js/stores/MiddlePanelStore.js +++ b/src/web/js/stores/MiddlePanelStore.js @@ -82,20 +82,18 @@ var MiddlePanelStore = assign({}, EventEmitter.prototype, { MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) { var changed = false; - switch(action.type) { - case ActionTypes.RELOAD_MIDDLE_PANEL: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.PARENT_FILTER: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.MIDDLE_PANEL_FILTER: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.CHANGE_ATTR: + if (action.type == ActionTypes.RELOAD_MIDDLE_PANEL + || action.type == ActionTypes.PARENT_FILTER + || action.type == ActionTypes.MIDDLE_PANEL_FILTER) { + changed = MiddlePanelStore.registerFilter(action); + changed = MiddlePanelStore.setArticles(action.articles) || changed; + } else if (action.type == ActionTypes.MARK_ALL_AS_READ) { + changed = MiddlePanelStore.registerFilter(action); + for(var i in action.articles) { + action.articles[i].read = true; + } + changed = MiddlePanelStore.setArticles(action.articles) || changed; + } else if (action.type == ActionTypes.CHANGE_ATTR) { var attr = action.attribute; var val = action.value_bool; action.articles.map(function(article) { @@ -112,19 +110,15 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) { } } }); - break; - case ActionTypes.LOAD_ARTICLE: - changed = true; - MiddlePanelStore._datas.selected_article = action.article.id; - for (var i in MiddlePanelStore._datas.articles) { - if(MiddlePanelStore._datas.articles[i].article_id == action.article.id) { - MiddlePanelStore._datas.articles[i].read = true; - break; - } + } else if (action.type == ActionTypes.LOAD_ARTICLE) { + changed = true; + MiddlePanelStore._datas.selected_article = action.article.id; + for (var i in MiddlePanelStore._datas.articles) { + if(MiddlePanelStore._datas.articles[i].article_id == action.article.id) { + MiddlePanelStore._datas.articles[i].read = true; + break; } - break; - default: - // pass + } } if(changed) {MiddlePanelStore.emitChange();} }); -- cgit