Skip to content

Commit

Permalink
allow passing in files while creating a new run for a world
Browse files Browse the repository at this point in the history
  • Loading branch information
narenranjit committed May 24, 2018
1 parent 34ae078 commit d7ca505
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 66 deletions.
4 changes: 2 additions & 2 deletions dist/components/assignment/assignment.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/components/assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.2.1/components/assignment/assignment.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.2.2/components/assignment/assignment.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
</head>
Expand Down Expand Up @@ -73,8 +73,8 @@
</div>
</div>
<!-- make sure to include jquery, epicenter.js and assignment.js -->
<script src="https://forio.com/tools/js-libs/2.2.1/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.1/components/assignment/assignment.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.2/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.2/components/assignment/assignment.js"></script>
<script>
new window.forio.MultiplayerAssignmentComponent({
el: '#assignment-component',
Expand Down
6 changes: 3 additions & 3 deletions dist/components/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- login.css provides styling for the group selector pop over dialog -->
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.2.1/components/login/login.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.2.2/components/login/login.css">

<!-- make sure to include jquery, epicenter.js and login.js -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.1/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.1/components/login/login.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.2/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.2.2/components/login/login.js"></script>
</head>
<body>
<!--
Expand Down
4 changes: 2 additions & 2 deletions dist/epicenter-multiplayer-dependencies.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/epicenter-multiplayer-dependencies.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/epicenter-multiplayer-dependencies.min.js.map

Large diffs are not rendered by default.

53 changes: 35 additions & 18 deletions dist/epicenter.js

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions dist/epicenter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/epicenter.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epicenter-js",
"version": "2.2.1",
"version": "2.2.2",
"repository": {
"type": "git",
"url": "https://github.com/forio/epicenter-js-libs"
Expand Down
3 changes: 1 addition & 2 deletions src/service/run-api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,12 @@ module.exports = function (config) {
*/
create: function (params, options) {
var createOptions = $.extend(true, {}, serviceOptions, options, { url: urlConfig.getAPIPath('run') });
var runApiParams = ['model', 'scope', 'files', 'ephemeral'];
if (typeof params === 'string') {
// this is just the model name
params = { model: params };
} else {
// whitelist the fields that we actually can send to the api
params = _pick(params, runApiParams);
params = rutil.extractValidRunParams(params);
}

var oldSuccess = createOptions.success;
Expand Down
9 changes: 5 additions & 4 deletions src/service/world-api-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var ConfigService = require('./configuration-service');
var TransportFactory = require('../transport/http-transport-factory');
var SessionManager = require('../store/session-manager');
var _pick = require('../util/object-util')._pick;
var rutil = require('../util/run-util');

var apiBase = 'multiplayer/';
var assignmentEndpoint = apiBase + 'assign';
Expand Down Expand Up @@ -553,14 +554,15 @@ module.exports = function (config) {

setIdFilterOrThrowError(options);

var getOptions = $.extend(true, {},
var postParams = $.extend(true, {},
serviceOptions,
options,
{ url: urlConfig.getAPIPath(apiEndpoint) + serviceOptions.filter + '/run' }
);

validateModelOrThrowError(getOptions);
return http.post(_pick(getOptions, 'model'), getOptions);
validateModelOrThrowError(postParams);
var validRunParams = rutil.extractValidRunParams(postParams);
return http.post(validRunParams, postParams);
},

/**
Expand Down Expand Up @@ -662,7 +664,6 @@ module.exports = function (config) {
*/
newRunForWorld: function (worldId, options) {
var currentRunOptions = $.extend(true, {},
serviceOptions,
options,
{ filter: worldId || serviceOptions.filter }
);
Expand Down
6 changes: 6 additions & 0 deletions src/util/run-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
*/
'use strict';
var qutil = require('./query-util');
var _pick = require('../util/object-util')._pick;
var MAX_URL_LENGTH = 2048;

module.exports = (function () {
return {
extractValidRunParams: function (params) {
var validParams = ['model', 'scope', 'files', 'ephemeral'];
return _pick(params, validParams);
},

/**
* returns operations of the form `[[op1,op2], [arg1, arg2]]`
* @param {Object|Array|String} operations operations to perform
Expand Down

0 comments on commit d7ca505

Please sign in to comment.