Passed
Push — develop ( f46262...cc5787 )
by Nikolay
07:20 queued 11s
created

sites/admin-cabinet/assets/js/src/SystemDiagnostic/system-diagnostic-index-logcapture.js   A

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 31
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 23
c 0
b 0
f 0
dl 0
loc 31
rs 10
mnd 1
bc 1
fnc 4
bpm 0.25
cpm 1.25
noi 0
1
/*
2
 * Copyright © MIKO LLC - All Rights Reserved
3
 * Unauthorized copying of this file, via any medium is strictly prohibited
4
 * Proprietary and confidential
5
 * Written by Nikolay Beketov, 8 2020
6
 */
7
/* global sessionStorage, PbxApi */
8
9
const systemDiagnosticCapture = {
10
	$startBtn: $('#start-capture-button'),
11
	$stopBtn: $('#stop-capture-button'),
12
	$showBtn: $('#show-last-log'),
13
	initialize() {
14
		if (sessionStorage.getItem('LogsCaptureStatus') === 'started') {
15
			systemDiagnosticCapture.$startBtn.addClass('disabled loading');
16
			systemDiagnosticCapture.$stopBtn.removeClass('disabled');
17
		} else {
18
			systemDiagnosticCapture.$startBtn.removeClass('disabled loading');
19
			systemDiagnosticCapture.$stopBtn.addClass('disabled');
20
		}
21
		systemDiagnosticCapture.$startBtn.on('click', (e) => {
22
			e.preventDefault();
23
			systemDiagnosticCapture.$startBtn.addClass('disabled loading');
24
			systemDiagnosticCapture.$stopBtn.removeClass('disabled');
25
			PbxApi.SystemStartLogsCapture();
26
		});
27
		systemDiagnosticCapture.$stopBtn.on('click', (e) => {
28
			e.preventDefault();
29
			systemDiagnosticCapture.$startBtn.removeClass('disabled loading');
30
			systemDiagnosticCapture.$stopBtn.addClass('disabled');
31
			PbxApi.SystemStopLogsCapture();
32
		});
33
34
	},
35
};
36
37
$(document).ready(() => {
38
	systemDiagnosticCapture.initialize();
39
});
40
41