1
0
Fork 0
mirror of https://github.com/Luzifer/past3.git synced 2024-11-10 00:40:00 +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() content = $('#editor').val()
saveFile(filename, content) saveFile(filename, content)
$('#deleteFile').bind 'click', () ->
filename = $('#filename').val()
deleteFile(filename)
$('#file-url').bind 'click', () -> $('#file-url').bind 'click', () ->
$(this).select() $(this).select()
@ -94,7 +98,14 @@ saveFile = (filename, content) ->
Bucket: window.past3_config.bucket Bucket: window.past3_config.bucket
ContentType: mime.mime ContentType: mime.mime
Key: getFilePrefix() + filename 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) -> loadFileIntoEditor = (err, data) ->
if err if err
@ -121,7 +132,7 @@ loadFileList = (err, data) ->
li.appendTo $('#fileList') li.appendTo $('#fileList')
saveFileCallback = (err, data) -> fileActionCallback = (err, data) ->
if err if err
error err error err
return return

View file

@ -22,9 +22,10 @@
{% endif %} {% endif %}
<style> <style>
#signInButton { margin: 20px 164px 0; }
.modal-body { text-align: center; }
#errorDisplay { display: none; } #errorDisplay { display: none; }
.file-mgmt { width: 100%; }
.modal-body { text-align: center; }
#signInButton { margin: 20px 164px 0; }
</style> </style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
@ -129,7 +130,10 @@
</div> <!-- /.col-md-10 --> </div> <!-- /.col-md-10 -->
<div class="col-md-2"> <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>
</div> </div>