Merge remote-tracking branch 'upstream/api-attribute-rename' into api-attributes

This commit is contained in:
Tan Jiang 2016-06-03 18:51:26 +08:00
commit 884f496854
28 changed files with 1175 additions and 1180 deletions

View File

@ -48,7 +48,7 @@ func hasProjectAdminRole(userID int, projectID int64) bool {
//sysadmin has all privileges to all projects //sysadmin has all privileges to all projects
func listRoles(userID int, projectID int64) ([]models.Role, error) { func listRoles(userID int, projectID int64) ([]models.Role, error) {
roles := make([]models.Role, 1) roles := make([]models.Role, 0, 1)
isSysAdmin, err := dao.IsAdminRole(userID) isSysAdmin, err := dao.IsAdminRole(userID)
if err != nil { if err != nil {
return roles, err return roles, err

View File

@ -13,7 +13,6 @@
limitations under the License. limitations under the License.
*/ */
.footer { .footer {
margin-top: 60px;
width: 100%; width: 100%;
/* Set the fixed height of the footer here */ /* Set the fixed height of the footer here */
height: 60px; height: 60px;

View File

@ -12,6 +12,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var AjaxUtil = function(params){ var AjaxUtil = function(params){
this.url = params.url; this.url = params.url;
@ -153,8 +154,13 @@ jQuery(function(){
} }
if(settings.callback != null){ if(settings.callback != null){
$("#dlgConfirm").on("click", function(){ var hasEntered = false;
$("#dlgConfirm").on("click", function(e){
if(!hasEntered) {
hasEntered = true;
settings.callback(); settings.callback();
}
}); });
} }
$(self).modal('show'); $(self).modal('show');

View File

@ -131,7 +131,6 @@ jQuery(function(){
} }
} }
data.Created = moment(new Date(data.Created)).format("YYYY-MM-DD HH:mm:ss"); data.Created = moment(new Date(data.Created)).format("YYYY-MM-DD HH:mm:ss");
$("#dlgModal").dialogModal({"title": i18n.getMessage("image_details"), "content": data}); $("#dlgModal").dialogModal({"title": i18n.getMessage("image_details"), "content": data});
} }
} }
@ -204,7 +203,7 @@ jQuery(function(){
if(operationType == "add"){ if(operationType == "add"){
ajaxOpts.url = "/api/projects/" + projectId + "/members/"; ajaxOpts.url = "/api/projects/" + projectId + "/members/";
ajaxOpts.type = "post"; ajaxOpts.type = "post";
ajaxOpts.data = {"roles" : checkedRoleItemList, "user_name": username}; ajaxOpts.data = {"roles" : checkedRoleItemList, "username": username};
}else if(operationType == "edit"){ }else if(operationType == "edit"){
ajaxOpts.url = "/api/projects/" + projectId + "/members/" + userId; ajaxOpts.url = "/api/projects/" + projectId + "/members/" + userId;
ajaxOpts.type = "put"; ajaxOpts.type = "put";
@ -241,24 +240,15 @@ jQuery(function(){
var ownerId = $("#ownerId").val(); var ownerId = $("#ownerId").val();
$("#tblUser tbody tr").remove(); $("#tblUser tbody tr").remove();
for(var i = 0; i < userList.length; ){ for(var i = 0; i < userList.length; i++){
var userId = userList[i].UserId; var userId = userList[i].user_id;
var roleId = userList[i].RoleId; var roleId = userList[i].role_id;
var username = userList[i].username; var username = userList[i].username;
var roleNameList = [];
for(var j = i; j < userList.length; i++, j++){
if(userList[j].UserId == userId){
roleNameList.push(name_mapping[userList[j].Rolename]);
}else{
break;
}
}
var row = '<tr>' + var row = '<tr>' +
'<td>' + username + '</td>' + '<td>' + username + '</td>' +
'<td>' + roleNameList.join(",") + '</td>' + '<td>' + name_mapping[userList[i].role_name] + '</td>' +
'<td>'; '<td>';
var isShowOperations = true; var isShowOperations = true;
if(loginedUserRoleId >= 3 /*role: developer guest*/){ if(loginedUserRoleId >= 3 /*role: developer guest*/){
@ -284,11 +274,11 @@ jQuery(function(){
$.each(LogList || [], function(i, e){ $.each(LogList || [], function(i, e){
$("#tabOperationLog tbody").append( $("#tabOperationLog tbody").append(
'<tr>' + '<tr>' +
'<td>' + e.Username + '</td>' + '<td>' + e.username + '</td>' +
'<td>' + e.RepoName + '</td>' + '<td>' + e.repo_name + '</td>' +
'<td>' + e.RepoTag + '</td>' + '<td>' + e.repo_tag + '</td>' +
'<td>' + e.Operation + '</td>' + '<td>' + e.operation + '</td>' +
'<td>' + moment(new Date(e.OpTime)).format("YYYY-MM-DD HH:mm:ss") + '</td>' + '<td>' + moment(new Date(e.op_time)).format("YYYY-MM-DD HH:mm:ss") + '</td>' +
'</tr>'); '</tr>');
}); });
} }
@ -302,7 +292,7 @@ jQuery(function(){
$("#operationType").val("edit"); $("#operationType").val("edit");
$("#editUserId").val(user.user_id); $("#editUserId").val(user.user_id);
$("#spnSearch").hide(); $("#spnSearch").hide();
$("#txtUserName").val(user.user_name); $("#txtUserName").val(user.username);
$("#txtUserName").prop("disabled", true); $("#txtUserName").prop("disabled", true);
$("#btnSave").removeClass("disabled"); $("#btnSave").removeClass("disabled");
$("#dlgUserTitle").text(i18n.getMessage("edit_members")); $("#dlgUserTitle").text(i18n.getMessage("edit_members"));
@ -404,7 +394,7 @@ jQuery(function(){
new AjaxUtil({ new AjaxUtil({
url: "/api/projects/" + projectId + "/logs/filter", url: "/api/projects/" + projectId + "/logs/filter",
data:{"username":username, "project_id" : projectId, "keywords" : getKeyWords() , "beginTimestamp" : beginTimestamp, "endTimestamp" : endTimestamp}, data:{"username":username, "project_id" : Number(projectId), "keywords" : getKeyWords() , "begin_timestamp" : beginTimestamp, "end_timestamp" : endTimestamp},
type: "post", type: "post",
success: function(data, status, xhr){ success: function(data, status, xhr){
if(xhr && xhr.status == 200){ if(xhr && xhr.status == 200){

View File

@ -19,7 +19,7 @@ jQuery(function(){
type: "get", type: "get",
success: function(data, status, xhr){ success: function(data, status, xhr){
if(xhr && xhr.status == 200){ if(xhr && xhr.status == 200){
if(data.HasAdminRole == 1) { if(data.has_admin_role == 1) {
renderForAdminRole(); renderForAdminRole();
} }
renderForAnyRole(); renderForAnyRole();
@ -55,16 +55,16 @@ jQuery(function(){
$("#tblProject tbody tr").remove(); $("#tblProject tbody tr").remove();
$.each(data || [], function(i, e){ $.each(data || [], function(i, e){
var row = '<tr>' + var row = '<tr>' +
'<td style="vertical-align: middle;"><a href="/registry/detail?project_id=' + e.ProjectId + '">' + e.Name + '</a></td>' + '<td style="vertical-align: middle;"><a href="/registry/detail?project_id=' + e.project_id + '">' + e.name + '</a></td>' +
'<td style="vertical-align: middle;">' + moment(new Date(e.CreationTime)).format("YYYY-MM-DD HH:mm:ss") + '</td>'; '<td style="vertical-align: middle;">' + moment(new Date(e.creation_time)).format("YYYY-MM-DD HH:mm:ss") + '</td>';
if(e.Public == 1 && e.Togglable){ if(e.public == 1 && e.Togglable){
row += '<td><button type="button" class="btn btn-success" projectid="' + e.ProjectId + '">' + i18n.getMessage("button_on")+ '</button></td>' row += '<td><button type="button" class="btn btn-success" projectid="' + e.project_id + '">' + i18n.getMessage("button_on")+ '</button></td>'
} else if (e.Public == 1) { } else if (e.public == 1) {
row += '<td><button type="button" class="btn btn-success" projectid="' + e.ProjectId + '" disabled>' + i18n.getMessage("button_on")+ '</button></td>'; row += '<td><button type="button" class="btn btn-success" projectid="' + e.project_id + '" disabled>' + i18n.getMessage("button_on")+ '</button></td>';
} else if (e.Public == 0 && e.Togglable) { } else if (e.public == 0 && e.Togglable) {
row += '<td><button type="button" class="btn btn-danger" projectid="' + e.ProjectId + '">' + i18n.getMessage("button_off")+ '</button></td>'; row += '<td><button type="button" class="btn btn-danger" projectid="' + e.project_id + '">' + i18n.getMessage("button_off")+ '</button></td>';
} else if (e.Public == 0) { } else if (e.public == 0) {
row += '<td><button type="button" class="btn btn-danger" projectid="' + e.ProjectId + '" disabled>' + i18n.getMessage("button_off")+ '</button></td>'; row += '<td><button type="button" class="btn btn-danger" projectid="' + e.project_id + '" disabled>' + i18n.getMessage("button_off")+ '</button></td>';
row += '</tr>'; row += '</tr>';
} }
$("#tblProject tbody").append(row); $("#tblProject tbody").append(row);
@ -163,12 +163,12 @@ jQuery(function(){
var row = '<tr>' + var row = '<tr>' +
'<td style="vertical-align: middle;">' + e.username + '</td>' + '<td style="vertical-align: middle;">' + e.username + '</td>' +
'<td style="vertical-align: middle;">' + e.email + '</td>'; '<td style="vertical-align: middle;">' + e.email + '</td>';
if(e.HasAdminRole == 1){ if(e.has_admin_role == 1){
row += '<td style="padding-left: 30px;"><button type="button" class="btn btn-success" userid="' + e.UserId + '">' + i18n.getMessage("button_on") + '</button></td>'; row += '<td style="padding-left: 30px;"><button type="button" class="btn btn-success" userid="' + e.user_id + '">' + i18n.getMessage("button_on") + '</button></td>';
} else { } else {
row += '<td style="padding-left: 30px;"><button type="button" class="btn btn-danger" userid="' + e.UserId + '">' + i18n.getMessage("button_off") + '</button></td>'; row += '<td style="padding-left: 30px;"><button type="button" class="btn btn-danger" userid="' + e.user_id + '">' + i18n.getMessage("button_off") + '</button></td>';
} }
row += '<td style="padding-left: 30px; vertical-align: middle;"><a href="#" style="visibility: hidden;" class="tdDeleteUser" userid="' + e.UserId + '" username="' + e.Username + '"><span class="glyphicon glyphicon-trash"></span></a></td>'; row += '<td style="padding-left: 30px; vertical-align: middle;"><a href="#" style="visibility: hidden;" class="tdDeleteUser" userid="' + e.user_id + '" username="' + e.username + '"><span class="glyphicon glyphicon-trash"></span></a></td>';
row += '</tr>'; row += '</tr>';
$("#tblUser tbody").append(row); $("#tblUser tbody").append(row);
}); });
@ -194,12 +194,12 @@ jQuery(function(){
} }
}).exec(); }).exec();
}); });
$("#tblUser tbody tr").on("mouseover", function(){ $("#tblUser tbody tr").on("mouseover", function(e){
$(".tdDeleteUser", this).css({"visibility":"visible"}); $(".tdDeleteUser", this).css({"visibility":"visible"});
}).on("mouseout", function(){ }).on("mouseout", function(e){
$(".tdDeleteUser", this).css({"visibility":"hidden"}); $(".tdDeleteUser", this).css({"visibility":"hidden"});
}); });
$("#tblUser tbody tr .tdDeleteUser").on("click", function(){ $("#tblUser tbody tr .tdDeleteUser").on("click", function(e){
var userId = $(this).attr("userid"); var userId = $(this).attr("userid");
$("#dlgModal") $("#dlgModal")
.dialogModal({ .dialogModal({
@ -219,6 +219,7 @@ jQuery(function(){
}).exec(); }).exec();
} }
}); });
}); });
}); });
} }

View File

@ -30,7 +30,6 @@ jQuery(function(){
} }
bindEnterKey(); bindEnterKey();
var spinner = new Spinner({scale:1}).spin(); var spinner = new Spinner({scale:1}).spin();
$("#btnSubmit").on("click", function(){ $("#btnSubmit").on("click", function(){

View File

@ -18,7 +18,7 @@
<li>{{.ProjectName}}</li> <li>{{.ProjectName}}</li>
</ol> </ol>
<div class="page-header" style="margin-top: -10px;"> <div class="page-header" style="margin-top: -10px;">
<h2>{{.ProjectName}} </h2></h4>{{i18n .Lang "owner"}}: {{.OwnerName}}</h4> <h2>{{.ProjectName}} </h2><h4>{{i18n .Lang "owner"}}: {{.OwnerName}}</h4>
</div> </div>
<div row="tabpanel"> <div row="tabpanel">
<div class="row"> <div class="row">
@ -53,7 +53,7 @@
</div> </div>
</div> </div>
</form> </form>
<p> <p/>
<div class="table-responsive div-height"> <div class="table-responsive div-height">
<div class="alert alert-danger" role="alert" id="divErrMsg"><center></center></div> <div class="alert alert-danger" role="alert" id="divErrMsg"><center></center></div>
<div class="panel-group" id="accordionRepo" role="tablist" aria-multiselectable="true"> <div class="panel-group" id="accordionRepo" role="tablist" aria-multiselectable="true">
@ -76,7 +76,7 @@
</div> </div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#dlgUser" id="btnAddUser">{{i18n .Lang "add_members"}}</button> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#dlgUser" id="btnAddUser">{{i18n .Lang "add_members"}}</button>
</form> </form>
<p> <p/>
<div class="table-responsive div-height"> <div class="table-responsive div-height">
<table id="tblUser" class="table table-hover"> <table id="tblUser" class="table table-hover">
<thead> <thead>
@ -108,8 +108,7 @@
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseAdvance" aria-expanded="false" aria-controls="collapseAdvance">{{i18n .Lang "advance"}}</button> <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseAdvance" aria-expanded="false" aria-controls="collapseAdvance">{{i18n .Lang "advance"}}</button>
</div> </div>
</div> </div>
<form> <p/>
<p></p>
<div class="collapse" id="collapseAdvance"> <div class="collapse" id="collapseAdvance">
<form class="form"> <form class="form">
<div class="form-group"> <div class="form-group">
@ -139,7 +138,6 @@
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
@ -151,7 +149,6 @@
</span> </span>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
@ -170,6 +167,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,6 +12,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<input type="hidden" id="currentLanguage" value="{{.Lang}}"> <input type="hidden" id="currentLanguage" value="{{.Lang}}">
<input type="hidden" id="isAdmin" value="{{.IsAdmin}}"> <input type="hidden" id="isAdmin" value="{{.IsAdmin}}">
<nav class="navbar navbar-default" role="navigation" style="margin-bottom: 0;"> <nav class="navbar navbar-default" role="navigation" style="margin-bottom: 0;">
@ -87,3 +88,4 @@
</form> </form>
</div> </div>
</nav> </nav>