|
|
|
@ -1,19 +1,8 @@ |
|
|
|
|
|
|
|
|
|
function str2Obj(str){ |
|
|
|
|
var data = {}; |
|
|
|
|
kv = str.split('&'); |
|
|
|
|
for(i in kv){ |
|
|
|
|
v = kv[i].split('='); |
|
|
|
|
data[v[0]] = v[1]; |
|
|
|
|
} |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function gogsPost(method,args,callback, title){ |
|
|
|
|
|
|
|
|
|
var _args = null;
|
|
|
|
|
if (typeof(args) == 'string'){ |
|
|
|
|
_args = JSON.stringify(str2Obj(args)); |
|
|
|
|
_args = JSON.stringify(toArrayObject(args)); |
|
|
|
|
} else { |
|
|
|
|
_args = JSON.stringify(args); |
|
|
|
|
} |
|
|
|
@ -185,6 +174,31 @@ function gogsUserList(page, search) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function userProjectList(user, search){ |
|
|
|
|
layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
title: '用户('+user+')项目列表', |
|
|
|
|
area: '500px', |
|
|
|
|
content:"<div class='bt-form pd20 c6'>\ |
|
|
|
|
<div>\ |
|
|
|
|
<div id='gogs_table' class='divtable' style='margin-top:5px;'>\ |
|
|
|
|
<table class='table table-hover'>\ |
|
|
|
|
<thead><tr><th>项目</th><th>操作</th></tr></thead>\ |
|
|
|
|
<tbody></tbody>\ |
|
|
|
|
</table>\ |
|
|
|
|
<div class='dataTables_paginate paging_bootstrap pagination' style='margin-top:0px;'>\ |
|
|
|
|
<ul class='page'><div class='gogs_page'></div></ul>\ |
|
|
|
|
</div>\ |
|
|
|
|
</div>\ |
|
|
|
|
</div>\ |
|
|
|
|
</div>", |
|
|
|
|
success:function(){ |
|
|
|
|
userProjectListPage(user,search); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function userProjectListPage(user, search){ |
|
|
|
|
var req = {}; |
|
|
|
|
if (!isNaN(user)){ |
|
|
|
|
req['page'] = user; |
|
|
|
@ -200,8 +214,7 @@ function userProjectList(user, search){ |
|
|
|
|
if(typeof(search) != 'undefined'){ |
|
|
|
|
req['search'] = search; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('.layui-layer-close1').click(); |
|
|
|
|
|
|
|
|
|
gogsPost('user_project_list', req, function(data){ |
|
|
|
|
var rdata = []; |
|
|
|
|
try { |
|
|
|
@ -218,7 +231,8 @@ function userProjectList(user, search){ |
|
|
|
|
var project_list = rdata['data']['data']; |
|
|
|
|
for (i in project_list) { |
|
|
|
|
var name = project_list[i]['name']; |
|
|
|
|
list += '<tr><td>'+name+'</td>\ |
|
|
|
|
list += '<tr>\ |
|
|
|
|
<td>'+name+'</td>\ |
|
|
|
|
<td>\ |
|
|
|
|
<a class="btlink" target="_blank" href="'+rdata['data']['root_url']+user+'/'+name+'">源码</a> | \ |
|
|
|
|
<a class="btlink" onclick="projectScript(\''+user+'\',\''+name+'\','+project_list[i]['has_hook']+');">脚本</a>\ |
|
|
|
@ -226,28 +240,15 @@ function userProjectList(user, search){ |
|
|
|
|
</tr>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var page = '<div class="dataTables_paginate paging_bootstrap pagination" style="margin-top:0px;"><ul id="softPage" class="page"><div>'; |
|
|
|
|
page += rdata['data']['list']; |
|
|
|
|
page += '</div></ul></div>'; |
|
|
|
|
$('#gogs_table tbody').html(list); |
|
|
|
|
|
|
|
|
|
var loadOpen = layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
title: '用户('+user+')项目列表', |
|
|
|
|
area: '500px', |
|
|
|
|
content:"<div class='bt-form pd20 c6'>\ |
|
|
|
|
<div>\ |
|
|
|
|
<div class='divtable' style='margin-top:5px;'>\ |
|
|
|
|
<table class='table table-hover'>\ |
|
|
|
|
<thead><tr><th>项目</th><th>操作</th></tr></thead>\ |
|
|
|
|
<tbody>" + list + "</tbody>\ |
|
|
|
|
</table>" + |
|
|
|
|
page + |
|
|
|
|
"</div></div></div>" |
|
|
|
|
}); |
|
|
|
|
var page = rdata['data']['list']; |
|
|
|
|
$('#gogs_table .gogs_page').html(page); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function projectScript(user, name,has_hook){ |
|
|
|
|
// console.log(user,name,has_hook);
|
|
|
|
|
var html = ''; |
|
|
|
@ -288,7 +289,7 @@ function projectScriptLoad(user,name){ |
|
|
|
|
|
|
|
|
|
layer.msg('加载成功!',{icon:1,time:2000,shade: [0.3, '#000']}); |
|
|
|
|
setTimeout(function(){ |
|
|
|
|
userProjectList(1); |
|
|
|
|
userProjectListPage(1); |
|
|
|
|
}, 2000); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -302,7 +303,7 @@ function projectScriptUnload(user,name){ |
|
|
|
|
|
|
|
|
|
layer.msg('卸载成功!',{icon:1,time:2000,shade: [0.3, '#000']}); |
|
|
|
|
setTimeout(function(){ |
|
|
|
|
userProjectList(1); |
|
|
|
|
userProjectListPage(1); |
|
|
|
|
}, 2000); |
|
|
|
|
}); |
|
|
|
|
}
|
|
|
|
|