From e21538fe99277d31cacde6f8596a24156faaefd7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 3 Jun 2018 19:57:52 +0200 Subject: datasettes --- app/client/modules/samplernn/samplernn.datasets.js | 9 +++------ app/client/modules/samplernn/samplernn.show.js | 5 ----- public/bundle.js | 15 ++++----------- public/bundle.js.map | 2 +- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index d37102b..0a42b8f 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -17,20 +17,17 @@ const samplernnModule = { class SampleRNNDatasets extends Component { constructor(props){ super(props) - console.log('ba') this.fileOptions = this.fileOptions.bind(this) this.pickFile = this.pickFile.bind(this) } componentWillMount(){ const id = this.props.id || this.props.match.params.id || localStorage.getItem('samplernn.last_id') - console.log(id) console.log('load dataset:', id) const { match, samplernn, actions } = this.props if (id === 'new') return if (id) { - localStorage.setItem('samplernn.last_id', id) + if (parseInt(id)) localStorage.setItem('samplernn.last_id', id) if (! samplernn.folder || samplernn.folder.id !== id) { - console.log('load directories') actions.load_directories(id) } } @@ -65,12 +62,12 @@ class SampleRNNDatasets extends Component { const { samplernn, match, history } = this.props const id = this.props.id || localStorage.getItem('samplernn.last_id') console.log(this.props.id) - if (this.props.id && this.props.id !== 'new') return null if (samplernn.loading) { console.log('loading') return Loading } - if (!samplernn.folder || !samplernn.data.folders.length) { + console.log(samplernn) + if (!samplernn.data.folder || !samplernn.data.folders.length) { console.log('no folders, redirect to /new') return history.push('/samplernn/new/') } diff --git a/app/client/modules/samplernn/samplernn.show.js b/app/client/modules/samplernn/samplernn.show.js index a6018c5..24d60ab 100644 --- a/app/client/modules/samplernn/samplernn.show.js +++ b/app/client/modules/samplernn/samplernn.show.js @@ -17,12 +17,7 @@ const samplernnModule = { } class SampleRNNShow extends Component { - constructor(){ - super() - console.log('piss') - } render(){ - console.log('dick') return ( 1 && arguments[1] !== undefined ? arguments[1] : [];\n 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_waiting', 'upload_complete', 'upload_error', 'sort']).reduce(function (a, b) {\n return (a[b] = as_type(type, b)) && a;\n }, {});\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.upload_action = undefined;\nexports.crud_upload = crud_upload;\n\nvar _crud = require('./crud.types');\n\nfunction _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; }\n\nfunction crud_upload(type, fd, data, dispatch) {\n return new Promise(function (resolve, reject) {\n var id = data.id;\n\n Object.keys(data).forEach(function (key) {\n if (key !== 'id') {\n fd.append(key, data[key]);\n }\n });\n\n var xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.addEventListener(\"load\", uploadComplete, false);\n xhr.addEventListener(\"error\", uploadFailed, false);\n xhr.addEventListener(\"abort\", uploadCancelled, false);\n xhr.open(\"POST\", '/' + type + '/' + id + '/upload/');\n xhr.send(fd);\n\n dispatch && dispatch({ type: (0, _crud.as_type)(type, 'upload_loading') });\n\n var complete = false;\n\n function uploadProgress(e) {\n if (e.lengthComputable) {\n var percent = Math.round(e.loaded * 100 / e.total) || 0;\n if (percent > 99) {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_waiting'),\n percent: percent\n }, type, id));\n } else {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_progress'),\n percent: percent\n }, type, id));\n }\n } else {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_error'),\n error: 'unable to compute upload progress'\n }, type, id));\n }\n }\n\n function uploadComplete(e) {\n try {\n var _data = JSON.parse(e.target.responseText);\n } catch (e) {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_error'),\n error: 'upload failed'\n }, type, id));\n reject(e);\n return;\n }\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_complete'),\n data: data\n }, type, id));\n resolve(data);\n }\n\n function uploadFailed(evt) {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_error'),\n error: 'upload failed'\n }, type, id));\n reject(evt);\n }\n\n function uploadCancelled(evt) {\n dispatch && dispatch(_defineProperty({\n type: (0, _crud.as_type)(type, 'upload_error'),\n error: 'upload cancelled'\n }, type, id));\n reject(evt);\n }\n });\n}\n\nvar upload_action = exports.upload_action = function upload_action(type, id, fd) {\n return function (dispatch) {\n return crud_upload(type, id, fd, dispatch);\n };\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.actions = exports.parser = exports.util = undefined;\n\nvar _crud = require('./crud.actions');\n\nvar _util = require('../util');\n\nvar util = _interopRequireWildcard(_util);\n\nvar _parser = require('./parser');\n\nvar parser = _interopRequireWildcard(_parser);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\n/*\nfor our crud events, create corresponding actions\nthe actions fire a 'loading' event, call the underlying api method, and then resolve.\nso you can do ... \n import { folderActions } from '../../api'\n folderActions.index({ module: 'samplernn' })\n folderActions.show(12)\n folderActions.create({ module: 'samplernn', name: 'foo' })\n folderActions.update(12, { module: 'pix2pix' })\n folderActions.destroy(12, { confirm: true })\n folderActions.upload(12, form_data)\n*/\n\nexports.util = util;\nexports.parser = parser;\nvar actions = exports.actions = ['folder', 'file', 'dataset', 'task', 'user'].reduce(function (a, b) {\n return (a[b] = (0, _crud.crud_actions)(b)) && a;\n}, {});","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.tumblr = exports.thumbnail = exports.loadImage = exports.tag = exports.parse = exports.lookup = exports.integrations = undefined;\n\nvar _nodeFetch = require('node-fetch');\n\nvar _nodeFetch2 = _interopRequireDefault(_nodeFetch);\n\nvar _fetchJsonp = require('fetch-jsonp');\n\nvar _fetchJsonp2 = _interopRequireDefault(_fetchJsonp);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar integrations = exports.integrations = [{\n type: 'image',\n regex: /\\.(jpeg|jpg|gif|png|svg)(\\?.*)?$/i,\n fetch: function fetch(url, done) {\n var img = new Image();\n img.onload = function () {\n if (!img) return;\n var width = img.naturalWidth,\n height = img.naturalHeight;\n img = null;\n done({\n url: url,\n type: \"image\",\n token: \"\",\n thumbnail: \"\",\n title: \"\",\n width: width,\n height: height\n });\n };\n img.src = url;\n if (img.complete) {\n img.onload();\n }\n },\n tag: function tag(media) {\n return '';\n }\n}, {\n type: 'video',\n regex: /\\.(mp4|webm)(\\?.*)?$/i,\n fetch: function fetch(url, done) {\n var video = document.createElement(\"video\");\n var url_parts = url.replace(/\\?.*$/, \"\").split(\"/\");\n var filename = url_parts[url_parts.length - 1];\n video.addEventListener(\"loadedmetadata\", function () {\n var width = video.videoWidth,\n height = video.videoHeight;\n video = null;\n done({\n url: url,\n type: \"video\",\n token: url,\n thumbnail: \"/public/assets/img/video-thumbnail.png\",\n title: filename,\n width: width,\n height: height\n });\n });\n video.src = url;\n video.load();\n },\n tag: function tag(media) {\n return '