1+ < script type ="text/x-red " data-template-name ="nodered get pods ">
2+ < div class = "form-row" >
3+ < label for = "node-input-targetid-search" > < i class = "fa fa-tasks" > </ i > Search</ label >
4+ < input type = "text" id = "node-input-targetid-search" placeholder = "Search" >
5+ </ div >
6+ < div class = "form-row" >
7+ < label for = "node-input-targetid" > < i class = "fa fa-tasks" > </ i > Target</ label >
8+ < select id = "node-input-targetid-select" >
9+ < option > Loading...</ option >
10+ </ select >
11+ < input id = "node-input-targetid" type = "hidden" >
12+ </ div >
13+ < div class = "form-row" >
14+ < label > < i class = "fa fa-tag" > </ i > Name</ label >
15+ < input type = "text" id = "node-input-name" placeholder = "Name" >
16+ </ div >
17+ </ script >
18+ < script type ="text/x-red " data-help-name ="nodered get pods ">
19+ < p > Grab all nodered pods for current user.</ p >
20+ </ script >
21+ < script type ="text/javascript ">
22+ RED . nodes . registerType ( 'nodered get pods' , {
23+ category : 'api' ,
24+ color : "#DEB887" ,
25+ paletteLabel : 'get' ,
26+ icon : "font-awesome/fa-database" ,
27+ defaults : {
28+ name : { value : "" } ,
29+ targetid : { value : "result._id" } ,
30+ } ,
31+ inputs : 1 ,
32+ outputs : 1 ,
33+ label : function ( ) {
34+ return this . name || "get pods" ;
35+ } ,
36+ labelStyle : function ( ) {
37+ return this . name ? "node_label_italic" : "" ;
38+ } ,
39+ oneditprepare : function ( ) {
40+ var reloadUsers = function ( firstrun ) {
41+ $ ( '#node-input-targetid-select' ) . empty ( ) ;
42+ $ ( '#node-input-targetid-select' ) . append ( $ ( '<option>' , {
43+ value : - 1 ,
44+ text : "Loading..."
45+ } ) ) ;
46+ $ ( '#node-input-targetid-select' ) . val ( - 1 ) ;
47+ $ . getJSON ( 'api_users' , { name : $ ( '#node-input-targetid-search' ) . val ( ) } , function ( data ) {
48+ $ ( '#node-input-targetid-select' ) . empty ( ) ;
49+ $ . each ( data , function ( i , ele ) {
50+ $ ( '#node-input-targetid-select' ) . append ( $ ( '<option>' , {
51+ value : ele . _id ,
52+ text : ele . name
53+ } ) ) ;
54+ } ) ;
55+ $ ( '#node-input-targetid-select' ) . val ( $ ( '#node-input-targetid' ) . val ( ) ) ;
56+ } ) . error ( function ( jqXHR , textStatus , errorThrown ) {
57+ console . log ( "error " + textStatus ) ;
58+ console . log ( "incoming Text " + jqXHR . responseText ) ;
59+ alert ( "error:" + jqXHR . responseText ) ;
60+ } ) ;
61+ }
62+ $ ( '#node-input-targetid-search' ) . change ( ( ) => {
63+ reloadUsers ( false ) ;
64+ } )
65+ reloadUsers ( true ) ;
66+ } ,
67+ oneditsave : function ( ) {
68+ $ ( '#node-input-targetid' ) . val ( $ ( '#node-input-targetid-select' ) . val ( ) ) ;
69+ }
70+
71+ } ) ;
72+
73+ </ script >
0 commit comments