mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-11-20 03:08:21 +01:00
prevent google drive pop up block
This commit is contained in:
parent
f939c3c099
commit
1e9674c342
@ -24,6 +24,7 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
fn(gapi.auth2.getAuthInstance().isSignedIn.get())
|
fn(gapi.auth2.getAuthInstance().isSignedIn.get())
|
||||||
else
|
else
|
||||||
_API.require @setting.apilink, () ->
|
_API.require @setting.apilink, () ->
|
||||||
|
# avoid popup block
|
||||||
gapi.load "client:auth2", () ->
|
gapi.load "client:auth2", () ->
|
||||||
gapi.client.init {
|
gapi.client.init {
|
||||||
apiKey: me.setting.API_KEY,
|
apiKey: me.setting.API_KEY,
|
||||||
@ -34,9 +35,12 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
.then () ->
|
.then () ->
|
||||||
gapi.auth2.getAuthInstance().isSignedIn.listen (r) ->
|
gapi.auth2.getAuthInstance().isSignedIn.listen (r) ->
|
||||||
fn(r)
|
fn(r)
|
||||||
|
_GUI.openDialog "YesNoDialog", (d) ->
|
||||||
|
return _courrier.osinfo "User abort the authentification" unless d
|
||||||
fn(gapi.auth2.getAuthInstance().isSignedIn.get())
|
fn(gapi.auth2.getAuthInstance().isSignedIn.get())
|
||||||
, (err) ->
|
, "Authentification", { text: "Do you want to login to Google Drive ?" }
|
||||||
_courrier.oserror "VFS cannot init GAPI", (_API.throwe "OS.VFS"), err
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot init GAPI: #{err.error}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
meta: (f) ->
|
meta: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@ -51,6 +55,8 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
.then (r) ->
|
.then (r) ->
|
||||||
return unless r.result
|
return unless r.result
|
||||||
f(r)
|
f(r)
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot get meta #{me.gid}", (_API.throwe "OS.VFS"), err
|
||||||
else
|
else
|
||||||
#console.log "Find file in ", me.parent()
|
#console.log "Find file in ", me.parent()
|
||||||
fp = me.parent().asFileHandler()
|
fp = me.parent().asFileHandler()
|
||||||
@ -66,6 +72,8 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
return unless r.result.files and r.result.files.length > 0
|
return unless r.result.files and r.result.files.length > 0
|
||||||
G_CACHE[me.path] = r.result.files[0].id
|
G_CACHE[me.path] = r.result.files[0].id
|
||||||
f { result: r.result.files[0] }
|
f { result: r.result.files[0] }
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot get meta #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
fields: () ->
|
fields: () ->
|
||||||
return "webContentLink, id, name,mimeType,description, kind, parents, properties, iconLink, createdTime, modifiedTime, owners, permissions, fullFileExtension, fileExtension, size"
|
return "webContentLink, id, name,mimeType,description, kind, parents, properties, iconLink, createdTime, modifiedTime, owners, permissions, fullFileExtension, fileExtension, size"
|
||||||
@ -121,6 +129,8 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
file.type = "dir"
|
file.type = "dir"
|
||||||
file.size = 0
|
file.size = 0
|
||||||
f { result: r.result.files }
|
f { result: r.result.files }
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot read #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
else
|
else
|
||||||
gapi.client.drive.files.get {
|
gapi.client.drive.files.get {
|
||||||
fileId: me.info.id,
|
fileId: me.info.id,
|
||||||
@ -128,6 +138,8 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
}
|
}
|
||||||
.then (r) ->
|
.then (r) ->
|
||||||
f r.body
|
f r.body
|
||||||
|
.catch(err) ->
|
||||||
|
_courrier.oserror "VFS cannot get read #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
when "mk"
|
when "mk"
|
||||||
return f { error: "#{@path} is not a directory" } unless @isFolder()
|
return f { error: "#{@path} is not a directory" } unless @isFolder()
|
||||||
@ -140,11 +152,13 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
resource: meta,
|
resource: meta,
|
||||||
fields: 'id'
|
fields: 'id'
|
||||||
}
|
}
|
||||||
.execute (r) ->
|
.then (r) ->
|
||||||
#console.log r
|
#console.log r
|
||||||
return _courrier.oserror "VFS cannot create : #{p}", (_API.throwe "OS.VFS"), r unless r and r.result
|
return _courrier.oserror "VFS cannot create : #{p}", (_API.throwe "OS.VFS"), r unless r and r.result
|
||||||
G_CACHE[me.child p] = r.result.id
|
G_CACHE[me.child p] = r.result.id
|
||||||
f r
|
f r
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot create #{p}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -153,7 +167,6 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
if gid
|
if gid
|
||||||
@save gid, p, f
|
@save gid, p, f
|
||||||
else
|
else
|
||||||
console.log "New file"
|
|
||||||
dir = @parent().asFileHandler()
|
dir = @parent().asFileHandler()
|
||||||
dir.onready () ->
|
dir.onready () ->
|
||||||
meta =
|
meta =
|
||||||
@ -165,10 +178,12 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
resource: meta,
|
resource: meta,
|
||||||
fields: 'id'
|
fields: 'id'
|
||||||
}
|
}
|
||||||
.execute (r) ->
|
.then (r) ->
|
||||||
return _courrier.oserror "VFS cannot write : #{me.path}", (_API.throwe "OS.VFS"), r unless r and r.result
|
return _courrier.oserror "VFS cannot write : #{me.path}", (_API.throwe "OS.VFS"), r unless r and r.result
|
||||||
G_CACHE[me.path] = r.result.id
|
G_CACHE[me.path] = r.result.id
|
||||||
me.save r.result.id, p, f
|
me.save r.result.id, p, f
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot write #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
when "upload"
|
when "upload"
|
||||||
return unless @isFolder()
|
return unless @isFolder()
|
||||||
@ -193,11 +208,13 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
gapi.client.drive.files.delete {
|
gapi.client.drive.files.delete {
|
||||||
fileId: me.info.id
|
fileId: me.info.id
|
||||||
}
|
}
|
||||||
.execute (r) ->
|
.then (r) ->
|
||||||
#console.log r
|
#console.log r
|
||||||
return _courrier.oserror "VFS cannot delete : #{me.path}", (_API.throwe "OS.VFS"), r unless r
|
return _courrier.oserror "VFS cannot delete : #{me.path}", (_API.throwe "OS.VFS"), r unless r
|
||||||
G_CACHE[me.path] = null
|
G_CACHE[me.path] = null
|
||||||
f { result: true }
|
f { result: true }
|
||||||
|
.catch(err) ->
|
||||||
|
_courrier.oserror "VFS cannot delete #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
when "publish"
|
when "publish"
|
||||||
return
|
return
|
||||||
@ -211,6 +228,8 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
return _courrier.oserror "VFS cannot get file : #{me.path}", (_API.throwe "OS.VFS"), r unless r.body
|
return _courrier.oserror "VFS cannot get file : #{me.path}", (_API.throwe "OS.VFS"), r unless r.body
|
||||||
blob = new Blob [r.body], { type: "octet/stream" }
|
blob = new Blob [r.body], { type: "octet/stream" }
|
||||||
_API.saveblob me.basename, blob
|
_API.saveblob me.basename, blob
|
||||||
|
.catch(err) ->
|
||||||
|
_courrier.oserror "VFS cannot fetch #{me.path}", (_API.throwe "OS.VFS"), err
|
||||||
|
|
||||||
when "move"
|
when "move"
|
||||||
dest = p.asFileHandler().parent().asFileHandler()
|
dest = p.asFileHandler().parent().asFileHandler()
|
||||||
@ -222,9 +241,11 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
removeParents: previousParents,
|
removeParents: previousParents,
|
||||||
fields: "id"
|
fields: "id"
|
||||||
}
|
}
|
||||||
.execute (r) ->
|
.then (r) ->
|
||||||
return _courrier.oserror "VFS cannot move : #{me.path}", (_API.throwe "OS.VFS"), r unless r
|
return _courrier.oserror "VFS cannot move : #{me.path}", (_API.throwe "OS.VFS"), r unless r
|
||||||
f r
|
f r
|
||||||
|
.catch (err) ->
|
||||||
|
_courrier.oserror "VFS cannot move #{me.gid}", (_API.throwe "OS.VFS"), err
|
||||||
else
|
else
|
||||||
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user