-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogleDriveFileUpload.html
113 lines (102 loc) · 4.77 KB
/
googleDriveFileUpload.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
<!--
/*******************************************************************************
* Copyright (C) 2018 Orange.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Rombit - initial API and implementation
******************************************************************************/
-->
<script type="text/javascript" data-lang="en-US">
RED.nodes.registerType('agile-GDrive-upload',{
category: 'googleDrive',
color: '#e2d96e',
defaults: {
google: {type:"google-credentials",required:true},
name: {value:""},
driveFolder: {value: ""},
driveFolderId: {value: ""}
},
inputs:1,
outputs:1,
icon: "white-globe.png",
label: function() {
return this.name||"agile Google Drive upload";
},
oneditprepare: function() {
var node = this;
try {
$("#node-input-driveFolder").autocomplete( "destroy" );
$("#node-input-driveFolderId").autocomplete( "destroy" );
} catch(err) {
}
$("#node-googleDrive-lookup-folder").click(function() {
$("#node-googleDrive-lookup-folder").addClass('disabled');
$.getJSON('folders',{googleNodeId: node.google},function(data) {
$("#node-googleDrive-lookup-folder").removeClass('disabled');
var folders = [];
var folderIds = [];
$.each(data, function(i, folder) {
folders.push({label:folder.name, id: folder.id});
folderIds.push(folder.id);
});
$("#node-input-driveFolder").autocomplete({
source:folders,
minLength:0,
close: function( event, ui ) {
$("#node-input-driveFolder").autocomplete( "destroy" );
},
select: function( event, ui ) {
$("#node-input-driveFolderId").val(ui.item.id)
}
}).autocomplete("search","");
});
});
},
oneditsave: function() {
this.driveFolder = $("#node-input-driveFolderId").val();
}
});
</script>
<script type="text/x-red" data-template-name="agile-GDrive-upload" data-lang="en-US">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="googleDriveFileUpload.label.name"></span></label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-google"><i class="fa fa-user"></i> <span data-i18n="googleDriveFileUpload.label.googleId"></span></label>
<input type="text" id="node-input-google">
</div>
<div class="form-row">
<label for="node-input-driveFolder"><i class="fa fa-folder"></i> <span data-i18n="googleDriveFileUpload.label.folder"></span></label>
<input readonly type="text" id="node-input-driveFolder" style="width:60%;" data-i18n="[placeholder]googleDriveFileUpload.label.folder">
<a id="node-googleDrive-lookup-folder" class="btn"><i id="node-googleDrive-lookup-folder-icon" class="fa fa-search"></i></a>
<input type="hidden" id="node-input-driveFolderId">
</div>
</script>
<script type="text/x-red" data-help-name="agile-GDrive-upload" data-lang="en-US">
<p>A node to upload files to the google drive API. </p>
<h1>Instructions</h1>
<h2>Configuration</h2>
<ul>
<li>1. Edit the node and add a Google Id, follow the instructions of the config node.</li>
<li>2. Add the google ID, click on done for the node config and deploy the flow.</li>
<li>3. Edit the node again, now you can browse the root folder list of your google Drive.</li>
</ul>
<h2>Upload a file</h2>
<p>Connect a node with the following output</p>
<p>msg.payload: The text content of the file upload</p>
<p>msg.localpath: The local file path of the file to upload</p>
<p>Either the payload or the localpath are required. The payload has a higher priority as the localpath</p>
<h1>Remarks</h1>
<ul>
<li>If the google callback returns that the profile fetching failed, you need to enable the google+ api in console.developers.google.com</li>
<li>Check in the console.developers.google.com dashboard that the google+ API and google Drive API are active.</li>
</ul>
<p>Version1.0</p>
</script>