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

dev_item_bank
杨树林 5 years ago
commit cf313a2f8e

@ -55,7 +55,7 @@ class Users::VideosController < Users::BaseController
def destroy def destroy
video = Video.find_by(id: params[:id]) video = Video.find_by(id: params[:id])
return render_forbidden unless video.user_id == current_user.id || current_user.admin_or_business? return render_forbidden unless video.user_id == current_user.id || current_user.admin?
return render_not_found if video.blank? return render_not_found if video.blank?
return render_error('该状态下不能删除视频') unless video.published? return render_error('该状态下不能删除视频') unless video.published?

@ -55,32 +55,32 @@ module CoursesHelper
return nil if mod.blank? or course.blank? return nil if mod.blank? or course.blank?
case mod.module_type case mod.module_type
when "announcement" when "announcement"
"/courses/#{course.id}/informs" "/classrooms/#{course.id}/informs"
when "online_learning" when "online_learning"
"/courses/#{course.id}/online_learning" "/classrooms/#{course.id}/online_learning"
when "shixun_homework" when "shixun_homework"
"/courses/#{course.id}/shixun_homeworks/#{mod.id}" "/classrooms/#{course.id}/shixun_homeworks/#{mod.id}"
when "common_homework" when "common_homework"
"/courses/#{course.id}/common_homeworks/#{mod.id}" "/classrooms/#{course.id}/common_homeworks/#{mod.id}"
when "group_homework" when "group_homework"
"/courses/#{course.id}/group_homeworks/#{mod.id}" "/classrooms/#{course.id}/group_homeworks/#{mod.id}"
when "graduation" when "graduation"
"/courses/#{course.id}/graduation_topics/#{mod.id}" "/classrooms/#{course.id}/graduation_topics/#{mod.id}"
when "exercise" when "exercise"
"/courses/#{course.id}/exercises/#{mod.id}" "/classrooms/#{course.id}/exercises/#{mod.id}"
when "poll" when "poll"
"/courses/#{course.id}/polls/#{mod.id}" "/classrooms/#{course.id}/polls/#{mod.id}"
when "attachment" when "attachment"
"/courses/#{course.id}/files/#{mod.id}" "/classrooms/#{course.id}/files/#{mod.id}"
when "board" when "board"
course_board = course.course_board course_board = course.course_board
"/courses/#{course.id}/boards/#{course_board.id}" "/classrooms/#{course.id}/boards/#{course_board.id}"
when "course_group" when "course_group"
"/courses/#{course.id}/course_groups" "/classrooms/#{course.id}/course_groups"
when "statistics" when "statistics"
"/courses/#{course.id}/statistics" "/classrooms/#{course.id}/statistics"
when "video" when "video"
"/courses/#{course.id}/course_videos" "/classrooms/#{course.id}/course_videos"
end end
end end
@ -88,17 +88,17 @@ module CoursesHelper
def category_url category, course def category_url category, course
case category.category_type case category.category_type
when "shixun_homework" when "shixun_homework"
"/courses/#{course.id}/shixun_homework/#{category.id}" "/classrooms/#{course.id}/shixun_homework/#{category.id}"
when "graduation" when "graduation"
if category.name == "毕设选题" if category.name == "毕设选题"
"/courses/#{course.id}/graduation_topics/#{category.course_module_id}" "/classrooms/#{course.id}/graduation_topics/#{category.course_module_id}"
else else
"/courses/#{course.id}/graduation_tasks/#{category.course_module_id}" "/classrooms/#{course.id}/graduation_tasks/#{category.course_module_id}"
end end
when "attachment" when "attachment"
"/courses/#{course.id}/file/#{category.id}" "/classrooms/#{course.id}/file/#{category.id}"
when "video" when "video"
"/courses/#{course.id}/course_video/#{category.id}" "/classrooms/#{course.id}/course_video/#{category.id}"
end end
end end
@ -147,7 +147,7 @@ module CoursesHelper
when "online_learning" when "online_learning"
course.shixuns.count course.shixuns.count
when "video" when "video"
course.course_videos.count + course.live_links.count course.videos_count + course.live_links.count
end end
end end
@ -296,11 +296,11 @@ module CoursesHelper
none_group_count = course.students.where(course_group_id: 0).size none_group_count = course.students.where(course_group_id: 0).size
group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1, group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1,
category_count: none_group_count, category_type: false, category_count: none_group_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/0"} second_category_url: "/classrooms/#{@course.id}/course_groups/0"}
course.course_groups.each do |course_group| course.course_groups.each do |course_group|
group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position, group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position,
category_count: course_group.course_members_count, category_type: false, category_count: course_group.course_members_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"} second_category_url: "/classrooms/#{@course.id}/course_groups/#{course_group.id}"}
end end
end end
group_info group_info

@ -160,6 +160,10 @@ class Course < ApplicationRecord
students.find_by(user_id: user_id)&.course_group_name students.find_by(user_id: user_id)&.course_group_name
end end
def videos_count
course_videos.where(video_id: videos.where("transcoded = 1 or videos.user_id = #{User.current.id}").pluck(:id))
.or(course_videos.where(course_videos: {is_link: true})).size
end
def teacher_group(user_id) def teacher_group(user_id)
data = data =

@ -94,7 +94,7 @@ class Video extends Component {
let videoId = { let videoId = {
videoId: item.id, videoId: item.id,
title: item.title, title: item.title,
file_url: item.file_url, file_url: (item.play_url || item.file_url),
cover_url: item.cover_url cover_url: item.cover_url
} }
this.setState({ this.setState({

@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext, memo } from 'react'; import React, { useState, useEffect, useContext, memo } from 'react';
import { Progress, Input, Tooltip } from 'antd' import { Progress, Input, Tooltip , Spin } from 'antd'
import { getUrl2, isDev, CBreadcrumb, ActionBtn, ThemeContext } from 'educoder' import { getUrl2, isDev, CBreadcrumb, ActionBtn, ThemeContext } from 'educoder'
import axios from 'axios' import axios from 'axios'
import moment from 'moment' import moment from 'moment'
@ -20,7 +20,7 @@ let _clipboard = null;
const clipboardMap = {} const clipboardMap = {}
function VideoInReviewItem (props) { function VideoInReviewItem (props) {
const theme = useContext(ThemeContext); const theme = useContext(ThemeContext);
const { history, file_url, cover_url, title, created_at, published_at, isReview, id const { history, file_url , play_url , cover_url , transcoded , title, created_at, published_at, isReview, id
, onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration,operation , deleteVideo , moveVideo ,link} = props; , onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration,operation , deleteVideo , moveVideo ,link} = props;
useEffect(()=> { useEffect(()=> {
if (!isReview) { if (!isReview) {
@ -44,24 +44,26 @@ function VideoInReviewItem (props) {
function toUpload() { function toUpload() {
history.push(`/users/${username}/videos/upload`) history.push(`/users/${username}/videos/upload`)
} }
const imgUrl = (!transcoded && !link) ? defaultImg : (cover_url || defaultImg);
return ( return (
<div className={`${isReview ? 'videoInReviewItem' : 'nItem'} videoItem`}> <div className={`${isReview ? 'videoInReviewItem' : 'nItem'} videoItem`}>
<Spin tip="正在转码,请稍等..." spinning={!transcoded && !link}>
<img className="cover" src={imgUrl} alt=""></img>
{ link ?
<a href={link} target='_blank' className="otherLinkPanel">
<span className="otherLink">外链</span>
</a>
: ""
}
<img className="cover" src={cover_url || defaultImg} alt=""></img> {!isReview && <div className="mask" onClick={() => onMaskClick(props)}></div>}
{ link ? {!isReview && !link && transcoded &&
<a href={link} target='_blank' className="otherLinkPanel"> <div className="playWrap" onClick={() => onMaskClick(props)}>
<span className="otherLink">外链</span> <img className="play mp23" src={playIcon}></img>
</a> {play_duration===0?"":<div className={"play_duration"}>累计学习时长{play_duration} h</div>}
: "" </div>
} }
</Spin>
{!isReview && <div className="mask" onClick={() => onMaskClick(props)}></div>}
{!isReview && !link &&
<div className="playWrap" onClick={() => onMaskClick(props)}>
<img className="play mp23" src={playIcon}></img>
{play_duration===0?"":<div className={"play_duration"}>累计学习时长{play_duration} h</div>}
</div>
}
<div className="square-main"> <div className="square-main">
<div className="title overflowHidden1" <div className="title overflowHidden1"
title={title && title.length > 20 ? title : ''} title={title && title.length > 20 ? title : ''}
@ -106,7 +108,7 @@ function VideoInReviewItem (props) {
{ {
!link ? !link ?
<Tooltip title="复制视频地址" placement="bottom"> <Tooltip title="复制视频地址" placement="bottom">
<i className={`icon-fuzhi iconfont copybtn_item_${id}`} data-clipboard-text={getCopyText(file_url, cover_url)}></i> <i className={`icon-fuzhi iconfont copybtn_item_${id}`} data-clipboard-text={getCopyText((play_url || file_url), cover_url)}></i>
</Tooltip>:"" </Tooltip>:""
} }

@ -57,9 +57,12 @@ function VideoUploadList (props) {
} }
function onUploadChange (e) { function onUploadChange (e) {
var file = e.target.files[0] var file = e.target.files[0];
setLoading(true);
if (!file) { if (!file) {
// alert("请先选择需要上传的文件!") // alert("请先选择需要上传的文件!")
setLoading(false);
return return
} }
// avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm // avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm
@ -71,6 +74,7 @@ function VideoUploadList (props) {
&& file.name.indexOf('.webm') == -1 && file.name.indexOf('.webm') == -1
) { ) {
showNotification(`不支持的视频格式`) showNotification(`不支持的视频格式`)
setLoading(false);
clearInput() clearInput()
return; return;
} }
@ -79,7 +83,8 @@ function VideoUploadList (props) {
}else if (file.size >(parseInt(MAX_FILE_SIZE) * 1024 * 1024)) { }else if (file.size >(parseInt(MAX_FILE_SIZE) * 1024 * 1024)) {
// 超过500m TODO // 超过500m TODO
clearInput() clearInput();
setLoading(false);
showNotification(`视频大小超过${MAX_FILE_SIZE}M`) showNotification(`视频大小超过${MAX_FILE_SIZE}M`)
return; return;
} }
@ -91,7 +96,8 @@ function VideoUploadList (props) {
} }
}) })
if (gotTheSameFileName) { if (gotTheSameFileName) {
clearInput() clearInput();
setLoading(false);
showNotification(`你不能上传同一个视频文件名称,请重新选择。`) showNotification(`你不能上传同一个视频文件名称,请重新选择。`)
return; return;
} }
@ -106,7 +112,6 @@ function VideoUploadList (props) {
// 重新创建 才会用最新的 dispatch // 重新创建 才会用最新的 dispatch
create: !uploader, create: !uploader,
addFileSuccess: (uploadInfo) => { addFileSuccess: (uploadInfo) => {
setLoading(true);
const file = uploadInfo.file; const file = uploadInfo.file;
console.log('addFileSuccess', uploadInfo) console.log('addFileSuccess', uploadInfo)
// const newvideos = [...videos, { // const newvideos = [...videos, {
@ -435,9 +440,10 @@ function VideoUploadList (props) {
>继续添加</ActionBtn>} >继续添加</ActionBtn>}
<div className={`description ${noUploads ? 'noUploads' : ''}`}> <div className={`description ${noUploads ? 'noUploads' : ''}`}>
<div className="">视频大小不支持断点续传单个视频文件最大500M单次最多支持3个视频文件上传 </div> <div class="description ">
<div className="">视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div> <div>上传说明目前不支持断点续传单个视频文件最大限制500M单次最多支持3个视频文件上传 </div>
<div className="">温馨提示请勿上传违法视频平台将为每一个视频分配一个地址您可以通过引用该地址将视频使用在实训项目等模块</div> <div>视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div>
<div>温馨提示<span class="color-orange-tip">为了更好播放的体验建议您优先上传MP4格式如果您是自己录制视频建议您保存的时候将视频编码设置为AVC(H264)</span></div></div>
</div> </div>
{!noUploads && <React.Fragment> {!noUploads && <React.Fragment>

Loading…
Cancel
Save