diff --git a/system/typemill/Controllers/ControllerApiImage.php b/system/typemill/Controllers/ControllerApiImage.php index a444560..a545470 100644 --- a/system/typemill/Controllers/ControllerApiImage.php +++ b/system/typemill/Controllers/ControllerApiImage.php @@ -72,7 +72,6 @@ class ControllerApiImage extends Controller { $url = $request->getQueryParams()['url'] ?? false; $path = $request->getQueryParams()['path'] ?? false; - $pagemedia = []; $storage = new StorageWrapper('\Typemill\Models\Storage'); diff --git a/system/typemill/Models/Storage.php b/system/typemill/Models/Storage.php index deef47d..c0c1a03 100644 --- a/system/typemill/Models/Storage.php +++ b/system/typemill/Models/Storage.php @@ -490,33 +490,33 @@ class Storage ## Timeout ## ###################### - public function timeoutIsOver($name, $timespan) - { - $location = 'cacheFolder'; - $folder = ''; - $filename = 'timer.yaml'; + public function timeoutIsOver($name, $timespan) + { + $location = 'cacheFolder'; + $folder = ''; + $filename = 'timer.yaml'; - // Get current timers from the YAML file, if it exists - $timers = $this->getYaml($location, $folder, $filename) ?: []; + // Get current timers from the YAML file, if it exists + $timers = $this->getYaml($location, $folder, $filename) ?: []; - $currentTime = time(); - $timeThreshold = $currentTime - $timespan; + $currentTime = time(); + $timeThreshold = $currentTime - $timespan; - # Check if the name exists and if the timestamp is older than the current time minus the timespan - if (!isset($timers[$name]) || !is_numeric($timers[$name]) || $timers[$name] <= $timeThreshold) - { - # If the name doesn't exist or the timestamp is older, update the timer - $timers[$name] = $currentTime; + # Check if the name exists and if the timestamp is older than the current time minus the timespan + if (!isset($timers[$name]) || !is_numeric($timers[$name]) || $timers[$name] <= $timeThreshold) + { + # If the name doesn't exist or the timestamp is older, update the timer + $timers[$name] = $currentTime; - # Update the YAML file with the new or updated timer - $this->updateYaml($location, $folder, $filename, $timers); + # Update the YAML file with the new or updated timer + $this->updateYaml($location, $folder, $filename, $timers); - return true; - } + return true; + } - # If the name exists and the timestamp is not older, return false - return false; - } + # If the name exists and the timestamp is not older, return false + return false; + } ################## @@ -663,22 +663,18 @@ class Storage foreach ($thumbs as $key => $name) { - if (file_exists($this->liveFolder . $name)) - { - $imagelist[] = [ - 'name' => $name, - 'timestamp' => filemtime($this->liveFolder . $name), - 'src_thumb' => 'media/thumbs/' . $name, - 'src_live' => 'media/live/' . $name, - ]; - } + $imagelist[] = [ + 'name' => $name, + 'src_thumb' => 'media/thumbs/' . $name, + 'src_live' => 'media/live/' . $name, + ]; } - $imagelist = Helpers::array_sort($imagelist, 'timestamp', SORT_DESC); - return $imagelist; } + + # get details from existing image for media library public function getImageDetails($name) { diff --git a/system/typemill/author/css/output.css b/system/typemill/author/css/output.css index e1b8743..3fe3ce1 100644 --- a/system/typemill/author/css/output.css +++ b/system/typemill/author/css/output.css @@ -694,14 +694,6 @@ video { right: 0px; } -.-bottom-3 { - bottom: -0.75rem; -} - -.right-4 { - right: 1rem; -} - .-top-3 { top: -0.75rem; } @@ -710,6 +702,14 @@ video { left: 50%; } +.-bottom-3 { + bottom: -0.75rem; +} + +.right-4 { + right: 1rem; +} + .bottom-3 { bottom: 0.75rem; } @@ -718,14 +718,14 @@ video { top: 2.5rem; } -.z-20 { - z-index: 20; -} - .z-10 { z-index: 10; } +.z-20 { + z-index: 20; +} + .z-50 { z-index: 50; } @@ -738,14 +738,14 @@ video { margin: 0px; } -.m-1 { - margin: 0.25rem; -} - .m-auto { margin: auto; } +.m-1 { + margin: 0.25rem; +} + .my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; @@ -771,16 +771,16 @@ video { margin-bottom: 2rem; } -.my-3 { - margin-top: 0.75rem; - margin-bottom: 0.75rem; -} - .my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; } +.my-3 { + margin-top: 0.75rem; + margin-bottom: 0.75rem; +} + .my-4 { margin-top: 1rem; margin-bottom: 1rem; @@ -942,6 +942,10 @@ video { height: 20rem; } +.h-8 { + height: 2rem; +} + .h-full { height: 100%; } @@ -950,10 +954,6 @@ video { height: 8rem; } -.h-8 { - height: 2rem; -} - .h-0 { height: 0px; } @@ -1002,10 +1002,6 @@ video { width: 40%; } -.w-20 { - width: 5rem; -} - .w-16 { width: 4rem; } @@ -1014,6 +1010,10 @@ video { width: 1.25rem; } +.w-20 { + width: 5rem; +} + .w-1\/4 { width: 25%; } @@ -1046,10 +1046,6 @@ video { width: 60%; } -.w-half { - width: 48%; -} - .w-3\/4 { width: 75%; } @@ -1070,6 +1066,10 @@ video { width: 91.666667%; } +.w-7 { + width: 1.75rem; +} + .max-w-md { max-width: 28rem; } @@ -1102,10 +1102,6 @@ video { flex-grow: 1; } -.grow { - flex-grow: 1; -} - .border-collapse { border-collapse: collapse; } @@ -1488,14 +1484,14 @@ video { padding: 2rem; } -.p-4 { - padding: 1rem; -} - .p-1 { padding: 0.25rem; } +.p-4 { + padding: 1rem; +} + .py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; @@ -1666,6 +1662,10 @@ video { padding-top: 0.75rem; } +.pb-1 { + padding-bottom: 0.25rem; +} + .text-left { text-align: left; } @@ -1715,6 +1715,11 @@ video { line-height: 1.25rem; } +.text-2xl { + font-size: 1.5rem; + line-height: 2rem; +} + .text-lg { font-size: 1.125rem; line-height: 1.75rem; @@ -1725,11 +1730,6 @@ video { line-height: 2.25rem; } -.text-2xl { - font-size: 1.5rem; - line-height: 2rem; -} - .font-bold { font-weight: 700; } @@ -1978,16 +1978,16 @@ video { background-color: rgb(244 63 94 / var(--tw-bg-opacity)); } -.hover\:bg-stone-700:hover { - --tw-bg-opacity: 1; - background-color: rgb(68 64 60 / var(--tw-bg-opacity)); -} - .hover\:bg-stone-100:hover { --tw-bg-opacity: 1; background-color: rgb(245 245 244 / var(--tw-bg-opacity)); } +.hover\:bg-stone-700:hover { + --tw-bg-opacity: 1; + background-color: rgb(68 64 60 / var(--tw-bg-opacity)); +} + .hover\:bg-stone-900:hover { --tw-bg-opacity: 1; background-color: rgb(28 25 23 / var(--tw-bg-opacity)); @@ -2097,16 +2097,16 @@ video { background-color: rgb(231 229 228 / var(--tw-bg-opacity)); } -.disabled\:text-stone-800:disabled { - --tw-text-opacity: 1; - color: rgb(41 37 36 / var(--tw-text-opacity)); -} - .disabled\:text-stone-900:disabled { --tw-text-opacity: 1; color: rgb(28 25 23 / var(--tw-text-opacity)); } +.disabled\:text-stone-800:disabled { + --tw-text-opacity: 1; + color: rgb(41 37 36 / var(--tw-text-opacity)); +} + .group:hover .group-hover\:visible { visibility: visible; } @@ -2214,16 +2214,16 @@ video { background-color: rgb(244 63 94 / var(--tw-bg-opacity)); } -.dark .hover\:dark\:bg-stone-600:hover { - --tw-bg-opacity: 1; - background-color: rgb(87 83 78 / var(--tw-bg-opacity)); -} - .dark .hover\:dark\:bg-stone-900:hover { --tw-bg-opacity: 1; background-color: rgb(28 25 23 / var(--tw-bg-opacity)); } +.dark .hover\:dark\:bg-stone-600:hover { + --tw-bg-opacity: 1; + background-color: rgb(87 83 78 / var(--tw-bg-opacity)); +} + .dark .dark\:hover\:bg-stone-200:hover { --tw-bg-opacity: 1; background-color: rgb(231 229 228 / var(--tw-bg-opacity)); diff --git a/system/typemill/author/js/vue-medialib.js b/system/typemill/author/js/vue-medialib.js index b9fb4b8..8c4fab4 100644 --- a/system/typemill/author/js/vue-medialib.js +++ b/system/typemill/author/js/vue-medialib.js @@ -1,578 +1,618 @@ const medialib = { - props: ['parentcomponent'], - template: `
-
-
-
-
- -
- - - -
-
-
-
-

Images

-
- - -
-
-
-

Files

-
- - -
-
-
-
-
{{errors}}
-
- -
- - - - - click to select - - -
-
{{ image.name }}
-
- - -
-
-
-
-
- -
-
-
-
- -
-
-
-
Name
-
{{ imagedetaildata.name}}
-
URL
-
{{ getImageUrl(imagedetaildata.src_live)}}
-
-
-
Size
-
{{ getSize(imagedetaildata.bytes) }}
-
-
-
Dimensions
-
{{ imagedetaildata.width }}x{{ imagedetaildata.height }} px
-
-
-
Type
-
{{ imagedetaildata.type }}
-
-
-
Date
-
{{ getDate(imagedetaildata.timestamp) }}
-
-
-
- - -
-
- -
-
-
-
- -
- -
{{ file.info.extension }}
- - - - click to select - -
-
-
{{ file.name }}
-
- - -
-
-
-
-
- -
-
-
-
-
{{ filedetaildata.info.extension }}
-
-
-
-
Name
-
{{ filedetaildata.name}}
-
URL
-
{{ filedetaildata.url }}
-
-
-
Size
-
{{ getSize(filedetaildata.bytes) }}
-
-
-
Type
-
{{ filedetaildata.info.extension }}
-
-
-
Date
-
{{ getDate(filedetaildata.timestamp) }}
-
-
-
- - -
-
- -
-
-
-
-
-
`, - data: function(){ - return { - active: false, - imagedata: false, - pagemedia: false, - showimages: true, - imagedetaildata: false, - showimagedetails: false, - filedata: false, - showfiles: false, - filedetaildata: false, - showfiledetails: false, - detailindex: false, - load: false, - adminurl: false, - baseurl: data.urlinfo.baseurl, - search: '', - errors: false, - } - }, - mounted: function(){ + props: ['parentcomponent'], + template: `
+
+
+
+
+ +
+ + + +
+
+
+
+

Images

+
+ + +
+
+
+

Files

+
+ + +
+
- this.errors = false; +
+

Pagination

+
    +
  • + +
  • +
+
- var self = this; +
+
+
{{errors}}
+
+ +
+ + + + + click to select + + +
+
{{ image.name }}
+
+ + +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
Name
+
{{ imagedetaildata.name}}
+
URL
+
{{ getImageUrl(imagedetaildata.src_live)}}
+
+
+
Size
+
{{ getSize(imagedetaildata.bytes) }}
+
+
+
Dimensions
+
{{ imagedetaildata.width }}x{{ imagedetaildata.height }} px
+
+
+
Type
+
{{ imagedetaildata.type }}
+
+
+
Date
+
{{ getDate(imagedetaildata.timestamp) }}
+
+
+
+ + +
+
+ +
+
+
+
+ +
+ +
{{ file.info.extension }}
+ + + + click to select + +
+
+
{{ file.name }}
+
+ + +
+
+
+
+
+ +
+
+
+
+
{{ filedetaildata.info.extension }}
+
+
+
+
Name
+
{{ filedetaildata.name}}
+
URL
+
{{ filedetaildata.url }}
+
+
+
Size
+
{{ getSize(filedetaildata.bytes) }}
+
+
+
Type
+
{{ filedetaildata.info.extension }}
+
+
+
Date
+
{{ getDate(filedetaildata.timestamp) }}
+
+
+
+ + +
+
+ +
+
+
+
+
+
`, + data: function(){ + return { + active: false, + imagedata: false, + pagemedia: false, + showimages: true, + imagedetaildata: false, + showimagedetails: false, + filedata: false, + showfiles: false, + filedetaildata: false, + showfiledetails: false, + detailindex: false, + load: false, + adminurl: false, + baseurl: data.urlinfo.baseurl, + search: '', + errors: false, + currentPage: 1, + totalPages: 0, + itemsPerPage: 15, + } + }, + mounted: function(){ - var itempath = false; - if(typeof data.item !== "undefined") - { - itempath = data.item.pathWithoutType; - } + this.errors = false; - tmaxios.get('/api/v1/pagemedia',{ - params: { - 'url': data.urlinfo.route, - 'path': itempath - } - }) - .then(function (response) - { - self.pagemedia = response.data.pagemedia; - }) - .catch(function (error) - { - if(error.response) - { - self.errors = error.response.data.errors; - } - }); + var self = this; - if(this.parentcomponent == 'files') - { - this.showFiles(); - this.active = 'pageFiles'; - } - if(this.parentcomponent == 'images') - { - this.showImages(); - this.active = 'pageImages'; - } - }, - computed: { - filteredImages() { + var itempath = false; + if(typeof data.item !== "undefined") + { + itempath = data.item.pathWithoutType; + } - var searchimages = this.search; - var filteredImages = {}; - var images = this.imagedata; - var pagemedia = this.pagemedia; - var active = this.active; + tmaxios.get('/api/v1/pagemedia',{ + params: { + 'url': data.urlinfo.route, + 'path': itempath + } + }) + .then(function (response) + { + self.pagemedia = response.data.pagemedia; + }) + .catch(function (error) + { + if(error.response) + { + self.errors = error.response.data.errors; + } + }); - if(images) - { - if(active == 'pageImages') - { - Object.keys(images).forEach(function(key) { - var imagename = images[key].name; - if(pagemedia.indexOf(imagename) !== -1) - { - filteredImages[key] = images[key]; - } - }); - } - else - { - Object.keys(images).forEach(function(key) { - var searchindex = key + ' ' + images[key].name; - if(searchindex.toLowerCase().indexOf(searchimages.toLowerCase()) !== -1) - { - filteredImages[key] = images[key]; - } - }); - } - } - return filteredImages; - }, - filteredFiles() { + if(this.parentcomponent == 'files') + { + this.showFiles(); + this.active = 'pageFiles'; + } + if(this.parentcomponent == 'images') + { + this.showImages(); + this.active = 'pageImages'; + } + }, + computed: { + filteredImages() { - var searchfiles = this.search; - var filteredFiles = {}; - var files = this.filedata; - var pagemedia = this.pagemedia; - var active = this.active; + var searchimages = this.search; + var filteredImages = {}; + var images = this.imagedata; + var pagemedia = this.pagemedia; + var active = this.active; - if(files) - { - if(active == 'pageFiles') - { - Object.keys(files).forEach(function(key) { - var filename = files[key].name; - if(pagemedia.indexOf(filename) !== -1) - { - filteredFiles[key] = files[key]; - } - }); - } - else - { - Object.keys(files).forEach(function(key) { - var searchindex = key + ' ' + files[key].name; - if(searchindex.toLowerCase().indexOf(searchfiles.toLowerCase()) !== -1) - { - filteredFiles[key] = files[key]; - } - }); - } - } - return filteredFiles; - }, - }, - methods: { - isActive(activestring) - { - if(this.active == activestring) - { - return 'bg-stone-700 dark:bg-stone-900 text-stone-50'; - } - return 'bg-stone-200 dark:bg-stone-600'; - }, - getBackgroundImage(image) - { - return 'background-image: url(' + this.baseurl + '/' + image.src_thumb + ');width:250px'; - }, - getImageUrl(relativeUrl) - { - return this.baseurl + '/' + relativeUrl; - }, - showImages(pagesOrAll) - { - this.active = pagesOrAll; - this.errors = false; - this.showimages = true; - this.showfiles = false; - this.showimagedetails = false; - this.showfiledetails = false; - this.imagedetaildata = false; - this.detailindex = false; - - if(!this.imagedata) - { - this.errors = false; + if(images) + { + if(active == 'pageImages') + { + Object.keys(images).forEach(function(key) { + var imagename = images[key].name; + if(pagemedia.indexOf(imagename) !== -1) + { + filteredImages[key] = images[key]; + } + }); + } + else if(searchimages != '') + { + Object.keys(images).forEach(function(key) { + var searchindex = key + ' ' + images[key].name; + if(searchindex.toLowerCase().indexOf(searchimages.toLowerCase()) !== -1) + { + filteredImages[key] = images[key]; + } + }); + } + else + { + const startIndex = (this.currentPage - 1) * this.itemsPerPage; + const endIndex = this.currentPage * this.itemsPerPage; + filteredImages = this.imagedata.slice(startIndex, endIndex); + } + } - var imageself = this; + return filteredImages; + }, + filteredFiles() { - var itempath = false; - if(typeof data.item !== "undefined") - { - itempath = data.item.pathWithoutType; - } - tmaxios.get('/api/v1/images',{ - params: { - 'url': data.urlinfo.route, - 'path': itempath, - } - }) - .then(function (response) - { - imageself.imagedata = response.data.images; - }) - .catch(function (error) - { - if(error.response) - { - let message = handleErrorMessage(error); - if(message) - { - eventBus.$emit('publishermessage', message); - } + var searchfiles = this.search; + var filteredFiles = {}; + var files = this.filedata; + var pagemedia = this.pagemedia; + var active = this.active; - imageself.errors = error.response.data.errors; + if(files) + { + if(active == 'pageFiles') + { + Object.keys(files).forEach(function(key) { + var filename = files[key].name; + if(pagemedia.indexOf(filename) !== -1) + { + filteredFiles[key] = files[key]; + } + }); + } + else + { + Object.keys(files).forEach(function(key) { + var searchindex = key + ' ' + files[key].name; + if(searchindex.toLowerCase().indexOf(searchfiles.toLowerCase()) !== -1) + { + filteredFiles[key] = files[key]; + } + }); + } + } + return filteredFiles; + }, + }, + methods: { + setCurrentImages() + { + const startIndex = (this.currentPage - 1) * this.itemsPerPage; + const endIndex = this.currentPage * this.itemsPerPage; + this.currentImages = this.imagedata.slice(startIndex, endIndex); + }, + calculateTotalPages() + { + this.totalPages = Math.ceil(this.imagedata.length / this.itemsPerPage); + }, + goToPage(num) + { + this.currentPage = num; + }, + isActive(activestring) + { + if(this.active == activestring) + { + return 'bg-stone-700 dark:bg-stone-900 text-stone-50'; + } + return 'bg-stone-200 dark:bg-stone-600'; + }, + getBackgroundImage(image) + { + return 'background-image: url(' + this.baseurl + '/' + image.src_thumb + ');width:250px'; + }, + getImageUrl(relativeUrl) + { + return this.baseurl + '/' + relativeUrl; + }, + showImages(pagesOrAll) + { + this.active = pagesOrAll; + this.errors = false; + this.showimages = true; + this.showfiles = false; + this.showimagedetails = false; + this.showfiledetails = false; + this.imagedetaildata = false; + this.detailindex = false; + + if(!this.imagedata) + { + this.errors = false; - } - }); - } - }, - showFiles(pagesOrAll) - { - this.active = pagesOrAll; - this.showimages = false; - this.showfiles = true; - this.showimagedetails = false; - this.showfiledetails = false; - this.imagedetaildata = false; - this.filedetaildata = false; - this.detailindex = false; + var imageself = this; - if(!this.filedata) - { - this.errors = false; - var filesself = this; + var itempath = false; + if(typeof data.item !== "undefined") + { + itempath = data.item.pathWithoutType; + } + tmaxios.get('/api/v1/images',{ + params: { + 'url': data.urlinfo.route, + 'path': itempath, + } + }) + .then(function (response) + { + imageself.imagedata = response.data.images; + imageself.calculateTotalPages(); + imageself.setCurrentImages(); + }) + .catch(function (error) + { + if(error.response) + { + let message = handleErrorMessage(error); + if(message) + { + eventBus.$emit('publishermessage', message); + } - tmaxios.get('/api/v1/files',{ - params: { - 'url': data.urlinfo.route, - } - }) - .then(function (response) - { - filesself.filedata = response.data.files; - }) - .catch(function (error) - { - if(error.response) - { - let message = handleErrorMessage(error); - if(message) - { - eventBus.$emit('publishermessage', message); - } + imageself.errors = error.response.data.errors; - fileself.errors = error.response.data.errors; - } - }); - } - }, - showImageDetails(image,index) - { - this.errors = false; - this.showimages = false; - this.showfiles = false; - this.showimagedetails = true; - this.showfiledetails = false; - this.detailindex = index; - this.adminurl = this.baseurl + '/tm/content/visual'; + } + }); + } + }, + showFiles(pagesOrAll) + { + this.active = pagesOrAll; + this.showimages = false; + this.showfiles = true; + this.showimagedetails = false; + this.showfiledetails = false; + this.imagedetaildata = false; + this.filedetaildata = false; + this.detailindex = false; - var imageself = this; + if(!this.filedata) + { + this.errors = false; + var filesself = this; - tmaxios.get('/api/v1/image',{ - params: { - 'url': data.urlinfo.route, - 'name': image.name, - } - }) - .then(function (response) - { - imageself.imagedetaildata = response.data.image; - }) - .catch(function (error) - { - if(error.response) - { - let message = handleErrorMessage(error); - if(message) - { - eventBus.$emit('publishermessage', message); - } + tmaxios.get('/api/v1/files',{ + params: { + 'url': data.urlinfo.route, + } + }) + .then(function (response) + { + filesself.filedata = response.data.files; + }) + .catch(function (error) + { + if(error.response) + { + let message = handleErrorMessage(error); + if(message) + { + eventBus.$emit('publishermessage', message); + } - imageself.errors = error.response.data.errors; + fileself.errors = error.response.data.errors; + } + }); + } + }, + showImageDetails(image,index) + { + this.errors = false; + this.showimages = false; + this.showfiles = false; + this.showimagedetails = true; + this.showfiledetails = false; + this.detailindex = index; + this.adminurl = this.baseurl + '/tm/content/visual'; - } - }); - }, - showFileDetails(file,index) - { - this.errors = false; - this.showimages = false; - this.showfiles = false; - this.showimagedetails = false; - this.showfiledetails = true; - this.filedetaildata = file; - this.detailindex = index; - this.adminurl = this.baseurl + '/tm/content/visual'; - }, - selectImage(image) - { - this.$emit('addFromMedialibEvent', image.src_live); - }, - selectFile(file) - { - let extension = file.info.extension.toUpperCase(); - let size = this.getSize(file.bytes); - file.name = file.name + ' (' + extension + ', ' + size + ')'; + var imageself = this; - this.$emit('addFromMedialibEvent', file); - }, - removeImage(index) - { - this.imagedata.splice(index,1); - }, - removeFile(index) - { - this.filedata.splice(index,1); - }, - deleteImage(image, index) - { - imageself = this; + tmaxios.get('/api/v1/image',{ + params: { + 'url': data.urlinfo.route, + 'name': image.name, + } + }) + .then(function (response) + { + imageself.imagedetaildata = response.data.image; + }) + .catch(function (error) + { + if(error.response) + { + let message = handleErrorMessage(error); + if(message) + { + eventBus.$emit('publishermessage', message); + } - tmaxios.delete('/api/v1/image',{ - data: { - 'url': data.urlinfo.route, - 'name': image.name, - 'index': index, - } - }) - .then(function (response) - { - imageself.showImages(); - imageself.removeImage(index); - }) - .catch(function (error) - { - if(error.response) - { - let message = handleErrorMessage(error); - if(message) - { - eventBus.$emit('publishermessage', message); - } + imageself.errors = error.response.data.errors; - imageself.errors = error.response.data.errors; + } + }); + }, + showFileDetails(file,index) + { + this.errors = false; + this.showimages = false; + this.showfiles = false; + this.showimagedetails = false; + this.showfiledetails = true; + this.filedetaildata = file; + this.detailindex = index; + this.adminurl = this.baseurl + '/tm/content/visual'; + }, + selectImage(image) + { + this.$emit('addFromMedialibEvent', image.src_live); + }, + selectFile(file) + { + let extension = file.info.extension.toUpperCase(); + let size = this.getSize(file.bytes); + file.name = file.name + ' (' + extension + ', ' + size + ')'; - } - }); - }, - deleteFile(file, index) - { - fileself = this; + this.$emit('addFromMedialibEvent', file); + }, + removeImage(index) + { + this.imagedata.splice(index,1); + }, + removeFile(index) + { + this.filedata.splice(index,1); + }, + deleteImage(image, index) + { + imageself = this; - tmaxios.delete('/api/v1/file',{ - data: { - 'url': data.urlinfo.route, - 'name': file.name, - 'index': index, - } - }) - .then(function (response) - { - fileself.showFiles(); - fileself.removeFile(index); - }) - .catch(function (error) - { - if(error.response) - { - let message = handleErrorMessage(error); - if(message) - { - eventBus.$emit('publishermessage', message); - } + tmaxios.delete('/api/v1/image',{ + data: { + 'url': data.urlinfo.route, + 'name': image.name, + 'index': index, + } + }) + .then(function (response) + { + imageself.showImages(); + imageself.removeImage(index); + }) + .catch(function (error) + { + if(error.response) + { + let message = handleErrorMessage(error); + if(message) + { + eventBus.$emit('publishermessage', message); + } - fileself.errors = error.response.data.errors; + imageself.errors = error.response.data.errors; - } - }); - }, - getDate(timestamp) - { - date = new Date(timestamp * 1000); - - datevalues = { - 'year': date.getFullYear(), - 'month': date.getMonth()+1, - 'day': date.getDate(), - 'hour': date.getHours(), - 'minute': date.getMinutes(), - 'second': date.getSeconds(), - }; - return datevalues.year + '-' + datevalues.month + '-' + datevalues.day; - }, - getSize(bytes) - { - var i = Math.floor(Math.log(bytes) / Math.log(1024)), - sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + } + }); + }, + deleteFile(file, index) + { + fileself = this; - return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i]; - }, - isChecked(classname) - { - if(this.imgclass == classname) - { - return ' checked'; - } - }, - }, + tmaxios.delete('/api/v1/file',{ + data: { + 'url': data.urlinfo.route, + 'name': file.name, + 'index': index, + } + }) + .then(function (response) + { + fileself.showFiles(); + fileself.removeFile(index); + }) + .catch(function (error) + { + if(error.response) + { + let message = handleErrorMessage(error); + if(message) + { + eventBus.$emit('publishermessage', message); + } + + fileself.errors = error.response.data.errors; + + } + }); + }, + getDate(timestamp) + { + date = new Date(timestamp * 1000); + + datevalues = { + 'year': date.getFullYear(), + 'month': date.getMonth()+1, + 'day': date.getDate(), + 'hour': date.getHours(), + 'minute': date.getMinutes(), + 'second': date.getSeconds(), + }; + return datevalues.year + '-' + datevalues.month + '-' + datevalues.day; + }, + getSize(bytes) + { + var i = Math.floor(Math.log(bytes) / Math.log(1024)), + sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i]; + }, + isChecked(classname) + { + if(this.imgclass == classname) + { + return ' checked'; + } + }, + }, } \ No newline at end of file diff --git a/system/typemill/settings/defaults.yaml b/system/typemill/settings/defaults.yaml index 53aa319..ee85890 100644 --- a/system/typemill/settings/defaults.yaml +++ b/system/typemill/settings/defaults.yaml @@ -1,4 +1,4 @@ -version: '2.2.2' +version: '2.3.0' title: 'Typemill' author: 'Unknown' copyright: false