-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnode-red-trello.html
146 lines (126 loc) · 4.81 KB
/
node-red-trello.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!-- CREDENTIALS -->
<script type="text/javascript">
(function() {
RED.nodes.registerType('trello-credentials',{
category: 'config',
defaults: {
name: {value:""}
},
credentials: {
token: {type: "password"},
apikey: {type:"password"}
},
label: function() {
return this.name;
},
exportable: false,
oneditprepare: function() {
var trelloConfigNodeId = this.id;
var apikeybutton = this._("trello.label.apikeybutton");
var trelloID = this._("trello.label.trello-id");
function showTrelloAuthStart(){
$("#node-config-dialog-ok").button("disable");
$("#node-config-input-apikey").change(function() {
$("#node-config-trello-tokenbutton").attr('href', 'https://trello.com/1/authorize?key='+$("#node-config-input-apikey").val()+'&name=NODE-RED&expiration=never&response_type=token&scope=read,write')
});
$("#node-config-input-token").change(function() {
if($("#node-config-input-token").val() && $("#node-config-input-token").val() != "" && $("#node-config-input-apikey").val() && $("#node-config-input-apikey").val() != ""){
//iuuh
}
});
$("#node-config-trello-startconfig").click(function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var username = JSON.parse(xmlhttp.response).username;
//this.name = username;
$("#node-config-input-name").val(username);
$("#node-config-dialog-ok").button("enable");
}
}
xmlhttp.open("GET","https://trello.com/1/members/me?key="+ $("#node-config-input-apikey").val() +"&token=" + $("#node-config-input-token").val() + "",true);
xmlhttp.send();
});
}
showTrelloAuthStart();
},
oneditsave: function() {
console.log("SAVE");
}
});
})();
</script>
<script type="text/x-red" data-template-name="trello-credentials">
<div class="form-row" id="node-config-trello-row">
<div style="text-align: center; margin-top: 20px; ">
<a class="btn" id="node-config-trello-devkey" href="https://trello.com/app-key" target="_blank"><span data-i18n="trello.label.apikeybutton"></span></a>
</div>
</div>
<div class="form-row">
<label for="node-config-input-apikey"><i class="fa fa-user"></i> <span data-i18n="trello.label.apikey"></span></label>
<input type="text" id="node-config-input-apikey">
</div>
<div style="text-align: center; margin-top: 20px; ">
<a class="btn" id="node-config-trello-tokenbutton" target="_blank">getToken</a>
</div>
<div class="form-row">
<label for="node-config-input-token"> <span data-i18n="trello.label.token"></span></label>
<input type="text" id="node-config-input-token">
</div>
<div style="text-align: center; margin-top: 20px; ">
<a class="btn" id="node-config-trello-startconfig" target="_blank">Start Config</a>
</div>
<input type="hidden" id="node-config-input-name">
</script>
<!-- CREATE CARD> -->
<script type="text/javascript">
RED.nodes.registerType('create-card',{
category: 'social-output',
color: '#298FCA',
defaults: {
trello: {value: "", type:"trello-credentials", required:true},
name: {value:""}
},
inputs:1,
outputs:0,
icon: "trello.png",
align: "right",
label: function() {
return this.name||"Create Card";
}
});
</script>
<script type="text/x-red" data-template-name="create-card">
<div class="form-row">
<label for="node-input-trello"><i class="fa fa-user"></i> <span data-i18n="trello.label.trello-id"></span></label>
<input type="text" id="node-input-trello">
</div>
</script>
<script type="text/x-red" data-help-name="create-card">
<p>A simple node to create a Trello Card</p>
</script>
<!-- GET BOARDS> -->
<script type="text/javascript">
RED.nodes.registerType('get-boards',{
category: 'social',
color: '#298FCA',
defaults: {
trello: {type:"trello-credentials", required:true}
},
inputs:1,
outputs:1,
icon: "trello.png",
label: function() {
return this.name||"Get Boards";
}
});
</script>
<script type="text/x-red" data-template-name="get-boards">
<div class="form-row">
<label for="node-input-trello"><i class="fa fa-user"></i> <span data-i18n="trello.label.trello-id"></span></label>
<input type="text" id="node-input-trello">
</div>
</script>
<script type="text/x-red" data-help-name="get-boards">
<p>A simple node to create a Trello Card</p>
</script>