Add server side invalid document template
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
recently accessed documents from 40 to 400.
|
recently accessed documents from 40 to 400.
|
||||||
* Integrate django-autoadmin into the core apps.
|
* Integrate django-autoadmin into the core apps.
|
||||||
* Update middleware to new style classes.
|
* Update middleware to new style classes.
|
||||||
|
* Add server side invalid document template.
|
||||||
|
|
||||||
3.1.11 (2019-04-XX)
|
3.1.11 (2019-04-XX)
|
||||||
===================
|
===================
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ Other changes
|
|||||||
recently accessed documents from 40 to 400.
|
recently accessed documents from 40 to 400.
|
||||||
* Integrate django-autoadmin into the core apps.
|
* Integrate django-autoadmin into the core apps.
|
||||||
* Update middleware to new style classes.
|
* Update middleware to new style classes.
|
||||||
|
* Add server side invalid document template.
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
--------
|
--------
|
||||||
|
|||||||
@@ -6,23 +6,24 @@ class MayanImage {
|
|||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
static intialize () {
|
static intialize (options) {
|
||||||
var app = this;
|
this.options = options || {};
|
||||||
|
this.options.templateInvalidDocument = this.options.templateInvalidDocument || '<span>Error loading document image</span>';
|
||||||
|
|
||||||
this.fancybox = $().fancybox({
|
$().fancybox({
|
||||||
animationDuration : 300,
|
|
||||||
buttons : [
|
|
||||||
'fullScreen',
|
|
||||||
'close',
|
|
||||||
],
|
|
||||||
selector: 'a.fancybox',
|
|
||||||
afterShow: function (instance, current) {
|
afterShow: function (instance, current) {
|
||||||
$('a.a-caption').on('click', function(event) {
|
$('a.a-caption').on('click', function(event) {
|
||||||
instance.close(true);
|
instance.close(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
animationEffect: 'fade',
|
||||||
|
animationDuration : 100,
|
||||||
|
buttons : [
|
||||||
|
'fullScreen',
|
||||||
|
'close',
|
||||||
|
],
|
||||||
infobar: true,
|
infobar: true,
|
||||||
|
selector: 'a.fancybox'
|
||||||
});
|
});
|
||||||
|
|
||||||
$('img.lazy-load').lazyload({
|
$('img.lazy-load').lazyload({
|
||||||
@@ -42,46 +43,53 @@ class MayanImage {
|
|||||||
|
|
||||||
$('.lazy-load').one('load', function() {
|
$('.lazy-load').one('load', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$(this).fadeIn(300);
|
$(this).show();
|
||||||
$(this).siblings('.spinner-container').remove();
|
$(this).siblings('.spinner-container').remove();
|
||||||
$(this).removeClass('lazy-load pull-left');
|
$(this).removeClass('lazy-load pull-left');
|
||||||
clearTimeout(MayanImage.timer);
|
clearTimeout(MayanImage.timer);
|
||||||
MayanImage.timer = setTimeout(MayanImage.timerFunction, 100);
|
MayanImage.timer = setTimeout(MayanImage.timerFunction, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.lazy-load-carousel').one('load', function() {
|
$('.lazy-load-carousel').one('load', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$(this).fadeIn(300);
|
$(this).show();
|
||||||
$(this).siblings('.spinner-container').remove();
|
$(this).siblings('.spinner-container').remove();
|
||||||
$(this).removeClass('lazy-load-carousel pull-left');
|
$(this).removeClass('lazy-load-carousel pull-left');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static timerFunction () {
|
static timerFunction () {
|
||||||
$.fn.matchHeight._maintainScroll = true;
|
|
||||||
$.fn.matchHeight._update();
|
$.fn.matchHeight._update();
|
||||||
}
|
}
|
||||||
|
|
||||||
load () {
|
load () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this.element.parent().parent().parent();
|
var container = this.element.parent().parent().parent();
|
||||||
|
var dataURL = this.element.attr('data-url');
|
||||||
|
|
||||||
this.element.attr('src', this.element.attr('data-url'));
|
if (dataURL === '') {
|
||||||
this.element.on('error', function() {
|
container.html(MayanImage.options.templateInvalidDocument);
|
||||||
// Check the .complete property to see if it is a real error
|
} else {
|
||||||
// or it was a cached image
|
this.element.attr('src', dataURL);
|
||||||
if (this.complete === false) {
|
setTimeout(function () {
|
||||||
// It is a cached image, set the src attribute to trigger
|
self.element.on('error', function () {
|
||||||
// it's display.
|
// Check the .complete property to see if it is a real
|
||||||
this.src = this.src;
|
// error or it was a cached image
|
||||||
} else {
|
if (this.complete === false) {
|
||||||
container.html(MayanImage.templateInvalidDocument);
|
// It is a cached image, set the src attribute to
|
||||||
}
|
// trigger it's display.
|
||||||
});
|
this.src = dataURL;
|
||||||
|
} else {
|
||||||
$.fn.matchHeight._maintainScroll = true;
|
container.html(
|
||||||
|
MayanImage.options.templateInvalidDocument
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MayanImage.templateInvalidDocument = $('#template-invalid-document').html();
|
|
||||||
MayanImage.timer = setTimeout(null);
|
MayanImage.timer = setTimeout(null);
|
||||||
|
|
||||||
|
$.fn.matchHeight._maintainScroll = true;
|
||||||
|
|||||||
@@ -61,17 +61,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script id="template-invalid-document" type="text/x-template">
|
|
||||||
<div class="text-center" style="border: height: 100%;">
|
|
||||||
<div class="fa-3x">
|
|
||||||
<span class="fa-layers fa-fw">
|
|
||||||
<i class="far fa-file text-primary"></i>
|
|
||||||
<i class="fa-inverse fas fa-times text-danger" data-fa-transform="shrink-6"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script id="template-error" type="text/x-template">
|
<script id="template-error" type="text/x-template">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2 class="title">{% blocktrans %}Server communication error{% endblocktrans %}</h2>
|
<h2 class="title">{% blocktrans %}Server communication error{% endblocktrans %}</h2>
|
||||||
@@ -120,7 +109,9 @@
|
|||||||
var app = new MayanApp();
|
var app = new MayanApp();
|
||||||
|
|
||||||
var afterBaseLoad = function () {
|
var afterBaseLoad = function () {
|
||||||
MayanImage.intialize();
|
MayanImage.intialize({
|
||||||
|
templateInvalidDocument: '{% spaceless %}{% include "documents/invalid_document.html" %}{% endspaceless %}'
|
||||||
|
});
|
||||||
app.doToastrMessages();
|
app.doToastrMessages();
|
||||||
app.resizeFullHeight();
|
app.resizeFullHeight();
|
||||||
app.setupSelect2();
|
app.setupSelect2();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from mayan.apps.common import (
|
|||||||
MayanAppConfig, MissingItem, menu_facet, menu_main, menu_object,
|
MayanAppConfig, MissingItem, menu_facet, menu_main, menu_object,
|
||||||
menu_secondary, menu_setup, menu_sidebar, menu_multi_item, menu_tools
|
menu_secondary, menu_setup, menu_sidebar, menu_multi_item, menu_tools
|
||||||
)
|
)
|
||||||
from mayan.apps.common.classes import ModelField
|
from mayan.apps.common.classes import ModelField, Template
|
||||||
from mayan.apps.common.signals import post_initial_setup
|
from mayan.apps.common.signals import post_initial_setup
|
||||||
from mayan.apps.common.widgets import TwoStateWidget
|
from mayan.apps.common.widgets import TwoStateWidget
|
||||||
from mayan.apps.dashboards.dashboards import dashboard_main
|
from mayan.apps.dashboards.dashboards import dashboard_main
|
||||||
@@ -333,6 +333,11 @@ class DocumentsApp(MayanAppConfig):
|
|||||||
func=lambda context: context['object'].documents.count()
|
func=lambda context: context['object'].documents.count()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Template(
|
||||||
|
name='invalid_document',
|
||||||
|
template_name='documents/invalid_document.html'
|
||||||
|
)
|
||||||
|
|
||||||
app.conf.CELERYBEAT_SCHEDULE.update(
|
app.conf.CELERYBEAT_SCHEDULE.update(
|
||||||
{
|
{
|
||||||
'task_check_delete_periods': {
|
'task_check_delete_periods': {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{% spaceless %}
|
||||||
|
<div class="text-center" style="border: height: 100%;">
|
||||||
|
<div class="fa-4x">
|
||||||
|
<span class="fa-layers fa-fw">
|
||||||
|
<i class="far fa-file text-primary"></i>
|
||||||
|
<i class="fas fa-times text-danger" data-fa-transform="shrink-8"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endspaceless %}
|
||||||
|
|
||||||
Reference in New Issue
Block a user