node-red-contrib-alice 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodes/alice-device.js +0 -1
- package/nodes/alice-range.js +0 -1
- package/nodes/alice.html +48 -29
- package/package.json +1 -1
package/nodes/alice-device.js
CHANGED
package/nodes/alice-range.js
CHANGED
package/nodes/alice.html
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
return this.name || "Alice-Credentials";
|
|
17
17
|
},
|
|
18
18
|
oneditprepare:function(){
|
|
19
|
+
// $('#dev-on-gate').text("checking ...");
|
|
20
|
+
$('#subscribe-status').text("checking ...");
|
|
19
21
|
let em = $('#node-config-input-email').val();
|
|
20
22
|
let idt = $('#node-config-input-id').val();
|
|
21
23
|
getDeviceCount(idt,em,"dev-on-gate");
|
|
@@ -26,32 +28,35 @@
|
|
|
26
28
|
$('#node-config-input-name').val(nodename);
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
|
-
function getDeviceCount(id, email, contId){
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
31
|
+
// function getDeviceCount(id, email, contId){
|
|
32
|
+
// $.ajax({
|
|
33
|
+
// url: "https://nodered-home.ru/api/v1/devices/count",
|
|
34
|
+
// type:"POST",
|
|
35
|
+
// headers: {
|
|
36
|
+
// 'Content-Type':'application/json'
|
|
37
|
+
// },
|
|
38
|
+
// crossDomain: true,
|
|
39
|
+
// contentType:"application/json",
|
|
40
|
+
// data: JSON.stringify({
|
|
41
|
+
// id: id,
|
|
42
|
+
// email: email
|
|
43
|
+
// }),
|
|
44
|
+
// dataType: "json",
|
|
45
|
+
// format:"json"
|
|
46
|
+
// })
|
|
47
|
+
// .done(result=>{
|
|
48
|
+
// $('#'+contId).text(result.data.text);
|
|
49
|
+
// })
|
|
50
|
+
// .fail(error=>{
|
|
51
|
+
// console.log(error)
|
|
52
|
+
// console.error(error.responseJSON);
|
|
53
|
+
// RED.notify("Error : "+error.responseJSON.message, {type:"error"});
|
|
54
|
+
// });
|
|
55
|
+
// };
|
|
54
56
|
function getSubscribeStatus(id, email, contId){
|
|
57
|
+
if (email.length < 3 || id.length < 3){
|
|
58
|
+
return;
|
|
59
|
+
};
|
|
55
60
|
$.ajax({
|
|
56
61
|
url: "https://nodered-home.ru/payment/getsubscribestatus",
|
|
57
62
|
type:"POST",
|
|
@@ -69,7 +74,7 @@
|
|
|
69
74
|
})
|
|
70
75
|
.done(result=>{
|
|
71
76
|
// console.log(result);
|
|
72
|
-
$('#'+contId).text(result.text);
|
|
77
|
+
$('#'+contId).text(result.data.text);
|
|
73
78
|
})
|
|
74
79
|
.fail(error=>{
|
|
75
80
|
console.log(error)
|
|
@@ -110,6 +115,7 @@
|
|
|
110
115
|
|
|
111
116
|
};
|
|
112
117
|
function pay(id, email) {
|
|
118
|
+
console.log("Start pay");
|
|
113
119
|
if (!id || !email){
|
|
114
120
|
RED.notify("Please authorize before purchasing a subscription", {type:"error"});
|
|
115
121
|
return;
|
|
@@ -117,6 +123,7 @@
|
|
|
117
123
|
$('#subscribe-button').prop('disabled', true);
|
|
118
124
|
RED.notify("Request has been sent. Please, wait",{type:"compact"});
|
|
119
125
|
let paymentWidget = new cp.CloudPayments();
|
|
126
|
+
console.log("Start get pay confi");
|
|
120
127
|
$.ajax({
|
|
121
128
|
url: "https://nodered-home.ru/payment/create",
|
|
122
129
|
type:"POST",
|
|
@@ -133,12 +140,20 @@
|
|
|
133
140
|
format:"json"
|
|
134
141
|
})
|
|
135
142
|
.done(paydata=>{
|
|
136
|
-
console.log(
|
|
143
|
+
console.log("pay config done");
|
|
144
|
+
console.log("Start widget");
|
|
137
145
|
paymentWidget.pay('auth', // или 'charge'
|
|
138
146
|
paydata,
|
|
139
147
|
{
|
|
140
148
|
onSuccess: function (result) { // success
|
|
141
149
|
//действие при успешной оплате
|
|
150
|
+
let em = $('#node-config-input-email').val();
|
|
151
|
+
let idt = $('#node-config-input-id').val();
|
|
152
|
+
$('#subscribe-status').text("checking ...");
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
getSubscribeStatus(idt,em,"subscribe-status");
|
|
155
|
+
}, 2000);
|
|
156
|
+
|
|
142
157
|
},
|
|
143
158
|
onFail: function (reason, options) { // fail
|
|
144
159
|
//действие при неуспешной оплате
|
|
@@ -209,13 +224,17 @@
|
|
|
209
224
|
<p><b>Subscription:</b></p>
|
|
210
225
|
</div>
|
|
211
226
|
<div class="form-row">
|
|
212
|
-
<label for="node-config-input-token" style="width: 150px">
|
|
213
|
-
<label for="node-config-input-token" style="width: 150px">Subscription status:</label> <span id="subscribe-status"></span>
|
|
227
|
+
<label for="node-config-input-token" style="width: 150px">Subscription status:</label> <span id="subscribe-status"></span>
|
|
214
228
|
<div class="form-tips" id="node-tip-subscribe-warn">
|
|
215
229
|
<span>Important:</span><br>
|
|
216
230
|
<span> - By purchasing a subscription, you agree to the terms of the <a href="https://nodered-home.ru/public_offer.pdf" target="_blank">public offer</a></span><br>
|
|
217
231
|
<span> - View and manage your subscriptions <a href="https://my.cloudpayments.ru/ru/unsubscribe" target="_blank">here</a></span>
|
|
218
232
|
<div style="text-align: end">
|
|
233
|
+
<!-- <label for="node-input-subList" style="text-align: start">Period:</label>
|
|
234
|
+
<select id="node-input-subList" style="width:70%; margin-top:10px; margin-bottom:10px;">
|
|
235
|
+
<option value=1>1 month - 199 rubles</option>
|
|
236
|
+
<option value=12>12 month - 2 300 rubles</option>
|
|
237
|
+
</select> -->
|
|
219
238
|
<button id="subscribe-button"
|
|
220
239
|
onclick="pay($('#node-config-input-id').val(), $('#node-config-input-email').val())"
|
|
221
240
|
class="ui-button">Buy a subscription
|