blob: 92681eef1717f6f83ffc834eaf2b8c84e0bf9e70 [file] [log] [blame]
Matteo Scandoloba678a92016-06-20 17:16:15 -07001/**
2 * © OpenCORD
3 *
4 * Visit http://guide.xosproject.org/devguide/addview/ for more information
5 *
6 * Created by teone on 6/22/16.
7 */
8
9(function () {
10 'use strict';
11
12 /**
13 * @ngdoc service
14 * @name xos.ArchiveManager.serviceGrid
15 **/
16
17 angular.module('xos.serviceGrid')
18 .service('ArchiveManager', function(){
19 this.createArchive = () => {
20 this.archive = new JSZip();
21 };
22
23 this.addFile = (fileName, content) => {
24 this.archive.file(fileName, content);
25 };
26
27 this.download = (name) => {
28 console.log(this.archive);
29 this.archive.generateAsync({type: 'blob'})
30 .then(function(content) {
31 saveAs(content, `${name}.zip`);
32 })
33 .catch(e => {
34 console.log(e);
35 });
36 };
37 });
38})();
39