1
0
Fork 0
mirror of https://github.com/Luzifer/past3.git synced 2024-12-22 20:31:16 +00:00

Add file deletion

This commit is contained in:
Knut Ahlers 2017-01-15 14:58:51 +01:00
parent 2ceaa676d9
commit 019cdda358
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 20 additions and 5 deletions

View file

@ -30,6 +30,10 @@ $ ->
content = $('#editor').val()
saveFile(filename, content)
$('#deleteFile').bind 'click', () ->
filename = $('#filename').val()
deleteFile(filename)
$('#file-url').bind 'click', () ->
$(this).select()
@ -94,7 +98,14 @@ saveFile = (filename, content) ->
Bucket: window.past3_config.bucket
ContentType: mime.mime
Key: getFilePrefix() + filename
}, saveFileCallback)
}, fileActionCallback)
deleteFile = (filename) ->
s3 = new AWS.S3()
s3.deleteObject({
Bucket: window.past3_config.bucket
Key: getFilePrefix() + filename
}, fileActionCallback)
loadFileIntoEditor = (err, data) ->
if err
@ -121,7 +132,7 @@ loadFileList = (err, data) ->
li.appendTo $('#fileList')
saveFileCallback = (err, data) ->
fileActionCallback = (err, data) ->
if err
error err
return

View file

@ -22,9 +22,10 @@
{% endif %}
<style>
#signInButton { margin: 20px 164px 0; }
.modal-body { text-align: center; }
#errorDisplay { display: none; }
.file-mgmt { width: 100%; }
.modal-body { text-align: center; }
#signInButton { margin: 20px 164px 0; }
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
@ -129,7 +130,10 @@
</div> <!-- /.col-md-10 -->
<div class="col-md-2">
<button class="btn btn-success col-md-12" id="saveFile"><i class="fa fa-save"></i> Save</button>
<div class="btn-group file-mgmt" role="group">
<button type="button" class="btn btn-success col-md-9" id="saveFile"><i class="fa fa-save"></i> Save</button>
<button type="button" class="btn btn-danger col-md-3" id="deleteFile"><i class="fa fa-trash"></i></button>
</div>
</div>
</div>