2017-08-04 10:23:50 +03:00
|
|
|
<div class="container upload-form" id="upload-form">
|
|
|
|
|
2017-08-01 17:59:51 +03:00
|
|
|
<input id="fileupload" type="file" name="image" data-url="/upload" multiple>
|
|
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
|
|
|
<script src="/file_uploader/js/vendor/jquery.ui.widget.js"></script>
|
|
|
|
<script src="/file_uploader/js/jquery.iframe-transport.js"></script>
|
|
|
|
<script src="/file_uploader/js/jquery.fileupload.js"></script>
|
|
|
|
<script>
|
|
|
|
$(function () {
|
|
|
|
$('#fileupload').fileupload({
|
|
|
|
dataType: 'json',
|
|
|
|
done: function (e, data) {
|
|
|
|
$.each(data.result.files, function (index, file) {
|
|
|
|
$('<p/>').text(file.name).appendTo('#lastUploadLog');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
sequentialUploads: true,
|
|
|
|
progressall: function (e, data) {
|
|
|
|
var progress = parseInt(data.loaded / data.total * 100, 10);
|
2018-08-03 23:19:35 +03:00
|
|
|
$('#progress .progress-bar').css(
|
2017-08-01 17:59:51 +03:00
|
|
|
'width',
|
|
|
|
progress + '%'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2018-08-03 23:19:35 +03:00
|
|
|
<div id="progress" class="container">
|
2017-08-03 08:47:39 +03:00
|
|
|
<div class="progress-bar" style="width: 0%;"></div>
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
2018-08-03 23:19:35 +03:00
|
|
|
<div id="lastUploadLog" class="container"></div>
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- display images from server -->
|
|
|
|
<div class="container">
|
|
|
|
<div id="images_list">
|
|
|
|
<div class="foto-block row" v-for="image in imagesList">
|
|
|
|
<div class="image col-md-3">
|
2017-08-02 07:55:54 +03:00
|
|
|
<img v-bind:src="image.thumbnail_url">
|
2017-08-03 08:47:39 +03:00
|
|
|
<div class="image_title">
|
|
|
|
{{ image.filename }}
|
|
|
|
</div>
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
|
|
|
<div class="foto-notes col-md-3">
|
2017-08-03 08:47:39 +03:00
|
|
|
<div class="image-scale image-original">
|
|
|
|
<div class="image-scale-url">
|
|
|
|
<a v-bind:href="image.original_url">Original</a>
|
|
|
|
</div>
|
|
|
|
<div @click="copyText" class="copy-img">
|
|
|
|
<img src={{ hostname+image.original_url }}>
|
|
|
|
</div>
|
|
|
|
<div @click="copyText" class="copy-bb-more">
|
|
|
|
[MORE=<img src={{ hostname+image.thumbnail_url }}>]<img src={{ hostname+image.original_url }}>[/MORE]
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="image-scale" v-for="scale in image.scales">
|
|
|
|
<div class="image-scale-url">
|
|
|
|
<a v-bind:href="scale.url">{{ scale.size }}</a>
|
|
|
|
</div>
|
|
|
|
<div @click="copyText" class="copy-img">
|
|
|
|
<img src={{ hostname+scale.url }}>
|
|
|
|
</div>
|
|
|
|
<div @click="copyText" class="copy-bb-more">
|
|
|
|
[MORE=<img src={{ hostname+image.thumbnail_url }}>]<img src={{ hostname+scale.url }}>[/MORE]
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-04 09:57:17 +03:00
|
|
|
<div class="container paginator">
|
|
|
|
<div class="btn-group">
|
|
|
|
<button type="button" class="btn btn-default">Prev</button>
|
|
|
|
<button type="button" class="btn btn-default" v-for="pageNumber in pagesCount" v-on:click="fetchData(pageNumber)">{{ pageNumber }}</button>
|
|
|
|
<button type="button" class="btn btn-default">Next</button>
|
|
|
|
</div>
|
|
|
|
<div class="container">
|
|
|
|
<div class="items-per-page-form">Fotos per page: <input v-model="imagesPerPage">
|
|
|
|
<button type="button" class="btn btn-default" v-on:click="fetchData()">Update</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
2017-08-04 09:57:17 +03:00
|
|
|
|
2017-08-01 17:59:51 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var apiURL = '<%= url_for('get_images') %>'
|
2017-08-01 21:04:12 +03:00
|
|
|
var hostname = window.location.protocol+"//"+window.location.host;
|
2017-08-01 17:59:51 +03:00
|
|
|
|
|
|
|
var demo = new Vue({
|
|
|
|
|
|
|
|
el: '#images_list',
|
|
|
|
data: {
|
2017-08-04 09:57:17 +03:00
|
|
|
imagesList: null,
|
|
|
|
pageNumber: 1,
|
|
|
|
pagesCount: 5,
|
|
|
|
imagesPerPage: 20,
|
2017-08-01 17:59:51 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
created: function () {
|
2017-08-04 10:23:50 +03:00
|
|
|
this.fetchData(this.pageNumber)
|
2017-08-01 17:59:51 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2017-08-04 09:57:17 +03:00
|
|
|
fetchData: function (pageNumber) {
|
|
|
|
var xhr = new XMLHttpRequest()
|
|
|
|
var self = this
|
|
|
|
xhr.open('GET', apiURL+"?page="+pageNumber+"&per-page="+self.imagesPerPage)
|
|
|
|
xhr.onload = function () {
|
|
|
|
var result = JSON.parse(xhr.responseText);
|
|
|
|
self.imagesList = result.images_list;
|
2017-08-04 10:23:50 +03:00
|
|
|
console.dir(self.imagesList);
|
2017-08-04 09:57:17 +03:00
|
|
|
self.pagesCount = result.pages_count;
|
|
|
|
}
|
|
|
|
xhr.send()
|
2017-08-01 21:04:12 +03:00
|
|
|
},
|
|
|
|
copyText(event) {
|
2017-08-04 09:57:17 +03:00
|
|
|
//TODO: rewrite it to vue or pure JS from jQuery
|
2017-08-01 21:04:12 +03:00
|
|
|
var $temp = $("<input>");
|
|
|
|
$("body").append($temp);
|
2017-08-03 09:10:23 +03:00
|
|
|
$temp.val($(event.target).text().trim()).select();
|
2017-08-01 21:04:12 +03:00
|
|
|
document.execCommand("copy");
|
|
|
|
$temp.remove();
|
|
|
|
},
|
2017-08-01 17:59:51 +03:00
|
|
|
}
|
2017-08-01 21:04:12 +03:00
|
|
|
|
2017-08-04 09:57:17 +03:00
|
|
|
});
|
2017-08-01 17:59:51 +03:00
|
|
|
</script>
|