|
1 | 1 | <script type="text/javascript">
|
2 | 2 | RED.nodes.registerType('rsync', {
|
3 | 3 | category: 'advanced',
|
4 |
| - color: '#a6bbcf', |
| 4 | + color: '#9999ff', |
5 | 5 | defaults: {
|
6 | 6 | name: { value: ""},
|
7 |
| - source: { value: "" }, |
8 |
| - destination: { value: "" }, |
| 7 | + source: { value: "", validate: RED.validators.typedInput("sourceType") }, |
| 8 | + sourceType: { value: "str" }, |
| 9 | + destination: { value: "", validate: RED.validators.typedInput("destinationType") }, |
| 10 | + destinationType: { value: "str" }, |
| 11 | + exclude: { value: "", validate: RED.validators.typedInput("excludeType") }, |
| 12 | + excludeType: { value: "str" }, |
| 13 | + include: { value: "", validate: RED.validators.typedInput("includeType") }, |
| 14 | + includeType: { value: "str" }, |
| 15 | + dryrun: { value: "" }, |
9 | 16 | verbose: { value: "" },
|
10 | 17 | recursive: { value: "" },
|
| 18 | + options: { value: ""}, |
| 19 | + extra: { value: "", validate: RED.validators.typedInput("extraType") }, |
| 20 | + extraType: { value: "str" }, |
11 | 21 | },
|
12 | 22 | inputs: 1,
|
13 | 23 | outputs: 2,
|
14 | 24 | icon: "file.png",
|
15 | 25 | label: function() {
|
16 | 26 | return this.name || "rsync";
|
17 |
| - } |
| 27 | + }, |
| 28 | + oneditprepare: function() { |
| 29 | + hookup("source", this.sourceType) |
| 30 | + hookup("destination", this.destinationType) |
| 31 | + hookup("exclude", this.excludeType) |
| 32 | + hookup("include", this.includeType) |
| 33 | + hookup("extra", this.extraType) |
| 34 | + }, |
18 | 35 | });
|
| 36 | + |
| 37 | + function hookup(name, field) { |
| 38 | + var f = "#node-input-"+name; |
| 39 | + var ft = f+"Type"; |
| 40 | + $(ft).val(field); |
| 41 | + $(f).typedInput({ |
| 42 | + default: 'str', |
| 43 | + typeField: $(ft), |
| 44 | + types: ['msg', 'flow', 'global', 'str', 'jsonata'], |
| 45 | + }); |
| 46 | + } |
19 | 47 | </script>
|
20 | 48 |
|
21 | 49 | <script type="text/x-red" data-template-name="rsync">
|
|
25 | 53 | </div>
|
26 | 54 | <div class="form-row">
|
27 | 55 | <label for="node-input-source"><i class="fa fa-file-text-o"></i> Source</label>
|
28 |
| - <input type="text" id="node-input-source" placeholder="Source"> |
| 56 | + <input type="text" id="node-input-source" style="width:70%"> |
| 57 | + <input type="hidden" id="node-input-sourceType"> |
29 | 58 | </div>
|
30 | 59 | <div class="form-row">
|
31 | 60 | <label for="node-input-destination"><i class="fa fa-file-text-o"></i> Destination</label>
|
32 |
| - <input type="text" id="node-input-destination" placeholder="Destination"> |
| 61 | + <input type="text" id="node-input-destination" style="width:70%"> |
| 62 | + <input type="hidden" id="node-input-destinationType"> |
| 63 | + </div> |
| 64 | + <div class="form-row"> |
| 65 | + <label for="node-input-exclude"><i class="fa fa-file-text-o"></i> Exclude</label> |
| 66 | + <input type="text" id="node-input-exclude" style="width:70%"> |
| 67 | + <input type="hidden" id="node-input-excludeType"> |
| 68 | + </div> |
| 69 | + <div class="form-row"> |
| 70 | + <label for="node-input-include"><i class="fa fa-file-text-o"></i> Include</label> |
| 71 | + <input type="text" id="node-input-include" style="width:70%"> |
| 72 | + <input type="hidden" id="node-input-includeType"> |
| 73 | + </div> |
| 74 | + <div class="form-row"> |
| 75 | + <label for="node-input-dryrun"><i class="fa fa-bug"></i> Dry run</label> |
| 76 | + <input type="checkbox" id="node-input-dryrun" style="display: inline-block; width: auto; vertical-align: top;"> |
33 | 77 | </div>
|
34 | 78 | <div class="form-row">
|
35 | 79 | <label for="node-input-verbose"><i class="fa fa-bug"></i> Verbose</label>
|
36 | 80 | <input type="checkbox" id="node-input-verbose" style="display: inline-block; width: auto; vertical-align: top;">
|
37 | 81 | </div>
|
38 | 82 | <div class="form-row">
|
39 |
| - <label for="node-input-recursive"><i class="fa fa-bug"></i> Recursive</label> |
| 83 | + <label for="node-input-recursive"><i class="fa fa-arrow-down"></i> Recursive</label> |
40 | 84 | <input type="checkbox" id="node-input-recursive" style="display: inline-block; width: auto; vertical-align: top;">
|
41 | 85 | </div>
|
| 86 | + <div class="form-row"> |
| 87 | + <label for="node-input-extra"><i class="fa fa-wrench"></i> Extra options</label> |
| 88 | + <input type="text" id="node-input-extra" style="width:70%"> |
| 89 | + <input type="hidden" id="node-input-extraType"> |
| 90 | + </div> |
42 | 91 | </script>
|
43 | 92 |
|
44 | 93 | <script type="text/x-red" data-help-name="rsync">
|
45 | 94 | <p>Uses rsyncwrapper to call rsync.</p>
|
46 |
| -<p>The node can be configured with the source and destination, as well as the options below.</p> |
| 95 | +<p> |
| 96 | + The node can be configured with the source and destination, as well as the options below. |
| 97 | +</p> |
47 | 98 | <p>When configured through the dialog, the source can only be a single folder or filename. However, when configured
|
48 | 99 | through msg, the source can also be an array of folders or filenames.</p>
|
49 | 100 |
|
50 | 101 | <h3>Inputs</h3>
|
51 |
| -<p>The following can be overridden by including them in the input msg</p> |
52 | 102 | <dl class="message-properties">
|
53 |
| - <dt>source |
54 |
| - <span class="property-type">string or array</span> |
55 |
| - </dt> |
56 |
| - <dd>The folder or filename to copy from. Can also be an array of folders and filenames.</dd> |
57 |
| - <dt>destination |
58 |
| - <span class="property-type">string</span> |
59 |
| - </dt> |
60 |
| - <dd>The folder or filename to copy to.</dd> |
61 |
| - <dt>verbose |
62 |
| - <span class="property-type">boolean</span> |
63 |
| - </dt> |
64 |
| - <dd>Include verbose flag on rsync command.</dd> |
65 |
| - <dt>recursive |
66 |
| - <span class="property-type">boolean</span> |
67 |
| - </dt> |
68 |
| - <dd>Recursively copy child folders.</dd> |
| 103 | + <dt>Source |
| 104 | + <span class="property-type">string or array</span> |
| 105 | + </dt> |
| 106 | + <dd> |
| 107 | + The folder or filename to copy from. Can also be an array of folders and filenames. |
| 108 | + If one or more contain "./", then "--relative" will be automatically added to the rsync. |
| 109 | + </dd> |
| 110 | + <dt> |
| 111 | + Destination |
| 112 | + <span class="property-type">string</span> |
| 113 | + </dt> |
| 114 | + <dt> |
| 115 | + Exclude |
| 116 | + <span class="property-type">string or array</span> |
| 117 | + </dt> |
| 118 | + <dd>One or more patterns to exclude.</dd> |
| 119 | + <dt> |
| 120 | + Include |
| 121 | + <span class="property-type">string or array</span> |
| 122 | + </dt> |
| 123 | + <dd> |
| 124 | + One or more patterns to include, overriding exclude. If "*" is excluded and you want to |
| 125 | + recurse sub-folders, add "*/" to (re)include sub-folders, along with the specific files |
| 126 | + you want to include. For example, exclude "*" and include ["*/", "*.sh"] to rsync all shell |
| 127 | + scripts in all sub-folders. |
| 128 | + </dd> |
| 129 | + <dt>Dry run |
| 130 | + <span class="property-type">boolean</span> |
| 131 | + </dt> |
| 132 | + <dd> |
| 133 | + Dry-run to show the files that would be copied without actually copying. Can be overridden |
| 134 | + with `msg.dryrun`. |
| 135 | + </dd> |
| 136 | + <dt>verbose |
| 137 | + <span class="property-type">boolean</span> |
| 138 | + </dt> |
| 139 | + <dd> |
| 140 | + Include verbose flag on rsync command. Can be overridden with `msg.verbose`. |
| 141 | + </dd> |
| 142 | + <dt>Recursive |
| 143 | + <span class="property-type">boolean</span> |
| 144 | + </dt> |
| 145 | + <dd>Recursively copy child folders. Can be overridden with `msg.recursive`.</dd> |
| 146 | + <dt>Extra options |
| 147 | + <span class="property-type">string or array</span> |
| 148 | + </dt> |
| 149 | + <dd>Include extra options on the rsync command line.</dd> |
69 | 150 | </dl>
|
70 | 151 | <h3>Outputs</h3>
|
71 | 152 | <dl class="message-properties">
|
72 | 153 | The resulting message will be sent to the first output if successfully, or the second output upon failure. The message will contain
|
73 | 154 | all of the input properties, as well as the following as appropriate:
|
74 | 155 |
|
75 | 156 | <dt>error
|
76 |
| - <span class="property-type">string</span> |
77 |
| - </dt> |
| 157 | + <span class="property-type">string</span> |
| 158 | + </dt> |
78 | 159 | <dt>stdout
|
79 |
| - <span class="property-type">string</span> |
80 |
| - </dt> |
| 160 | + <span class="property-type">string</span> |
| 161 | + </dt> |
81 | 162 | <dt>stderr
|
82 |
| - <span class="property-type">string</span> |
83 |
| - </dt> |
84 |
| - <dt>cmd |
85 |
| - <span class="property-type">string</span> |
86 |
| - <dd>The command line as sent to rsync.</dd> |
87 |
| - </dt> |
| 163 | + <span class="property-type">string</span> |
| 164 | + </dt> |
| 165 | + <dt>cmd |
| 166 | + <span class="property-type">string</span> |
| 167 | + <dd>The command line as sent to rsync.</dd> |
| 168 | + </dt> |
| 169 | +</dl> |
| 170 | +<h3>Details</h3> |
| 171 | +<dl class="message-properties"> |
| 172 | +To configure the inputs as arrays, use the JSONata format. For example, to add the following extra arguments to rsync: |
| 173 | + |
| 174 | +``` |
| 175 | +[ |
| 176 | + '--prune-empty-dirs', |
| 177 | + '--times' |
| 178 | +] |
| 179 | +``` |
| 180 | + |
| 181 | +</dl> |
88 | 182 | </script>
|
0 commit comments