nfp_sites/filadelfia_web/app/page_upload.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-11-09 09:44:04 +00:00
const m = require('mithril')
const Authentication = require('./authentication')
const api = require('./api')
2023-11-14 07:27:04 +00:00
const Input = require('./input')
2023-11-09 09:44:04 +00:00
2023-11-14 07:27:04 +00:00
const Upload = {
2023-11-09 09:44:04 +00:00
oninit: function(vnode) {
2023-11-14 07:27:04 +00:00
Authentication.requiresLogin()
2023-11-09 09:44:04 +00:00
this.error = ''
2023-11-15 04:43:05 +00:00
let d = new Date()
d.setDate(d.getDate() - d.getDay())
d.setHours(11)
d.setMinutes(0)
d.setSeconds(0)
d.setMilliseconds(0)
2023-11-14 07:27:04 +00:00
this.form = {
2023-11-09 09:44:04 +00:00
title: '',
2023-11-15 04:43:05 +00:00
date: d,
2023-11-09 09:44:04 +00:00
file: null,
}
},
2023-11-14 07:27:04 +00:00
uploadvideo: function(vnode, e) {
2023-11-15 04:43:05 +00:00
console.log(this.form)
return false
2023-11-09 09:44:04 +00:00
},
view: function(vnode) {
return [
2023-11-14 07:27:04 +00:00
m('div.page.page-upload', [
m('div.modal', [
m('form', {
onsubmit: this.uploadvideo.bind(this, vnode),
}, [
m('h3', 'Upload new video'),
this.error ? m('p.error', this.error) : null,
m(Input, {
label: 'Title',
form: this.form,
formKey: 'title',
}),
m(Input, {
label: 'Date',
2023-11-15 04:43:05 +00:00
type: 'text',
utility: 'datetime',
2023-11-14 07:27:04 +00:00
form: this.form,
formKey: 'date',
}),
m('input.spinner', {
hidden: api.loading,
type: 'submit',
2023-11-15 04:43:05 +00:00
value: 'Begin upload',
2023-11-14 07:27:04 +00:00
}),
api.loading ? m('div.loading-spinner') : null,
]),
2023-11-09 09:44:04 +00:00
]),
]),
]
},
}
2023-11-14 07:27:04 +00:00
module.exports = Upload