Passed
Push — develop ( bef097...351c48 )
by Nikolay
12:23
created

sites/admin-cabinet/assets/js/src/Restart/restart-manage.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 31
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 31
rs 10
c 0
b 0
f 0
mnd 0
bc 0
fnc 4
bpm 0
cpm 1
noi 0
1
/*
2
 * MikoPBX - free phone system for small business
3
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License along with this program.
16
 * If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
/* global PbxApi */
20
21
/**
22
 * Object responsible for handling system restart and shutdown.
23
 *
24
 * @module restart
25
 */
26
const restart = {
27
28
    /**
29
     * Initializes the restart object by attaching event listeners to the restart and shutdown buttons.
30
     */
31
    initialize() {
32
33
        /**
34
         * Event listener for the restart button click event.
35
         * @param {Event} e - The click event.
36
         */
37
        $('#restart-button').on('click', (e) => {
38
            $(e.target).closest('button').addClass('loading');
39
            PbxApi.SystemReboot();
40
        });
41
42
        /**
43
         * Event listener for the shutdown button click event.
44
         * @param {Event} e - The click event.
45
         */
46
        $('#shutdown-button').on('click', (e) => {
47
            $(e.target).closest('button').addClass('loading');
48
            PbxApi.SystemShutDown();
49
        });
50
    },
51
};
52
53
// When the document is ready, initialize the reboot shutDown form
54
$(document).ready(() => {
55
    restart.initialize();
56
});
57
58