Passed
Push — develop ( f809bc...611f71 )
by
unknown
02:04
created

helper.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
import { timelineDebugData } from './timelineDebugData.js'
2
import i18n from './i18n.js'
3
4
export const FETCH_CONFIG = {
5
  headers: {
6
    'Accept': 'application/json',
7
    'Content-Type': 'application/json'
8
  }
9
}
10
11
export const MODE = {
12
  VIEW: 'view',
13
  EDIT: 'edit',
14
  REVISION: 'revision'
15
}
16
17
export const removeExtensionOfFilename = filename => filename.split('.').splice(0, (filename.split('.').length - 1)).join('.')
18
19
export const displayFileSize = (bytes, decimals) => {
20
  if (bytes === 0) return '0 Bytes'
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
21
  const k = 1024
22
  const dm = decimals <= 0 ? 0 : decimals || 2
23
  const sizes = [i18n.t('Bytes'), i18n.t('KB'), i18n.t('MB'), i18n.t('GB'), i18n.t('TB'), i18n.t('PB'), i18n.t('EB'), i18n.t('ZB'), i18n.t('YB')]
24
  const i = Math.floor(Math.log(bytes) / Math.log(k))
25
  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
26
}
27
28
export const debug = {
29
  config: {
30
    slug: 'file',
31
    faIcon: 'paperclip',
32
    hexcolor: '#ff9900',
33
    creationLabel: 'Upload a file',
34
    domContainer: 'appFeatureContainer',
35
    apiUrl: 'http://192.168.1.153:6543/api/v2',
36
    availableStatuses: [{
37
      label: 'Open',
38
      slug: 'open',
39
      faIcon: 'square-o',
40
      hexcolor: '#3f52e3',
41
      globalStatus: 'open'
42
    }, {
43
      label: 'Validated',
44
      slug: 'closed-validated',
45
      faIcon: 'check-square-o',
46
      hexcolor: '#008000',
47
      globalStatus: 'closed'
48
    }, {
49
      label: 'Cancelled',
50
      slug: 'closed-unvalidated',
51
      faIcon: 'close',
52
      hexcolor: '#f63434',
53
      globalStatus: 'closed'
54
    }, {
55
      label: 'Deprecated',
56
      slug: 'closed-deprecated',
57
      faIcon: 'warning',
58
      hexcolor: '#ababab',
59
      globalStatus: 'closed'
60
    }],
61
    translation: {
62
      en: {
63
        translation: {
64
          'Last version': 'Last version debug en'
65
        }
66
      },
67
      fr: {
68
        translation: {
69
          'Last version': 'Dernière version debug fr'
70
        }
71
      }
72
    }
73
  },
74
  loggedUser: { // @FIXME this object is outdated
75
    user_id: 1,
76
    username: 'Smoi',
77
    firstname: 'Côme',
78
    lastname: 'Stoilenom',
79
    email: '[email protected]',
80
    lang: 'fr',
81
    avatar_url: 'https://avatars3.githubusercontent.com/u/11177014?s=460&v=4',
82
    idRoleUserWorkspace: 8
83
  },
84
  content: {
85
    author: {
86
      avatar_url: null,
87
      public_name: 'Global manager',
88
      user_id: 1 // -1 or 1 for debug
89
    },
90
    content_id: 1,
91
    content_type: 'file',
92
    created: '2018-06-18T14:59:26Z',
93
    current_revision_id: 11,
94
    is_archived: false,
95
    is_deleted: false,
96
    label: 'Current Menu',
97
    last_modifier: {
98
      avatar_url: null,
99
      public_name: 'Global manager',
100
      user_id: 1
101
    },
102
    modified: '2018-06-18T14:59:26Z',
103
    parent_id: 2,
104
    raw_content: '<div>bonjour, je suis un lapin.</div>',
105
    show_in_ui: true,
106
    slug: 'current-menu',
107
    status: 'open',
108
    sub_content_types: ['thread', 'html-document', 'file', 'folder'],
109
    workspace_id: 1,
110
    contentFull: null,
111
    page_nb: 1
112
  },
113
  timeline: timelineDebugData,
114
  idWorkspace: 1
115
}
116