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