appscms-tools-theme 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/js/googledriveinput.js +12 -50
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5660c6c8d30fafcde3cc7f33bb5989fde3c42474efbbb395d889d87fa3e5c60
|
4
|
+
data.tar.gz: ee605be8266d14e51bc154c5f556569f081a6ce2103184f384ad255eca0869df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b090f84f376ed0f02c620ecb55c4a3ab70ebe6d188a7bae78bacaa0c1701260e62d12bd25b8768a502af028a814b5ca2ec892f690508f22462eea36260a95ed
|
7
|
+
data.tar.gz: 0a190f93bf38161dd74af76e93b0853573c72574586cdeb56122ff652cddaf3c55baa1e9595bb61a2dbf1f45e3f4ced157e7c2614ae8ea4526de738714081c79
|
@@ -2,7 +2,7 @@
|
|
2
2
|
---
|
3
3
|
|
4
4
|
var mimeTypes
|
5
|
-
const addScripts=()=>{
|
5
|
+
export const addScripts=()=>{
|
6
6
|
const scripts=document.getElementsByTagName('script')
|
7
7
|
const check= Array.from(scripts).find(item=>item.src==='https://www.dropbox.com/static/api/2/dropins.js')
|
8
8
|
if(!check){
|
@@ -28,35 +28,34 @@ const scope = [
|
|
28
28
|
]
|
29
29
|
let pickerApiLoaded = false
|
30
30
|
let oauthToken
|
31
|
-
const loadPicker = (mimeType) => {
|
32
|
-
mimeTypes=mimeType
|
31
|
+
export const loadPicker = (mimeType,showLoader,closeLoader,getFile) => {
|
33
32
|
gapi.load('auth', { callback: onAuthApiLoad })
|
34
|
-
gapi.load('picker', { callback: onPickerApiLoad })
|
33
|
+
gapi.load('picker', { callback: onPickerApiLoad(mimeType,showLoader,closeLoader,getFile) })
|
35
34
|
}
|
36
|
-
const onAuthApiLoad = () => {
|
35
|
+
const onAuthApiLoad = (mimeType,showLoader,closeLoader,getFile) => {
|
37
36
|
window.gapi.auth.authorize(
|
38
37
|
{
|
39
38
|
client_id: clientId,
|
40
39
|
scope: scope,
|
41
40
|
immediate: false,
|
42
41
|
},
|
43
|
-
handleAuthResult
|
42
|
+
handleAuthResult(authResult,mimeType,showLoader,closeLoader,getFile)
|
44
43
|
)
|
45
44
|
}
|
46
45
|
let onPickerApiLoad = () => {
|
47
46
|
pickerApiLoaded = true
|
48
47
|
createPicker()
|
49
48
|
}
|
50
|
-
const handleAuthResult = (authResult) => {
|
49
|
+
const handleAuthResult = (authResult,mimeType,showLoader,closeLoader,getFile) => {
|
51
50
|
if (authResult && !authResult.error) {
|
52
51
|
oauthToken = authResult.access_token
|
53
|
-
createPicker()
|
52
|
+
createPicker(mimeType,showLoader,closeLoader,getFile)
|
54
53
|
}
|
55
54
|
}
|
56
|
-
const createPicker = () => {
|
55
|
+
const createPicker = (mimeType,showLoader,closeLoader,getFile) => {
|
57
56
|
if (pickerApiLoaded && oauthToken) {
|
58
57
|
const view = new google.picker.View(google.picker.ViewId.DOCS)
|
59
|
-
view.setMimeTypes(
|
58
|
+
view.setMimeTypes(mimeType)
|
60
59
|
const picker = new google.picker.PickerBuilder()
|
61
60
|
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
62
61
|
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
|
@@ -65,12 +64,12 @@ const createPicker = () => {
|
|
65
64
|
.addView(view)
|
66
65
|
.addView(new google.picker.DocsUploadView())
|
67
66
|
.setDeveloperKey(developerKey)
|
68
|
-
.setCallback(pickerCallback)
|
67
|
+
.setCallback(pickerCallback(data,showLoader,closeLoader,getFile))
|
69
68
|
.build()
|
70
69
|
picker.setVisible(true)
|
71
70
|
}
|
72
71
|
}
|
73
|
-
const pickerCallback = async (data) => {
|
72
|
+
const pickerCallback = async (data,showLoader,closeLoader,getFile) => {
|
74
73
|
if (data.action == google.picker.Action.PICKED) {
|
75
74
|
showLoader()
|
76
75
|
const res = await fetch(
|
@@ -89,7 +88,7 @@ const pickerCallback = async (data) => {
|
|
89
88
|
getFile(file)
|
90
89
|
}
|
91
90
|
}
|
92
|
-
|
91
|
+
export const chooseFromDropbox=(filemimes,showLoader,closeLoader,getDropBoxFile)=> {
|
93
92
|
Dropbox.choose({
|
94
93
|
success: async (files) => {
|
95
94
|
if (files.length < 0) {
|
@@ -114,43 +113,6 @@ function chooseFromDropbox(filemimes) {
|
|
114
113
|
})
|
115
114
|
}
|
116
115
|
|
117
|
-
const fileupload=(file)=>{
|
118
|
-
gapi.load('auth', {'callback': onAuthLoad});
|
119
|
-
}
|
120
|
-
const onAuthLoad=()=> {
|
121
|
-
window.gapi.auth.authorize(
|
122
|
-
{
|
123
|
-
'client_id': clientId,
|
124
|
-
'scope': scope,
|
125
|
-
'immediate': false
|
126
|
-
},
|
127
|
-
handleAuth);
|
128
|
-
}
|
129
|
-
const handleAuth=(authResult)=> {
|
130
|
-
if (authResult && !authResult.error) {
|
131
|
-
showuploadloading()
|
132
|
-
var formData = new FormData();
|
133
|
-
const fileToUpload = file
|
134
|
-
var metadata = {
|
135
|
-
name: fileToUpload.name,
|
136
|
-
mimeType: fileToUpload.type
|
137
|
-
};
|
138
|
-
formData.append( "metadata", new Blob( [JSON.stringify( metadata )], {type: "application/json"} ));
|
139
|
-
formData.append( "file", fileToUpload );
|
140
|
-
fetch( "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", {
|
141
|
-
method: "POST",
|
142
|
-
headers: new Headers({ "Authorization": "Bearer " + gapi.auth.getToken().access_token }),
|
143
|
-
body: formData
|
144
|
-
}).then( function( response ){
|
145
|
-
stopuploadloading()
|
146
|
-
return response.json();
|
147
|
-
|
148
|
-
}).then( function( value ){
|
149
|
-
stopuploadloading()
|
150
|
-
showmessage()
|
151
|
-
});
|
152
|
-
}
|
153
|
-
}
|
154
116
|
|
155
117
|
|
156
118
|
|