summaryrefslogtreecommitdiff
path: root/public/bundle.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/bundle.js')
-rw-r--r--public/bundle.js345
1 files changed, 335 insertions, 10 deletions
diff --git a/public/bundle.js b/public/bundle.js
index 544a50a..4c841f9 100644
--- a/public/bundle.js
+++ b/public/bundle.js
@@ -71,10 +71,183 @@
/************************************************************************/
/******/ ({
-/***/ "./app/client/api/crud.type.js":
-/*!*************************************!*\
- !*** ./app/client/api/crud.type.js ***!
- \*************************************/
+/***/ "./app/client/api/crud.actions.js":
+/*!****************************************!*\
+ !*** ./app/client/api/crud.actions.js ***!
+ \****************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.crud_action = undefined;
+exports.crud_actions = crud_actions;
+
+var _crud = __webpack_require__(/*! ./crud.fetch */ "./app/client/api/crud.fetch.js");
+
+var _crud2 = __webpack_require__(/*! ./crud.types */ "./app/client/api/crud.types.js");
+
+var _crud3 = __webpack_require__(/*! ./crud.upload */ "./app/client/api/crud.upload.js");
+
+function crud_actions(type) {
+ var fetch_type = (0, _crud.crud_fetch)(type);
+ return ['index', 'show', 'create', 'update', 'destroy'].reduce(function (lookup, param) {
+ lookup[param] = crud_action(type, param, function (q) {
+ return fetch_type[param](q);
+ });
+ return lookup;
+ }, {
+ action: function action(method, fn) {
+ return crud_action(type, method, fn);
+ },
+ upload: function upload(id, fd) {
+ return (0, _crud3.upload_action)(type, id, fd);
+ }
+ });
+}
+
+var crud_action = exports.crud_action = function crud_action(type, method, fn) {
+ return function (q) {
+ return function (dispatch) {
+ dispatch({ type: (0, _crud2.as_type)(type, method + '_loading') });
+ fn(q).then(function (data) {
+ dispatch({ type: (0, _crud2.as_type)(type, method), data: data });
+ }).catch(function (e) {
+ dispatch({ type: (0, _crud2.as_type)(type, method + '_error') });
+ });
+ };
+ };
+};
+
+/***/ }),
+
+/***/ "./app/client/api/crud.fetch.js":
+/*!**************************************!*\
+ !*** ./app/client/api/crud.fetch.js ***!
+ \**************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.crud_fetch = crud_fetch;
+exports.postBody = postBody;
+
+var _nodeFetch = __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/browser.js");
+
+var _nodeFetch2 = _interopRequireDefault(_nodeFetch);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function crud_fetch(type, tag) {
+ var uri = '/api/' + type + '/' + (tag || '');
+ return {
+ index: function index(q) {
+ return (0, _nodeFetch2.default)(_get_url(uri, q), _get_headers()).then(function (req) {
+ return req.json();
+ }).catch(error);
+ },
+
+ show: function show(id) {
+ return (0, _nodeFetch2.default)(uri + id).then(function (req) {
+ return req.json();
+ }).catch(error);
+ },
+
+ create: function create(data) {
+ return (0, _nodeFetch2.default)(uri, post(data)).then(function (req) {
+ return req.json();
+ }).catch(error);
+ },
+
+ update: function update(data) {
+ return (0, _nodeFetch2.default)(uri + data.id, put(data)).then(function (req) {
+ return req.json();
+ }).catch(error);
+ },
+
+ destroy: function destroy(data) {
+ return (0, _nodeFetch2.default)(uri + data.id, _destroy(data)).then(function (req) {
+ return req.json();
+ }).catch(error);
+ }
+ };
+}
+
+function _get_url(_url, data) {
+ var url = new URL(window.location.origin + _url);
+ if (data) {
+ Object.keys(data).forEach(function (key) {
+ return url.searchParams.append(key, data[key]);
+ });
+ }
+ return url;
+}
+function _get_headers() {
+ return {
+ method: 'GET',
+ headers: {
+ 'Accept': 'application/json'
+ }
+ };
+}
+function post(data) {
+ return {
+ method: 'POST',
+ body: JSON.stringify(data),
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+ };
+}
+function postBody(data) {
+ return {
+ method: 'POST',
+ body: data,
+ headers: {
+ 'Accept': 'application/json'
+ }
+ };
+}
+function put(data) {
+ return {
+ method: 'PUT',
+ body: JSON.stringify(data),
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+ };
+}
+function _destroy(data) {
+ return {
+ method: 'DELETE',
+ body: JSON.stringify(data),
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+ };
+}
+function error(err) {
+ console.warn(err);
+}
+
+/***/ }),
+
+/***/ "./app/client/api/crud.types.js":
+/*!**************************************!*\
+ !*** ./app/client/api/crud.types.js ***!
+ \**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
@@ -84,20 +257,139 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.crud_type = crud_type;
var as_type = exports.as_type = function as_type(a, b) {
return [a, b].join('_').toUpperCase();
};
-function crud_type(type) {
+var crud_type = exports.crud_type = function crud_type(type) {
var actions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
-
return actions.concat(['index_loading', 'index', 'index_error', 'show_loading', 'show', 'show_error', 'create_loading', 'create', 'create_error', 'update_loading', 'update', 'update_error', 'destroy_loading', 'destroy', 'destroy_error', 'upload_loading', 'upload_progress', 'upload_complete', 'upload_error', 'sort']).reduce(function (a, b) {
return (a[b] = as_type(type, b)) && a;
}, {});
- return aa;
+};
+
+/***/ }),
+
+/***/ "./app/client/api/crud.upload.js":
+/*!***************************************!*\
+ !*** ./app/client/api/crud.upload.js ***!
+ \***************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.upload_action = undefined;
+exports.crud_upload = crud_upload;
+
+var _crud = __webpack_require__(/*! ./crud.types */ "./app/client/api/crud.types.js");
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function crud_upload(type, id, fd, dispatch) {
+ return new Promise(function (resolve, reject) {
+ var xhr = new XMLHttpRequest();
+ xhr.upload.addEventListener("progress", uploadProgress, false);
+ xhr.addEventListener("load", uploadComplete, false);
+ xhr.addEventListener("error", uploadFailed, false);
+ xhr.addEventListener("abort", uploadCanceled, false);
+ xhr.open("POST", '/' + type + '/' + id + '/upload/');
+ xhr.send(fd);
+
+ dispatch && dispatch({ type: (0, _crud.as_type)(type, 'upload_loading') });
+
+ function uploadProgress(e) {
+ if (e.lengthComputable) {
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_progress'),
+ percent: Math.round(e.loaded * 100 / e.total)
+ }, type, id));
+ } else {
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_error'),
+ error: 'unable to compute upload progress'
+ }, type, id));
+ }
+ }
+
+ function uploadComplete(e) {
+ try {
+ var _data = JSON.parse(e.target.responseText);
+ } catch (e) {
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_error'),
+ error: 'upload failed'
+ }, type, id));
+ return;
+ }
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_complete'),
+ data: data
+ }, type, id));
+ }
+
+ uploadFailed = function uploadFailed(evt) {
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_error'),
+ error: 'upload failed'
+ }, type, id));
+ };
+
+ uploadCancelled = function uploadCancelled(evt) {
+ dispatch && dispatch(_defineProperty({
+ type: (0, _crud.as_type)(type, 'upload_error'),
+ error: 'upload cancelled'
+ }, type, id));
+ };
+ });
}
+var upload_action = exports.upload_action = function upload_action(type, id, fd) {
+ return function (dispatch) {
+ return crud_upload(type, id, fd, dispatch);
+ };
+};
+
+/***/ }),
+
+/***/ "./app/client/api/index.js":
+/*!*********************************!*\
+ !*** ./app/client/api/index.js ***!
+ \*********************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.actions = undefined;
+
+var _crud = __webpack_require__(/*! ./crud.actions */ "./app/client/api/crud.actions.js");
+
+/*
+for our crud events, create corresponding actions
+the actions fire a 'loading' event, call the underlying api method, and then resolve.
+so you can do ...
+ import { folderActions } from '../../api'
+ folderActions.index({ module: 'samplernn' })
+ folderActions.show(12)
+ folderActions.create({ module: 'samplernn', name: 'foo' })
+ folderActions.update(12, { module: 'pix2pix' })
+ folderActions.destroy(12, { confirm: true })
+ folderActions.upload(12, form_data)
+*/
+
+var actions = exports.actions = ['folder', 'file', 'dataset', 'task', 'user'].reduce(function (a, b) {
+ return (a[b] = (0, _crud.crud_actions)(b)) && a;
+}, {});
+
/***/ }),
/***/ "./app/client/common/button.component.js":
@@ -3082,6 +3374,8 @@ var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"
var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
+var _api = __webpack_require__(/*! ../../api */ "./app/client/api/index.js");
+
var _group = __webpack_require__(/*! ../../common/group.component */ "./app/client/common/group.component.js");
var _group2 = _interopRequireDefault(_group);
@@ -3113,6 +3407,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+// folderActions.index({ module: 'samplernn' })
+// folderActions.show(12)
+// folderActions.create({ module: 'samplernn', name: 'foo' })
+// folderActions.update(12, { module: 'pix2pix' })
+// folderActions.destroy(12, { confirm: true })
+// folderActions.upload(12, form_data)
var SampleRNNDatasets = function (_Component) {
_inherits(SampleRNNDatasets, _Component);
@@ -3125,6 +3425,7 @@ var SampleRNNDatasets = function (_Component) {
_this.handleUpload = _this.handleUpload.bind(_this);
_this.handleURL = _this.handleURL.bind(_this);
+ props.actions.folder.index({ module: 'samplernn' });
return _this;
}
@@ -3220,7 +3521,9 @@ var mapStateToProps = function mapStateToProps(state) {
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
- // actions: bindActionCreators(liveActions, dispatch)
+ actions: {
+ folder: (0, _redux.bindActionCreators)(_api.actions.folder, dispatch)
+ }
};
};
@@ -3335,6 +3638,9 @@ var samplernnReducer = function samplernnReducer() {
return state;
}
return _extends({}, state);
+ case _types2.default.folder.index:
+ console.log(action);
+ return;
default:
return state;
}
@@ -4608,7 +4914,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
-var _crud = __webpack_require__(/*! ./api/crud.type */ "./app/client/api/crud.type.js");
+var _crud = __webpack_require__(/*! ./api/crud.types */ "./app/client/api/crud.types.js");
exports.default = {
system: {
@@ -25067,6 +25373,25 @@ webpackContext.id = "./node_modules/moment/locale sync recursive ^\\.\\/.*$";
/***/ }),
+/***/ "./node_modules/node-fetch/browser.js":
+/*!********************************************!*\
+ !*** ./node_modules/node-fetch/browser.js ***!
+ \********************************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = exports = window.fetch;
+
+// Needed for TypeScript and Webpack.
+exports.default = window.fetch.bind(window);
+
+exports.Headers = window.Headers;
+exports.Request = window.Request;
+exports.Response = window.Response;
+
+
+/***/ }),
+
/***/ "./node_modules/object-assign/index.js":
/*!*********************************************!*\
!*** ./node_modules/object-assign/index.js ***!