mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
gogs 项目管理细化
This commit is contained in:
+23
-1
@@ -821,7 +821,7 @@ def projectScriptSelf_Create():
|
||||
if os.path.exists(abs_file):
|
||||
return mw.returnJson(False, '脚本已经存在!')
|
||||
|
||||
mw.writeFile(abs_file, "#!/bin/bash\n")
|
||||
mw.writeFile(abs_file, "#!/bin/bash\necho `date +'%Y-%m-%d %H:%M:%S'`\n")
|
||||
|
||||
rdata = {}
|
||||
rdata['abs_file'] = abs_file
|
||||
@@ -885,6 +885,26 @@ def projectScriptSelf_Logs():
|
||||
return mw.returnJson(False, '日志不存在!')
|
||||
|
||||
|
||||
def projectScriptSelf_Run():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['user', 'name', 'file'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
user = args['user']
|
||||
name = args['name'] + '.git'
|
||||
file = args['file']
|
||||
|
||||
custom_hooks = getRootPath() + '/' + user + '/' + \
|
||||
name + '/custom_hooks'
|
||||
self_path = custom_hooks + '/self/' + file
|
||||
self_logs_path = custom_hooks + '/self_logs/' + file + '.log'
|
||||
|
||||
shell = "sh -x " + self_path + " 2>" + self_logs_path
|
||||
mw.execShell(shell)
|
||||
return mw.returnJson(True, '执行成功!')
|
||||
|
||||
|
||||
def projectScriptSelf_Rename():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['user', 'name', 'o_file', 'n_file'])
|
||||
@@ -1031,6 +1051,8 @@ if __name__ == "__main__":
|
||||
print(projectScriptSelf_Del())
|
||||
elif func == 'project_script_self_logs':
|
||||
print(projectScriptSelf_Logs())
|
||||
elif func == 'project_script_self_run':
|
||||
print(projectScriptSelf_Run())
|
||||
elif func == 'project_script_self_rename':
|
||||
print(projectScriptSelf_Rename())
|
||||
elif func == 'project_script_self_enable':
|
||||
|
||||
@@ -534,6 +534,7 @@ function projectScriptSelfRender(user, name){
|
||||
'<a class="btlink del" data-index="'+i+'" target="_blank">删除</a>' + ' | ' +
|
||||
'<a class="btlink edit" data-index="'+i+'" target="_blank">编辑</a>' + ' | ' +
|
||||
'<a class="btlink logs" data-index="'+i+'" target="_blank">日志</a>' + ' | ' +
|
||||
'<a class="btlink run" data-index="'+i+'" target="_blank">手动</a>' + ' | ' +
|
||||
'<a class="btlink rename" data-index="'+i+'" target="_blank">重命名</a>' +
|
||||
'</td></tr>';
|
||||
}
|
||||
@@ -574,6 +575,15 @@ function projectScriptSelfRender(user, name){
|
||||
});
|
||||
});
|
||||
|
||||
$('#gogs_self_table .run').click(function(){
|
||||
var i = $(this).data('index');
|
||||
var file = data[i]["name"];
|
||||
gogsPost('project_script_self_run', {'user':user,'name':name,'file':file}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg,{icon:data.status?1:2,time:2000,shade: [0.3, '#000']});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#gogs_self_table .rename').click(function(){
|
||||
var i = $(this).data('index');
|
||||
|
||||
Reference in New Issue
Block a user