-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp-dump-ui.coffee
More file actions
46 lines (38 loc) · 1.21 KB
/
app-dump-ui.coffee
File metadata and controls
46 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
templateHelpers =
downloadToken : ->
if Meteor.user()
return Accounts?._storedLoginToken()
Template.appDumpDownload.helpers templateHelpers
Template.appDumpUpload.helpers templateHelpers
Template.appDumpDownload.events
'click .app-dump-download' : (e) ->
e.preventDefault()
$form = $(e.currentTarget).closest 'form'
collectionDumpUrl = '/appDump?'
for dataItem in $form.serializeArray()
if dataItem.value
collectionDumpUrl += "&#{encodeURIComponent dataItem.name}=" + encodeURIComponent dataItem.value
window.location.href = collectionDumpUrl
Template.appDumpUpload.onCreated ->
@uploading = new ReactiveVar false
Template.appDumpUpload.helpers
uploading: ->
Template.instance().uploading.get()
Template.appDumpUpload.events
'change .app-dump-upload' : (e, tmpl) ->
$form = $(e.currentTarget).closest 'form'
tmpl.uploading.set true
$.ajax
type: "POST"
url: '/appDump'
data: new FormData($form[0])
cache: false
enctype: 'multipart/form-data'
contentType: false
processData: false
.done (data) ->
alert 'Restore Complete'
.fail (err) ->
alert err.responseText
.always ->
tmpl.uploading.set false