This commit is contained in:
cxt 2015-11-12 17:20:11 +08:00
commit 7a93fddb83
7 changed files with 94 additions and 42 deletions

View File

@ -607,6 +607,13 @@ class ProjectsController < ApplicationController
@project.organization_id = params[:organization_id]
params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0
params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0
# 更新公开私有时同步gitlab公开私有
unless @project.gpid.nil?
g = Gitlab.client
gproject = g.project(@project.gpid)
params[:project][:is_public] ? g.edit_project(gproject.id, 20) : g.edit_project(gproject.id, 0)
end
# end
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
if params[:project][:is_public] == '0'

View File

@ -28,7 +28,7 @@
showNormalImage('message_description_<%= @article.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @article.id%>').show();" onmouseout="$('#message_setting_<%= @article.id%>').hide();">
<div class="postRightContainer" onmouseover="$('#message_setting_<%= @article.id%>').show();" onmouseout="$('#message_setting_<%= @article.id%>').hide();">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
@ -165,7 +165,7 @@
<%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %>
<% end %>
<div class="cl"></div>
</div>

View File

@ -32,7 +32,7 @@
<%#end%>
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRight mt0">
<div class="homepageRightBanner">
<div class="NewsBannerName">
<%= @user.name%>的博客

View File

@ -72,6 +72,23 @@ class Gitlab::Client
post(url, :body => {:name => name}.merge(options))
end
# Updates a project team member to a specified access level.
# id (required) - The ID of a project
# name (optional) - project name
# path (optional) - repository name for project
# description (optional) - short project description
# default_branch (optional)
# issues_enabled (optional)
# merge_requests_enabled (optional)
# wiki_enabled (optional)
# snippets_enabled (optional)
# public (optional) - if true same as setting visibility_level = 20
# visibility_level (optional)
def edit_project(id, visibility_level)
put("/projects/#{id}", :body => {:visibility_level => visibility_level})
end
# Deletes a project.
#
# @example

View File

@ -10,6 +10,9 @@ module Trustie
DEVELOPER = 30
MASTER = 40
OWNER = 50
# 项目公开和私有
PUBLIC = 20
PRIVATE = 0
end
class Sync
@ -45,7 +48,8 @@ module Trustie
issues_enabled: false,
snippets_enabled: false,
public: false,
user_id: gid
user_id: gid,
visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE
)
project.gpid = gproject.id
project.save!
@ -84,7 +88,8 @@ module Trustie
merge_requests_enabled: true,
public: false,
user_id: gid,
import_url: import_url
import_url: import_url,
visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE
)
puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
project.gpid = gproject.id

View File

@ -155,13 +155,13 @@ function addFile(inputEl, file, eagerUpload,btnId) {
addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
//上传开始调用函数
function onLoadstart(e) {
fileSpan.removeClass('ajax-waiting');
fileSpan.addClass('ajax-loading');
$('input:submit', $(this).parents('form')).attr('disabled', 'disabled');
}
//更改progressbar的值
function onProgress(e) {
if (e.lengthComputable) {
this.progressbar('value', e.loaded * 100 / e.total);
@ -177,40 +177,43 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
progressEventHandler: onProgress.bind(progressSpan)
})
.done(function(result) {
progressSpan.progressbar('value', 100).remove();
var containerid = $(inputEl).data('containerid');
console.log($(inputEl))
if(containerid == undefined ){
var count = $('#attachments_fields>span').length;
$('#'+btnId).removeAttr("disabled");
$('#'+btnId).val('确定')
$('#'+btnId).css('background-color','#269ac9')
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
}
else{
$('#'+btnId).removeAttr("disabled");
$('#'+btnId).val('确定')
$('#'+btnId).css('background-color','#269ac9')
var count = $('#attachments_fields' + containerid + '>span').length;
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
}
progressSpan.progressbar('value', 100).remove(); //上传完成就去掉该文件名后的进度条
fileSpan.find('input.description, a').css('display', 'inline-block');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
if ($("#network_issue")) {
progressSpan.text("网络错误");
if ($("#network_issue")) { //在上传处都要给出一个network_issue的div用来显示错误
$("#network_issue").show();
}
}).always(function() {
ajaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
$('input:submit', form).removeAttr('disabled');
var containerid = $(inputEl).data('containerid');//多个上传控件需要的容器id
if(containerid == undefined ){
var count = 1;//同步上传参数为1所以不需要去获取正在上传的文件就知道是1
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
}
form.dequeue('upload');
else{
var count = 1;
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
}
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { //所有文件上传完毕,更改状态
$('input:submit', form).removeAttr('disabled');
$('#' + btnId).removeAttr("disabled");
$('#' + btnId).val('确定')
$('#' + btnId).css('background-color', '#269ac9')
if(containerid == undefined ){
var count = $('#attachments_fields>span').length;
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
}else{
var count = $('#attachments_fields' + containerid + '>span').length;
$('#upload_file_count'+containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
}
}
form.dequeue('upload');//上传完成一个就退出一个
});
//gcm files count and add delete_all link
@ -222,7 +225,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
$('#'+btnId).attr("disabled",true);
$('#'+btnId).val('提交中');
$('#'+btnId).css('background-color','#c1c1c1')
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
$('#upload_file_count').html("<span id=\"count\">1</span>" + $(inputEl).data('lebelFileUploding'));//目前肯定是穿一个文件
if (count >= 1) {
var add_attachs = $('.add_attachment');
var delete_all = $('.remove_all');
@ -239,7 +242,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
$('#'+btnId).attr("disabled",true);
$('#'+btnId).val('提交中');
$('#'+btnId).css('background-color','#c1c1c1')
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
$('#upload_file_count' + containerid).html("<span id=\"count\">1</span>" + $(inputEl).data('lebelFileUploding'));//目前肯定是穿一个文件
if (count >= 1) {
var add_attachs = $('.add_attachment').filter(function(index) {
return $(this).data('containerid') == containerid;
@ -262,17 +265,25 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
//gcm
}
//在插入文件名的后边插入div
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.upload_filename'));
progressSpan.progressbar();
fileSpan.addClass('ajax-waiting');
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
progressSpan.progressbar(); //将div处理成progress bar
fileSpan.addClass('ajax-waiting'); //添加文件正在上传的状态
var containerid = $(inputEl).data('containerid');//多个上传控件需要的容器id
if(containerid == undefined ){ //选择了多少个文件也要显示,因为有时候文件过大,一时半会传不完,但还是显示文件没有选择
var count = $('#attachments_fields>span').length;
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + '个文件被选择');
}else{
var count = $('#attachments_fields' + containerid + '>span').length;
$('#upload_file_count'+containerid).html("<span id=\"count\">" + count + "</span>" + '个文件被选择');
}
//最大的同步上传参数
var maxSyncUpload = 1 //$(inputEl).data('max-concurrent-uploads');
//如果没有指定同步上传参数 或者参数不对,或者需要上传的文件已经小于同步上传的个数,那么直接上传
if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
actualUpload(file, attachmentId, fileSpan, inputEl,btnId);
else
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
else //否则就进行队列上传
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl,btnId));
}
ajaxUpload.uploading = 0;
@ -338,6 +349,10 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
function addInputFiles(inputEl,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// if(inputEl.files.length >= 5){
// alert('一次选择的文件不能超过5个')
// return;
// }
// upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl,btnId);
// $(inputEl).remove();
@ -365,6 +380,10 @@ function addInputFiles_board(inputEl, id,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// if(inputEl.files.length >= 5){
// alert('一次选择的文件不能超过5个')
// return;
// }
// upload files using ajax
uploadAndAttachFiles_board(inputEl.files, inputEl, id,btnId);
// $(inputEl).remove();
@ -497,6 +516,10 @@ function addInputFilesCourseSource(inputEl) {
btnId = arguments[2];
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// if(inputEl.files.length >= 5){
// alert('一次选择的文件不能超过5个')
// return;
// }
// upload files using ajax
uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox,btnId);
// $(inputEl).remove();

View File

@ -261,7 +261,7 @@ a:hover.grey_n_btn{ background:#717171; color:#fff;}
.green_btn{ background:#28be6c; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;}
a.green_btn{background:#28be6c;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;}
a:hover.green_btn{ background:#14ad5a;}
.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;}
.blue_btn{ background:#64bdd9; color:#fff; font-weight:normal;padding:2px 8px; text-align:center;}
a.blue_btn{background:#64bdd9;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;}
a:hover.blue_btn{ background:#329cbd;}
a.orange_btn{ background:#ff5722;color:#fff; font-weight:normal; padding:2px 10px; text-align:center; }