summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/commands/site/populate.py81
-rw-r--r--frontend/app/actions.js4
-rw-r--r--frontend/app/views/graph/components/page.edit.js1
-rw-r--r--frontend/app/views/graph/components/page.form.js12
4 files changed, 94 insertions, 4 deletions
diff --git a/cli/commands/site/populate.py b/cli/commands/site/populate.py
new file mode 100644
index 0000000..4b5bb73
--- /dev/null
+++ b/cli/commands/site/populate.py
@@ -0,0 +1,81 @@
+import click
+
+# lines = """/static/media/last-museum/zohra-opoku/.mp4
+# /static/media/last-museum/zohra-opoku/MVI_4388.mp4
+# /static/media/last-museum/zohra-opoku/MVI_4390.mp4
+# /static/media/last-museum/zohra-opoku/.mp4""".split("\n")
+
+lines = [
+"/static/media/last-museum/zohra-opoku/MVI_4367.mp4",
+]
+
+letters = ['a','b','c','d','e','f','g','h','i','j']
+
+@click.command('populate')
+@click.pass_context
+def cli(ctx):
+ """Populate video pages"""
+
+ import requests
+
+ def post(endpoint, data):
+ resp = requests.post(endpoint, json=data)
+ return None if resp.status_code != 200 else resp.json()
+
+ graph_id = 3
+ name = "Zohra Opoku. Chapter 9: To Me Belongs Yesterday"
+ index = 0
+
+ for url in lines:
+ slug = url.split("/")[5].replace(".mp4", "").lower()
+ slug = "opoku-" + "9-to-me-belongs-yesterday" # + letters[index]
+ print(slug)
+ index += 1
+
+ page_data = {
+ "graph_id": graph_id,
+ "path": slug,
+ "title": name,
+ "username": "jules",
+ "description":"",
+ "settings": {
+ "x": 0.05,
+ "y": 0.05,
+ "background_color": "#000000",
+ "background_audio_id": 0,
+ "restart_audio": False
+ }
+ }
+ page_res = post("http://0.0.0.0:5000/api/v1/page/", page_data)
+ page_id = page_res['res']['id']
+
+ tile_data = {
+ "graph_id": graph_id,
+ "page_id": page_id,
+ "target_page_id": None,
+ "type": "video",
+ "settings": {
+ "x": 0,
+ "y": 0,
+ "width": 1920,
+ "height": 1080,
+ "rotation": 0,
+ "scale": 1,
+ "opacity": 1,
+ "units": False,
+ "align": "center_center",
+ "has_audio": False,
+ "audio_on_click_id": 0,
+ "audio_on_hover_id": 0,
+ "navigate_when_audio_finishes": False,
+ "video_style": "cover",
+ "url": url,
+ "external_link_url": "",
+ "cursor": "none",
+ "muted": True,
+ "loop": True,
+ "autoadvance": False
+ }
+ }
+
+ page_res = post("http://0.0.0.0:5000/api/v1/tile/", tile_data)
diff --git a/frontend/app/actions.js b/frontend/app/actions.js
index 0fba6d1..6cfa470 100644
--- a/frontend/app/actions.js
+++ b/frontend/app/actions.js
@@ -1,5 +1,5 @@
import { bindActionCreators } from 'redux'
-import { actions as crudActions } from './api'
+import { actions as crudActions } from 'app/api'
import * as siteActions from 'app/views/site/site.actions'
@@ -15,4 +15,4 @@ export default
.concat([
// ['socket', socketActions],
])
- .reduce((a,b) => (a[b[0]] = b[1])&&a,{}) \ No newline at end of file
+ .reduce((a,b) => (a[b[0]] = b[1])&&a,{})
diff --git a/frontend/app/views/graph/components/page.edit.js b/frontend/app/views/graph/components/page.edit.js
index 4025726..16a7eef 100644
--- a/frontend/app/views/graph/components/page.edit.js
+++ b/frontend/app/views/graph/components/page.edit.js
@@ -45,6 +45,7 @@ class PageEdit extends Component {
return (
<PageForm
data={show.res}
+ actions={{ graph: this.props.graphActions }}
graph={this.props.graph.show.res}
onSubmit={this.handleSubmit.bind(this)}
/>
diff --git a/frontend/app/views/graph/components/page.form.js b/frontend/app/views/graph/components/page.form.js
index 8148864..a060698 100644
--- a/frontend/app/views/graph/components/page.form.js
+++ b/frontend/app/views/graph/components/page.form.js
@@ -2,6 +2,8 @@ import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import { session } from 'app/session'
+import actions from 'app/actions'
+import { history } from 'app/store'
import { TextInput, ColorInput, Checkbox, LabelDescription, TextArea, SubmitButton, Loader } from 'app/common'
import AudioSelect from 'app/views/audio/components/audio.select'
@@ -127,11 +129,17 @@ export default class PageForm extends Component {
}
}
- handleDelete() {
+ handleDelete(e) {
+ e && e.preventDefault()
+ e && e.stopPropagation()
const { data } = this.state
console.log(data)
if (confirm('Really delete this page?')) {
- actions.page.delete(page_id)
+ actions.page.destroy(data)
+ .then(() => {
+ this.props.actions.graph.hideEditPageForm()
+ history.goBack()
+ })
}
}