import * as React from "react"; import {GroupedPlayers, PlayerHeader} from "./PlayerItemList"; declare var smartformsrecordingparams:any; export class PlayerItem extends React.Component{ public $Container:JQuery; constructor(){ super(); this.SubRecordingSelected.bind(this); this.state={ }; } render(){ let child; if(this.props.item==null) child=( [,

Loading Recorded Sessions

]); else child=([
{this.MillisecondsToDuration(this.props.item.Duration.toString())}
{this.MillisecondsToDate(this.props.item.StartTime)}
{this.props.item.UserId!=''?this.props.item.UserId:this.props.item.SessionId.substr(0,this.props.item.SessionId.lastIndexOf('.'))}
,
{this.props.item.RelatedPlays.map((headerItem,index)=>{return ( [ , {this.SubRecordingSelected(e,headerItem)}}>{headerItem.url==''?'/':headerItem.url}({this.MillisecondsToDuration(headerItem.duration)}), index: ] )})}
,
]); return (this.$Container=jQuery(node)} className={'list-group-item '+this.props.className}> {child} ); } public SubRecordingSelected(e:any,itemSelected) { e.stopPropagation(); if(this.props.onItemSelected!=null) this.props.onItemSelected(itemSelected); } private MillisecondsToDate(start_time: string) { let date=new Date(parseInt(start_time)); let monthName; switch (date.getMonth()) { case 0: monthName='Jan'; break; case 1: monthName='Feb'; break; case 2: monthName='Mar'; break; case 3: monthName='Apr'; break; case 4: monthName='May'; break; case 5: monthName='Jun'; break; case 6: monthName='Jul'; break; case 7: monthName='Aug'; break; case 8: monthName='Sep'; break; case 9: monthName='Oct'; break; case 10: monthName='Nov'; break; case 11: monthName='Dec'; } return monthName+'-'+this.FormatTimeSection(date.getDate())+'-'+date.getFullYear()+' '+this.FormatTimeSection(date.getHours())+':'+this.FormatTimeSection(date.getMinutes())+":"+this.FormatTimeSection(date.getSeconds()); } private FormatTimeSection(time:number) { if(time>=10) return time; return '0'+time.toString(); } private MillisecondsToDuration(st: string) { let start_time:number=parseInt(st); let ms = start_time % 1000; start_time = (start_time - ms) / 1000; let secs = start_time % 60; start_time = (start_time - secs) / 60; let mins = start_time % 60; let hrs = (start_time - mins) / 60; return (hrs>0?this.FormatTimeSection(hrs) + ':':'') + (mins>0? this.FormatTimeSection(mins) + ':':'') + this.FormatTimeSection(secs)+(hrs==0&&mins==0?'s':''); } } // interface PlayerItemState{ } interface PlayerItemProps{ item:GroupedPlayers; selectedItem:PlayerHeader; onClick:(node:any)=>void; className:string; onItemSelected:(PlayerHeader)=>void; }