Total Complexity | 7 |
Complexity/F | 2.33 |
Lines of Code | 46 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** |
||
13 | 'use strict'; |
||
14 | |||
15 | if (!OCA.Analytics) { |
||
16 | /** |
||
17 | * @namespace |
||
18 | */ |
||
19 | OCA.Analytics = {}; |
||
20 | } |
||
21 | /** |
||
22 | * @namespace OCA.Analytics.Viewer |
||
23 | */ |
||
24 | OCA.Analytics.Viewer = { |
||
25 | |||
26 | registerFileActions: function () { |
||
27 | let mime_array = ['text/csv', 'text/plain']; |
||
28 | let icon_url = OC.imagePath('analytics', 'app-dark'); |
||
29 | |||
30 | for (let i = 0; i < mime_array.length; i++) { |
||
31 | let mime = mime_array[i]; |
||
32 | OCA.Files.fileActions.registerAction({ |
||
33 | name: 'analytics', |
||
34 | displayName: t('analytics', 'Show in Analytics'), |
||
35 | mime: mime, |
||
36 | permissions: OC.PERMISSION_READ, |
||
37 | icon: icon_url, |
||
38 | actionHandler: OCA.Analytics.Viewer.importFile |
||
39 | }); |
||
40 | } |
||
41 | }, |
||
42 | |||
43 | importFile: function (file, data) { |
||
44 | file = encodeURIComponent(file); |
||
45 | let dirLoad = data.dir.substr(1); |
||
46 | if (dirLoad !== '') { |
||
47 | dirLoad = dirLoad + '/'; |
||
48 | } |
||
49 | window.location = OC.generateUrl('/apps/analytics/#/f/') + dirLoad + file; |
||
50 | }, |
||
51 | }; |
||
52 | |||
53 | document.addEventListener('DOMContentLoaded', function () { |
||
54 | if (typeof OCA !== 'undefined' && typeof OCA.Files !== 'undefined' && typeof OCA.Files.fileActions !== 'undefined' && $('#header').hasClass('share-file') === false) { |
||
55 | OCA.Analytics.Viewer.registerFileActions(); |
||
56 | } |
||
57 | return true; |
||
58 | }); |