From bd3e47491e2f68a8237c7f5a6b4b6d0efca5f2ce Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 26 Dec 2018 15:57:26 +0800 Subject: [PATCH] update --- plugins/gae/index.html | 2 +- plugins/gae/index.py | 42 +++++++++++++++++++++++++++++++++++++++++- plugins/gae/js/gae.js | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/plugins/gae/index.html b/plugins/gae/index.html index 67d4a11bb..c03a47aca 100755 --- a/plugins/gae/index.html +++ b/plugins/gae/index.html @@ -20,8 +20,8 @@ function readme(){ var html = '

开发文档:https://cloud.google.com/sdk/docs/

'; html += '

* 注意:本插件通过Google JSON 格式赋权免交互式

'; html += '

* 注意:添加:gcloud auth activate-service-account --key-file [KEY_FILE] << y

'; - html += '

* 注意:设置后,一般同步项目命令:gcloud app deploy << y

'; + html += '

* 注意:可以查看命令,把命令加入到脚本中...自动更新。

'; $('.bt-w-main .soft-man-con').html(html); } \ No newline at end of file diff --git a/plugins/gae/index.py b/plugins/gae/index.py index d992aa390..3fd9be603 100755 --- a/plugins/gae/index.py +++ b/plugins/gae/index.py @@ -115,7 +115,7 @@ def projectListAsync(): file = getServerDir() + '/' + args['name'] + '.json' if not os.path.exists(file): - return 'file not exists!' + return 'not configured file!' content = public.readFile(file) contentObj = json.loads(content) @@ -132,6 +132,42 @@ def projectListAsync(): return 'ok' +def projectListCmd(): + args = getArgs() + if not 'name' in args: + return 'missing name!' + + file = getServerDir() + '/' + args['name'] + '.json' + if not os.path.exists(file): + return 'not configured file!' + + content = public.readFile(file) + contentObj = json.loads(content) + asyncUser = contentObj['client_email'] + cmd = getServerDir() + '/google-cloud-sdk/bin/' + projectDir = public.getWwwDir() + '/' + args['name'] + asyncCmd = 'cd ' + projectDir + ' && ' + cmd + 'gcloud app deploy << y' + return asyncCmd + + +def projectListUrl(): + args = getArgs() + if not 'name' in args: + return 'missing name!' + + file = getServerDir() + '/' + args['name'] + '.json' + if not os.path.exists(file): + return 'not configured file!' + + content = public.readFile(file) + contentObj = json.loads(content) + asyncUser = contentObj['client_email'] + plist = asyncUser.split('@') + + url = 'https://' + plist[0] + '.appspot.com' + return url + + def projectList(): args = getArgs() @@ -172,5 +208,9 @@ if __name__ == "__main__": print projectListDel() elif func == 'project_list_async': print projectListAsync() + elif func == 'project_list_cmd': + print projectListCmd() + elif func == 'project_list_url': + print projectListUrl() else: print 'error' diff --git a/plugins/gae/js/gae.js b/plugins/gae/js/gae.js index bf1a3d1e3..859a945e6 100755 --- a/plugins/gae/js/gae.js +++ b/plugins/gae/js/gae.js @@ -55,7 +55,8 @@ function projectList(page, search){ ''+ulist[i]['dir']+''+ ''+setName+' | ' + '同步 | ' + - '查看命令' + + '命令 | ' + + '访问' + ''; } @@ -109,12 +110,38 @@ function gaeProjectDel(pname){ }); } - function gaeAsyncProject(pname){ - console.log(pname); gaePost('project_list_async', {'name':pname}, function(data){ console.log(data); - // layer.msg('同步成功!',{icon:0,time:2000,shade: [0.3, '#000']}); + if (data.data !='ok'){ + layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']}); + } else { + layer.msg('同步成功!',{icon:0,time:2000,shade: [0.3, '#000']}); + } + }); +} + + +function gaeProjectCmd(pname){ + gaePost('project_list_cmd', {'name':pname}, function(data){ + var data_str = data.data; + if (data_str.indexOf('gcloud') !== -1){ + layer.msg(data.data,{icon:1,time:5000,shade: [0.3, '#000']}); + } else { + layer.msg(data.data,{icon:0,time:5000,shade: [0.3, '#000']}); + } + }); +} + + +function gaeProjectUrl(pname){ + gaePost('project_list_url', {'name':pname}, function(data){ + var data_str = data.data; + if (data_str.indexOf('appspot.com') !== -1){ + window.open(data.data); + } else { + layer.msg(data.data,{icon:0,time:5000,shade: [0.3, '#000']}); + } }); }