1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,96 @@ |
1 |
+/** |
|
2 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
+ * |
|
4 |
+ * @author Double Bastion LLC |
|
5 |
+ * |
|
6 |
+ * @license GNU AGPL version 3 or any later version |
|
7 |
+ * |
|
8 |
+ * This program is free software; you can redistribute it and/or |
|
9 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
+ * License as published by the Free Software Foundation; either |
|
11 |
+ * version 3 of the License, or any later version. |
|
12 |
+ * |
|
13 |
+ * This program is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
+ * |
|
18 |
+ * You should have received a copy of the GNU Affero General Public |
|
19 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$(document).ready(function() { |
|
24 |
+ |
|
25 |
+ $("#save_fax_settings").on("click", function(event) { |
|
26 |
+ |
|
27 |
+ event.preventDefault(); |
|
28 |
+ OC.msg.startAction("#paxfax_save_msg", t("pax_fax", "Saved")); |
|
29 |
+ |
|
30 |
+ var baseUrl = OC.generateUrl("/apps/pax_fax/user/updatesettings"); |
|
31 |
+ var userid = "<?php p($userId); ?>"; |
|
32 |
+ var getnotify = 0; |
|
33 |
+ |
|
34 |
+ if ($("#get_notification").is(':checked')) { |
|
35 |
+ getnotify = 1; |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ var emailaddressinit = $("#notification_email").val(); |
|
39 |
+ |
|
40 |
+ function validate_email($email) { |
|
41 |
+ var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; |
|
42 |
+ return email_reg.test($email); |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ if (validate_email(emailaddressinit)) { |
|
46 |
+ var notifyemail = emailaddressinit; |
|
47 |
+ } else { |
|
48 |
+ var notifyemail = ''; |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ var datatosave = { |
|
52 |
+ userId: userid, |
|
53 |
+ apiKey: $("#api_key").val(), |
|
54 |
+ apiSecret: $("#api_secret").val(), |
|
55 |
+ webhookToken: $("#webhook_token").val(), |
|
56 |
+ receiveUrl: $("#receive_url").val(), |
|
57 |
+ getNotification: getnotify, |
|
58 |
+ notificationEmail: notifyemail |
|
59 |
+ }; |
|
60 |
+ |
|
61 |
+ $.ajax({ |
|
62 |
+ method: 'PUT', |
|
63 |
+ url: baseUrl + '/' + userid, |
|
64 |
+ contentType: 'application/json', |
|
65 |
+ data: JSON.stringify(datatosave), |
|
66 |
+ error: function(resp){ |
|
67 |
+ alert('Error ! Please check your settings !'); |
|
68 |
+ } |
|
69 |
+ }); |
|
70 |
+ |
|
71 |
+ }); |
|
72 |
+ |
|
73 |
+ var baseUrlget = OC.generateUrl("/apps/pax_fax/user/getsettings"); |
|
74 |
+ var userid = "<?php p($userId); ?>"; |
|
75 |
+ |
|
76 |
+ $.ajax({ |
|
77 |
+ method: 'GET', |
|
78 |
+ url: baseUrlget + '/' + userid, |
|
79 |
+ contentType: 'application/json', |
|
80 |
+ success: function(settingsfromdb) { |
|
81 |
+ $("#api_key").val(settingsfromdb.api_key); |
|
82 |
+ $("#api_secret").val(settingsfromdb.api_secret); |
|
83 |
+ $("#webhook_token").val(settingsfromdb.webhook_token); |
|
84 |
+ $("#receive_url").val(settingsfromdb.receive_url); |
|
85 |
+ $("#notification_email").val(settingsfromdb.notification_email); |
|
86 |
+ |
|
87 |
+ if (settingsfromdb.get_notification == 1) { |
|
88 |
+ $("#get_notification").attr('checked', true); |
|
89 |
+ } else { |
|
90 |
+ $("#get_notification").attr('checked', false); |
|
91 |
+ } |
|
92 |
+ } |
|
93 |
+ }); |
|
94 |
+ |
|
95 |
+}); |
|
96 |
+ |