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
|
|
|
/* global sessionStorage, globalRootUrl, Config, Resumable */ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The PbxApi object is responsible for conversation with backend core API |
22
|
|
|
* |
23
|
|
|
* @module PbxApi |
24
|
|
|
*/ |
25
|
|
|
const PbxApi = { |
26
|
|
|
|
27
|
|
|
// AdvicesProcessor |
28
|
|
|
advicesGetList: `${Config.pbxUrl}/pbxcore/api/advices/getList`, // Generates a list of notifications about the system, firewall, passwords, and wrong settings. |
29
|
|
|
|
30
|
|
|
// CdrDBProcessor |
31
|
|
|
pbxGetActiveChannels: `${Config.pbxUrl}/pbxcore/api/cdr/getActiveChannels`, // Get active channels. These are the unfinished calls (endtime IS NULL). |
32
|
|
|
|
33
|
|
|
// SystemManagementProcessor |
34
|
|
|
systemPing: `${Config.pbxUrl}/pbxcore/api/system/ping`, // Ping backend (described in nginx.conf) |
35
|
|
|
systemReboot: `${Config.pbxUrl}/pbxcore/api/system/reboot`, // Reboot the operating system. |
36
|
|
|
systemShutDown: `${Config.pbxUrl}/pbxcore/api/system/shutdown`, // Shutdown the system. |
37
|
|
|
systemGetDateTime: `${Config.pbxUrl}/pbxcore/api/system/getDate`, // Retrieves the system date and time. |
38
|
|
|
systemSetDateTime: `${Config.pbxUrl}/pbxcore/api/system/setDate`, // Updates the system date and time. |
39
|
|
|
systemSendTestEmail: `${Config.pbxUrl}/pbxcore/api/system/sendMail`, // Sends an email notification. |
40
|
|
|
systemRestoreDefaultSettings: `${Config.pbxUrl}/pbxcore/api/system/restoreDefault`, // Restore default system settings |
41
|
|
|
systemConvertAudioFile: `${Config.pbxUrl}/pbxcore/api/system/convertAudioFile`, // Convert the audio file to various codecs using Asterisk. |
42
|
|
|
systemUpdateMailSettings: `${Config.pbxUrl}/pbxcore/api/system/updateMailSettings`, // Tries to send a test email. |
43
|
|
|
systemUpgrade: `${Config.pbxUrl}/pbxcore/api/system/upgrade`, // Upgrade the PBX using uploaded IMG file. |
44
|
|
|
|
45
|
|
|
// ModulesManagementProcessor |
46
|
|
|
modulesModuleStartDownload: `${Config.pbxUrl}/pbxcore/api/modules/core/moduleStartDownload`, // Starts the module download in a separate background process |
47
|
|
|
modulesModuleDownloadStatus: `${Config.pbxUrl}/pbxcore/api/modules/core/moduleDownloadStatus`, // Returns the download status of a module. |
48
|
|
|
modulesInstallModule: `${Config.pbxUrl}/pbxcore/api/modules/core/installNewModule`, // Installs a new additional extension module from an early uploaded zip archive. |
49
|
|
|
modulesGetModuleInstallationStatus: `${Config.pbxUrl}/pbxcore/api/modules/core/statusOfModuleInstallation`, // Checks the status of a module installation by the provided zip file path. |
50
|
|
|
modulesEnableModule: `${Config.pbxUrl}/pbxcore/api/modules/core/enableModule`, // Enables extension module. |
51
|
|
|
modulesDisableModule: `${Config.pbxUrl}/pbxcore/api/modules/core/disableModule`, // Disables extension module. |
52
|
|
|
modulesUnInstallModule: `${Config.pbxUrl}/pbxcore/api/modules/core/uninstallModule`, // Uninstall extension module. |
53
|
|
|
modulesGetAvailable: `${Config.pbxUrl}/pbxcore/api/modules/core/getAvailableModules`, // Retrieves available modules on MIKO repository. |
54
|
|
|
modulesGetLink: `${Config.pbxUrl}/pbxcore/api/modules/core/getModuleLink`, // Retrieves the installation link for a module. |
55
|
|
|
|
56
|
|
|
// FirewallManagementProcessor |
57
|
|
|
firewallGetBannedIp: `${Config.pbxUrl}/pbxcore/api/firewall/getBannedIp`, // Retrieve a list of banned IP addresses or get data for a specific IP address. |
58
|
|
|
firewallUnBanIp: `${Config.pbxUrl}/pbxcore/api/firewall/unBanIp`, // Remove an IP address from the fail2ban ban list. |
59
|
|
|
|
60
|
|
|
// SIPStackProcessor |
61
|
|
|
sipGetRegistry: `${Config.pbxUrl}/pbxcore/api/sip/getRegistry`, // Retrieves the statuses of SIP providers registration. |
62
|
|
|
sipGetPeersStatus: `${Config.pbxUrl}/pbxcore/api/sip/getPeersStatuses`, // Retrieves the statuses of SIP peers. |
63
|
|
|
sipGetPeerStatus: `${Config.pbxUrl}/pbxcore/api/sip/getSipPeer`, // Retrieves the status of provided SIP peer. |
64
|
|
|
|
65
|
|
|
// IAXStackProcessor |
66
|
|
|
iaxGetRegistry: `${Config.pbxUrl}/pbxcore/api/iax/getRegistry`, // Retrieves the statuses of IAX providers registration. |
67
|
|
|
|
68
|
|
|
// SysLogsManagementProcessor |
69
|
|
|
syslogStartLogsCapture: `${Config.pbxUrl}/pbxcore/api/syslog/startLog`, // Starts the collection of logs and captures TCP packets. |
70
|
|
|
syslogStopLogsCapture: `${Config.pbxUrl}/pbxcore/api/syslog/stopLog`, // Stops tcpdump and starts creating a log files archive for download. |
71
|
|
|
syslogPrepareLog: `${Config.pbxUrl}/pbxcore/api/syslog/prepareLog`, // Starts creating a log files archive for download. |
72
|
|
|
syslogDownloadLogsArchive: `${Config.pbxUrl}/pbxcore/api/syslog/downloadLogsArchive`, // Checks if archive ready then create download link containing logs and PCAP file. |
73
|
|
|
syslogGetLogsList: `${Config.pbxUrl}/pbxcore/api/syslog/getLogsList`, // Returns list of log files to show them on web interface |
74
|
|
|
syslogGetLogFromFile: `${Config.pbxUrl}/pbxcore/api/syslog/getLogFromFile`, // Gets partially filtered log file strings. |
75
|
|
|
syslogDownloadLogFile: `${Config.pbxUrl}/pbxcore/api/syslog/downloadLogFile`, // Prepares a downloadable link for a log file with the provided name. |
76
|
|
|
|
77
|
|
|
// FilesManagementProcessor |
78
|
|
|
filesUploadFile: `${Config.pbxUrl}/pbxcore/api/files/uploadFile`, // Upload files into the system by chunks |
79
|
|
|
filesStatusUploadFile: `${Config.pbxUrl}/pbxcore/api/files/statusUploadFile`, // Returns Status of uploading and merging process |
80
|
|
|
filesGetFileContent: `${Config.pbxUrl}/pbxcore/api/files/getFileContent`, // Get the content of config file by it name. |
81
|
|
|
filesRemoveAudioFile: `${Config.pbxUrl}/pbxcore/api/files/removeAudioFile`, // Delete audio files (mp3, wav, alaw ..) by name its name. |
82
|
|
|
filesDownloadNewFirmware: `${Config.pbxUrl}/pbxcore/api/files/downloadNewFirmware`, // Downloads the firmware file from the provided URL. |
83
|
|
|
filesFirmwareDownloadStatus: `${Config.pbxUrl}/pbxcore/api/files/firmwareDownloadStatus`, // Get the progress status of the firmware file download.. |
84
|
|
|
|
85
|
|
|
// SysinfoManagementProcessor |
86
|
|
|
sysinfoGetInfo: `${Config.pbxUrl}/pbxcore/api/sysinfo/getInfo`, // Gets collection of the system information. |
87
|
|
|
sysinfoGetExternalIP: `${Config.pbxUrl}/pbxcore/api/sysinfo/getExternalIpInfo`, // Gets an external IP address of the system. |
88
|
|
|
|
89
|
|
|
// LicenseManagementProcessor |
90
|
|
|
licensePing: `${Config.pbxUrl}/pbxcore/api/license/ping`, // Check connection with license server. |
91
|
|
|
licenseResetKey: `${Config.pbxUrl}/pbxcore/api/license/resetKey`, // Reset license key settings. |
92
|
|
|
licenseProcessUserRequest: `${Config.pbxUrl}/pbxcore/api/license/processUserRequest`, // Update license key, get new one, activate coupon |
93
|
|
|
licenseGetLicenseInfo: `${Config.pbxUrl}/pbxcore/api/license/getLicenseInfo`, // Retrieves license information from the license server. |
94
|
|
|
licenseGetMikoPBXFeatureStatus: `${Config.pbxUrl}/pbxcore/api/license/getMikoPBXFeatureStatus`, // Checks whether the license system is working properly or not. |
95
|
|
|
licenseCaptureFeatureForProductId: `${Config.pbxUrl}/pbxcore/api/license/captureFeatureForProductId`, // Tries to capture a feature for a product. |
96
|
|
|
licenseSendPBXMetrics: `${Config.pbxUrl}/pbxcore/api/license/sendPBXMetrics`, // Make an API call to send PBX metrics |
97
|
|
|
|
98
|
|
|
// Extensions |
99
|
|
|
extensionsGetPhonesRepresent: `${Config.pbxUrl}/pbxcore/api/extensions/getPhonesRepresent`, // Returns CallerID names for the numbers list. |
100
|
|
|
extensionsGetPhoneRepresent: `${Config.pbxUrl}/pbxcore/api/extensions/getPhoneRepresent`, // Returns CallerID names for the number. |
101
|
|
|
extensionsGetForSelect: `${Config.pbxUrl}/pbxcore/api/extensions/getForSelect?type={type}`, // Retrieves the extensions list limited by type parameter. |
102
|
|
|
extensionsAvailable: `${Config.pbxUrl}/pbxcore/api/extensions/available?number={number}`, // Checks the number uniqueness. |
103
|
|
|
extensionsGetRecord: `${Config.pbxUrl}/pbxcore/api/extensions/getRecord?id={id}`, // Get data structure for saveRecord request, if id parameter is empty it returns structure with default data. |
104
|
|
|
extensionsSaveRecord: `${Config.pbxUrl}/pbxcore/api/extensions/saveRecord`, // Saves extensions, sip, users, external phones, forwarding rights with POST data. |
105
|
|
|
extensionsDeleteRecord: `${Config.pbxUrl}/pbxcore/api/extensions/deleteRecord`, // Deletes the extension record with its dependent tables. |
106
|
|
|
|
107
|
|
|
// Users |
108
|
|
|
usersAvailable: `${Config.pbxUrl}/pbxcore/api/users/available?email={email}`, // Checks the email uniqueness. |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Tries to parse a JSON string. |
113
|
|
|
* |
114
|
|
|
* @param {string} jsonString - The JSON string to be parsed. |
115
|
|
|
* @returns {boolean|any} - Returns the parsed JSON object if parsing is successful and the result is an object. |
116
|
|
|
* Otherwise, returns `false`. |
117
|
|
|
*/ |
118
|
|
|
tryParseJSON(jsonString) { |
119
|
|
|
try { |
120
|
|
|
const o = JSON.parse(jsonString); |
121
|
|
|
|
122
|
|
|
// Handle non-exception-throwing cases: |
123
|
|
|
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking, |
124
|
|
|
// but... JSON.parse(null) returns null, and typeof null === "object", |
125
|
|
|
// so we must check for that, too. Thankfully, null is falsey, so this suffices: |
126
|
|
|
if (o && typeof o === 'object') { |
127
|
|
|
return o; |
128
|
|
|
} |
129
|
|
|
return false; |
130
|
|
|
} catch (e) { |
131
|
|
|
return false; |
132
|
|
|
} |
133
|
|
|
}, |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Checks the success response from the backend. |
137
|
|
|
* |
138
|
|
|
* @param {Object} response - The response object to be checked for success. |
139
|
|
|
* @returns {boolean} - Returns `true` if the response is defined, has non-empty keys, and the 'result' property is `true`. |
140
|
|
|
*/ |
141
|
|
|
successTest(response) { |
142
|
|
|
return response !== undefined |
143
|
|
|
&& Object.keys(response).length > 0 |
144
|
|
|
&& response.result !== undefined |
145
|
|
|
&& response.result === true; |
146
|
|
|
}, |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Checks the connection with the PBX. |
150
|
|
|
* Ping backend (described in nginx.conf) |
151
|
|
|
* |
152
|
|
|
* @param {function} callback - The callback function to be called after checking the PBX connection. |
153
|
|
|
* It will receive `true` in case of successful connection or `false` otherwise. |
154
|
|
|
* @returns {void} |
155
|
|
|
*/ |
156
|
|
|
SystemPingPBX(callback) { |
157
|
|
|
$.api({ |
158
|
|
|
url: PbxApi.systemPing, |
159
|
|
|
on: 'now', |
160
|
|
|
dataType: 'text', |
161
|
|
|
timeout: 2000, |
162
|
|
|
onComplete(response) { |
163
|
|
|
if (response !== undefined |
164
|
|
|
&& response.toUpperCase() === 'PONG') { |
165
|
|
|
callback(true); |
166
|
|
|
} else { |
167
|
|
|
callback(false); |
168
|
|
|
} |
169
|
|
|
}, |
170
|
|
|
onFailure() { |
171
|
|
|
callback(false); |
172
|
|
|
}, |
173
|
|
|
}); |
174
|
|
|
}, |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Retrieves the list of banned by fail2ban IP addresses. |
178
|
|
|
* |
179
|
|
|
* @param {function} callback - The callback function to be called after retrieving the list of banned IP addresses. |
180
|
|
|
* It will receive the response data or `false` in case of failure. |
181
|
|
|
* @returns {void} |
182
|
|
|
*/ |
183
|
|
|
FirewallGetBannedIp(callback) { |
184
|
|
|
$.api({ |
185
|
|
|
url: PbxApi.firewallGetBannedIp, |
186
|
|
|
on: 'now', |
187
|
|
|
successTest: PbxApi.successTest, |
188
|
|
|
onSuccess(response) { |
189
|
|
|
callback(response.data); |
190
|
|
|
}, |
191
|
|
|
onFailure() { |
192
|
|
|
callback(false); |
193
|
|
|
}, |
194
|
|
|
onError() { |
195
|
|
|
callback(false); |
196
|
|
|
}, |
197
|
|
|
}); |
198
|
|
|
}, |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Removes an IP from the fail2ban list. |
202
|
|
|
* |
203
|
|
|
* @param {string} ipAddress - The IP address to be removed from the fail2ban list. |
204
|
|
|
* @param {function} callback - The callback function to be called after removing the IP. |
205
|
|
|
* It will receive the response data or `false` in case of failure. |
206
|
|
|
* @returns {boolean} - Always returns `true`. |
207
|
|
|
*/ |
208
|
|
|
FirewallUnBanIp(ipAddress, callback) { |
209
|
|
|
$.api({ |
210
|
|
|
url: PbxApi.firewallUnBanIp, |
211
|
|
|
on: 'now', |
212
|
|
|
method: 'POST', |
213
|
|
|
data: {ip: ipAddress}, |
214
|
|
|
successTest: PbxApi.successTest, |
215
|
|
|
onSuccess(response) { |
216
|
|
|
callback(response.data); |
217
|
|
|
}, |
218
|
|
|
onFailure() { |
219
|
|
|
callback(false); |
220
|
|
|
}, |
221
|
|
|
onError() { |
222
|
|
|
callback(false); |
223
|
|
|
}, |
224
|
|
|
}); |
225
|
|
|
}, |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Retrieves the statuses of SIP peers. |
229
|
|
|
* |
230
|
|
|
* @param {function} callback - The callback function to be called after retrieving the peers' status. |
231
|
|
|
* It will receive the response data. |
232
|
|
|
* @returns {boolean} - Always returns `true`. |
233
|
|
|
*/ |
234
|
|
|
GetPeersStatus(callback) { |
235
|
|
|
$.api({ |
236
|
|
|
url: PbxApi.sipGetPeersStatus, |
237
|
|
|
on: 'now', |
238
|
|
|
successTest: PbxApi.successTest, |
239
|
|
|
onSuccess(response) { |
240
|
|
|
callback(response.data); |
241
|
|
|
}, |
242
|
|
|
onFailure() { |
243
|
|
|
callback(false); |
244
|
|
|
}, |
245
|
|
|
onError(errorMessage, element, xhr) { |
246
|
|
|
if (xhr.status === 401) { |
247
|
|
|
window.location = `${globalRootUrl}session/index`; |
248
|
|
|
} |
249
|
|
|
}, |
250
|
|
|
}); |
251
|
|
|
}, |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Retrieves the status of provided SIP peer. |
255
|
|
|
* |
256
|
|
|
* @param {Object} data - The data object containing the necessary information to retrieve the peer status. |
257
|
|
|
* @param {function} callback - The callback function to be called after retrieving the peer status. |
258
|
|
|
* It will receive the response data. |
259
|
|
|
* @returns {boolean} - Always returns `true`. |
260
|
|
|
*/ |
261
|
|
|
GetPeerStatus(data, callback) { |
262
|
|
|
$.api({ |
263
|
|
|
url: PbxApi.sipGetPeerStatus, |
264
|
|
|
on: 'now', |
265
|
|
|
method: 'POST', |
266
|
|
|
data: JSON.stringify(data), |
267
|
|
|
successTest: PbxApi.successTest, |
268
|
|
|
onSuccess(response) { |
269
|
|
|
callback(response.data); |
270
|
|
|
}, |
271
|
|
|
onFailure() { |
272
|
|
|
callback(false); |
273
|
|
|
}, |
274
|
|
|
onError(errorMessage, element, xhr) { |
275
|
|
|
if (xhr.status === 401) { |
276
|
|
|
window.location = `${globalRootUrl}session/index`; |
277
|
|
|
} |
278
|
|
|
}, |
279
|
|
|
}); |
280
|
|
|
}, |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Retrieves the statuses of SIP providers registration. |
284
|
|
|
* |
285
|
|
|
* @param {function} callback - The callback function to be called after retrieving the statuses. |
286
|
|
|
* It will receive the response data. |
287
|
|
|
* @returns {void} |
288
|
|
|
*/ |
289
|
|
|
GetSipProvidersStatuses(callback) { |
290
|
|
|
$.api({ |
291
|
|
|
url: PbxApi.sipGetRegistry, |
292
|
|
|
on: 'now', |
293
|
|
|
successTest: PbxApi.successTest, |
294
|
|
|
onSuccess(response) { |
295
|
|
|
callback(response.data); |
296
|
|
|
}, |
297
|
|
|
onError(errorMessage, element, xhr) { |
298
|
|
|
if (xhr.status === 401) { |
299
|
|
|
window.location = `${globalRootUrl}session/index`; |
300
|
|
|
} |
301
|
|
|
}, |
302
|
|
|
}); |
303
|
|
|
}, |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Retrieves the statuses of IAX providers registration. |
307
|
|
|
* |
308
|
|
|
* @param {function} callback - The callback function to be called after retrieving the statuses. |
309
|
|
|
* It will receive the response data. |
310
|
|
|
* @returns {void} |
311
|
|
|
*/ |
312
|
|
|
GetIaxProvidersStatuses(callback) { |
313
|
|
|
$.api({ |
314
|
|
|
url: PbxApi.iaxGetRegistry, |
315
|
|
|
on: 'now', |
316
|
|
|
successTest: PbxApi.successTest, |
317
|
|
|
onSuccess(response) { |
318
|
|
|
callback(response.data); |
319
|
|
|
}, |
320
|
|
|
onError(errorMessage, element, xhr) { |
321
|
|
|
if (xhr.status === 401) { |
322
|
|
|
window.location = `${globalRootUrl}session/index`; |
323
|
|
|
} |
324
|
|
|
}, |
325
|
|
|
}); |
326
|
|
|
}, |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Sends a test email. |
330
|
|
|
* |
331
|
|
|
* @param {Object} data - The data object containing the necessary information to send the test email. |
332
|
|
|
* @param {function} callback - The callback function to be called after sending the test email. |
333
|
|
|
* It will receive `true` in case of success or the error message in case of failure. |
334
|
|
|
* @returns {void} |
335
|
|
|
*/ |
336
|
|
|
SendTestEmail(data, callback) { |
337
|
|
|
$.api({ |
338
|
|
|
url: PbxApi.systemSendTestEmail, |
339
|
|
|
on: 'now', |
340
|
|
|
method: 'POST', |
341
|
|
|
data: data, |
342
|
|
|
successTest: PbxApi.successTest, |
343
|
|
|
onSuccess() { |
344
|
|
|
callback(true); |
345
|
|
|
}, |
346
|
|
|
onFailure(response) { |
347
|
|
|
callback(response.data.message); |
348
|
|
|
}, |
349
|
|
|
}); |
350
|
|
|
}, |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* Tries to send a test email. |
354
|
|
|
* |
355
|
|
|
* @param {function} callback - The callback function to be called after updating the mail settings. |
356
|
|
|
* It will receive the response data or `false` in case of failure. |
357
|
|
|
* @returns {void} |
358
|
|
|
*/ |
359
|
|
|
UpdateMailSettings(callback) { |
360
|
|
|
$.api({ |
361
|
|
|
url: PbxApi.systemUpdateMailSettings, |
362
|
|
|
on: 'now', |
363
|
|
|
successTest: PbxApi.successTest, |
364
|
|
|
onSuccess(response) { |
365
|
|
|
callback(response.data); |
366
|
|
|
}, |
367
|
|
|
onError(errorMessage, element, xhr) { |
368
|
|
|
if (xhr.status === 401) { |
369
|
|
|
window.location = `${globalRootUrl}session/index`; |
370
|
|
|
} |
371
|
|
|
}, |
372
|
|
|
}); |
373
|
|
|
}, |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Retrieves the file content from the server. |
377
|
|
|
* |
378
|
|
|
* @param {Object} data - The data object containing the necessary information to retrieve the file content. |
379
|
|
|
* @param {function} callback - The callback function to be called after retrieving the file content. |
380
|
|
|
* It will receive the response data. |
381
|
|
|
* @returns {void} |
382
|
|
|
*/ |
383
|
|
|
GetFileContent(data, callback) { |
384
|
|
|
$.api({ |
385
|
|
|
url: PbxApi.filesGetFileContent, |
386
|
|
|
on: 'now', |
387
|
|
|
method: 'POST', |
388
|
|
|
data: data, |
389
|
|
|
onSuccess(response) { |
390
|
|
|
if (response !== undefined) { |
391
|
|
|
callback(response); |
392
|
|
|
} |
393
|
|
|
}, |
394
|
|
|
}); |
395
|
|
|
}, |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Retrieves the system date and time. |
399
|
|
|
* |
400
|
|
|
* @param {function} callback - The callback function to be called after retrieving the date and time information. |
401
|
|
|
* It will receive the response data or `false` in case of failure. |
402
|
|
|
* @returns {void} |
403
|
|
|
*/ |
404
|
|
|
GetDateTime(callback) { |
405
|
|
|
$.api({ |
406
|
|
|
url: PbxApi.systemGetDateTime, |
407
|
|
|
on: 'now', |
408
|
|
|
successTest: PbxApi.successTest, |
409
|
|
|
onSuccess(response) { |
410
|
|
|
callback(response.data); |
411
|
|
|
}, |
412
|
|
|
onError() { |
413
|
|
|
callback(false); |
414
|
|
|
}, |
415
|
|
|
}); |
416
|
|
|
}, |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Updates the system date and time. |
420
|
|
|
* |
421
|
|
|
* @param {Object} data - The data object containing the updated date and time information. |
422
|
|
|
* @returns {void} |
423
|
|
|
*/ |
424
|
|
|
UpdateDateTime(data) { |
425
|
|
|
$.api({ |
426
|
|
|
url: PbxApi.systemSetDateTime, |
427
|
|
|
on: 'now', |
428
|
|
|
method: 'POST', |
429
|
|
|
data: data, |
430
|
|
|
}); |
431
|
|
|
}, |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Gets an external IP address of the system. |
435
|
|
|
* |
436
|
|
|
* @param {function} callback - The callback function to be called after retrieving the information. |
437
|
|
|
* It will receive the response data or `false` in case of failure. |
438
|
|
|
* @returns {void} |
439
|
|
|
*/ |
440
|
|
|
GetExternalIp(callback) { |
441
|
|
|
$.api({ |
442
|
|
|
url: PbxApi.sysinfoGetExternalIP, |
443
|
|
|
on: 'now', |
444
|
|
|
successTest: PbxApi.successTest, |
445
|
|
|
onSuccess(response) { |
446
|
|
|
callback(response.data); |
447
|
|
|
}, |
448
|
|
|
onError() { |
449
|
|
|
callback(false); |
450
|
|
|
}, |
451
|
|
|
}); |
452
|
|
|
}, |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* Retrieves active calls based on CDR data. |
456
|
|
|
* |
457
|
|
|
* @param {function} callback - The callback function to be called after retrieving the list of active calls. |
458
|
|
|
* It will receive the response data or `false` in case of no active calls. |
459
|
|
|
* @returns {void} |
460
|
|
|
*/ |
461
|
|
|
GetActiveChannels(callback) { |
462
|
|
|
$.api({ |
463
|
|
|
url: PbxApi.pbxGetActiveChannels, |
464
|
|
|
on: 'now', |
465
|
|
|
successTest: PbxApi.successTest, |
466
|
|
|
onSuccess(response) { |
467
|
|
|
if (Object.keys(response).length > 0) { |
468
|
|
|
callback(response.data); |
469
|
|
|
} else { |
470
|
|
|
callback(false); |
471
|
|
|
} |
472
|
|
|
}, |
473
|
|
|
onError(errorMessage, element, xhr) { |
474
|
|
|
if (xhr.status === 401) { |
475
|
|
|
window.location = `${globalRootUrl}session/index`; |
476
|
|
|
} |
477
|
|
|
}, |
478
|
|
|
}); |
479
|
|
|
}, |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* Reboot the operating system. |
483
|
|
|
* |
484
|
|
|
* @returns {void} |
485
|
|
|
*/ |
486
|
|
|
SystemReboot() { |
487
|
|
|
$.api({ |
488
|
|
|
url: PbxApi.systemReboot, |
489
|
|
|
on: 'now', |
490
|
|
|
}); |
491
|
|
|
}, |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Shutdown the system. |
495
|
|
|
* |
496
|
|
|
* @returns {void} |
497
|
|
|
*/ |
498
|
|
|
SystemShutDown() { |
499
|
|
|
$.api({ |
500
|
|
|
url: PbxApi.systemShutDown, |
501
|
|
|
on: 'now', |
502
|
|
|
}); |
503
|
|
|
}, |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* Gets collection of the system information. |
507
|
|
|
* |
508
|
|
|
* @param {function} callback - The callback function to be called after retrieving the system information. |
509
|
|
|
* It will receive the response data or `false` in case of failure. |
510
|
|
|
* @returns {void} |
511
|
|
|
*/ |
512
|
|
|
SysInfoGetInfo(callback) { |
513
|
|
|
$.api({ |
514
|
|
|
url: PbxApi.sysinfoGetInfo, |
515
|
|
|
on: 'now', |
516
|
|
|
successTest: PbxApi.successTest, |
517
|
|
|
onSuccess(response) { |
518
|
|
|
callback(response.data); |
519
|
|
|
}, |
520
|
|
|
onFailure() { |
521
|
|
|
callback(false); |
522
|
|
|
}, |
523
|
|
|
onError() { |
524
|
|
|
callback(false); |
525
|
|
|
}, |
526
|
|
|
}); |
527
|
|
|
}, |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Starts the collection of logs and captures TCP packets. |
531
|
|
|
* |
532
|
|
|
* @param {function} callback - The callback function to be called after starting the logs capture. |
533
|
|
|
* It will receive the response data or `false` in case of failure. |
534
|
|
|
* @returns {void} |
535
|
|
|
*/ |
536
|
|
|
SyslogStartLogsCapture(callback) { |
537
|
|
|
$.api({ |
538
|
|
|
url: PbxApi.syslogStartLogsCapture, |
539
|
|
|
on: 'now', |
540
|
|
|
successTest: PbxApi.successTest, |
541
|
|
|
onSuccess(response) { |
542
|
|
|
callback(response.data); |
543
|
|
|
}, |
544
|
|
|
onFailure() { |
545
|
|
|
callback(false); |
546
|
|
|
}, |
547
|
|
|
onError() { |
548
|
|
|
callback(false); |
549
|
|
|
}, |
550
|
|
|
}); |
551
|
|
|
}, |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* Starts creating a log files archive for download. |
555
|
|
|
* |
556
|
|
|
* @param {function} callback - The callback function to be called after starting the logs collection. |
557
|
|
|
* It will receive the response data or `false` in case of failure. |
558
|
|
|
* @returns {void} |
559
|
|
|
*/ |
560
|
|
|
SyslogPrepareLog(callback) { |
561
|
|
|
$.api({ |
562
|
|
|
url: PbxApi.syslogPrepareLog, |
563
|
|
|
on: 'now', |
564
|
|
|
successTest: PbxApi.successTest, |
565
|
|
|
onSuccess(response) { |
566
|
|
|
callback(response.data); |
567
|
|
|
}, |
568
|
|
|
onFailure() { |
569
|
|
|
callback(false); |
570
|
|
|
}, |
571
|
|
|
onError() { |
572
|
|
|
callback(false); |
573
|
|
|
}, |
574
|
|
|
}); |
575
|
|
|
}, |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Stops tcpdump and starts creating a log files archive for download. |
579
|
|
|
* |
580
|
|
|
* @param {function} callback - The callback function to be called after stopping the logs capture. |
581
|
|
|
* It will receive the response data or `false` in case of failure. |
582
|
|
|
* @returns {void} |
583
|
|
|
*/ |
584
|
|
|
SyslogStopLogsCapture(callback) { |
585
|
|
|
sessionStorage.setItem('LogsCaptureStatus', 'stopped'); |
586
|
|
|
$.api({ |
587
|
|
|
url: PbxApi.syslogStopLogsCapture, |
588
|
|
|
on: 'now', |
589
|
|
|
successTest: PbxApi.successTest, |
590
|
|
|
onSuccess(response) { |
591
|
|
|
callback(response.data); |
592
|
|
|
}, |
593
|
|
|
onFailure() { |
594
|
|
|
callback(false); |
595
|
|
|
}, |
596
|
|
|
onError() { |
597
|
|
|
callback(false); |
598
|
|
|
}, |
599
|
|
|
}); |
600
|
|
|
}, |
601
|
|
|
|
602
|
|
|
/** |
603
|
|
|
* Gets the list of log files. |
604
|
|
|
* |
605
|
|
|
* @param {function} callback - The callback function to be called after retrieving the list of log files. |
606
|
|
|
* It will receive the response data or `false` in case of failure. |
607
|
|
|
* @returns {void} |
608
|
|
|
*/ |
609
|
|
|
SyslogGetLogsList(callback) { |
610
|
|
|
$.api({ |
611
|
|
|
url: PbxApi.syslogGetLogsList, |
612
|
|
|
on: 'now', |
613
|
|
|
successTest: PbxApi.successTest, |
614
|
|
|
onSuccess(response) { |
615
|
|
|
callback(response.data); |
616
|
|
|
}, |
617
|
|
|
onFailure() { |
618
|
|
|
callback(false); |
619
|
|
|
}, |
620
|
|
|
onError() { |
621
|
|
|
callback(false); |
622
|
|
|
}, |
623
|
|
|
}); |
624
|
|
|
}, |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* Gets partially filtered log file strings. |
628
|
|
|
* |
629
|
|
|
* @param {Object} params - The parameters for retrieving log file strings. |
630
|
|
|
* @param {string} params.filename - The name of the log file. |
631
|
|
|
* @param {string|null} [params.filter=null] - The filter to apply on the log file (optional). |
632
|
|
|
* @param {number} params.lines - The number of lines to retrieve. |
633
|
|
|
* @param {number} params.offset - The offset from which to start retrieving lines. |
634
|
|
|
* @param {function} callback - The callback function to be called after retrieving the log file strings. |
635
|
|
|
* It will receive the response data or the error response. |
636
|
|
|
* @returns {void} |
637
|
|
|
*/ |
638
|
|
|
SyslogGetLogFromFile(params, callback) { |
639
|
|
|
$.api({ |
640
|
|
|
url: PbxApi.syslogGetLogFromFile, |
641
|
|
|
on: 'now', |
642
|
|
|
method: 'POST', |
643
|
|
|
data: { |
644
|
|
|
filename: params.filename, |
645
|
|
|
filter: params.filter, |
646
|
|
|
lines: params.lines, |
647
|
|
|
offset: params.offset |
648
|
|
|
}, |
649
|
|
|
successTest: PbxApi.successTest, |
650
|
|
|
onSuccess(response) { |
651
|
|
|
callback(response.data); |
652
|
|
|
}, |
653
|
|
|
onFailure(response) { |
654
|
|
|
callback(response); |
655
|
|
|
}, |
656
|
|
|
onError(response) { |
657
|
|
|
callback(response); |
658
|
|
|
}, |
659
|
|
|
}); |
660
|
|
|
}, |
661
|
|
|
|
662
|
|
|
/** |
663
|
|
|
* Prepares a downloadable link for a log file with the provided name. |
664
|
|
|
* |
665
|
|
|
* @param {string} filename - The name of the log file to be downloaded. |
666
|
|
|
* @param {function} callback - The callback function to be called after downloading the log file. |
667
|
|
|
* It will receive the response data or `false` in case of failure. |
668
|
|
|
* @returns {void} |
669
|
|
|
*/ |
670
|
|
|
SyslogDownloadLogFile(filename, callback) { |
671
|
|
|
$.api({ |
672
|
|
|
url: PbxApi.syslogDownloadLogFile, |
673
|
|
|
on: 'now', |
674
|
|
|
method: 'POST', |
675
|
|
|
data: {filename}, |
676
|
|
|
successTest: PbxApi.successTest, |
677
|
|
|
onSuccess(response) { |
678
|
|
|
callback(response.data); |
679
|
|
|
}, |
680
|
|
|
onFailure(response) { |
681
|
|
|
callback(false); |
682
|
|
|
}, |
683
|
|
|
onError(response) { |
684
|
|
|
callback(false); |
685
|
|
|
}, |
686
|
|
|
}); |
687
|
|
|
}, |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Requests a zipped archive containing logs and PCAP file. |
691
|
|
|
* Checks if archive ready it returns download link |
692
|
|
|
* |
693
|
|
|
* @param {string} filename - The name of the file to be downloaded. |
694
|
|
|
* @param {function} callback - The callback function to be called after requesting the logs archive. |
695
|
|
|
* It will receive the response data or the error response. |
696
|
|
|
* @returns {void} |
697
|
|
|
*/ |
698
|
|
|
SyslogDownloadLogsArchive(filename, callback) { |
699
|
|
|
$.api({ |
700
|
|
|
url: PbxApi.syslogDownloadLogsArchive, |
701
|
|
|
on: 'now', |
702
|
|
|
method: 'POST', |
703
|
|
|
data: {filename}, |
704
|
|
|
successTest: PbxApi.successTest, |
705
|
|
|
onSuccess(response) { |
706
|
|
|
callback(response.data); |
707
|
|
|
}, |
708
|
|
|
onFailure(response) { |
709
|
|
|
callback(response); |
710
|
|
|
}, |
711
|
|
|
onError(response) { |
712
|
|
|
callback(response); |
713
|
|
|
}, |
714
|
|
|
}); |
715
|
|
|
}, |
716
|
|
|
|
717
|
|
|
/** |
718
|
|
|
* Upgrade the PBX using uploaded IMG file. |
719
|
|
|
* |
720
|
|
|
* @param {string} filePath - The temporary file path for the upgrade. |
721
|
|
|
* @param {function} callback - The callback function to be called after starting the system upgrade. |
722
|
|
|
* It will receive a boolean indicating the success of the operation. |
723
|
|
|
* @returns {void} |
724
|
|
|
*/ |
725
|
|
|
SystemUpgrade(filePath, callback) { |
726
|
|
|
$.api({ |
727
|
|
|
url: PbxApi.systemUpgrade, |
728
|
|
|
on: 'now', |
729
|
|
|
method: 'POST', |
730
|
|
|
data: {temp_filename: filePath}, |
731
|
|
|
successTest: PbxApi.successTest, |
732
|
|
|
onSuccess() { |
733
|
|
|
callback(true); |
734
|
|
|
}, |
735
|
|
|
onFailure(response) { |
736
|
|
|
callback(response); |
737
|
|
|
}, |
738
|
|
|
onError(response) { |
739
|
|
|
callback(response); |
740
|
|
|
}, |
741
|
|
|
}); |
742
|
|
|
}, |
743
|
|
|
|
744
|
|
|
/** |
745
|
|
|
* Convert the audio file to various codecs using Asterisk. |
746
|
|
|
* |
747
|
|
|
* @param {string} filePath - The uploaded file path. |
748
|
|
|
* @param {string} category - The category of the audio file (e.g., 'moh', 'custom', etc.). |
749
|
|
|
* @param {function} callback - The callback function to be called after converting the audio file. |
750
|
|
|
* It will receive the response data or `false` in case of failure. |
751
|
|
|
* @returns {void} |
752
|
|
|
*/ |
753
|
|
|
SystemConvertAudioFile(filePath, category, callback) { |
754
|
|
|
$.api({ |
755
|
|
|
on: 'now', |
756
|
|
|
url: PbxApi.systemConvertAudioFile, |
757
|
|
|
method: 'POST', |
758
|
|
|
data: {temp_filename: filePath, category: category}, |
759
|
|
|
successTest: PbxApi.successTest, |
760
|
|
|
onSuccess(response) { |
761
|
|
|
callback(response.data); |
762
|
|
|
}, |
763
|
|
|
onFailure() { |
764
|
|
|
callback(false); |
765
|
|
|
}, |
766
|
|
|
onError() { |
767
|
|
|
callback(false); |
768
|
|
|
}, |
769
|
|
|
}); |
770
|
|
|
}, |
771
|
|
|
|
772
|
|
|
/** |
773
|
|
|
* Deletes an audio file from disk. |
774
|
|
|
* |
775
|
|
|
* @param {string} filePath - The full path to the file. |
776
|
|
|
* @param {string|null} [fileId=null] - The ID of the file (optional). |
777
|
|
|
* @param {function|null} [callback=null] - The callback function (optional). |
778
|
|
|
* It will be called with the fileId parameter if provided. |
779
|
|
|
* @returns {void} |
780
|
|
|
*/ |
781
|
|
|
FilesRemoveAudioFile(filePath, fileId = null, callback = null) { |
782
|
|
|
$.api({ |
783
|
|
|
url: PbxApi.filesRemoveAudioFile, |
784
|
|
|
on: 'now', |
785
|
|
|
method: 'POST', |
786
|
|
|
data: {filename: filePath}, |
787
|
|
|
successTest: PbxApi.successTest, |
788
|
|
|
onSuccess() { |
789
|
|
|
if (callback !== null) { |
790
|
|
|
callback(fileId); |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
}, |
794
|
|
|
}); |
795
|
|
|
}, |
796
|
|
|
|
797
|
|
|
/** |
798
|
|
|
* Installs a new additional extension module from an early uploaded zip archive. |
799
|
|
|
* |
800
|
|
|
* @param {string} filePath - The file path of the module to be installed. |
801
|
|
|
* @param {function} callback - The callback function to be called after attempting to install the module. |
802
|
|
|
* It will receive the response object. |
803
|
|
|
* @returns {void} |
804
|
|
|
*/ |
805
|
|
|
ModulesInstallModule(filePath, callback) { |
806
|
|
|
$.api({ |
807
|
|
|
url: PbxApi.modulesInstallModule, |
808
|
|
|
on: 'now', |
809
|
|
|
method: 'POST', |
810
|
|
|
data: { |
811
|
|
|
filePath |
812
|
|
|
}, |
813
|
|
|
successTest: PbxApi.successTest, |
814
|
|
|
onSuccess(response) { |
815
|
|
|
callback(response); |
816
|
|
|
}, |
817
|
|
|
onFailure(response) { |
818
|
|
|
callback(response); |
819
|
|
|
}, |
820
|
|
|
onError(response) { |
821
|
|
|
callback(response); |
822
|
|
|
}, |
823
|
|
|
}); |
824
|
|
|
}, |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* Checks the status of a module installation by the provided zip file path. |
828
|
|
|
* |
829
|
|
|
* @param {string} filePath - The file path of the module. |
830
|
|
|
* @param {function} callback - The callback function to be called with the installation status and response data. |
831
|
|
|
* It will receive a boolean indicating the success of the operation and the response data. |
832
|
|
|
* @returns {void} |
833
|
|
|
*/ |
834
|
|
|
ModulesGetModuleInstallationStatus(filePath, callback) { |
835
|
|
|
$.api({ |
836
|
|
|
url: PbxApi.modulesGetModuleInstallationStatus, |
837
|
|
|
on: 'now', |
838
|
|
|
method: 'POST', |
839
|
|
|
data: {filePath: filePath}, |
840
|
|
|
successTest: PbxApi.successTest, |
841
|
|
|
onSuccess(response) { |
842
|
|
|
callback(true, response); |
843
|
|
|
}, |
844
|
|
|
onFailure(response) { |
845
|
|
|
callback(false, response); |
846
|
|
|
}, |
847
|
|
|
onError(response) { |
848
|
|
|
callback(false, response); |
849
|
|
|
}, |
850
|
|
|
}); |
851
|
|
|
}, |
852
|
|
|
|
853
|
|
|
/** |
854
|
|
|
* Starts the module download in a separate background process. |
855
|
|
|
* |
856
|
|
|
* @param {Object} params - The parameters required for uploading the module. |
857
|
|
|
* @param {string} params.uniqid - The unique ID of the module. |
858
|
|
|
* @param {string} params.md5 - The MD5 hash of the module. |
859
|
|
|
* @param {number} params.size - The size of the module in bytes. |
860
|
|
|
* @param {string} params.updateLink - The URL from which to download the module. |
861
|
|
|
* @param {function} callback - The callback function to be called after attempting to upload the module. |
862
|
|
|
* It will receive a boolean indicating the success of the operation. |
863
|
|
|
* @returns {void} |
864
|
|
|
*/ |
865
|
|
|
ModulesModuleStartDownload(params, callback) { |
866
|
|
|
$.api({ |
867
|
|
|
url: PbxApi.modulesModuleStartDownload, |
868
|
|
|
on: 'now', |
869
|
|
|
method: 'POST', |
870
|
|
|
data: { |
871
|
|
|
uniqid: params.uniqid, |
872
|
|
|
md5: params.md5, |
873
|
|
|
size: params.size, |
874
|
|
|
url: params.updateLink |
875
|
|
|
}, |
876
|
|
|
successTest: PbxApi.successTest, |
877
|
|
|
onSuccess() { |
878
|
|
|
callback(true); |
879
|
|
|
}, |
880
|
|
|
onFailure(response) { |
881
|
|
|
callback(response); |
882
|
|
|
}, |
883
|
|
|
onError(response) { |
884
|
|
|
callback(response); |
885
|
|
|
}, |
886
|
|
|
}); |
887
|
|
|
}, |
888
|
|
|
|
889
|
|
|
/** |
890
|
|
|
* Uninstall extension module. |
891
|
|
|
* |
892
|
|
|
* @param {string} moduleName - The ID of the module to be deleted. |
893
|
|
|
* @param {boolean} keepSettings - Whether to keep the module settings or not. |
894
|
|
|
* @param {function} callback - The callback function to be called after attempting to delete the module. |
895
|
|
|
* It will receive a boolean indicating the success of the operation. |
896
|
|
|
* @returns {void} |
897
|
|
|
*/ |
898
|
|
|
ModulesUnInstallModule(moduleName, keepSettings, callback) { |
899
|
|
|
$.api({ |
900
|
|
|
url: PbxApi.modulesUnInstallModule, |
901
|
|
|
on: 'now', |
902
|
|
|
method: 'POST', |
903
|
|
|
data: { |
904
|
|
|
uniqid: moduleName, |
905
|
|
|
keepSettings: keepSettings |
906
|
|
|
}, |
907
|
|
|
successTest: PbxApi.successTest, |
908
|
|
|
onSuccess() { |
909
|
|
|
callback(true); |
910
|
|
|
}, |
911
|
|
|
onFailure(response) { |
912
|
|
|
callback(response); |
913
|
|
|
}, |
914
|
|
|
onError(response) { |
915
|
|
|
callback(response); |
916
|
|
|
}, |
917
|
|
|
}); |
918
|
|
|
}, |
919
|
|
|
|
920
|
|
|
/** |
921
|
|
|
* Gets the download status of a module. |
922
|
|
|
* |
923
|
|
|
* @param {string} moduleUniqueID - The unique ID of the module for which the download status is requested. |
924
|
|
|
* @param {function} callback - The callback function to be called with the response data on successful download status. |
925
|
|
|
* @param {function} failureCallback - The callback function to be called in case of failure or timeout. |
926
|
|
|
* @returns {void} |
927
|
|
|
*/ |
928
|
|
|
ModulesModuleDownloadStatus(moduleUniqueID, callback, failureCallback) { |
929
|
|
|
$.api({ |
930
|
|
|
url: PbxApi.modulesModuleDownloadStatus, |
931
|
|
|
on: 'now', |
932
|
|
|
timeout: 3000, |
933
|
|
|
method: 'POST', |
934
|
|
|
data: {uniqid: moduleUniqueID}, |
935
|
|
|
successTest: PbxApi.successTest, |
936
|
|
|
onSuccess(response) { |
937
|
|
|
callback(response.data); |
938
|
|
|
}, |
939
|
|
|
onFailure() { |
940
|
|
|
failureCallback(); |
941
|
|
|
}, |
942
|
|
|
onError() { |
943
|
|
|
failureCallback(); |
944
|
|
|
}, |
945
|
|
|
onAbort() { |
946
|
|
|
failureCallback(); |
947
|
|
|
}, |
948
|
|
|
}); |
949
|
|
|
}, |
950
|
|
|
|
951
|
|
|
/** |
952
|
|
|
* Disables extension module. |
953
|
|
|
* |
954
|
|
|
* @param {string} moduleUniqueID - The unique ID of the module to be disabled. |
955
|
|
|
* @param {function} callback - The callback function to be called after attempting to disable the module. |
956
|
|
|
* It will receive the response object and a boolean indicating the success of the operation. |
957
|
|
|
* @returns {void} |
958
|
|
|
*/ |
959
|
|
|
ModulesDisableModule(moduleUniqueID, callback) { |
960
|
|
|
$.api({ |
961
|
|
|
url: PbxApi.modulesDisableModule, |
962
|
|
|
on: 'now', |
963
|
|
|
method: 'POST', |
964
|
|
|
data: {uniqid: moduleUniqueID}, |
965
|
|
|
successTest: PbxApi.successTest, |
966
|
|
|
onSuccess(response) { |
967
|
|
|
callback(response, true); |
968
|
|
|
}, |
969
|
|
|
onFailure(response) { |
970
|
|
|
callback(response, false); |
971
|
|
|
}, |
972
|
|
|
onError(response) { |
973
|
|
|
callback(response, false); |
974
|
|
|
}, |
975
|
|
|
|
976
|
|
|
}); |
977
|
|
|
}, |
978
|
|
|
|
979
|
|
|
/** |
980
|
|
|
* Enables extension module. |
981
|
|
|
* |
982
|
|
|
* @param {string} moduleUniqueID - The unique ID of the module to be disabled. |
983
|
|
|
* @param {function} callback - The callback function to be called after attempting to disable the module. |
984
|
|
|
* It will receive the response object and a boolean indicating the success of the operation. |
985
|
|
|
* @returns {void} |
986
|
|
|
*/ |
987
|
|
|
ModulesEnableModule(moduleUniqueID, callback) { |
988
|
|
|
$.api({ |
989
|
|
|
url: PbxApi.modulesEnableModule, |
990
|
|
|
on: 'now', |
991
|
|
|
method: 'POST', |
992
|
|
|
data: {uniqid: moduleUniqueID}, |
993
|
|
|
successTest: PbxApi.successTest, |
994
|
|
|
onSuccess(response) { |
995
|
|
|
callback(response, true); |
996
|
|
|
}, |
997
|
|
|
onFailure(response) { |
998
|
|
|
callback(response, false); |
999
|
|
|
}, |
1000
|
|
|
onError(response) { |
1001
|
|
|
callback(response, false); |
1002
|
|
|
}, |
1003
|
|
|
|
1004
|
|
|
}); |
1005
|
|
|
}, |
1006
|
|
|
|
1007
|
|
|
/** |
1008
|
|
|
* Retrieves available modules on MIKO repository. |
1009
|
|
|
* |
1010
|
|
|
* @param {function} callback - The callback function to execute on success. |
1011
|
|
|
* @returns {void} Returns true. |
1012
|
|
|
*/ |
1013
|
|
|
ModulesGetAvailable(callback) { |
1014
|
|
|
$.api({ |
1015
|
|
|
url: PbxApi.modulesGetAvailable, |
1016
|
|
|
on: 'now', |
1017
|
|
|
successTest: PbxApi.successTest, |
1018
|
|
|
onSuccess(response) { |
1019
|
|
|
callback(response.data, true); |
1020
|
|
|
}, |
1021
|
|
|
onFailure(response) { |
1022
|
|
|
callback(response, false); |
1023
|
|
|
}, |
1024
|
|
|
onError(response) { |
1025
|
|
|
callback(response, false); |
1026
|
|
|
}, |
1027
|
|
|
}); |
1028
|
|
|
}, |
1029
|
|
|
|
1030
|
|
|
/** |
1031
|
|
|
* Retrieves the installation link for a module. |
1032
|
|
|
* |
1033
|
|
|
* @param {object} params - The parameters for retrieving the installation link. |
1034
|
|
|
* @param {function} cbSuccess - The callback function to execute on success. |
1035
|
|
|
* @param {function} cbFailure - The callback function to execute on failure. |
1036
|
|
|
* |
1037
|
|
|
* @returns {void} Returns true. |
1038
|
|
|
*/ |
1039
|
|
|
ModulesGetModuleLink(params, cbSuccess, cbFailure) { |
1040
|
|
|
$.api({ |
1041
|
|
|
url: PbxApi.modulesGetLink, |
1042
|
|
|
on: 'now', |
1043
|
|
|
method: 'POST', |
1044
|
|
|
data: {releaseId: params.releaseId}, |
1045
|
|
|
successTest: PbxApi.successTest, |
1046
|
|
|
onSuccess(response) { |
1047
|
|
|
cbSuccess(params, response.data); |
1048
|
|
|
}, |
1049
|
|
|
onFailure(response) { |
1050
|
|
|
cbFailure(params); |
1051
|
|
|
}, |
1052
|
|
|
onError(response) { |
1053
|
|
|
cbFailure(params); |
1054
|
|
|
}, |
1055
|
|
|
}); |
1056
|
|
|
}, |
1057
|
|
|
|
1058
|
|
|
|
1059
|
|
|
/** |
1060
|
|
|
* Downloads new firmware from the provided URL. |
1061
|
|
|
* |
1062
|
|
|
* @param {Object} params - The parameters required for downloading the firmware. |
1063
|
|
|
* @param {string} params.md5 - The MD5 hash of the firmware. |
1064
|
|
|
* @param {number} params.size - The size of the firmware in bytes. |
1065
|
|
|
* @param {string} params.version - The version of the firmware. |
1066
|
|
|
* @param {string} params.updateLink - The URL from which to download the firmware. |
1067
|
|
|
* @param {function} callback - The callback function to be called with the response data or error information. |
1068
|
|
|
* @returns {void} |
1069
|
|
|
*/ |
1070
|
|
|
FilesDownloadNewFirmware(params, callback) { |
1071
|
|
|
$.api({ |
1072
|
|
|
url: PbxApi.filesDownloadNewFirmware, |
1073
|
|
|
on: 'now', |
1074
|
|
|
method: 'POST', |
1075
|
|
|
data: { |
1076
|
|
|
md5: params.md5, |
1077
|
|
|
size: params.size, |
1078
|
|
|
version: params.version, |
1079
|
|
|
url: params.updateLink |
1080
|
|
|
}, |
1081
|
|
|
successTest: PbxApi.successTest, |
1082
|
|
|
onSuccess(response) { |
1083
|
|
|
callback(response.data); |
1084
|
|
|
}, |
1085
|
|
|
onFailure(response) { |
1086
|
|
|
callback(response); |
1087
|
|
|
}, |
1088
|
|
|
onError(response) { |
1089
|
|
|
callback(response); |
1090
|
|
|
}, |
1091
|
|
|
}); |
1092
|
|
|
}, |
1093
|
|
|
|
1094
|
|
|
/** |
1095
|
|
|
* Get the progress status of the firmware file download. |
1096
|
|
|
* |
1097
|
|
|
* @param {string} filename - The name of the firmware file. |
1098
|
|
|
* @param {function} callback - The callback function to be called with the response data or `false` in case of failure. |
1099
|
|
|
* @returns {undefined} |
1100
|
|
|
*/ |
1101
|
|
|
FilesFirmwareDownloadStatus(filename, callback) { |
1102
|
|
|
$.api({ |
1103
|
|
|
url: PbxApi.filesFirmwareDownloadStatus, |
1104
|
|
|
on: 'now', |
1105
|
|
|
method: 'POST', |
1106
|
|
|
data: {filename}, |
1107
|
|
|
successTest: PbxApi.successTest, |
1108
|
|
|
onSuccess(response) { |
1109
|
|
|
callback(response.data); |
1110
|
|
|
}, |
1111
|
|
|
onFailure() { |
1112
|
|
|
callback(false); |
1113
|
|
|
}, |
1114
|
|
|
onError() { |
1115
|
|
|
callback(false); |
1116
|
|
|
}, |
1117
|
|
|
}); |
1118
|
|
|
}, |
1119
|
|
|
|
1120
|
|
|
/** |
1121
|
|
|
* Connects the file upload handler for uploading files in parts. |
1122
|
|
|
* |
1123
|
|
|
* @param {string} buttonId - The ID of the button to assign the file upload functionality. |
1124
|
|
|
* @param {string[]} fileTypes - An array of allowed file types. |
1125
|
|
|
* @param {function} callback - The callback function to be called during different upload events. |
1126
|
|
|
* It will receive event information such as progress, success, error, etc. |
1127
|
|
|
* @returns {void} |
1128
|
|
|
*/ |
1129
|
|
|
SystemUploadFileAttachToBtn(buttonId, fileTypes, callback) { |
1130
|
|
|
const r = new Resumable({ |
1131
|
|
|
target: PbxApi.filesUploadFile, |
1132
|
|
|
testChunks: false, |
1133
|
|
|
chunkSize: 3 * 1024 * 1024, |
1134
|
|
|
maxFiles: 1, |
1135
|
|
|
simultaneousUploads: 1, |
1136
|
|
|
fileType: fileTypes, |
1137
|
|
|
}); |
1138
|
|
|
|
1139
|
|
|
r.assignBrowse(document.getElementById(buttonId)); |
1140
|
|
|
r.on('fileSuccess', (file, response) => { |
1141
|
|
|
callback('fileSuccess', {file, response}); |
1142
|
|
|
}); |
1143
|
|
|
r.on('fileProgress', (file) => { |
1144
|
|
|
callback('fileProgress', {file}); |
1145
|
|
|
}); |
1146
|
|
|
r.on('fileAdded', (file, event) => { |
1147
|
|
|
r.upload(); |
1148
|
|
|
callback('fileAdded', {file, event}); |
1149
|
|
|
}); |
1150
|
|
|
r.on('fileRetry', (file) => { |
1151
|
|
|
callback('fileRetry', {file}); |
1152
|
|
|
}); |
1153
|
|
|
r.on('fileError', (file, message) => { |
1154
|
|
|
callback('fileError', {file, message}); |
1155
|
|
|
}); |
1156
|
|
|
r.on('uploadStart', () => { |
1157
|
|
|
callback('uploadStart'); |
1158
|
|
|
}); |
1159
|
|
|
r.on('complete', () => { |
1160
|
|
|
callback('complete'); |
1161
|
|
|
}); |
1162
|
|
|
r.on('progress', () => { |
1163
|
|
|
const percent = 100 * r.progress(); |
1164
|
|
|
callback('progress', {percent}); |
1165
|
|
|
}); |
1166
|
|
|
r.on('error', (message, file) => { |
1167
|
|
|
callback('error', {message, file}); |
1168
|
|
|
}); |
1169
|
|
|
r.on('pause', () => { |
1170
|
|
|
callback('pause'); |
1171
|
|
|
}); |
1172
|
|
|
r.on('cancel', () => { |
1173
|
|
|
callback('cancel'); |
1174
|
|
|
}); |
1175
|
|
|
}, |
1176
|
|
|
|
1177
|
|
|
/** |
1178
|
|
|
* Enables uploading a file using chunk resumable worker. |
1179
|
|
|
* |
1180
|
|
|
* @param {File} file - The file to be uploaded. |
1181
|
|
|
* @param {function} callback - The callback function to be called during different upload events. |
1182
|
|
|
* It will receive event information such as progress, success, error, etc. |
1183
|
|
|
* @returns {void} |
1184
|
|
|
*/ |
1185
|
|
|
FilesUploadFile(file, callback) { |
1186
|
|
|
const r = new Resumable({ |
1187
|
|
|
target: PbxApi.filesUploadFile, |
1188
|
|
|
testChunks: false, |
1189
|
|
|
chunkSize: 3 * 1024 * 1024, |
1190
|
|
|
simultaneousUploads: 1, |
1191
|
|
|
maxFiles: 1, |
1192
|
|
|
}); |
1193
|
|
|
|
1194
|
|
|
r.addFile(file); |
1195
|
|
|
r.upload(); |
1196
|
|
|
r.on('fileSuccess', (file, response) => { |
1197
|
|
|
callback('fileSuccess', {file, response}); |
1198
|
|
|
}); |
1199
|
|
|
r.on('fileProgress', (file) => { |
1200
|
|
|
callback('fileProgress', {file}); |
1201
|
|
|
}); |
1202
|
|
|
r.on('fileAdded', (file, event) => { |
1203
|
|
|
r.upload(); |
1204
|
|
|
callback('fileAdded', {file, event}); |
1205
|
|
|
}); |
1206
|
|
|
r.on('fileRetry', (file) => { |
1207
|
|
|
callback('fileRetry', {file}); |
1208
|
|
|
}); |
1209
|
|
|
r.on('fileError', (file, message) => { |
1210
|
|
|
callback('fileError', {file, message}); |
1211
|
|
|
}); |
1212
|
|
|
r.on('uploadStart', () => { |
1213
|
|
|
callback('uploadStart'); |
1214
|
|
|
}); |
1215
|
|
|
r.on('complete', () => { |
1216
|
|
|
callback('complete'); |
1217
|
|
|
}); |
1218
|
|
|
r.on('progress', () => { |
1219
|
|
|
const percent = 100 * r.progress(); |
1220
|
|
|
callback('progress', {percent}); |
1221
|
|
|
}); |
1222
|
|
|
r.on('error', (message, file) => { |
1223
|
|
|
callback('error', {message, file}); |
1224
|
|
|
}); |
1225
|
|
|
r.on('pause', () => { |
1226
|
|
|
callback('pause'); |
1227
|
|
|
}); |
1228
|
|
|
r.on('cancel', () => { |
1229
|
|
|
callback('cancel'); |
1230
|
|
|
}); |
1231
|
|
|
}, |
1232
|
|
|
|
1233
|
|
|
/** |
1234
|
|
|
* Gets the uploading status of a file. |
1235
|
|
|
* |
1236
|
|
|
* @param {string} fileId - The ID of the file for which the status is requested. |
1237
|
|
|
* @param {function} callback - The callback function to be called with the response data or `false` in case of failure. |
1238
|
|
|
* @returns {void} |
1239
|
|
|
*/ |
1240
|
|
|
FilesGetStatusUploadFile(fileId, callback) { |
1241
|
|
|
$.api({ |
1242
|
|
|
url: PbxApi.filesStatusUploadFile, |
1243
|
|
|
on: 'now', |
1244
|
|
|
method: 'POST', |
1245
|
|
|
data: {id: fileId}, |
1246
|
|
|
successTest: PbxApi.successTest, |
1247
|
|
|
onSuccess(response) { |
1248
|
|
|
callback(response.data); |
1249
|
|
|
}, |
1250
|
|
|
onFailure() { |
1251
|
|
|
callback(false); |
1252
|
|
|
}, |
1253
|
|
|
onError() { |
1254
|
|
|
callback(false); |
1255
|
|
|
}, |
1256
|
|
|
}); |
1257
|
|
|
}, |
1258
|
|
|
|
1259
|
|
|
/** |
1260
|
|
|
* Update WorkerApiCommands language. |
1261
|
|
|
* |
1262
|
|
|
* @returns {void} |
1263
|
|
|
*/ |
1264
|
|
|
SystemChangeCoreLanguage() { |
1265
|
|
|
$.api({ |
1266
|
|
|
url: PbxApi.systemChangeCoreLanguage, |
1267
|
|
|
on: 'now', |
1268
|
|
|
}); |
1269
|
|
|
}, |
1270
|
|
|
|
1271
|
|
|
/** |
1272
|
|
|
* Restore default system settings. |
1273
|
|
|
* |
1274
|
|
|
* @param {function} callback - The callback function to be called after the operation completes. |
1275
|
|
|
* It will receive a boolean value indicating the success of the operation. |
1276
|
|
|
* @returns {void} |
1277
|
|
|
*/ |
1278
|
|
|
SystemRestoreDefaultSettings(callback) { |
1279
|
|
|
$.api({ |
1280
|
|
|
url: PbxApi.systemRestoreDefaultSettings, |
1281
|
|
|
on: 'now', |
1282
|
|
|
successTest: PbxApi.successTest, |
1283
|
|
|
onSuccess() { |
1284
|
|
|
callback(true); |
1285
|
|
|
}, |
1286
|
|
|
onFailure(response) { |
1287
|
|
|
callback(response.messages); |
1288
|
|
|
}, |
1289
|
|
|
}); |
1290
|
|
|
}, |
1291
|
|
|
|
1292
|
|
|
|
1293
|
|
|
/** |
1294
|
|
|
* Generates a list of notifications about the system, firewall, passwords, and wrong settings. |
1295
|
|
|
* |
1296
|
|
|
* @param {function} callback - The callback function to be called with the response data or `false` in case of failure. |
1297
|
|
|
* @returns {void} |
1298
|
|
|
*/ |
1299
|
|
|
AdvicesGetList(callback) { |
1300
|
|
|
$.api({ |
1301
|
|
|
url: PbxApi.advicesGetList, |
1302
|
|
|
on: 'now', |
1303
|
|
|
successTest: PbxApi.successTest, |
1304
|
|
|
onSuccess(response) { |
1305
|
|
|
callback(response.data); |
1306
|
|
|
}, |
1307
|
|
|
onFailure() { |
1308
|
|
|
callback(false); |
1309
|
|
|
}, |
1310
|
|
|
onError() { |
1311
|
|
|
callback(false); |
1312
|
|
|
}, |
1313
|
|
|
}); |
1314
|
|
|
}, |
1315
|
|
|
|
1316
|
|
|
/** |
1317
|
|
|
* Check connection with license server. |
1318
|
|
|
* @param {Function} callback - The callback function to be executed after the check operation. |
1319
|
|
|
* @returns {void} |
1320
|
|
|
*/ |
1321
|
|
|
LicensePing(callback) { |
1322
|
|
|
$.api({ |
1323
|
|
|
url: PbxApi.licensePing, |
1324
|
|
|
on: 'now', |
1325
|
|
|
successTest: PbxApi.successTest, |
1326
|
|
|
onSuccess() { |
1327
|
|
|
callback(true); |
1328
|
|
|
}, |
1329
|
|
|
onFailure() { |
1330
|
|
|
callback(false); |
1331
|
|
|
}, |
1332
|
|
|
onError() { |
1333
|
|
|
callback(false); |
1334
|
|
|
}, |
1335
|
|
|
}); |
1336
|
|
|
}, |
1337
|
|
|
|
1338
|
|
|
/** |
1339
|
|
|
* Reset license key settings. |
1340
|
|
|
* @param {Function} callback - The callback function to be executed after the reset operation. |
1341
|
|
|
* @returns {void} |
1342
|
|
|
*/ |
1343
|
|
|
LicenseResetLicenseKey(callback) { |
1344
|
|
|
$.api({ |
1345
|
|
|
url: PbxApi.licenseResetKey, |
1346
|
|
|
on: 'now', |
1347
|
|
|
successTest: PbxApi.successTest, |
1348
|
|
|
onSuccess(response) { |
1349
|
|
|
callback(response.data); |
1350
|
|
|
}, |
1351
|
|
|
onFailure() { |
1352
|
|
|
callback(false); |
1353
|
|
|
}, |
1354
|
|
|
onError() { |
1355
|
|
|
callback(false); |
1356
|
|
|
}, |
1357
|
|
|
}); |
1358
|
|
|
}, |
1359
|
|
|
|
1360
|
|
|
/** |
1361
|
|
|
* Update license key, get new one, activate coupon |
1362
|
|
|
* |
1363
|
|
|
* @param {Object} formData - The data for the license update request. |
1364
|
|
|
* @param {function} callback - The callback function to handle the response. |
1365
|
|
|
* @returns {void} |
1366
|
|
|
*/ |
1367
|
|
|
LicenseProcessUserRequest(formData, callback) { |
1368
|
|
|
$.api({ |
1369
|
|
|
url: PbxApi.licenseProcessUserRequest, |
1370
|
|
|
on: 'now', |
1371
|
|
|
method: 'POST', |
1372
|
|
|
data: formData, |
1373
|
|
|
successTest: PbxApi.successTest, |
1374
|
|
|
onSuccess(response) { |
1375
|
|
|
callback(response, true); |
1376
|
|
|
}, |
1377
|
|
|
onFailure(response) { |
1378
|
|
|
callback(response, false); |
1379
|
|
|
}, |
1380
|
|
|
onError() { |
1381
|
|
|
callback(false); |
1382
|
|
|
}, |
1383
|
|
|
}); |
1384
|
|
|
}, |
1385
|
|
|
|
1386
|
|
|
/** |
1387
|
|
|
* Retrieves license information from the license server. |
1388
|
|
|
* |
1389
|
|
|
* @param {function} callback - The callback function to handle the result. |
1390
|
|
|
*/ |
1391
|
|
|
LicenseGetLicenseInfo(callback) { |
1392
|
|
|
$.api({ |
1393
|
|
|
url: PbxApi.licenseGetLicenseInfo, |
1394
|
|
|
on: 'now', |
1395
|
|
|
successTest: PbxApi.successTest, |
1396
|
|
|
onSuccess(response) { |
1397
|
|
|
callback(response.data); |
1398
|
|
|
}, |
1399
|
|
|
onFailure(response) { |
1400
|
|
|
callback(response); |
1401
|
|
|
}, |
1402
|
|
|
onError() { |
1403
|
|
|
callback(false); |
1404
|
|
|
}, |
1405
|
|
|
}); |
1406
|
|
|
}, |
1407
|
|
|
|
1408
|
|
|
/** |
1409
|
|
|
* Checks whether the license system is working properly or not. |
1410
|
|
|
* |
1411
|
|
|
* @param {function} callback - The callback function to handle the result. |
1412
|
|
|
*/ |
1413
|
|
|
LicenseGetMikoPBXFeatureStatus(callback) { |
1414
|
|
|
$.api({ |
1415
|
|
|
url: PbxApi.licenseGetMikoPBXFeatureStatus, |
1416
|
|
|
on: 'now', |
1417
|
|
|
successTest: PbxApi.successTest, |
1418
|
|
|
onSuccess() { |
1419
|
|
|
callback(true); |
1420
|
|
|
}, |
1421
|
|
|
onFailure(response) { |
1422
|
|
|
callback(response); |
1423
|
|
|
}, |
1424
|
|
|
onError() { |
1425
|
|
|
callback(false); |
1426
|
|
|
}, |
1427
|
|
|
}); |
1428
|
|
|
}, |
1429
|
|
|
|
1430
|
|
|
/** |
1431
|
|
|
* Tries to capture a feature for a product. |
1432
|
|
|
* If it fails, it tries to get a trial and then tries to capture again. |
1433
|
|
|
* |
1434
|
|
|
* @param {object} params - The parameters for capturing the feature. |
1435
|
|
|
* @param {string} params.licFeatureId - The feature ID to capture. |
1436
|
|
|
* @param {string} params.licProductId - The product ID for capturing the feature. |
1437
|
|
|
* @param {function} callback - The callback function to handle the result. |
1438
|
|
|
*/ |
1439
|
|
|
LicenseCaptureFeatureForProductId(params, callback) { |
1440
|
|
|
const licFeatureId = params.licFeatureId; |
1441
|
|
|
const licProductId = params.licProductId; |
1442
|
|
|
$.api({ |
1443
|
|
|
url: PbxApi.licenseCaptureFeatureForProductId, |
1444
|
|
|
on: 'now', |
1445
|
|
|
method: 'POST', |
1446
|
|
|
data: {licFeatureId, licProductId}, |
1447
|
|
|
successTest: PbxApi.successTest, |
1448
|
|
|
onSuccess() { |
1449
|
|
|
callback(params, true); |
1450
|
|
|
}, |
1451
|
|
|
onFailure(response) { |
1452
|
|
|
callback(response.messages, false); |
1453
|
|
|
}, |
1454
|
|
|
onError() { |
1455
|
|
|
callback('', false); |
1456
|
|
|
}, |
1457
|
|
|
}); |
1458
|
|
|
}, |
1459
|
|
|
/** |
1460
|
|
|
* Make an API call to send PBX metrics |
1461
|
|
|
* |
1462
|
|
|
* @param callback |
1463
|
|
|
*/ |
1464
|
|
|
LicenseSendPBXMetrics(callback) { |
1465
|
|
|
$.api({ |
1466
|
|
|
url: PbxApi.licenseSendPBXMetrics, |
1467
|
|
|
on: 'now', |
1468
|
|
|
successTest: PbxApi.successTest, |
1469
|
|
|
onSuccess() { |
1470
|
|
|
callback(true); |
1471
|
|
|
}, |
1472
|
|
|
onFailure() { |
1473
|
|
|
callback(false); |
1474
|
|
|
}, |
1475
|
|
|
onError() { |
1476
|
|
|
callback(false); |
1477
|
|
|
}, |
1478
|
|
|
}); |
1479
|
|
|
}, |
1480
|
|
|
|
1481
|
|
|
/** |
1482
|
|
|
* Fetches phone representations for a list of phone numbers using an API call. |
1483
|
|
|
* |
1484
|
|
|
* @param {string[]} numbers - An array of phone numbers to fetch representations for. |
1485
|
|
|
* @param {function} callback - The callback function to handle the API response. |
1486
|
|
|
*/ |
1487
|
|
|
ExtensionsGetPhonesRepresent(numbers, callback) { |
1488
|
|
|
$.api({ |
1489
|
|
|
url: PbxApi.extensionsGetPhonesRepresent, |
1490
|
|
|
on: 'now', |
1491
|
|
|
method: 'POST', |
1492
|
|
|
data: {numbers}, |
1493
|
|
|
successTest: PbxApi.successTest, |
1494
|
|
|
onSuccess(response) { |
1495
|
|
|
callback(response); |
1496
|
|
|
}, |
1497
|
|
|
onFailure(response) { |
1498
|
|
|
callback(response); |
1499
|
|
|
}, |
1500
|
|
|
onError() { |
1501
|
|
|
callback(false); |
1502
|
|
|
}, |
1503
|
|
|
}); |
1504
|
|
|
}, |
1505
|
|
|
|
1506
|
|
|
/** |
1507
|
|
|
* Deletes the extension record with its dependent tables. |
1508
|
|
|
* |
1509
|
|
|
* @param {string} id - id of deleting extensions record. |
1510
|
|
|
* @param {function} callback - The callback function to handle the API response. |
1511
|
|
|
*/ |
1512
|
|
|
ExtensionsDeleteRecord(id, callback) { |
1513
|
|
|
$.api({ |
1514
|
|
|
url: PbxApi.extensionsDeleteRecord, |
1515
|
|
|
on: 'now', |
1516
|
|
|
method: 'POST', |
1517
|
|
|
data: {id}, |
1518
|
|
|
successTest: PbxApi.successTest, |
1519
|
|
|
onSuccess(response) { |
1520
|
|
|
callback(response); |
1521
|
|
|
}, |
1522
|
|
|
onFailure(response) { |
1523
|
|
|
callback(response); |
1524
|
|
|
}, |
1525
|
|
|
onError() { |
1526
|
|
|
callback(false); |
1527
|
|
|
}, |
1528
|
|
|
}); |
1529
|
|
|
}, |
1530
|
|
|
|
1531
|
|
|
}; |
1532
|
|
|
|
1533
|
|
|
// requirejs(["pbx/PbxAPI/extensionsAPI"]); |
1534
|
|
|
// requirejs(["pbx/PbxAPI/usersAPI"]); |
|
|
|
|