-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0300cdb
commit f2358a7
Showing
13 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
angular.module('bhima.services') | ||
.service('DownloadLinkService', DownloadLinkService); | ||
|
||
// dependencies injection | ||
DownloadLinkService.$inject = []; | ||
|
||
// service definition | ||
function DownloadLinkService() { | ||
const service = this; | ||
|
||
const typeMime = { | ||
aac : 'audio/aac', | ||
abw : 'application/x-abiword', | ||
arc : 'application/octet-stream', | ||
avi : 'video/x-msvideo', | ||
azw : 'application/vnd.amazon.ebook', | ||
bin : 'application/octet-stream', | ||
bmp : 'image/bmp', | ||
bz : 'application/x-bzip', | ||
bz2 : 'application/x-bzip2', | ||
csh : 'application/x-csh', | ||
css : 'text/css', | ||
csv : 'text/csv', | ||
doc : 'application/msword', | ||
docx : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | ||
eot : 'application/vnd.ms-fontobject', | ||
epub : 'application/epub+zip', | ||
gif : 'image/gif', | ||
html : 'text/html', | ||
ico : 'image/x-icon', | ||
ics : 'text/calendar', | ||
jar : 'application/java-archive', | ||
jpeg : 'image/jpeg', | ||
jpg : 'image/jpeg', | ||
js : 'application/javascript', | ||
json : 'application/json', | ||
midi : 'audio/midi', | ||
mpeg : 'video/mpeg', | ||
mpkg : 'application/vnd.apple.installer+xml', | ||
odp : 'application/vnd.oasis.opendocument.presentation', | ||
ods : 'application/vnd.oasis.opendocument.spreadsheet', | ||
odt : 'application/vnd.oasis.opendocument.text', | ||
oga : 'audio/ogg', | ||
ogv : 'video/ogg', | ||
ogx : 'application/ogg', | ||
otf : 'font/otf', | ||
png : 'image/png', | ||
pdf : 'application/pdf', | ||
ppt : 'application/vnd.ms-powerpoint', | ||
pptx : 'application/vnd.openxmlformats-officedocument.presentationml.presentation', | ||
rar : 'application/x-rar-compressed', | ||
rtf : 'application/rtf', | ||
sh : 'application/x-sh', | ||
svg : 'image/svg+xml', | ||
swf : 'application/x-shockwave-flash', | ||
tar : 'application/x-tar', | ||
tiff : 'image/tiff', | ||
tif : 'image/tiff', | ||
ts : 'application/typescript', | ||
ttf : 'font/ttf', | ||
vsd : 'application/vnd.visio', | ||
wav : 'audio/x-wav', | ||
weba : 'audio/webm', | ||
webm : 'video/webm', | ||
webp : 'image/webp', | ||
woff : 'font/woff', | ||
woff2 : 'font/woff2', | ||
xhtml : 'application/xhtml+xml', | ||
xls : 'application/vnd.ms-excel', | ||
xlsx : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
xml : 'application/xml', | ||
xul : 'application/vnd.mozilla.xul+xml', | ||
zip : 'application/zip', | ||
'3gp' : 'video/3gpp', | ||
'7z' : 'application/x-7z-compressed', | ||
}; | ||
|
||
/** | ||
* Download on the client file served by the server | ||
* @param {stream} data binary stream of the file | ||
* @param {string} type the mime type extension of the file | ||
* @param {string} filename the name of the file withour the extension | ||
*/ | ||
service.download = (data, type, filename = 'fichier') => { | ||
const name = (filename || 'fichier').concat('.', type); | ||
const file = new Blob([data], { type : typeMime[type] || 'application/octet-stream' }); | ||
|
||
const url = window.URL || window.webkitURL; | ||
|
||
const downloadLink = angular.element('<a></a>'); | ||
downloadLink.attr('href', url.createObjectURL(file)); | ||
downloadLink.attr('target', '_self'); | ||
downloadLink.attr('download', name); | ||
downloadLink[0].click(); | ||
}; | ||
|
||
return service; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
client/src/modules/stock/entry/modals/generateTags.modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<form | ||
name="GenerateTagNumbersForm" | ||
bh-submit="$ctrl.submit(GenerateTagNumbersForm)" | ||
novalidate> | ||
|
||
<div class="modal-header"> | ||
<ol class="headercrumb"> | ||
<li class="static"> | ||
<i class="fa fa-barcode"></i> | ||
<span translate>STOCK.GENERATE_TAG_NUMBERS</span> | ||
</li> | ||
</ol> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<div class="form-group"> | ||
<label for="totalTags" translate>FORM.LABELS.NUMBER_OF_TAGS</label> | ||
<input | ||
name="totalTags" | ||
type="number" | ||
step="1" | ||
class="form-control" | ||
ng-model="$ctrl.totalTags" | ||
translate-attr="{ 'placeholder' : 'FORM.PLACEHOLDERS.TAG_NUMBER_TO_GENERATE' }"> | ||
<p class="form-text text-muted" translate>FORM.INFO.TAG_NUMBERS_TO_GENERATE</p> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" ng-click="$ctrl.cancel()" data-method="cancel" translate> | ||
FORM.BUTTONS.CLOSE | ||
</button> | ||
|
||
<bh-loading-button loading-state="GenerateTagNumbersForm.$loading"> | ||
<span translate>FORM.BUTTONS.SUBMIT</span> | ||
</bh-loading-button> | ||
</div> | ||
</form> |
32 changes: 32 additions & 0 deletions
32
client/src/modules/stock/entry/modals/generateTags.modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
angular.module('bhima.controllers') | ||
.controller('GenerateTagsModalController', GenerateTagsModalController); | ||
|
||
GenerateTagsModalController.$inject = [ | ||
'$uibModalInstance', 'NotifyService', | ||
'LotService', 'DownloadLinkService', | ||
]; | ||
|
||
function GenerateTagsModalController(Instance, Notify, Lots, DownloadLink) { | ||
const vm = this; | ||
|
||
vm.cancel = cancel; | ||
vm.submit = submit; | ||
|
||
// submit | ||
function submit() { | ||
if (vm.totalTags <= 0 || !vm.totalTags) { return null; } | ||
|
||
return Lots.generateTags(vm.totalTags) | ||
.then(file => { | ||
DownloadLink.download(file, 'csv', 'barcodes'); | ||
|
||
Instance.close(); | ||
}) | ||
.catch(Notify.errorHandler); | ||
} | ||
|
||
// cancel | ||
function cancel() { | ||
Instance.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters