Skip to content

Commit

Permalink
Merge branch 'master' into SWIK-906-robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
abijames authored Dec 5, 2018
2 parents 636ccf9 + 15a1eb3 commit 7324220
Show file tree
Hide file tree
Showing 35 changed files with 1,453 additions and 32 deletions.
33 changes: 33 additions & 0 deletions actions/slide/addLTI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import UserProfileStore from '../../stores/UserProfileStore';
import {shortTitle} from '../../configs/general';
import striptags from 'striptags';
import TreeUtil from '../../components/Deck/TreePanel/util/TreeUtil';
const log = require('../log/clog');
import addActivity from '../activityfeed/addActivity';
import {navigateAction} from 'fluxible-router';
import Util from '../../components/common/Util';

export default function addLTI(context, payload, done) {
//log.info(context);
//console.log('actions/slide/addLTI.js');
//enrich with user id
let userid = context.getStore(UserProfileStore).userid;
if (userid != null && userid !== '') {

context.service.create('lticonsumer', payload, {timeout: 20 * 1000}, (err, res) => {
//console.log('addLTI.js');
//console.log('res='+res);
if (err) {
console.log(err);
//console.log('ADD_LTI_FAILURE');
context.dispatch('ADD_LTI_FAILURE', err);
} else {
context.dispatch('ADD_LTI_SUCCESS', res);
}
done();
});

} //end if (userid != null && userid !== '')
else
done();
}
11 changes: 11 additions & 0 deletions actions/user/userprofile/cancelUserlti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UserProfileStore from '../../../stores/UserProfileStore';
import {navigateAction} from 'fluxible-router';

export default function cancelUserlti(context, payload, done) {

context.dispatch('CANCEL_USERLTI_SUCCESS');
context.executeAction(navigateAction, {
url: '/user/' + context.getStore(UserProfileStore).username + '/ltis/overview'
});

}
37 changes: 34 additions & 3 deletions actions/user/userprofile/chooseAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ import notFoundError from '../../error/notFoundError';
const log = require('../../log/clog');
import loadUserCollections from '../../collections/loadUserCollections';
import loadUserRecommendations from '../../recommendations/loadUserRecommendations';
import { shortTitle } from '../../../configs/general';
import { shortTitle, LTI_ID } from '../../../configs/general';
import UserProfileStore from '../../../stores/UserProfileStore';

import loadUserStats from '../../stats/loadUserStats';

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

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

let title = shortTitle + ' | ';

switch(payload.params.category){
case categories.categories[0]:
switch(payload.params.item){
Expand All @@ -29,7 +33,7 @@ export function chooseAction(context, payload, done) {
title += 'Account';
break;
case categories.settings[2]:
title += 'Authorized Accounts';
title += 'Authorized Accounts & Services';
break;
default:
title = shortTitle;
Expand Down Expand Up @@ -63,6 +67,23 @@ export function chooseAction(context, payload, done) {
case categories.categories[5]:
title += 'User Stats';
break;
/*
case categories.categories[6]:
switch(payload.params.item){
case categories.ltis[0]:
title += 'My Learning Services';
break;
case categories.ltis[1]:
title += 'Add Learning Service';
break;
default:
title = shortTitle;
break;
};
break;
*/


default:
title = shortTitle;
};
Expand All @@ -73,6 +94,7 @@ export function chooseAction(context, payload, done) {
context.executeAction(fetchUser, payload, callback);
},
(callback) => {

switch (payload.params.category) {
case categories.categories[0]:
case categories.categories[1]:
Expand Down Expand Up @@ -103,9 +125,18 @@ export function chooseAction(context, payload, done) {
context.dispatch('USER_CATEGORY', {category: payload.params.category});
context.executeAction(loadUserStats, {}, callback);
break;
case categories.categories[6]:
if(!categories.settings.includes(payload.params.item) && !categories.ltis.includes(payload.params.item) ){
context.executeAction(notFoundError, {}, callback);
break;
}
context.dispatch('USER_CATEGORY', {category: payload.params.category, item: payload.params.item});
callback();
break;
default:
context.executeAction(notFoundError, {}, callback);
}

}
],
(err, result) => {
Expand Down
14 changes: 14 additions & 0 deletions actions/user/userprofile/deleteUserlti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import UserProfileStore from '../../../stores/UserProfileStore';

export default function deleteUserlti(context, payload, done) {
context.dispatch('UPDATE_USERLTIS_STATUS', null);
payload.jwt = context.getStore(UserProfileStore).jwt;
context.service.update('userProfile.deleteUserlti', payload, { timeout: 20 * 1000 }, (err, res) => {
if (err) {
context.dispatch('DELETE_USERLTI_FAILED', err);
} else {
context.dispatch('DELETE_USERLTI_SUCCESS', payload.ltiid);
}
done();
});
}
14 changes: 14 additions & 0 deletions actions/user/userprofile/leaveUserlti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import UserProfileStore from '../../../stores/UserProfileStore';

export default function leaveUserlti(context, payload, done) {
context.dispatch('UPDATE_USERLTIS_STATUS', null);
payload.jwt = context.getStore(UserProfileStore).jwt;
context.service.update('userProfile.leaveUserlti', payload, { timeout: 20 * 1000 }, (err, res) => {
if (err) {
context.dispatch('LEAVE_USERLTI_FAILED', err);
} else {
context.dispatch('LEAVE_USERLTI_SUCCESS', payload.ltiid);
}
done();
});
}
18 changes: 18 additions & 0 deletions actions/user/userprofile/saveUserlti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import UserProfileStore from '../../../stores/UserProfileStore';
import {navigateAction} from 'fluxible-router';

export default function saveUserlti(context, payload, done) {
context.dispatch('SAVE_USERLTI_START', {});
payload.jwt = context.getStore(UserProfileStore).jwt;
context.service.update('userProfile.saveUserlti', payload, {timeout: 60 * 1000}, { timeout: 60 * 1000 }, (err, res) => {
if (err) {
context.dispatch('SAVE_USERLTI_FAILED', err);
} else {
context.dispatch('SAVE_USERLTI_SUCCESS', res);
context.executeAction(navigateAction, {
url: '/user/' + context.getStore(UserProfileStore).username + '/ltis/overview'
});
}
done();
});
}
27 changes: 27 additions & 0 deletions actions/user/userprofile/updateUserlti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const log = require('../../log/clog');
import { shortTitle } from '../../../configs/general';

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

if (payload.offline) {
context.dispatch('UPDATE_USERLTI', payload.lti);
context.dispatch('UPDATE_PAGE_TITLE', {pageTitle: shortTitle + ' | Edit LTI ' + payload.lti.name});
return done();
}

let payload2 = {
ltiid: payload.lti._id
};

context.service.read('userlti.read', payload2, { timeout: 20 * 1000 }, (err, res) => {
if (err) {
context.dispatch('UPDATE_USERLTI', payload.lti);
}
else {
context.dispatch('UPDATE_USERLTI', res[0]);
context.dispatch('UPDATE_PAGE_TITLE', {pageTitle: shortTitle + ' | Edit LTI ' + res[0].name});
}
done();
});
}
39 changes: 39 additions & 0 deletions components/Deck/ContentPanel/ContentActions/DownloadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ class DownloadModal extends React.Component{
case 'HTML':
return Microservices.pdf.uri +'/exportOfflineHTML/'+ splittedId[0];
break;
case 'xAPI Launch (Live)':
return Microservices.xapi.uri +'/getTinCanPackage/' + splittedId[0]+ '?offline=false&format=xml';
break;
case 'xAPI Launch (Offline)':
return Microservices.xapi.uri +'/getTinCanPackage/' + splittedId[0]+ '?offline=true&format=xml';
break;
case 'SCORMv1.2':
case 'SCORMv2':
case 'SCORMv3':
case 'SCORMv4':
let version = type.split('v'); //separates format from version. In second position we have the version
return Microservices.pdf.uri + '/exportSCORM/' + splittedId[0]+ '?version='+version[1];
break;


default:
return '';

Expand Down Expand Up @@ -246,6 +254,37 @@ class DownloadModal extends React.Component{

/>
</Form.Field>

<Form.Field>
<Radio
label='xAPI Launch (Live)'
name='downloadRadioGroup'
value='xAPI Launch (Live)'
checked={this.state.radioValue === 'xAPI Launch (Live)'}
onChange={this.handleRadioChange}
role="radio"
aria-checked={this.state.radioValue === 'xAPI Launch (Live)'}
aria-label='xAPI Launch (Live)'
tabIndex="-1"

/>
</Form.Field>

<Form.Field>
<Radio
label='xAPI Launch (Offline)'
name='downloadRadioGroup'
value='xAPI Launch (Offline)'
checked={this.state.radioValue === 'xAPI Launch (Offline)'}
onChange={this.handleRadioChange}
role="radio"
aria-checked={this.state.radioValue === 'xAPI Launch (Offline)'}
aria-label='xAPI Launch (Offline)'
tabIndex="-1"

/>
</Form.Field>

<Form.Field>
<Radio
label='SCORM 1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ class SlideContentEditor extends React.Component {
}
}
handleSaveButton(){
console.log('SlideContentEditor.handleSaveButton');
if (this.props.UserProfileStore.username !== '') {
// Replace the onbeforeunload function by a Blank Function because it is not neccesary when saved.
// TODO: wait for successfull save signal from
Expand Down Expand Up @@ -841,6 +842,22 @@ class SlideContentEditor extends React.Component {
let tags = this.props.SlideViewStore.tags? this.props.SlideViewStore: [];
let transition = this.props.SlideEditStore.slideTransition ? this.props.SlideEditStore.slideTransition : 'none';


let ltiWidth = this.props.SlideEditStore.ltiWidth;
let ltiHeight = this.props.SlideEditStore.ltiHeight;
let ltiURL = this.props.SlideEditStore.ltiURL;
let ltiKey = this.props.SlideEditStore.ltiKey;
let ltiResponseURL = this.props.SlideEditStore.ltiResponseURL;
let ltiResponseHTML = this.props.SlideEditStore.ltiResponseHTML;

/*
console.log('SlideContentEditor.ltiHeight='+ltiHeight);
console.log('SlideContentEditor.ltiURL='+ltiURL);
console.log('SlideContentEditor.ltiKey='+ltiKey);
console.log('SlideContentEditor.ltiResponseURL='+ltiResponseURL);
console.log('SlideContentEditor.ltiResponseHTML='+ltiResponseHTML);
*/

//setTimeout(function() {
this.context.executeAction(saveSlide, {
id: currentSelector.sid,
Expand All @@ -851,7 +868,15 @@ class SlideContentEditor extends React.Component {
dataSources: dataSources,
selector: currentSelector,
tags: tags,
transition: transition

ltiWidth: ltiWidth,
ltiHeight: ltiHeight,
ltiURL: ltiURL,
ltiKey: ltiKey,
ltiResponseURL: ltiResponseURL,
ltiResponseHTML: ltiResponseHTML,

transition: transition,
});
//},500);

Expand Down Expand Up @@ -1252,7 +1277,7 @@ class SlideContentEditor extends React.Component {
$('.pptx2html [style*="absolute"]').each(function () {
if($(this).find('iframe:first').length)
{
//console.log('iframe found');
console.log('iframe found');
//console.log($(this).find('iframe:first').attr('width'));
//console.log($(this).find('iframe:first').width());
if ($(this).width() < $(this).find('iframe:first').attr('width'))
Expand All @@ -1266,6 +1291,9 @@ class SlideContentEditor extends React.Component {
//console.log('adjust iframe height');
}
}
else {
console.log('iframe not found');
}
});
}
correctDimensionsBoxesImg(){
Expand Down Expand Up @@ -2079,6 +2107,34 @@ class SlideContentEditor extends React.Component {
this.resizeDrag();
}
}

if (nextProps.SlideEditStore.ltiClick === 'true' && nextProps.SlideEditStore.ltiClick !== this.props.SlideEditStore.ltiClick)
{
let uniqueID = this.getuniqueID();
let iframe;
if(nextProps.SlideEditStore.ltiResponseURL !== '') {
iframe = '<iframe src="'+nextProps.SlideEditStore.ltiResponseURL+'" width="'+nextProps.SlideEditStore.ltiWidth+'" height="'+nextProps.SlideEditStore.ltiHeight+'" frameborder="0" allow="encrypted-media"></iframe>';
}
else if(nextProps.SlideEditStore.ltiResponseHTML !== '') {
let newHTML = nextProps.SlideEditStore.ltiResponseHTML.replace(/\"/g, '\'');
iframe = '<iframe srcdoc="'+newHTML+'" width="'+nextProps.SlideEditStore.ltiWidth+'" height="'+nextProps.SlideEditStore.ltiHeight+'" frameborder="0" allow="encrypted-media"></iframe>';
}
if($('.pptx2html').length) //if slide is in canvas mode
{
$('.pptx2html').append('<div id="'+uniqueID+'" style="position: absolute; top: 300px; left: 250px; width: '+nextProps.SlideEditStore.ltiWidth+'px; height: '+nextProps.SlideEditStore.ltiHeight+'px; z-index: '+(this.getHighestZIndex() + 10)+';">'+iframe+'</div>');
this.hasChanges = true;
//this.correctDimensionsBoxes('iframe');
}
else { //if slide is in non-canvas mode
this.refs.inlineContent.innerHTML += iframe;
}
if($('.pptx2html').length) //if slide is in canvas mode
{
//this.uniqueIDAllElements();
this.resizeDrag();
}
}

if (nextProps.SlideEditStore.title !== '' &&
nextProps.SlideEditStore.title !== this.props.SlideEditStore.title &&
nextProps.SlideEditStore.LeftPanelTitleChange !== false)
Expand Down
Loading

0 comments on commit 7324220

Please sign in to comment.