Skip to content

Commit

Permalink
Merge branch 'master' into SWIK-2103-Support-for-NV3D-charts-in-front…
Browse files Browse the repository at this point in the history
…-end
  • Loading branch information
kadevgraaf authored Oct 24, 2018
2 parents 0f7363b + e1b9814 commit 502fa9c
Show file tree
Hide file tree
Showing 415 changed files with 16,630 additions and 5,429 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ script:
- npm run build:nostart
after_success:
- git reset --hard && rm configs/microservices.js configs/general.js configs/secrets.js
- openssl aes-256-cbc -K $encrypted_ecdba13b2a41_key -iv $encrypted_ecdba13b2a41_iv -in deployment_keys.tar.enc -out deployment_keys.tar -d
- openssl aes-256-cbc -K $encrypted_188f43b2b0d2_key -iv $encrypted_188f43b2b0d2_iv -in deployment_keys.tar.enc -out deployment_keys.tar -d
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] ; then ./travis_scripts/dockerhub.sh ; fi
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] ; then ./travis_scripts/deploy.sh ; fi
- npm run coverall
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ ENV SERVICE_URL_DECK= \
SERVICE_URL_SIGNALING= \
SERVICE_URL_QUESTION= \
SERVICE_URL_NLP= \
SERVICE_LEARNINGLOCKER_API_URL= \
SERVICE_LEARNINGLOCKER_API_AUTH= \
SERVICE_USER_PRIVATE_RECAPTCHA_KEY= \
SERVICE_USER_PUBLIC_RECAPTCHA_KEY= \
SERVICE_USER_APIKEY= \
Expand Down
4 changes: 3 additions & 1 deletion actions/attachSubdeck/loadRecentDecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import methodNotAllowedError from '../error/methodNotAllowedError';

export default function loadRecentDecks(context,payload,done){
log.info(context);

context.dispatch('ATTACHSUBDECK_LOAD_RECENTDECKS_LOADING', []);

context.service.read('deck.recent', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {

Expand All @@ -20,7 +23,6 @@ export default function loadRecentDecks(context,payload,done){
context.dispatch('ATTACHSUBDECK_LOAD_RECENTDECKS', []);
}
} else { //Normal action

context.dispatch('ATTACHSUBDECK_LOAD_RECENTDECKS', res);
}
done();
Expand Down
12 changes: 10 additions & 2 deletions actions/attachSubdeck/loadSearchedDecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import log from '../log/clog';
import notFoundError from '../error/notFoundError';
import methodNotAllowedError from '../error/methodNotAllowedError';
import searchSyntaxError from '../error/searchSyntaxError';
import updateModalSubtitle from '../collections/updateModalSubtitle';

export default function loadSearchedDecks(context,payload,done){
log.info(context);

context.dispatch('ATTACHSUBDECK_LOAD_SEARCHDECKS_LOADING');
context.executeAction(updateModalSubtitle, 'Search Results');

payload.query.expand = false;
payload.query.spellcheck = false;
payload.query.pageSize = 50;
payload.query.facets = false;

context.service.read('searchresults.list', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {
if (err.statusCode === 404) {
Expand All @@ -27,8 +37,6 @@ export default function loadSearchedDecks(context,payload,done){
return;
}
} else { //Normal action

log.info(context,res);
context.dispatch('ATTACHSUBDECK_LOAD_SEARCHDECKS', res);
}

Expand Down
24 changes: 24 additions & 0 deletions actions/collections/addDeckToCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';
import UserProfileStore from '../../stores/UserProfileStore';

export default function addDeckToCollection(context, payload, done) {
log.info(context);

// enrich payload with jwt
payload.jwt = context.getStore(UserProfileStore).jwt;

// define operation
payload.op = 'add';

context.service.update('deckgroups.updateDecksOfCollection', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename, message: err.message});
context.dispatch('ADD_DECK_TO_COLLECTION_FAILURE', err);
} else {
context.dispatch('ADD_DECK_TO_COLLECTION_SUCCESS', payload.collection);
}

done();
});
}
24 changes: 21 additions & 3 deletions actions/collections/addNewCollection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';
import UserProfileStore from '../../stores/UserProfileStore';
import addDeckToCollection from './addDeckToCollection';

export default function addNewCollection(context, payload, done) {
log.info(context);
Expand All @@ -12,10 +13,27 @@ export default function addNewCollection(context, payload, done) {
if (err) {
log.error(context, {filepath: __filename});
context.dispatch('ADD_COLLECTION_FAILURE', err);
done();
} else {
context.dispatch('ADD_COLLECTION_SUCCESS', res);
}

done();
// also add new collection to a deck
if (payload.deckId) {
context.executeAction(addDeckToCollection, {
deckId: payload.deckId,
collection: res,
collectionId: res._id,
}).then( () => {
context.dispatch('ADD_COLLECTION_SUCCESS', res);
done();
}).catch( (err) => {
log.error(context, {filepath: __filename});
context.dispatch('ADD_COLLECTION_FAILURE', err);
done();
});
} else {
context.dispatch('ADD_COLLECTION_SUCCESS', res);
done();
}
}
});
}
8 changes: 0 additions & 8 deletions actions/collections/addSelectedCollection.js

This file was deleted.

10 changes: 9 additions & 1 deletion actions/collections/loadCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import serviceUnavailable from '../error/serviceUnavailable';
import notFoundError from '../error/notFoundError';
import loadCollectionDetails from './loadCollectionDetails';
import fetchUser from '../../actions/user/userprofile/fetchUser';
import getFollowing from '../../actions/following/getFollowing';
import UserProfileStore from '../../stores/UserProfileStore';

// loads deck collection details and user info
export default function loadCollection(context, payload, done) {
log.info(context);

// load required actions in parallel
async.parallel([
(callback) => {
Expand All @@ -21,6 +21,14 @@ export default function loadCollection(context, payload, done) {
},
(callback) => {
context.executeAction(loadCollectionDetails, payload, callback);
},
(callback) => {
const userId = context.getStore(UserProfileStore).getState().userid;
if (userId !== undefined && userId !== null && userId !== '') {
context.executeAction(getFollowing, {playlistId: payload.params.id, userId: userId, followed_type: 'playlist'}, callback);
} else {
callback();
}
}
], (err, results) => {
if (err) {
Expand Down
6 changes: 6 additions & 0 deletions actions/collections/loadCollectionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';
import UserProfileStore from '../../stores/UserProfileStore';
import notFoundError from '../error/notFoundError';
import { shortTitle } from '../../configs/general';

// loads a deck collection
export default function loadCollectionDetails(context, payload, done) {
Expand All @@ -22,6 +23,11 @@ export default function loadCollectionDetails(context, payload, done) {
} else {
res.sortBy = (payload.query.sort) ? payload.query.sort : 'order';
context.dispatch('LOAD_COLLECTION_DETAILS_SUCCESS', res);

let pageTitle = shortTitle + ' | Playlist | ' + res.title;
context.dispatch('UPDATE_PAGE_TITLE', {
pageTitle: pageTitle
});
}

done();
Expand Down
36 changes: 36 additions & 0 deletions actions/collections/loadCollectionsTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import async from 'async';
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';
import notFoundError from '../error/notFoundError';
import loadDeckCollections from './loadDeckCollections';
import loadUserCollections from './loadUserCollections';
import UserProfileStore from '../../stores/UserProfileStore';

// loads collection for a deck and the user collection options
export default function loadCollectionsTab(context, payload, done) {
log.info(context);

// load required actions in parallel
async.parallel([
(callback) => {
context.executeAction(loadDeckCollections, payload, callback);
},
(callback) => {
// if logged in, then request collections that the user has edit rights
if (context.getStore(UserProfileStore).userid) {
context.executeAction(loadUserCollections, payload, callback);
} else {
callback();
}
}
], (err, results) => {
if (err) {
log.error(context, {filepath: __filename});
context.executeAction(serviceUnavailable, payload, done);
return;
}

done();
});

}
51 changes: 18 additions & 33 deletions actions/collections/loadDeckCollections.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
const log = require('../log/clog');
import log from '../log/clog';
import serviceUnavailable from '../error/serviceUnavailable';
import UserProfileStore from '../../stores/UserProfileStore';

// loads deck groups assigned by the current user to a deck
// loads deck collections assigned to a deck
export default function loadDeckCollections(context, payload, done) {
log.info(context);

// enrich payload with user id
if(payload.params){
payload.params.userId = context.getStore(UserProfileStore).userid;
payload.params.jwt = context.getStore(UserProfileStore).jwt;
} else {
payload.userId = context.getStore(UserProfileStore).userid;
payload.jwt = context.getStore(UserProfileStore).jwt;
}

context.dispatch('UPDATE_COLLECTIONS_LOADING', true);
let args = (payload.params) ? payload.params : payload;
args.countOnly = false;

// first get user groups that the user is member of
context.service.read('usergroup.member', payload, {timeout: 20 * 1000}, (err, usergroups) => {
if(err){
log.error(context, {filepath: __filename});
done();
// then get deck collection options
context.service.read('deckgroups.forDeck', args, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename, message: err.message});
context.dispatch('LOAD_DECK_COLLECTIONS_FAILURE', err);
} else {

// then get deck collection options
payload.usergroups = usergroups;
context.service.read('deckgroups.forDeck', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename});
context.dispatch('LOAD_COLLECTIONS_FAILURE', err);
} else {
context.dispatch('LOAD_COLLECTIONS_SUCCESS', res);
}

context.dispatch('UPDATE_COLLECTIONS_LOADING', false);

done();
context.dispatch('LOAD_DECK_COLLECTIONS_SUCCESS', {
selector: payload.params,
collections: res
});
context.dispatch('LOAD_PLAYLISTS_COUNT', res.length);
context.dispatch('UPDATE_MODULE_TYPE_SUCCESS', { moduleType: 'playlists' });
}
});

done();
});

}
20 changes: 20 additions & 0 deletions actions/collections/loadGroupCollections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const log = require('../log/clog');

// loads user group collections
export default function loadGroupCollections(context, payload, done) {
log.info(context);

context.dispatch('SET_COLLECTIONS_LOADING'); // show loading indicator
let params = (payload.params) ? payload.params : payload;

context.service.read('deckgroups.forGroup', params, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename, message: err.message});
context.dispatch('LOAD_USER_COLLECTIONS_FAILURE', err);
} else {
context.dispatch('LOAD_USER_COLLECTIONS_SUCCESS', res);
}

done();
});
}
22 changes: 22 additions & 0 deletions actions/collections/loadPlaylistsCount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import log from '../log/clog';
import serviceUnavailable from '../error/serviceUnavailable';

// loads count of deck collections assigned to a deck
export default function loadPlaylistsCount(context, payload, done) {
log.info(context);

let args = (payload.params) ? payload.params : payload;
args.countOnly = true;

context.service.read('deckgroups.forDeck', args, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename, message: err.message});
context.dispatch('LOAD_PLAYLISTS_COUNT_FAILURE', err);
} else {
context.dispatch('LOAD_PLAYLISTS_COUNT', res);
}

done();
});

}
Loading

0 comments on commit 502fa9c

Please sign in to comment.