Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
anke1460 5 years ago
commit 24beb2d16d

@ -111,8 +111,15 @@ class CoursesController < ApplicationController
end
videos = custom_sort(videos, params[:sort_by], params[:sort_direction])
@count = videos.count
@videos = paginate videos.includes(video: [user: :user_extension], user: :user_extension)
#sql = "left join videos on videos.id=course_videos.video_id AND (videos.transcoded=1 OR videos.user_id = #{current_user.id})"
#@videos = paginate videos.joins(sql).includes(video: [user: :user_extension], user: :user_extension)
videos = videos.includes(video: [user: :user_extension], user: :user_extension)
videos = videos.where(videos: {transcoded: true})
.or(videos.where(videos: {user_id: current_user.id}))
.or(videos.where(course_videos: {is_link: true}))
@count = videos.count
@videos = paginate videos
end
def delete_course_video
@ -133,13 +140,17 @@ class CoursesController < ApplicationController
# 视频移动到目录
def move_to_category
tip_exception("请选择要移动的目录") if params[:new_category_id].blank?
category = @course.course_second_categories.find_by(id: params[:new_category_id])
if params[:new_category_id].to_i == 0 || category.present?
videos = @course.course_videos.where(video_id: params[:video_ids]).or(@course.course_videos.where(id: params[:video_ids]))
video = @course.course_videos.where(video_id: params[:video_ids]).or(@course.course_videos.where(id: params[:video_ids])).first
user_id = video.user_id || video.video.user_id
tip_exception("您不是课堂管理员或者视频发布者,暂不能移动视频。") unless @user_course_identity < Course::PROFESSOR || user_id == current_user.id
videos.update_all(course_second_category_id: params[:new_category_id])
video.update!(course_second_category_id: params[:new_category_id])
normal_status(0, "操作成功")
else
normal_status(-1, "目录不存在")

@ -1,5 +1,4 @@
json.extract! video, :id, :title, :cover_url, :file_url, :play_url, :vv, :user_id, :transcoded
json.play_duration video.video_play_duration
json.published_at video.display_published_at
json.created_at video.display_created_at

@ -168,11 +168,18 @@ class Video extends Component {
}
// 移动到
moveVideo=(id)=>{
this.setState({
moveVisible:true,
moveVideoId:id
})
moveVideo=(id,flag)=>{
if(!flag){
this.setState({
moveVisible:true,
moveVideoId:id
})
}else{
this.props.define({
title:'提示',
content:"您不是课堂管理员或者视频发布者,暂不能移动视频。",
})
}
}
setMoveVisible=(flag)=>{
this.setState({
@ -194,6 +201,9 @@ class Video extends Component {
const { videos, upload, uploadVideo, videoData, changePage, pageSize, page } = this.props;
const operation = admin || business;
const {course_identity} = this.props.coursedata;
const flagMove = parseInt(course_identity) < 5;
return (
<div>
<EditVideoModal {...this.props} visible={visible} setVisible={this.setVisible}
@ -232,10 +242,12 @@ class Video extends Component {
{
videos && videos.length > 0 ?
<React.Fragment>
<p className="font-grey-9 mt20 mb20 pl5"> <span className="color-orange">{videoData && videoData.count}</span> </p>
<div className="videoContent">
{
videos.map((item, key) => {
console.log(course_identity > 2 && item.user_id === user_id)
return (
<VideoInReviewItem
{...this.props}
@ -247,7 +259,7 @@ class Video extends Component {
getCopyText={this.getCopyText}
operation={operation || item.user_id === user_id}
deleteVideo={(admin || item.user_id === user_id) ? this.deleteVideo : undefined}
moveVideo={videoData && videoData.has_category && (operation || item.user_id === user_id) ? ()=>this.moveVideo(item.id):undefined}
moveVideo={videoData && videoData.has_category && flagMove ? ()=>this.moveVideo(item.id,(course_identity > 2 && item.user_id !== user_id)):undefined}
>
</VideoInReviewItem>
)

@ -301,11 +301,11 @@ class VideoIndex extends Component{
<span>
{
videoId ?
<WordsBtn style="blue" onClick={()=>this.editDir(videoData && videoData.category_name,videoId)} className={"mr30 font-16"}>目录重命名</WordsBtn>
<WordsBtn style="blue" onClick={()=>this.editDir(videoData && videoData.category_name,videoId)} className={"ml30 font-16"}>目录重命名</WordsBtn>
:
<WordsBtn style="blue" className="mr30 font-16" onClick={this.addDir}>新建目录</WordsBtn>
<WordsBtn style="blue" className="ml30 font-16" onClick={this.addDir}>新建目录</WordsBtn>
}
<WordsBtn style="blue" className="mr30 font-16" onClick={()=>this.setLinkeVisible(true)}>增加外链</WordsBtn>
<WordsBtn style="blue" className="ml30 font-16" onClick={()=>this.setLinkeVisible(true)}>增加外链</WordsBtn>
</span>:""
}
{
@ -313,9 +313,9 @@ class VideoIndex extends Component{
<span>
{
upload ?
<WordsBtn style="grey" className="font-16" onClick={()=>this.uploadVideo(false)}>取消</WordsBtn>
<WordsBtn style="grey" className="font-16 ml30" onClick={()=>this.uploadVideo(false)}>取消</WordsBtn>
:
<WordsBtn style="blue" className="font-16" onClick={this.toUpload}>上传视频</WordsBtn>
<WordsBtn style="blue" className="font-16 ml30" onClick={this.toUpload}>上传视频</WordsBtn>
}
</span>:""
}

@ -82,7 +82,7 @@ function doCreateUploader (options) {
var uploadAddress = data.UploadAddress
var videoId = data.VideoId
uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress, videoId)
}
}).catch((error) => {
// 删除当前出错的,并执行下一个任务
@ -106,7 +106,7 @@ function doCreateUploader (options) {
if (response.data.status == -1) {
options.onUploadError && options.onUploadError(uploadInfo)
return;
}
}
const data = response.data.data
var uploadAuth = data.UploadAuth
var uploadAddress = data.UploadAddress

@ -126,7 +126,6 @@ function VideoUploadList (props) {
dispatch({type: 'addVideo', uploadInfo})
},
onUploadProgress: (uploadInfo, totalSize, progress) => {
setLoading(false);
console.log("upload",uploadInfo);
var progressPercent = Math.ceil(progress * 100)
@ -169,15 +168,15 @@ function VideoUploadList (props) {
},
onUploadEnd: (uploadInfo) => {
console.log('onUploadEnd', uploadInfo)
setLoading(false);
},
onUploadSucceed: (uploadInfo) => {
console.log('onUploadSucceed', uploadInfo)
setLoading(false);
},
onUploadError: (uploadInfo) => {
setLoading(false);
},
// 可能需要等lib加载完毕才能执行
gotUploader: (_uploader) => {

Loading…
Cancel
Save