Skip to content

Commit

Permalink
SWIK-1958 added a service and a store
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaun committed Mar 8, 2018
1 parent 8c0ac0e commit 8570d7f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
17 changes: 14 additions & 3 deletions actions/user/userprofile/chooseAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import fetchUser from './fetchUser';
import { fetchUserDecks } from './fetchUserDecks';
import notFoundError from '../../error/notFoundError';
const log = require('../../log/clog');
import loadUserCollections from '../../collections/loadUserCollections';
import loadUserCollections from '../../collections/loadUserCollections';
// import loadUserRecommendations from '../../recommendations/loadUserRecommendations';
import loadUserPerformancePredictions from '../../analytics/loadUserPerformancePredictions';
import { shortTitle } from '../../../configs/general';
import UserProfileStore from '../../../stores/UserProfileStore';

export const categories = { //Do NOT alter the order of these items! Just add your items. Used in UserProfile and CategoryBox components
categories: ['settings', 'groups', 'collections'],
categories: ['settings', 'groups', 'collections', 'recommendations', 'analytics'],
settings: ['profile', 'account', 'integrations'],
groups: ['overview', 'edit']
groups: ['overview', 'edit'],
analytics: ['performanceprediction']
};

export function chooseAction(context, payload, done) {
Expand Down Expand Up @@ -71,6 +74,14 @@ export function chooseAction(context, payload, done) {
context.dispatch('USER_CATEGORY', {category: payload.params.category, item: payload.params.item});
context.executeAction(loadUserCollections, {}, callback);
break;
case categories.categories[3]:
context.dispatch('USER_CATEGORY', {category: payload.params.category, item: payload.params.item});
context.executeAction(loadUserRecommendations, {}, callback);
break;
case categories.categories[4]:
context.dispatch('USER_CATEGORY', {category: payload.params.category, item: payload.params.item});
context.executeAction(loadUserPerformancePredictions, {}, callback);
break;
case undefined:
context.executeAction(fetchUserDecks, {params: {username: payload.params.username}}, callback);
break;
Expand Down
6 changes: 4 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import MediaStore from './stores/MediaStore';
import UserReviewStore from './stores/UserReviewStore';
import DeckCollectionStore from './stores/DeckCollectionStore';
import SSOStore from './stores/SSOStore';
import UserPerformancePredictionsStore from './stores/UserPerformancePredictionsStore';

// create new fluxible instance & register all stores
const app = new Fluxible({
Expand Down Expand Up @@ -94,9 +95,10 @@ const app = new Fluxible({
ContentLikeStore,
DeckFamilyStore,
UserReviewStore,
MediaStore,
MediaStore,
DeckCollectionStore,
SSOStore
SSOStore,
UserPerformancePredictionsStore
]
});

Expand Down
2 changes: 1 addition & 1 deletion components/User/UserProfile/CategoryBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CategoryBox extends React.Component {
</div>
<NavLink className="item" href={'/user/' + this.props.username + '/analytics/performanceprediction'} activeStyle={this.styles}>
<p>
<i className="icon users"/>
<i className="icon chart bar"/>
<FormattedMessage
id='CategoryBox.myAnalytics'
defaultMessage=' My Analytics'
Expand Down
21 changes: 21 additions & 0 deletions components/User/UserProfile/UserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UserGroups from './UserGroups';
import UserGroupEdit from './UserGroupEdit';
import { connectToStores } from 'fluxible-addons-react';
import UserProfileStore from '../../../stores/UserProfileStore';
import UserPerformancePredictions from './UserAnalytics/UserPerformancePredictions';
import PrivatePublicUserProfile from './PrivatePublicUserProfile/PrivatePublicUserProfile';
import Integrations from './Integrations';
import { FormattedMessage, defineMessages } from 'react-intl';
Expand Down Expand Up @@ -111,6 +112,14 @@ class UserProfile extends React.Component {
default:
return this.notImplemented();
}});
case categories.categories[4]:
return this.addScaffold(() => {switch(this.props.UserProfileStore.categoryItem){
case categories.analytics[0]:
return this.displayPerformancePredictions();
break;
default:
return this.notImplemented();
}});
default:
return this.displayUserProfile();
};
Expand Down Expand Up @@ -221,6 +230,18 @@ class UserProfile extends React.Component {
return (<UserGroupEdit saveUsergroupError={this.props.UserProfileStore.saveUsergroupError} username={this.props.UserProfileStore.username} currentUsergroup={this.props.UserProfileStore.currentUsergroup} userid={this.props.UserProfileStore.userid} saveUsergroupIsLoading={this.props.UserProfileStore.saveUsergroupIsLoading} picture={this.props.UserProfileStore.user.picture} />);
}







displayPerformancePredictions() {
return (
<UserPerformancePredictions />
);
}

notImplemented() {
return (<h3>
<FormattedMessage
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fetchrPlugin.registerService(require('./services/media'));
fetchrPlugin.registerService(require('./services/userreview'));
fetchrPlugin.registerService(require('./services/nlp'));
fetchrPlugin.registerService(require('./services/deckgroups'));
fetchrPlugin.registerService(require('./services/analytics'));

// ************************** UI Internationalisation routines ***************************************

Expand Down

0 comments on commit 8570d7f

Please sign in to comment.