-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSoC 2015 - 2214 Dashboard as main page #434
Conversation
In this commit, added a new module for dashboard. Landing page of fauxton changed into the dashboard page Closes COUCHDB-2214
This commit added a widget to the dashboard to show the summary of active tasks in the system Closes COUCHDB-2214
please remove the space around the |
}); | ||
|
||
return Resources; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need that file
looks really really good! added some notes... |
In this commit, fixed the auto updating issue of active task table and create actions and stores for dashboard module. Closes COUCHDB-2214
@robertkowalski I did the changes you and @michellephung suggested. |
return { | ||
collection: activeTaskList.getCollection(), | ||
|
||
setPolling: activeTaskList.setPolling, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. @robertkowalski, I thought the pattern was to use action to update the store and rely entirely on listening to the store changes to get the changes into the component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes @benkeen you describe the way to go, this has to be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benkeen @robertkowalski
Can you explain little bit more about this? I just follow the implementation of ActiveTaskWidget. So I am not clear about what you are suggesting. If you can, it will be very helpful specially for future works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Sorry for the wait in responding. This'll take a bit of explanation, so sorry for the long message.
One of the ideas in the flux pattern (which we use in Fauxton) is to have one-way communication as shown in the diagram here. Information flows one-way, like so:
- User clicks on something in a React component,
- the component fires an action (in an
actions.js
file), - the action dispatches an event (for us, that's the
FauxtonAPI.dispatch()
call), - stores listen to these events (in their
dispatch()
methods), change the content of the store, then notify anyone that's interested that the store has changed. - finally, it comes full circle. React components listen for changes in the store by listening to their change events. That's the purpose of the
storeName.on('change', this.onChange)
lines.
You're already doing this in your DashboardController
component, just not for every item in its state.
So why do all this. The benefit is that it standardizes how data moves around the application, and keeps things simple - regardless of how much bigger the application gets. This is pretty cool.
Here's a simple example: imagine if a user shrunk/expanded the main sidebar, and multiple components in the page needed to know about it to make use of the new space. Maybe one was a graph and needed to redraw for the extra space, and maybe another component could switch from "basic" to "advanced" view or something.
With flux, you can just publish the single event, then each store could listen for it, change whatever data was needed internally, then notify any components that was listening: and they would then have the choice to rerender or not, based on what changed. This is basic "pub/sub": allowing you to keep code loosely coupled, but still communicate. By setting content on the store directly like you're doing here, it ties the component to the individual store and blocks out any other stores which may be interested in the event down the road. Now true, that may be unimportant in certain cases, but by doing it consistently everywhere, it makes the whole application super, super easy to follow (albeit a bit verbose at times!).
So what you need to do is replace the this.state.setPolling();
and this.state.clearPolling();
lines with Actions.setPolling()
and Actions.clearPolling()
methods (and include your actions.js file in your components.react.jsx
file as a dependency). In the actions.js
file, add those methods, which just dispatch two new event - just like you're already doing there - defined in your actiontypes.js file. Then update the store's dispatch()
method to listen to them, and do a this.triggerChange();
. Lastly you can remove setPolling
and clearPolling
from your component's getStoreState()
method.
It feels a bit weird at first adding in all this extra code for something that works already, but it'll be better down the road!
Let me know if I'm not clear on anything. I probably didn't do great justice to the Flux pattern, but that's the gist of it. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benkeen
Thank you very much for your detailed explanation. Now I am clear about how flux works and how we should apply it in the project :)
@wadsashika, this looks terrific! Sorry for all my nit-picky comments above. Luckily I'm in a different country so can't hurl your coffee mug at me. |
@benkeen I think it would be my phone :D anyway thank you very much for the comments. It really helps to get a better idea of the code. When I read some comments, I wonder that some mistakes you pointed out are already in the code. Because when I implement this, I referred activeTask module. In my first commit, I directly used active task store to get the list of active tasks. But later I took those functions to a separate store in dashboard as a suggestion made by @michellephung . I'll do the changes you pointed out and push those changes. |
hmm wait a sec... why are we copy pasting that code over and are not reusing the code? |
@wadsashika you can include the 'Active Tasks Store' in your 'Active Tasks Widgets Store', to get access to the functions. Active Tasks Store <-- active tasks functions only I'm thinking eventually you will have several 'X Widget Stores', which will include (require) the stores from their respective addons, and you will write your widget-specific functions in those. For example, you might have a 'most recent databases widget', which would have it's own store file, and that 'most recent database widget store' would have custom functions that you write that are only for the widget. Another option, would be for you to write your custom widget functions directly into each of the add-ons stores, and then call the functions from your dashboard jsx file. @benkeen @robertkowalski. is one option better than another here? I thought having the widgets each having their own stores would mean that they'd be easier to debug, and later customize or extend. |
@wadsashika that's a fair point. But I wouldn't worry: I don't think any of the points I make above are actual bugs, just stylistic. And none are particularly egregious, I'm just giving you a hard time because you're new and hey, that's my job here. ;) Internally, we mix and match who reviews who's code, and everyone has their own viewpoints. That's the awesome part about code reviews: you always get feedback that you won't have thought of, and everyone's different. So you're right, some of these things are already in the code but I wouldn't worry too much about it. We work as a group. And of course: you're always welcome to disagree! If Michelle or Robert were here in Vancouver, I'm pretty sure I'd have demanded settling an argument by an arm wrestle or something. @michellephung, @robertkowalski that's a fair point Robert. But yeah I'm not averse keeping the widget separate for the moment. Once it's a little more settled we could look at extracting shared code if there are big chunks. The parts I looked at looked like just pieces here and there, which isn't so bad. |
In this commit fixed the stylistic issues suggested Closes COUCHDB-2214
ACTIVE_TASKS_CLEAR_POLLING: 'ACTIVE_TASKS_CLEAR_POLLING', | ||
ACTIVE_TASKS_GET_DOC_COUNT: 'ACTIVE_TASKS_GET_DOC_COUNT' | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename all of these
hi @wadsashika try looking here: this is where from the 'All Databases' page, the column is getting the number of docs in each database from, |
Renamed functions and ActionTypes in dashboard Closes COUCHDB-2214
Hi, There are some gaps I left open in the PR, that you should watch out for:
|
Hi @michellephung, |
source and target total docs
In here we calculate the progress of replication using checkpointed_source_seq and source_seq Closes COUCHDB-2214
Active tasks will move left and right when click next button and previous button Closes COUCHDB-2214
Implemented test cases for active tasks widget new design Closes COUCHDB-2214
Hey! The left/right arrows look great! I love the animation and that scrolling also works. more things (sorry!) to fix:
instead of re-adding app/addons/dashboard/tests/fakeActiveTaskResponseForWidget.js, you can include the fake-data file from the activetasks folder. Tests look like a good start, but you should write tests for each function you create, and make sure the function does what it's supposed to do. (you can do this by passing it some data, and then asserting the results). The travis tests (the red X next to your commit) wont pass until it reaches the all_dbs pages on default. Lets put on hold the dashboard being the default page on initialization, until we can re-write the nightwatch tests, or think of an alternative. Good work this week :D |
you can add this line: |
something like this: |
Added non-continuous tag, show full database url if it is a remote database and rounded the progress to two decimal places Closes COUCHDB-2214
Renamed the existing files and added new files Closes COUCHDB-2214
added more padding to database names lines in active tasks box and fixed calculating the progress error in 1.6 Closes COUCHDB-2214
Closes COUCHDB-2214
Ayola Jayamaha on dev@couchdb.apache.org replies: I would like to contribute to this project as time permits. Hope you would Thank you in advance! |
Abandoned issue. Closing here. |
JIRA Ticket - https://issues.apache.org/jira/browse/COUCHDB-2214
Added a widget that shows active tasks to the dashboard. In here I reused functions in Active task module. I did not implement test cases yet.