<commit_before>import React, { Component } from 'react';
 
import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import DropDownMenu from 'material-ui/DropDownMenu';
import Checkbox from 'material-ui/Checkbox';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import Drawer from 'material-ui/Drawer';
import IconButton from 'material-ui/IconButton';
import CameraIcon from 'material-ui/svg-icons/image/photo-camera';

import AutoComplete from 'material-ui/AutoComplete';
import RaisedButton from 'material-ui/RaisedButton';
import Snackbar from 'material-ui/Snackbar';

import Paint from './Paint.jsx';
import Folder from './Folder.jsx';

import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
 
const settings = require('../../settings.js');
const  MobileDetect = require('mobile-detect'),
    mdd = new MobileDetect(navigator.userAgent);

const styles = {
  toolbar:{
    position: 'fixed',
    top: 0,
    width: '100%'
  },
  checkbox: {
    marginTop: 18,
    marginLeft: 12,
    marginBottom: 12,
    width: 100
  },
  label: {
    marginTop: 20,
  },
  label_check:{
    whiteSpace: "nowrap"
  },
  button:{margin: 12,},
  btn_ico:{marginTop: 8, marginRight:22},
  auto_complete:{marginTop: 5,marginLeft: 20,width:150}
}; 
// App component - represents the whole app
export default class Shoot extends Component {
  constructor(props) {
    super(props);

    //console.log(this.props);
    let path_default = props.params.path?props.params.path:'upload';
    this.state = {
      path:path_default,
      pics: [],
      bSelAll:false,
      dt_default:new Date(),
      openDelete:false,
      sels:[],
      openFolder:false,
      folders:[],
      sb_open:true,
      sb_msg:'正在请求图片...'
    };
    var me=this;
    this.onDirChange(this.state.path);
  }
  handleSBClose(){
    this.setState({sb_open:false,sb_msg:''});
  }
  componentDidMount() {
    ginf.app = this;
    document.title='拍照上传';
  }
  takePic(){
        MeteorCamera.getPicture({  
          width: 800,
          height: 1600,
          quality: 75
        }, function (err, data) {
          if (err) {
            console.log('error', err);
          }
          if(data)
            Meteor.call('pic.take', data,'/upload');
    });    
  }
  onItemAdded(data){
    //console.log('新加入图片：'+data);   
    let pics = this.state.pics;
    let plen = this.state.path.length;

    for(var k=0; k<data.length; k++){
      let dk = data[k];
      let ldk = dk.toLowerCase();
      let fn = dk.substring(plen+1);
      //忽略抽点推送的抽点文件
      if(dk.indexOf(this.state.path)!=0 || 
         fn.indexOf('/')!=-1 || fn.indexOf('\\')!=-1 ||
        (!ldk.endsWith('.jpg')&& !ldk.endsWith('.png')&& !ldk.endsWith('.jpeg')))
        continue;
      pics.push({fn:fn});
    }   
    this.setState({sb_open:true,sb_msg:'新加入图片：'+data,pics:pics});
  }
  onItemDeleted(data){
    //当前目录
    let pics = this.state.pics;
    let sels = this.state.sels;
    let plen = this.state.path.length;

    for(var k=0; k<data.length; k++){
      let dk = data[k];
      let fn = dk.substring(plen+1);

      if(dk.indexOf(this.state.path)!=0 
        ||fn.indexOf('/')!=-1 || fn.indexOf('\\')!=-1)
      //remove paper
      for(var i=0; i<pics.length; i++){
        if(pics[i].fn==fn){
          pics.splice(i,1);
          break;
        }
      } 
      //remove from selected
      for(var i=0; i<sels.length; i++){
        if(sels[i].fn==fn){
          sels.splice(i,1);
          break;
        }
      }       
    }   
    this.setState({pics:pics,sb_open:true,sb_msg:'移除图片：'+data});
  }
  getChildContext() {
     return { muiTheme: getMuiTheme(baseTheme) };
  }
  onDirChange(p1,p2){
    let me = this;
    Meteor.call('folder.getMyPics', p1, function(error, result){
        if(error){
            console.log(error);
        } else {
            //console.log('----正在请求图片：'+result);
            me.setState({path:p1,pics:result,sb_open:true,<commit_msg>拍照删除无刷新<commit_after>import React, { Component } from 'react';
 
import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import DropDownMenu from 'material-ui/DropDownMenu';
import Checkbox from 'material-ui/Checkbox';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import Drawer from 'material-ui/Drawer';
import IconButton from 'material-ui/IconButton';
import CameraIcon from 'material-ui/svg-icons/image/photo-camera';

import AutoComplete from 'material-ui/AutoComplete';
import RaisedButton from 'material-ui/RaisedButton';
import Snackbar from 'material-ui/Snackbar';

import Paint from './Paint.jsx';
import Folder from './Folder.jsx';

import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
 
const settings = require('../../settings.js');
const  MobileDetect = require('mobile-detect'),
    mdd = new MobileDetect(navigator.userAgent);

const styles = {
  toolbar:{
    position: 'fixed',
    top: 0,
    width: '100%'
  },
  checkbox: {
    marginTop: 18,
    marginLeft: 12,
    marginBottom: 12,
    width: 100
  },
  label: {
    marginTop: 20,
  },
  label_check:{
    whiteSpace: "nowrap"
  },
  button:{margin: 12,},
  btn_ico:{marginTop: 8, marginRight:22},
  auto_complete:{marginTop: 5,marginLeft: 20,width:150}
}; 
// App component - represents the whole app
export default class Shoot extends Component {
  constructor(props) {
    super(props);

    //console.log(this.props);
    let path_default = props.params.path?props.params.path:'upload';
    this.state = {
      path:path_default,
      pics: [],
      bSelAll:false,
      dt_default:new Date(),
      openDelete:false,
      sels:[],
      openFolder:false,
      folders:[],
      sb_open:true,
      sb_msg:'正在请求图片...'
    };
    var me=this;
    this.onDirChange(this.state.path);
  }
  handleSBClose(){
    this.setState({sb_open:false,sb_msg:''});
  }
  componentDidMount() {
    ginf.app = this;
    document.title='拍照上传';
  }
  takePic(){
        MeteorCamera.getPicture({  
          width: 800,
          height: 1600,
          quality: 75
        }, function (err, data) {
          if (err) {
            console.log('error', err);
          }
          if(data)
            Meteor.call('pic.take', data,'/upload');
    });    
  }
  onItemAdded(data){
    //console.log('新加入图片：'+data);   
    let pics = this.state.pics;
    let plen = this.state.path.length;

    for(var k=0; k<data.length; k++){
      let dk = data[k];
      let ldk = dk.toLowerCase();
      let fn = dk.substring(plen+1);
      //忽略抽点推送的抽点文件
      if(dk.indexOf(this.state.path)!=0 || 
         fn.indexOf('/')!=-1 || fn.indexOf('\\')!=-1 ||
        (!ldk.endsWith('.jpg')&& !ldk.endsWith('.png')&& !ldk.endsWith('.jpeg')))
        continue;
      pics.push({fn:fn});
    }   
    this.setState({sb_open:true,sb_msg:'新加入图片：'+data,pics:pics});
  }
  onItemDeleted(data){
    //当前目录
    let pics = this.state.pics;
    let sels = this.state.sels;
    let plen = this.state.path.length;

    for(var k=0; k<data.length; k++){
      let dk = data[k];
      let fn = dk.substring(plen+1);

      if(dk.indexOf(this.state.path)!=0 
        ||fn.indexOf('/')!=-1 || fn.indexOf('\\')!=-1)
        continue;
      //remove paper
      for(var i=0; i<pics.length; i++){
        if(pics[i].fn==fn){
          pics.splice(i,1);
          break;
        }
      } 
      //remove from selected
      for(var i=0; i<sels.length; i++){
        if(sels[i].fn==fn){
          sels.splice(i,1);
          break;
        }
      }       
    }   
    this.setState({pics:pics,sb_open:true,sb_msg:'移除图片：'+data});
  }
  getChildContext() {
     return { muiTheme: getMuiTheme(baseTheme) };
  }
  onDirChange(p1,p2){
    let me = this;
    Meteor.call('folder.getMyPics', p1, function(error, result){
        if(error){
            console.log(error);
        } else {
            //console.log('----正在请求图片：'+result);
            me.setState({path:p1,pics:result,sb_open:true,
{'fraction_non_alphanumeric': 0.1634199134199134, 'fraction_numerical': 0.012746512746512747, 'mean_word_length': 2.6735865724381624, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3786027', 'n_tokens_mistral': 3013, 'n_tokens_neox': 2953, 'n_words': 532}