Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

Adjustreact
杨树明 5 years ago
commit 8a757f1b27

@ -25,7 +25,7 @@ class CoursesController < ApplicationController
:delete_course_teacher, :teacher_application_review, :students, :all_course_groups,
:transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search,
:base_info, :get_historical_courses, :create_group_by_importing_file, :course_videos,
:attahcment_category_list,:export_member_scores_excel, :duplicate_course,
:attahcment_category_list,:export_member_scores_excel, :duplicate_course, :delete_course_video,
:switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course,
:informs, :update_informs, :online_learning, :update_task_position, :tasks_list,
:join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs,
@ -109,6 +109,15 @@ class CoursesController < ApplicationController
@videos = paginate videos
end
def delete_course_video
video = Video.find_by(id: params[:video_id])
tip_exception(404, "找不到资源") if video.blank?
tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?)
video.destroy!
AliyunVod::Service.delete_video([video.uuid]) rescue nil
render_ok
end
def visits_plus_one
new_visits = @course.visits + 1
@course.update_visits(new_visits)

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

@ -516,6 +516,7 @@ Rails.application.routes.draw do
get 'act_score'
get 'statistics'
get 'course_videos'
delete 'delete_course_video'
post :inform_up
post :inform_down
get :calculate_all_shixun_scores

@ -10,6 +10,7 @@ import ClipboardJS from 'clipboard'
import './video.css';
import '../../user/usersInfo/video/InfosVideo.css'
import axios from 'axios';
const DEFAULT_VIDEO_WIDTH_IN_MD = "90%" // 400
const DEFAULT_VIDEO_HEIGHT_IN_MD = "55%" // 400
@ -17,7 +18,6 @@ const DEFAULT_VIDEO_HEIGHT_IN_MD = "55%" // 400
const videoEl = null;
let _clipboard = null;
class Video extends Component{
constructor(props){
super(props);
@ -69,9 +69,8 @@ class Video extends Component{
// 编辑成功后回调的方法
editSuccess=()=>{
const { page } = this.state;
this.props.showNotification("视频名称修改成功!");
const { listFunc } = this.props;
const { listFunc , page } = this.props;
listFunc && listFunc(page);
}
@ -132,13 +131,42 @@ class Video extends Component{
return `<video src="${file_url}" controls="true" controlslist="nodownload" width="${DEFAULT_VIDEO_WIDTH_IN_MD}" height="${DEFAULT_VIDEO_HEIGHT_IN_MD}" poster="${cover_url}">您的浏览器不支持 video 标签。</video>`
}
// 删除事件
deleteVideo=(item)=>{
this.props.confirm({
content: '该视频将被删除,不可恢复',
subContent:'是否确认删除?',
onOk: () => {
const CourseId=this.props.match.params.coursesId;
const url = `/courses/${CourseId}/delete_course_video.json`;
axios.delete(url,{
params:{
video_id:item.id
}
}).then(result=>{
if(result){
this.props.showNotification(`删除成功!`);
const { listFunc , page } = this.props;
listFunc && listFunc(page);
}
}).catch(error=>{
console.log(error);
})
},
onCancel() {
console.log('Cancel');
},
});
}
render(){
const { visible , videoVisible , videoId } = this.state;
const CourseId=this.props.match.params.coursesId;
const login=this.props.user&&this.props.user.login;
const _inputValue = videoId && this.getCopyText(videoId.file_url, videoId.cover_url);
const { admin , is_teacher ,business} = this.props.user;
const { admin , is_teacher ,business , user_id} = this.props.user;
const { videos , upload , uploadVideo , videoData , changePage ,pageSize ,page } = this.props;
@ -195,6 +223,7 @@ class Video extends Component{
onMaskClick={this.onMaskClick}
getCopyText={this.getCopyText}
operation={operation}
deleteVideo={(admin || item.user_id === user_id) ? this.deleteVideo : undefined}
>
</VideoInReviewItem>
)

@ -189,6 +189,16 @@ class VideoIndex extends Component{
{...this.props}
{...this.state}
></LivesNew>
{
liveVisible ?
<style>{
`
body{
width: 100%!important;
overflow: hidden!important;
}
`}</style>:""
}
<div className="edu-back-white" style={{marginBottom:"1px"}}>
<div className="clearfix pl30 pr30 menuDiv">

@ -57,7 +57,7 @@
z-index: 99;
}
.videoItem .square-main {
padding: 9px 8px;
padding: 15px 10px;
background: #fff;
border-radius:12px;

@ -20,7 +20,7 @@ const clipboardMap = {}
function VideoInReviewItem (props) {
const theme = useContext(ThemeContext);
const { history, file_url, cover_url, title, created_at, published_at, isReview, id
, onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration,operation} = props;
, onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration,operation , deleteVideo} = props;
useEffect(()=> {
if (!isReview) {
_clipboard = new ClipboardJS(`.copybtn_item_${id}`);
@ -73,6 +73,15 @@ function VideoInReviewItem (props) {
</Tooltip> } {vv===0?"":vv}
</span>
{ isReview != true && <div>
{
deleteVideo &&
<Tooltip title="删除" placement="bottom">
<i className="icon-shanchu iconfont" onClick={() => deleteVideo(props)}
style={{ marginTop: '1px', display: 'inline-block'}}
></i>
</Tooltip>
}
{
operation &&
<Tooltip title="编辑" placement="bottom">

Loading…
Cancel
Save