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 Alexey Portnov, 8 2020 |
6
|
|
|
*/ |
7
|
|
|
/* global sessionStorage, globalRootUrl, Config, Resumable */ |
8
|
|
|
|
9
|
|
|
const PbxApi = { |
10
|
|
|
pbxPing: `${Config.pbxUrl}/pbxcore/api/system/ping`, |
11
|
|
|
pbxGetHistory: `${Config.pbxUrl}/pbxcore/api/cdr/get_history`, // Запрос истории звонков POST -d '{"number": "212", "start":"2018-01-01", "end":"2019-01-01"}' |
12
|
|
|
pbxGetSipRegistry: `${Config.pbxUrl}/pbxcore/api/sip/getRegistry`, |
13
|
|
|
pbxGetIaxRegistry: `${Config.pbxUrl}/pbxcore/api/iax/getRegistry`, |
14
|
|
|
pbxGetPeersStatus: `${Config.pbxUrl}/pbxcore/api/sip/getPeersStatuses`, |
15
|
|
|
pbxGetPeerStatus: `${Config.pbxUrl}/pbxcore/api/sip/getSipPeer`, |
16
|
|
|
pbxGetActiveCalls: `${Config.pbxUrl}/pbxcore/api/cdr/getActiveCalls`, // Получить активные звонки, |
17
|
|
|
pbxGetActiveChannels: `${Config.pbxUrl}/pbxcore/api/cdr/getActiveChannels`, // Получить активные звонки, |
18
|
|
|
syslogStartLogsCapture: `${Config.pbxUrl}/pbxcore/api/syslog/startLog`, |
19
|
|
|
syslogStopLogsCapture: `${Config.pbxUrl}/pbxcore/api/syslog/stopLog`, |
20
|
|
|
syslogGetLogsList: `${Config.pbxUrl}/pbxcore/api/syslog/getLogsList`, //curl http://127.0.0.1/pbxcore/api/system/getLogsList |
21
|
|
|
syslogGetLogFromFile: `${Config.pbxUrl}/pbxcore/api/syslog/getLogFromFile`, |
22
|
|
|
syslogDownloadLogFile: `${Config.pbxUrl}/pbxcore/api/syslog/downloadLogFile`, //Download logfile by name |
23
|
|
|
syslogDownloadLogsArchive: `${Config.pbxUrl}/pbxcore/api/syslog/downloadLogsArchive`, // Ask for zipped logs and PCAP file |
24
|
|
|
systemReboot: `${Config.pbxUrl}/pbxcore/api/system/reboot`, // Рестарт ОС |
25
|
|
|
systemShutDown: `${Config.pbxUrl}/pbxcore/api/system/shutdown`, // Выключить машину |
26
|
|
|
systemGetBannedIp: `${Config.pbxUrl}/pbxcore/api/system/getBanIp`, // Получение забаненных ip |
27
|
|
|
systemUnBanIp: `${Config.pbxUrl}/pbxcore/api/system/unBanIp`, // Снятие бана IP адреса curl -X POST -d '{"ip": "172.16.156.1"}' |
28
|
|
|
systemGetDateTime: `${Config.pbxUrl}/pbxcore/api/system/getDate`,//curl http://172.16.156.223/pbxcore/api/system/getDate |
29
|
|
|
systemSetDateTime: `${Config.pbxUrl}/pbxcore/api/system/setDate`, // Set system date curl -X POST -d timestamp=1602509882 http://127.0.0.1/pbxcore/api/system/setDate |
30
|
|
|
systemSendTestEmail: `${Config.pbxUrl}/pbxcore/api/system/sendMail`, // Отправить почту |
31
|
|
|
systemRestoreDefaultSettings: `${Config.pbxUrl}/pbxcore/api/system/restoreDefault`, // Delete all system settings |
32
|
|
|
systemConvertAudioFile: `${Config.pbxUrl}/pbxcore/api/system/convertAudioFile`, |
33
|
|
|
updateMailSettings: `${Config.pbxUrl}/pbxcore/api/system/updateMailSettings`, |
34
|
|
|
systemUpgrade: `${Config.pbxUrl}/pbxcore/api/system/upgrade`, // Обновление АТС файлом |
35
|
|
|
systemInstallModule: `${Config.pbxUrl}/pbxcore/api/system/installNewModule`, |
36
|
|
|
systemDeleteModule: `${Config.pbxUrl}/pbxcore/api/system/uninstallModule`, |
37
|
|
|
systemDisableModule: `${Config.pbxUrl}/pbxcore/api/system/disableModule`, |
38
|
|
|
systemEnableModule: `${Config.pbxUrl}/pbxcore/api/system/enableModule`, |
39
|
|
|
filesUploadFile: `${Config.pbxUrl}/pbxcore/api/files/uploadResumable`, |
40
|
|
|
filesStatusUploadFile: `${Config.pbxUrl}/pbxcore/api/files/statusUploadFile`, |
41
|
|
|
filesGetFileContent: `${Config.pbxUrl}/pbxcore/api/files/fileReadContent`, // Получить контент файла по имени |
42
|
|
|
filesRemoveAudioFile: `${Config.pbxUrl}/pbxcore/api/files/removeAudioFile`, |
43
|
|
|
filesDownloadNewFirmware: `${Config.pbxUrl}/pbxcore/api/files/downloadNewFirmware`, // Обновление АТС онлайн |
44
|
|
|
filesFirmwareDownloadStatus: `${Config.pbxUrl}/pbxcore/api/files/firmwareDownloadStatus`, // Получение статуса обновления |
45
|
|
|
filesDownloadNewModule: `${Config.pbxUrl}/pbxcore/api/files/downloadNewModule`, |
46
|
|
|
filesModuleDownloadStatus: `${Config.pbxUrl}/pbxcore/api/files/moduleDownloadStatus`, |
47
|
|
|
sysinfoGetInfo: `${Config.pbxUrl}/pbxcore/api/sysinfo/getInfo`, // Get system information |
48
|
|
|
sysinfoGetExternalIP: `${Config.pbxUrl}/pbxcore/api/sysinfo/getExternalIpInfo`, //Get external IP address, |
49
|
|
|
advicesGetList: `${Config.pbxUrl}/pbxcore/api/advices/getList`, |
50
|
|
|
licenseResetKey: `${Config.pbxUrl}/pbxcore/api/license/resetKey`, |
51
|
|
|
licenseProcessUserRequest: `${Config.pbxUrl}/pbxcore/api/license/processUserRequest`, |
52
|
|
|
licenseGetLicenseInfo: `${Config.pbxUrl}/pbxcore/api/license/getLicenseInfo`, |
53
|
|
|
licenseGetMikoPBXFeatureStatus: `${Config.pbxUrl}/pbxcore/api/license/getMikoPBXFeatureStatus`, |
54
|
|
|
licenseCaptureFeatureForProductId: `${Config.pbxUrl}/pbxcore/api/license/captureFeatureForProductId`, |
55
|
|
|
licenseSendPBXMetrics: `${Config.pbxUrl}/pbxcore/api/license/sendPBXMetrics`, |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Проверка ответа на JSON |
59
|
|
|
* @param jsonString |
60
|
|
|
* @returns {boolean|any} |
61
|
|
|
*/ |
62
|
|
|
tryParseJSON(jsonString) { |
63
|
|
|
try { |
64
|
|
|
const o = JSON.parse(jsonString); |
65
|
|
|
|
66
|
|
|
// Handle non-exception-throwing cases: |
67
|
|
|
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking, |
68
|
|
|
// but... JSON.parse(null) returns null, and typeof null === "object", |
69
|
|
|
// so we must check for that, too. Thankfully, null is falsey, so this suffices: |
70
|
|
|
if (o && typeof o === 'object') { |
71
|
|
|
return o; |
72
|
|
|
} |
73
|
|
|
return false; |
74
|
|
|
} catch (e) { |
75
|
|
|
return false; |
76
|
|
|
} |
77
|
|
|
}, |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Проверка ответа PBX на успех |
81
|
|
|
* @param response |
82
|
|
|
*/ |
83
|
|
|
successTest(response) { |
84
|
|
|
return response !== undefined |
85
|
|
|
&& Object.keys(response).length > 0 |
86
|
|
|
&& response.result !== undefined |
87
|
|
|
&& response.result === true; |
88
|
|
|
}, |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Проверка связи с PBX |
92
|
|
|
* @param callback |
93
|
|
|
*/ |
94
|
|
|
PingPBX(callback) { |
95
|
|
|
$.api({ |
96
|
|
|
url: PbxApi.pbxPing, |
97
|
|
|
on: 'now', |
98
|
|
|
dataType: 'text', |
99
|
|
|
timeout: 2000, |
100
|
|
|
onComplete(response) { |
101
|
|
|
if (response !== undefined |
102
|
|
|
&& response.toUpperCase() === 'PONG') { |
103
|
|
|
callback(true); |
104
|
|
|
} else { |
105
|
|
|
callback(false); |
106
|
|
|
} |
107
|
|
|
}, |
108
|
|
|
onFailure() { |
109
|
|
|
callback(false); |
110
|
|
|
}, |
111
|
|
|
}); |
112
|
|
|
}, |
113
|
|
|
/** |
114
|
|
|
* Получение списка забанненых IP адресов |
115
|
|
|
* @param callback |
116
|
|
|
*/ |
117
|
|
|
SystemGetBannedIp(callback) { |
118
|
|
|
$.api({ |
119
|
|
|
url: PbxApi.systemGetBannedIp, |
120
|
|
|
on: 'now', |
121
|
|
|
successTest: PbxApi.successTest, |
122
|
|
|
onSuccess(response) { |
123
|
|
|
callback(response.data); |
124
|
|
|
}, |
125
|
|
|
onFailure() { |
126
|
|
|
callback(false); |
127
|
|
|
}, |
128
|
|
|
onError() { |
129
|
|
|
callback(false); |
130
|
|
|
}, |
131
|
|
|
}); |
132
|
|
|
}, |
133
|
|
|
/** |
134
|
|
|
* Delete IP from fail2ban list |
135
|
|
|
* @param ipAddress |
136
|
|
|
* @param callback |
137
|
|
|
* @returns {boolean} |
138
|
|
|
*/ |
139
|
|
|
SystemUnBanIp(ipAddress, callback) { |
140
|
|
|
$.api({ |
141
|
|
|
url: PbxApi.systemUnBanIp, |
142
|
|
|
on: 'now', |
143
|
|
|
method: 'POST', |
144
|
|
|
data: {ip: ipAddress}, |
145
|
|
|
successTest: PbxApi.successTest, |
146
|
|
|
onSuccess(response) { |
147
|
|
|
callback(response.data); |
148
|
|
|
}, |
149
|
|
|
onFailure() { |
150
|
|
|
callback(false); |
151
|
|
|
}, |
152
|
|
|
onError() { |
153
|
|
|
callback(false); |
154
|
|
|
}, |
155
|
|
|
}); |
156
|
|
|
}, |
157
|
|
|
/** |
158
|
|
|
* Получение статуса регистрации пиров |
159
|
|
|
* @param callback |
160
|
|
|
* @returns {boolean} |
161
|
|
|
*/ |
162
|
|
|
GetPeersStatus(callback) { |
163
|
|
|
$.api({ |
164
|
|
|
url: PbxApi.pbxGetPeersStatus, |
165
|
|
|
on: 'now', |
166
|
|
|
successTest: PbxApi.successTest, |
167
|
|
|
onSuccess(response) { |
168
|
|
|
callback(response.data); |
169
|
|
|
}, |
170
|
|
|
onFailure() { |
171
|
|
|
callback(false); |
172
|
|
|
}, |
173
|
|
|
onError(errorMessage, element, xhr) { |
174
|
|
|
if (xhr.status === 403) { |
175
|
|
|
window.location = `${globalRootUrl}session/index`; |
176
|
|
|
} |
177
|
|
|
}, |
178
|
|
|
}); |
179
|
|
|
}, |
180
|
|
|
/** |
181
|
|
|
* Получение статуса регистрации пира |
182
|
|
|
* @param callback |
183
|
|
|
* @returns {boolean} |
184
|
|
|
*/ |
185
|
|
|
GetPeerStatus(data, callback) { |
186
|
|
|
$.api({ |
187
|
|
|
url: PbxApi.pbxGetPeerStatus, |
188
|
|
|
on: 'now', |
189
|
|
|
method: 'POST', |
190
|
|
|
data: JSON.stringify(data), |
191
|
|
|
successTest: PbxApi.successTest, |
192
|
|
|
onSuccess(response) { |
193
|
|
|
callback(response.data); |
194
|
|
|
}, |
195
|
|
|
onFailure() { |
196
|
|
|
callback(false); |
197
|
|
|
}, |
198
|
|
|
onError(errorMessage, element, xhr) { |
199
|
|
|
if (xhr.status === 403) { |
200
|
|
|
window.location = `${globalRootUrl}session/index`; |
201
|
|
|
} |
202
|
|
|
}, |
203
|
|
|
}); |
204
|
|
|
}, |
205
|
|
|
/** |
206
|
|
|
* Получение статусов регистрации проовайдеров |
207
|
|
|
* @param callback |
208
|
|
|
*/ |
209
|
|
|
GetSipProvidersStatuses(callback) { |
210
|
|
|
$.api({ |
211
|
|
|
url: PbxApi.pbxGetSipRegistry, |
212
|
|
|
on: 'now', |
213
|
|
|
successTest: PbxApi.successTest, |
214
|
|
|
onSuccess(response) { |
215
|
|
|
callback(response.data); |
216
|
|
|
}, |
217
|
|
|
onError(errorMessage, element, xhr) { |
218
|
|
|
if (xhr.status === 403) { |
219
|
|
|
window.location = `${globalRootUrl}session/index`; |
220
|
|
|
} |
221
|
|
|
}, |
222
|
|
|
}); |
223
|
|
|
}, |
224
|
|
|
/** |
225
|
|
|
* Получение статусов регистрации проовайдеров IAX |
226
|
|
|
* @param callback |
227
|
|
|
*/ |
228
|
|
|
GetIaxProvidersStatuses(callback) { |
229
|
|
|
$.api({ |
230
|
|
|
url: PbxApi.pbxGetIaxRegistry, |
231
|
|
|
on: 'now', |
232
|
|
|
successTest: PbxApi.successTest, |
233
|
|
|
onSuccess(response) { |
234
|
|
|
callback(response.data); |
235
|
|
|
}, |
236
|
|
|
onError(errorMessage, element, xhr) { |
237
|
|
|
if (xhr.status === 403) { |
238
|
|
|
window.location = `${globalRootUrl}session/index`; |
239
|
|
|
} |
240
|
|
|
}, |
241
|
|
|
}); |
242
|
|
|
}, |
243
|
|
|
/** |
244
|
|
|
* Отпарвляет тестовое сообщение на почту |
245
|
|
|
* @param data |
246
|
|
|
*/ |
247
|
|
|
SendTestEmail(data, callback) { |
248
|
|
|
$.api({ |
249
|
|
|
url: PbxApi.systemSendTestEmail, |
250
|
|
|
on: 'now', |
251
|
|
|
method: 'POST', |
252
|
|
|
data: data, |
253
|
|
|
successTest: PbxApi.successTest, |
254
|
|
|
onSuccess() { |
255
|
|
|
callback(true); |
256
|
|
|
}, |
257
|
|
|
onFailure(response) { |
258
|
|
|
callback(response.data.message); |
259
|
|
|
}, |
260
|
|
|
}); |
261
|
|
|
}, |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Получение статусов регистрации проовайдеров IAX |
265
|
|
|
* @param callback |
266
|
|
|
*/ |
267
|
|
|
UpdateMailSettings(callback) { |
268
|
|
|
$.api({ |
269
|
|
|
url: PbxApi.updateMailSettings, |
270
|
|
|
on: 'now', |
271
|
|
|
successTest: PbxApi.successTest, |
272
|
|
|
onSuccess(response) { |
273
|
|
|
callback(response.data); |
274
|
|
|
}, |
275
|
|
|
onError(errorMessage, element, xhr) { |
276
|
|
|
if (xhr.status === 403) { |
277
|
|
|
window.location = `${globalRootUrl}session/index`; |
278
|
|
|
} |
279
|
|
|
}, |
280
|
|
|
}); |
281
|
|
|
}, |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Gets file content from server |
285
|
|
|
* @param data |
286
|
|
|
* @param callback |
287
|
|
|
*/ |
288
|
|
|
GetFileContent(data, callback) { |
289
|
|
|
$.api({ |
290
|
|
|
url: PbxApi.filesGetFileContent, |
291
|
|
|
on: 'now', |
292
|
|
|
method: 'POST', |
293
|
|
|
data: data, |
294
|
|
|
onSuccess(response) { |
295
|
|
|
if (response !== undefined) { |
296
|
|
|
callback(response); |
297
|
|
|
} |
298
|
|
|
}, |
299
|
|
|
}); |
300
|
|
|
}, |
301
|
|
|
/** |
302
|
|
|
* Get the linux datetime |
303
|
|
|
*/ |
304
|
|
|
GetDateTime(callback) { |
305
|
|
|
$.api({ |
306
|
|
|
url: PbxApi.systemGetDateTime, |
307
|
|
|
on: 'now', |
308
|
|
|
successTest: PbxApi.successTest, |
309
|
|
|
onSuccess(response) { |
310
|
|
|
callback(response.data); |
311
|
|
|
}, |
312
|
|
|
onError() { |
313
|
|
|
callback(false); |
314
|
|
|
}, |
315
|
|
|
}); |
316
|
|
|
}, |
317
|
|
|
/** |
318
|
|
|
* Updates the linux datetime |
319
|
|
|
* @param data |
320
|
|
|
*/ |
321
|
|
|
UpdateDateTime(data) { |
322
|
|
|
$.api({ |
323
|
|
|
url: PbxApi.systemSetDateTime, |
324
|
|
|
on: 'now', |
325
|
|
|
method: 'POST', |
326
|
|
|
data: data, |
327
|
|
|
}); |
328
|
|
|
}, |
329
|
|
|
/** |
330
|
|
|
* Получаем информацию о внешнем IP станции |
331
|
|
|
* @param callback |
332
|
|
|
*/ |
333
|
|
|
GetExternalIp(callback) { |
334
|
|
|
$.api({ |
335
|
|
|
url: PbxApi.sysinfoGetExternalIP, |
336
|
|
|
on: 'now', |
337
|
|
|
successTest: PbxApi.successTest, |
338
|
|
|
onSuccess(response) { |
339
|
|
|
callback(response.data); |
340
|
|
|
}, |
341
|
|
|
onError() { |
342
|
|
|
callback(false); |
343
|
|
|
}, |
344
|
|
|
}); |
345
|
|
|
}, |
346
|
|
|
/** |
347
|
|
|
* Получение списка активных вызовов |
348
|
|
|
* @param callback |
349
|
|
|
*/ |
350
|
|
|
GetCurrentCalls(callback) { |
351
|
|
|
$.api({ |
352
|
|
|
url: PbxApi.pbxGetActiveChannels, |
353
|
|
|
on: 'now', |
354
|
|
|
successTest: PbxApi.successTest, |
355
|
|
|
onSuccess(response) { |
356
|
|
|
if (Object.keys(response).length > 0) { |
357
|
|
|
callback(response.data); |
358
|
|
|
} else { |
359
|
|
|
callback(false); |
360
|
|
|
} |
361
|
|
|
}, |
362
|
|
|
onError(errorMessage, element, xhr) { |
363
|
|
|
if (xhr.status === 403) { |
364
|
|
|
window.location = `${globalRootUrl}session/index`; |
365
|
|
|
} |
366
|
|
|
}, |
367
|
|
|
}); |
368
|
|
|
}, |
369
|
|
|
/** |
370
|
|
|
* Перезагрузка станции |
371
|
|
|
*/ |
372
|
|
|
SystemReboot() { |
373
|
|
|
$.api({ |
374
|
|
|
url: PbxApi.systemReboot, |
375
|
|
|
on: 'now', |
376
|
|
|
}); |
377
|
|
|
}, |
378
|
|
|
/** |
379
|
|
|
* ShutDown MikoPBX |
380
|
|
|
*/ |
381
|
|
|
SystemShutDown() { |
382
|
|
|
$.api({ |
383
|
|
|
url: PbxApi.systemShutDown, |
384
|
|
|
on: 'now', |
385
|
|
|
}); |
386
|
|
|
}, |
387
|
|
|
/** |
388
|
|
|
* Gets system information |
389
|
|
|
* @param callback function |
390
|
|
|
*/ |
391
|
|
|
SysInfoGetInfo(callback) { |
392
|
|
|
$.api({ |
393
|
|
|
url: PbxApi.sysinfoGetInfo, |
394
|
|
|
on: 'now', |
395
|
|
|
successTest: PbxApi.successTest, |
396
|
|
|
onSuccess(response) { |
397
|
|
|
callback(response.data); |
398
|
|
|
}, |
399
|
|
|
onFailure() { |
400
|
|
|
callback(false); |
401
|
|
|
}, |
402
|
|
|
onError() { |
403
|
|
|
callback(false); |
404
|
|
|
}, |
405
|
|
|
}); |
406
|
|
|
}, |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* Start logs collection and pickup TCP packages |
410
|
|
|
* @param callback function |
411
|
|
|
*/ |
412
|
|
|
SyslogStartLogsCapture(callback) { |
413
|
|
|
$.api({ |
414
|
|
|
url: PbxApi.syslogStartLogsCapture, |
415
|
|
|
on: 'now', |
416
|
|
|
successTest: PbxApi.successTest, |
417
|
|
|
onSuccess(response) { |
418
|
|
|
callback(response.data); |
419
|
|
|
}, |
420
|
|
|
onFailure() { |
421
|
|
|
callback(false); |
422
|
|
|
}, |
423
|
|
|
onError() { |
424
|
|
|
callback(false); |
425
|
|
|
}, |
426
|
|
|
}); |
427
|
|
|
}, |
428
|
|
|
/** |
429
|
|
|
* Stop tcp dump and start making file for download |
430
|
|
|
* @param callback function |
431
|
|
|
*/ |
432
|
|
|
SyslogStopLogsCapture(callback) { |
433
|
|
|
sessionStorage.setItem('LogsCaptureStatus', 'stopped'); |
434
|
|
|
$.api({ |
435
|
|
|
url: PbxApi.syslogStopLogsCapture, |
436
|
|
|
on: 'now', |
437
|
|
|
successTest: PbxApi.successTest, |
438
|
|
|
onSuccess(response) { |
439
|
|
|
callback(response.data); |
440
|
|
|
}, |
441
|
|
|
onFailure() { |
442
|
|
|
callback(false); |
443
|
|
|
}, |
444
|
|
|
onError() { |
445
|
|
|
callback(false); |
446
|
|
|
}, |
447
|
|
|
}); |
448
|
|
|
}, |
449
|
|
|
/** |
450
|
|
|
* Gets logs files list |
451
|
|
|
* @param callback function |
452
|
|
|
*/ |
453
|
|
|
SyslogGetLogsList(callback) { |
454
|
|
|
$.api({ |
455
|
|
|
url: PbxApi.syslogGetLogsList, |
456
|
|
|
on: 'now', |
457
|
|
|
successTest: PbxApi.successTest, |
458
|
|
|
onSuccess(response) { |
459
|
|
|
callback(response.data); |
460
|
|
|
}, |
461
|
|
|
onFailure() { |
462
|
|
|
callback(false); |
463
|
|
|
}, |
464
|
|
|
onError() { |
465
|
|
|
callback(false); |
466
|
|
|
}, |
467
|
|
|
}); |
468
|
|
|
}, |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* Get logfiles strings partially and filtered |
472
|
|
|
* @param params |
473
|
|
|
* @param callback function |
474
|
|
|
*/ |
475
|
|
|
SyslogGetLogFromFile(params, callback) { |
476
|
|
|
$.api({ |
477
|
|
|
url: PbxApi.syslogGetLogFromFile, |
478
|
|
|
on: 'now', |
479
|
|
|
method: 'POST', |
480
|
|
|
data: { |
481
|
|
|
filename: params.filename, |
482
|
|
|
filter: params.filter, |
483
|
|
|
lines: params.lines, |
484
|
|
|
offset: params.offset |
485
|
|
|
}, |
486
|
|
|
successTest: PbxApi.successTest, |
487
|
|
|
onSuccess(response) { |
488
|
|
|
callback(response.data); |
489
|
|
|
}, |
490
|
|
|
onFailure(response) { |
491
|
|
|
callback(response); |
492
|
|
|
}, |
493
|
|
|
onError(response) { |
494
|
|
|
callback(response); |
495
|
|
|
}, |
496
|
|
|
}); |
497
|
|
|
}, |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* Download logfile by name |
501
|
|
|
* @param filename |
502
|
|
|
* @param callback function |
503
|
|
|
*/ |
504
|
|
|
SyslogDownloadLogFile(filename, callback) { |
505
|
|
|
$.api({ |
506
|
|
|
url: PbxApi.syslogDownloadLogFile, |
507
|
|
|
on: 'now', |
508
|
|
|
method: 'POST', |
509
|
|
|
data: {filename}, |
510
|
|
|
successTest: PbxApi.successTest, |
511
|
|
|
onSuccess(response) { |
512
|
|
|
callback(response.data); |
513
|
|
|
}, |
514
|
|
|
onFailure(response) { |
515
|
|
|
callback(false); |
516
|
|
|
}, |
517
|
|
|
onError(response) { |
518
|
|
|
callback(false); |
519
|
|
|
}, |
520
|
|
|
}); |
521
|
|
|
}, |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* Ask for zipped logs and PCAP file |
525
|
|
|
* @param filename |
526
|
|
|
* @param callback function |
527
|
|
|
*/ |
528
|
|
|
SyslogDownloadLogsArchive(filename, callback) { |
529
|
|
|
$.api({ |
530
|
|
|
url: PbxApi.syslogDownloadLogsArchive, |
531
|
|
|
on: 'now', |
532
|
|
|
method: 'POST', |
533
|
|
|
data: {filename}, |
534
|
|
|
successTest: PbxApi.successTest, |
535
|
|
|
onSuccess(response) { |
536
|
|
|
callback(response.data); |
537
|
|
|
}, |
538
|
|
|
onFailure(response) { |
539
|
|
|
callback(response); |
540
|
|
|
}, |
541
|
|
|
onError(response) { |
542
|
|
|
callback(response); |
543
|
|
|
}, |
544
|
|
|
}); |
545
|
|
|
}, |
546
|
|
|
/** |
547
|
|
|
* Start system upgrade |
548
|
|
|
* @param filePath tempFile path for upgrade |
549
|
|
|
* @param callback function |
550
|
|
|
*/ |
551
|
|
|
SystemUpgrade(filePath, callback) { |
552
|
|
|
$.api({ |
553
|
|
|
url: PbxApi.systemUpgrade, |
554
|
|
|
on: 'now', |
555
|
|
|
method: 'POST', |
556
|
|
|
data: {temp_filename:filePath}, |
557
|
|
|
successTest: PbxApi.successTest, |
558
|
|
|
onSuccess() { |
559
|
|
|
callback(true); |
560
|
|
|
}, |
561
|
|
|
onFailure(response) { |
562
|
|
|
callback(response); |
563
|
|
|
}, |
564
|
|
|
onError(response) { |
565
|
|
|
callback(response); |
566
|
|
|
}, |
567
|
|
|
}); |
568
|
|
|
}, |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Convert audio file to wav with 8000 bitrate |
572
|
|
|
* @param filePath - uploaded file |
573
|
|
|
* @param category - category {moh, custom, etc...} |
574
|
|
|
* @param callback - callback function |
575
|
|
|
*/ |
576
|
|
|
SystemConvertAudioFile(filePath, category, callback) { |
577
|
|
|
$.api({ |
578
|
|
|
on: 'now', |
579
|
|
|
url: PbxApi.systemConvertAudioFile, |
580
|
|
|
method: 'POST', |
581
|
|
|
data: {temp_filename:filePath, category:category}, |
582
|
|
|
successTest: PbxApi.successTest, |
583
|
|
|
onSuccess(response) { |
584
|
|
|
callback(response.data); |
585
|
|
|
}, |
586
|
|
|
onFailure() { |
587
|
|
|
callback(false); |
588
|
|
|
}, |
589
|
|
|
onError() { |
590
|
|
|
callback(false); |
591
|
|
|
}, |
592
|
|
|
}); |
593
|
|
|
}, |
594
|
|
|
/** |
595
|
|
|
* Deletes audio file from disk |
596
|
|
|
* @param filePath - full path to the file |
597
|
|
|
* @param fileId |
598
|
|
|
* @param callback - callback function |
599
|
|
|
*/ |
600
|
|
|
FilesRemoveAudioFile(filePath, fileId=null, callback=null) { |
601
|
|
|
$.api({ |
602
|
|
|
url: PbxApi.filesRemoveAudioFile, |
603
|
|
|
on: 'now', |
604
|
|
|
method: 'POST', |
605
|
|
|
data: {filename:filePath}, |
606
|
|
|
successTest: PbxApi.successTest, |
607
|
|
|
onSuccess() { |
608
|
|
|
if (callback!==null){ |
609
|
|
|
callback(fileId); |
610
|
|
|
} |
611
|
|
|
|
612
|
|
|
}, |
613
|
|
|
}); |
614
|
|
|
}, |
615
|
|
|
|
616
|
|
|
/** |
617
|
|
|
* Install uploaded module |
618
|
|
|
* @param filePath |
619
|
|
|
* @param callback - функция колбека |
620
|
|
|
*/ |
621
|
|
|
SystemInstallModule(filePath, callback) { |
622
|
|
|
$.api({ |
623
|
|
|
url: PbxApi.systemInstallModule, |
624
|
|
|
on: 'now', |
625
|
|
|
method: 'POST', |
626
|
|
|
data: { |
627
|
|
|
filePath |
628
|
|
|
}, |
629
|
|
|
successTest: PbxApi.successTest, |
630
|
|
|
onSuccess() { |
631
|
|
|
callback(true); |
632
|
|
|
}, |
633
|
|
|
onFailure(response) { |
634
|
|
|
callback(response); |
635
|
|
|
}, |
636
|
|
|
onError(response) { |
637
|
|
|
callback(response); |
638
|
|
|
}, |
639
|
|
|
}); |
640
|
|
|
}, |
641
|
|
|
|
642
|
|
|
/** |
643
|
|
|
* Uploads module as json with link by POST request |
644
|
|
|
* @param params |
645
|
|
|
* @param callback - функция колбека |
646
|
|
|
*/ |
647
|
|
|
FilesDownloadNewModule(params, callback) { |
648
|
|
|
$.api({ |
649
|
|
|
url: PbxApi.filesDownloadNewModule, |
650
|
|
|
on: 'now', |
651
|
|
|
method: 'POST', |
652
|
|
|
data: { |
653
|
|
|
uniqid:params.uniqid, |
654
|
|
|
md5:params.md5, |
655
|
|
|
size:params.size, |
656
|
|
|
url:params.updateLink |
657
|
|
|
}, |
658
|
|
|
successTest: PbxApi.successTest, |
659
|
|
|
onSuccess() { |
660
|
|
|
callback(true); |
661
|
|
|
}, |
662
|
|
|
onFailure(response) { |
663
|
|
|
callback(response); |
664
|
|
|
}, |
665
|
|
|
onError(response) { |
666
|
|
|
callback(response); |
667
|
|
|
}, |
668
|
|
|
}); |
669
|
|
|
}, |
670
|
|
|
|
671
|
|
|
/** |
672
|
|
|
* Удаление модуля расширения |
673
|
|
|
* |
674
|
|
|
* @param moduleName - id модуля |
675
|
|
|
* @param keepSettings bool - сохранять ли настройки |
676
|
|
|
* @param callback - функция колбека |
677
|
|
|
*/ |
678
|
|
|
SystemDeleteModule(moduleName, keepSettings, callback) { |
679
|
|
|
$.api({ |
680
|
|
|
url: PbxApi.systemDeleteModule, |
681
|
|
|
on: 'now', |
682
|
|
|
method: 'POST', |
683
|
|
|
data: { |
684
|
|
|
uniqid: moduleName, |
685
|
|
|
keepSettings: keepSettings |
686
|
|
|
}, |
687
|
|
|
successTest: PbxApi.successTest, |
688
|
|
|
onSuccess() { |
689
|
|
|
callback(true); |
690
|
|
|
}, |
691
|
|
|
onFailure(response) { |
692
|
|
|
callback(response); |
693
|
|
|
}, |
694
|
|
|
onError(response) { |
695
|
|
|
callback(response); |
696
|
|
|
}, |
697
|
|
|
}); |
698
|
|
|
}, |
699
|
|
|
/** |
700
|
|
|
* Gets module download status |
701
|
|
|
* @param moduleUniqueID |
702
|
|
|
* @param callback |
703
|
|
|
* @param failureCallback |
704
|
|
|
*/ |
705
|
|
|
FilesModuleDownloadStatus(moduleUniqueID, callback, failureCallback) { |
706
|
|
|
$.api({ |
707
|
|
|
url: PbxApi.filesModuleDownloadStatus, |
708
|
|
|
on: 'now', |
709
|
|
|
timeout: 3000, |
710
|
|
|
method: 'POST', |
711
|
|
|
data: {uniqid:moduleUniqueID}, |
712
|
|
|
successTest: PbxApi.successTest, |
713
|
|
|
onSuccess(response) { |
714
|
|
|
callback(response.data); |
715
|
|
|
}, |
716
|
|
|
onFailure() { |
717
|
|
|
failureCallback(); |
718
|
|
|
}, |
719
|
|
|
onError() { |
720
|
|
|
failureCallback(); |
721
|
|
|
}, |
722
|
|
|
onAbort() { |
723
|
|
|
failureCallback(); |
724
|
|
|
}, |
725
|
|
|
}); |
726
|
|
|
}, |
727
|
|
|
|
728
|
|
|
/** |
729
|
|
|
* Disable pbxExtension module |
730
|
|
|
* @param {*} moduleUniqueID |
731
|
|
|
* @param {function(...[*]=)} callback |
732
|
|
|
*/ |
733
|
|
|
SystemDisableModule(moduleUniqueID, callback) { |
734
|
|
|
$.api({ |
735
|
|
|
url: PbxApi.systemDisableModule, |
736
|
|
|
on: 'now', |
737
|
|
|
method: 'POST', |
738
|
|
|
data: {uniqid:moduleUniqueID}, |
739
|
|
|
successTest: PbxApi.successTest, |
740
|
|
|
onSuccess(response) { |
741
|
|
|
callback(response, true); |
742
|
|
|
}, |
743
|
|
|
onFailure(response) { |
744
|
|
|
callback(response, false); |
745
|
|
|
}, |
746
|
|
|
onError(response) { |
747
|
|
|
callback(response, false); |
748
|
|
|
}, |
749
|
|
|
|
750
|
|
|
}); |
751
|
|
|
}, |
752
|
|
|
/** |
753
|
|
|
* Disable pbxExtension module |
754
|
|
|
* @param {string} moduleUniqueID |
755
|
|
|
* @param {function(...[*]=)} callback |
756
|
|
|
*/ |
757
|
|
|
SystemEnableModule(moduleUniqueID, callback) { |
758
|
|
|
$.api({ |
759
|
|
|
url: PbxApi.systemEnableModule, |
760
|
|
|
on: 'now', |
761
|
|
|
method: 'POST', |
762
|
|
|
data: {uniqid:moduleUniqueID}, |
763
|
|
|
successTest: PbxApi.successTest, |
764
|
|
|
onSuccess(response) { |
765
|
|
|
callback(response, true); |
766
|
|
|
}, |
767
|
|
|
onFailure(response) { |
768
|
|
|
callback(response, false); |
769
|
|
|
}, |
770
|
|
|
onError(response) { |
771
|
|
|
callback(response, false); |
772
|
|
|
}, |
773
|
|
|
|
774
|
|
|
}); |
775
|
|
|
}, |
776
|
|
|
/** |
777
|
|
|
* Downloads new firmware from provided url |
778
|
|
|
* |
779
|
|
|
*/ |
780
|
|
|
FilesDownloadNewFirmware(params, callback) { |
781
|
|
|
$.api({ |
782
|
|
|
url: PbxApi.filesDownloadNewFirmware, |
783
|
|
|
on: 'now', |
784
|
|
|
method: 'POST', |
785
|
|
|
data: { |
786
|
|
|
md5:params.md5, |
787
|
|
|
size:params.size, |
788
|
|
|
version:params.version, |
789
|
|
|
url:params.updateLink |
790
|
|
|
}, |
791
|
|
|
successTest: PbxApi.successTest, |
792
|
|
|
onSuccess(response) { |
793
|
|
|
callback(response.data); |
794
|
|
|
}, |
795
|
|
|
onFailure(response) { |
796
|
|
|
callback(response); |
797
|
|
|
}, |
798
|
|
|
onError(response) { |
799
|
|
|
callback(response); |
800
|
|
|
}, |
801
|
|
|
}); |
802
|
|
|
}, |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* Gets firmware download status |
806
|
|
|
* @param {string} filename |
807
|
|
|
* @param {function(*): (undefined)} callback |
808
|
|
|
*/ |
809
|
|
|
FilesFirmwareDownloadStatus(filename, callback) { |
810
|
|
|
$.api({ |
811
|
|
|
url: PbxApi.filesFirmwareDownloadStatus, |
812
|
|
|
on: 'now', |
813
|
|
|
method: 'POST', |
814
|
|
|
data: {filename}, |
815
|
|
|
successTest: PbxApi.successTest, |
816
|
|
|
onSuccess(response) { |
817
|
|
|
callback(response.data); |
818
|
|
|
}, |
819
|
|
|
onFailure() { |
820
|
|
|
callback(false); |
821
|
|
|
}, |
822
|
|
|
onError() { |
823
|
|
|
callback(false); |
824
|
|
|
}, |
825
|
|
|
}); |
826
|
|
|
}, |
827
|
|
|
/** |
828
|
|
|
* Подключение обработчкика загрузки файлов по частям |
829
|
|
|
*/ |
830
|
|
|
SystemUploadFileAttachToBtn(buttonId, fileTypes, callback) { |
831
|
|
|
const r = new Resumable({ |
832
|
|
|
target: PbxApi.filesUploadFile, |
833
|
|
|
testChunks: false, |
834
|
|
|
chunkSize: 30 * 1024 * 1024, |
835
|
|
|
maxFiles: 1, |
836
|
|
|
fileType: fileTypes, |
837
|
|
|
}); |
838
|
|
|
|
839
|
|
|
r.assignBrowse(document.getElementById(buttonId)); |
840
|
|
|
r.on('fileSuccess', (file, response) => { |
841
|
|
|
callback('fileSuccess', {file, response}); |
842
|
|
|
}); |
843
|
|
|
r.on('fileProgress', (file) => { |
844
|
|
|
callback('fileProgress', {file}); |
845
|
|
|
}); |
846
|
|
|
r.on('fileAdded', (file, event) => { |
847
|
|
|
r.upload(); |
848
|
|
|
callback('fileAdded', {file, event}); |
849
|
|
|
}); |
850
|
|
|
r.on('fileRetry', (file) => { |
851
|
|
|
callback('fileRetry', {file}); |
852
|
|
|
}); |
853
|
|
|
r.on('fileError', (file, message) => { |
854
|
|
|
callback('fileError', {file, message}); |
855
|
|
|
}); |
856
|
|
|
r.on('uploadStart', () => { |
857
|
|
|
callback('uploadStart'); |
858
|
|
|
}); |
859
|
|
|
r.on('complete', () => { |
860
|
|
|
callback('complete'); |
861
|
|
|
}); |
862
|
|
|
r.on('progress', () => { |
863
|
|
|
const percent = 100 * r.progress(); |
864
|
|
|
callback('progress', {percent}); |
865
|
|
|
}); |
866
|
|
|
r.on('error', (message, file) => { |
867
|
|
|
callback('error', {message, file}); |
868
|
|
|
}); |
869
|
|
|
r.on('pause', () => { |
870
|
|
|
callback('pause'); |
871
|
|
|
}); |
872
|
|
|
r.on('cancel', () => { |
873
|
|
|
callback('cancel'); |
874
|
|
|
}); |
875
|
|
|
}, |
876
|
|
|
/** |
877
|
|
|
* Enables upload by chunk resumable worker |
878
|
|
|
*/ |
879
|
|
|
FilesUploadFile(file, callback) { |
880
|
|
|
const r = new Resumable({ |
881
|
|
|
target: PbxApi.filesUploadFile, |
882
|
|
|
testChunks: false, |
883
|
|
|
chunkSize: 30 * 1024 * 1024, |
884
|
|
|
maxFiles: 1, |
885
|
|
|
}); |
886
|
|
|
|
887
|
|
|
r.addFile(file); |
888
|
|
|
r.upload(); |
889
|
|
|
r.on('fileSuccess', (file, response) => { |
890
|
|
|
callback('fileSuccess', {file, response}); |
891
|
|
|
}); |
892
|
|
|
r.on('fileProgress', (file) => { |
893
|
|
|
callback('fileProgress', {file}); |
894
|
|
|
}); |
895
|
|
|
r.on('fileAdded', (file, event) => { |
896
|
|
|
r.upload(); |
897
|
|
|
callback('fileAdded', {file, event}); |
898
|
|
|
}); |
899
|
|
|
r.on('fileRetry', (file) => { |
900
|
|
|
callback('fileRetry', {file}); |
901
|
|
|
}); |
902
|
|
|
r.on('fileError', (file, message) => { |
903
|
|
|
callback('fileError', {file, message}); |
904
|
|
|
}); |
905
|
|
|
r.on('uploadStart', () => { |
906
|
|
|
callback('uploadStart'); |
907
|
|
|
}); |
908
|
|
|
r.on('complete', () => { |
909
|
|
|
callback('complete'); |
910
|
|
|
}); |
911
|
|
|
r.on('progress', () => { |
912
|
|
|
const percent = 100 * r.progress(); |
913
|
|
|
callback('progress', {percent}); |
914
|
|
|
}); |
915
|
|
|
r.on('error', (message, file) => { |
916
|
|
|
callback('error', {message, file}); |
917
|
|
|
}); |
918
|
|
|
r.on('pause', () => { |
919
|
|
|
callback('pause'); |
920
|
|
|
}); |
921
|
|
|
r.on('cancel', () => { |
922
|
|
|
callback('cancel'); |
923
|
|
|
}); |
924
|
|
|
}, |
925
|
|
|
|
926
|
|
|
/** |
927
|
|
|
* Gets uploading status |
928
|
|
|
*/ |
929
|
|
|
FilesGetStatusUploadFile(fileId, callback) { |
930
|
|
|
$.api({ |
931
|
|
|
url: PbxApi.filesStatusUploadFile, |
932
|
|
|
on: 'now', |
933
|
|
|
method: 'POST', |
934
|
|
|
data: {id:fileId}, |
935
|
|
|
successTest: PbxApi.successTest, |
936
|
|
|
onSuccess(response) { |
937
|
|
|
callback(response.data); |
938
|
|
|
}, |
939
|
|
|
onFailure() { |
940
|
|
|
callback(false); |
941
|
|
|
}, |
942
|
|
|
onError() { |
943
|
|
|
callback(false); |
944
|
|
|
}, |
945
|
|
|
}); |
946
|
|
|
}, |
947
|
|
|
/** |
948
|
|
|
* Update WorkerApiCommands language |
949
|
|
|
*/ |
950
|
|
|
SystemChangeCoreLanguage() { |
951
|
|
|
$.api({ |
952
|
|
|
url: PbxApi.systemChangeCoreLanguage, |
953
|
|
|
on: 'now', |
954
|
|
|
}); |
955
|
|
|
}, |
956
|
|
|
/** |
957
|
|
|
* Delete all system settings |
958
|
|
|
*/ |
959
|
|
|
SystemRestoreDefaultSettings(callback) { |
960
|
|
|
$.api({ |
961
|
|
|
url: PbxApi.systemRestoreDefaultSettings, |
962
|
|
|
on: 'now', |
963
|
|
|
successTest: PbxApi.successTest, |
964
|
|
|
onSuccess() { |
965
|
|
|
callback(true); |
966
|
|
|
}, |
967
|
|
|
onFailure(response) { |
968
|
|
|
callback(response.messages); |
969
|
|
|
}, |
970
|
|
|
}); |
971
|
|
|
}, |
972
|
|
|
|
973
|
|
|
|
974
|
|
|
/** |
975
|
|
|
* Makes the list of notifications about system, firewall, passwords, wrong settings |
976
|
|
|
* |
977
|
|
|
* @param callback |
978
|
|
|
* |
979
|
|
|
*/ |
980
|
|
|
AdvicesGetList(callback) { |
981
|
|
|
$.api({ |
982
|
|
|
url: PbxApi.advicesGetList, |
983
|
|
|
on: 'now', |
984
|
|
|
successTest: PbxApi.successTest, |
985
|
|
|
onSuccess(response) { |
986
|
|
|
callback(response.data); |
987
|
|
|
}, |
988
|
|
|
onFailure() { |
989
|
|
|
callback(false); |
990
|
|
|
}, |
991
|
|
|
onError() { |
992
|
|
|
callback(false); |
993
|
|
|
}, |
994
|
|
|
}); |
995
|
|
|
}, |
996
|
|
|
|
997
|
|
|
/** |
998
|
|
|
* Reset license key settings |
999
|
|
|
* |
1000
|
|
|
* @param callback |
1001
|
|
|
* |
1002
|
|
|
*/ |
1003
|
|
|
LicenseResetLicenseKey(callback) { |
1004
|
|
|
$.api({ |
1005
|
|
|
url: PbxApi.licenseResetKey, |
1006
|
|
|
on: 'now', |
1007
|
|
|
successTest: PbxApi.successTest, |
1008
|
|
|
onSuccess(response) { |
1009
|
|
|
callback(response.data); |
1010
|
|
|
}, |
1011
|
|
|
onFailure() { |
1012
|
|
|
callback(false); |
1013
|
|
|
}, |
1014
|
|
|
onError() { |
1015
|
|
|
callback(false); |
1016
|
|
|
}, |
1017
|
|
|
}); |
1018
|
|
|
}, |
1019
|
|
|
|
1020
|
|
|
/** |
1021
|
|
|
* Update license key, get new one, activate coupon |
1022
|
|
|
* |
1023
|
|
|
* @param formData |
1024
|
|
|
* @param callback |
1025
|
|
|
*/ |
1026
|
|
|
LicenseProcessUserRequest(formData, callback) { |
1027
|
|
|
$.api({ |
1028
|
|
|
url: PbxApi.licenseProcessUserRequest, |
1029
|
|
|
on: 'now', |
1030
|
|
|
method: 'POST', |
1031
|
|
|
data: formData, |
1032
|
|
|
successTest: PbxApi.successTest, |
1033
|
|
|
onSuccess(response) { |
1034
|
|
|
callback(response.data, true); |
1035
|
|
|
}, |
1036
|
|
|
onFailure(response) { |
1037
|
|
|
callback(response, false); |
1038
|
|
|
}, |
1039
|
|
|
onError() { |
1040
|
|
|
callback(false); |
1041
|
|
|
}, |
1042
|
|
|
}); |
1043
|
|
|
}, |
1044
|
|
|
|
1045
|
|
|
/** |
1046
|
|
|
* Get license information from license server |
1047
|
|
|
* |
1048
|
|
|
* @param callback |
1049
|
|
|
* |
1050
|
|
|
*/ |
1051
|
|
|
LicenseGetLicenseInfo(callback) { |
1052
|
|
|
$.api({ |
1053
|
|
|
url: PbxApi.licenseGetLicenseInfo, |
1054
|
|
|
on: 'now', |
1055
|
|
|
successTest: PbxApi.successTest, |
1056
|
|
|
onSuccess(response) { |
1057
|
|
|
callback(response.data); |
1058
|
|
|
}, |
1059
|
|
|
onFailure(response) { |
1060
|
|
|
callback(response); |
1061
|
|
|
}, |
1062
|
|
|
onError() { |
1063
|
|
|
callback(false); |
1064
|
|
|
}, |
1065
|
|
|
}); |
1066
|
|
|
}, |
1067
|
|
|
|
1068
|
|
|
/** |
1069
|
|
|
* Check whether license system works good or not |
1070
|
|
|
* |
1071
|
|
|
* @param callback |
1072
|
|
|
* |
1073
|
|
|
*/ |
1074
|
|
|
LicenseGetMikoPBXFeatureStatus(callback) { |
1075
|
|
|
$.api({ |
1076
|
|
|
url: PbxApi.licenseGetMikoPBXFeatureStatus, |
1077
|
|
|
on: 'now', |
1078
|
|
|
successTest: PbxApi.successTest, |
1079
|
|
|
onSuccess() { |
1080
|
|
|
callback(true); |
1081
|
|
|
}, |
1082
|
|
|
onFailure(response) { |
1083
|
|
|
callback(response); |
1084
|
|
|
}, |
1085
|
|
|
onError() { |
1086
|
|
|
callback(false); |
1087
|
|
|
}, |
1088
|
|
|
}); |
1089
|
|
|
}, |
1090
|
|
|
|
1091
|
|
|
/** |
1092
|
|
|
* Tries to capture feature. |
1093
|
|
|
* If it fails we try to get trial and then try capture again. |
1094
|
|
|
* |
1095
|
|
|
* @param params |
1096
|
|
|
* @param callback |
1097
|
|
|
*/ |
1098
|
|
|
LicenseCaptureFeatureForProductId(params, callback) { |
1099
|
|
|
const licFeatureId = params.licFeatureId; |
1100
|
|
|
const licProductId = params.licProductId; |
1101
|
|
|
$.api({ |
1102
|
|
|
url: PbxApi.licenseCaptureFeatureForProductId, |
1103
|
|
|
on: 'now', |
1104
|
|
|
method: 'POST', |
1105
|
|
|
data: {licFeatureId, licProductId}, |
1106
|
|
|
successTest: PbxApi.successTest, |
1107
|
|
|
onSuccess() { |
1108
|
|
|
callback(params, true); |
1109
|
|
|
}, |
1110
|
|
|
onFailure(response) { |
1111
|
|
|
callback(response.messages, false); |
1112
|
|
|
}, |
1113
|
|
|
onError() { |
1114
|
|
|
callback('', false); |
1115
|
|
|
}, |
1116
|
|
|
}); |
1117
|
|
|
}, |
1118
|
|
|
/** |
1119
|
|
|
* Sends PBX metrics |
1120
|
|
|
* |
1121
|
|
|
* @param callback |
1122
|
|
|
*/ |
1123
|
|
|
LicenseSendPBXMetrics(callback) { |
1124
|
|
|
$.api({ |
1125
|
|
|
url: PbxApi.licenseSendPBXMetrics, |
1126
|
|
|
on: 'now', |
1127
|
|
|
successTest: PbxApi.successTest, |
1128
|
|
|
onSuccess() { |
1129
|
|
|
callback(true); |
1130
|
|
|
}, |
1131
|
|
|
onFailure() { |
1132
|
|
|
callback(false); |
1133
|
|
|
}, |
1134
|
|
|
onError() { |
1135
|
|
|
callback(false); |
1136
|
|
|
}, |
1137
|
|
|
}); |
1138
|
|
|
}, |
1139
|
|
|
|
1140
|
|
|
}; |
1141
|
|
|
|