Skip to content

Commit

Permalink
Revert unnecessary commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kavitha-sundararajan committed Apr 4, 2024
1 parent 693c8ca commit de739bb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ui/app/common/domain/services/visitDocumentService.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('bahmni.common.domain')
.service('visitDocumentService', ['$http', 'auditLogService', 'configurations', '$q', function ($http, auditLogService, configurations, $q) {
.service('visitDocumentService', ['$http', 'auditLogService', 'configurations', '$q', 'messagingService', '$translate', function ($http, auditLogService, configurations, $q, messagingService, $translate) {
var removeVoidedDocuments = function (documents) {
documents.forEach(function (document) {
if (document.voided && document.image) {
Expand Down Expand Up @@ -54,13 +54,25 @@ angular.module('bahmni.common.domain')
return response;
}, function (error) {
if (error.status === 413) {
var maxAllowedSize = roundToNearestHalf(error.data.maxDocumentSizeMB * 0.70);
messagingService.showMessage("error", $translate.instant("FILE_SIZE_LIMIT_EXCEEDED_MESSAGE", { maxAllowedSize: maxAllowedSize }));
if (!isNaN(error.data.maxDocumentSizeMB)) {
var maxAllowedSize = roundToNearestHalf(error.data.maxDocumentSizeMB * 0.70);
messagingService.showMessage("error", $translate.instant("FILE_SIZE_LIMIT_EXCEEDED_MESSAGE", { maxAllowedSize: maxAllowedSize }));
} else {
messagingService.showMessage("error", $translate.instant("SIZE_LIMIT_EXCEEDED_MESSAGE"));
}
}
return $q.reject(error);
});
};

var roundToNearestHalf = function (value) {
var floorValue = Math.floor(value);
if ((value - floorValue) < 0.5) {
return floorValue;
}
return floorValue + 0.5;
};

this.getFileType = function (fileType) {
var pdfType = "pdf";
var imageType = "image";
Expand All @@ -72,4 +84,4 @@ angular.module('bahmni.common.domain')
}
return "not_supported";
};
}]);
}]);

0 comments on commit de739bb

Please sign in to comment.