<commit_before>import React, { PureComponent } from 'react';
import Swiper from 'react-id-swiper';
import 'react-id-swiper/src/styles/scss/swiper.scss';
import moment from 'moment';
import _ from 'lodash/fp';

import PluginDetailPanel from '../../../plugin-page-component/PluginDetailPanel';
import ImagesDetailPanel from '../images-page-component/ImagesDetailPanel';
import { valuesNames, valuesLabels } from '../forms.config';
import { hasClass } from '../../../../utils/plugin-helpers.utils';

const IMAGES_PANEL = 'imagesPanel';
const IMAGES_DETAIL_PANEL = 'imagesDetailPanel';
const SCALE = 100;

export default class ImagesDetail extends PureComponent {
  getURLtoImage = id => `http://4192.168.127.12/orthanc/instances/${id}/preview`;

  state = {
    styleSwiper: {},
    coordX: '',
    coordY: '',
    drag: false,
    targ: {},
    marginTop: 0,
    marginLeft: 0,
    touchMode: true,
  };

  componentWillReceiveProps(nextProps) {
    if (nextProps.instanceIds[0] !== this.props.instanceIds[0]) {
      this.setState({ styleSwiper: {}, touchMode: true });
      this.swiper.allowTouchMove = true;
    }
  }

  componentDidMount() {
    document.onmousedown = this.startDrag;
    document.onmouseup = this.stopDrag;
  }

  startDrag = /* istanbul ignore next */ (e) => {
    if (!this.state.touchMode) {
      if (e.preventDefault) e.preventDefault();

      let target = e.target ? e.target : e.srcElement;

      if (hasClass(target, 'swiper-slide')) {
        target = target.querySelector('img');
      }

      if (target.id !== `img-${this.swiper.activeIndex}`) { return }

      this.setState({ targ: target });

      if (target.id !== `img-${this.swiper.activeIndex}`) { return }
      const marginTop = parseInt(target.style.marginTop) || 0;
      const marginLeft = parseInt(target.style.marginLeft) || 0;
      this.setState({
        coordX: parseInt(e.clientX),
        coordY: parseInt(e.clientY),
        drag: true,
        marginTop,<commit_msg>Different protocols for the GET image in the DEV mode and SECURE mode<commit_after>import React, { PureComponent } from 'react';
import Swiper from 'react-id-swiper';
import 'react-id-swiper/src/styles/scss/swiper.scss';
import moment from 'moment';
import _ from 'lodash/fp';

import PluginDetailPanel from '../../../plugin-page-component/PluginDetailPanel';
import ImagesDetailPanel from '../images-page-component/ImagesDetailPanel';
import { valuesNames, valuesLabels } from '../forms.config';
import { hasClass } from '../../../../utils/plugin-helpers.utils';

const IMAGES_PANEL = 'imagesPanel';
const IMAGES_DETAIL_PANEL = 'imagesDetailPanel';
const SCALE = 100;

export default class ImagesDetail extends PureComponent {
  state = {
    styleSwiper: {},
    coordX: '',
    coordY: '',
    drag: false,
    targ: {},
    marginTop: 0,
    marginLeft: 0,
    touchMode: true,
  };

  componentWillReceiveProps(nextProps) {
    if (nextProps.instanceIds[0] !== this.props.instanceIds[0]) {
      this.setState({ styleSwiper: {}, touchMode: true });
      this.swiper.allowTouchMove = true;
    }
  }

  componentDidMount() {
    document.onmousedown = this.startDrag;
    document.onmouseup = this.stopDrag;
  }

  getURLtoImage = (id) => `${window.location.protocol}//192.168.127.12/orthanc/instances/${id}/preview`;

  startDrag = /* istanbul ignore next */ (e) => {
    if (!this.state.touchMode) {
      if (e.preventDefault) e.preventDefault();

      let target = e.target ? e.target : e.srcElement;

      if (hasClass(target, 'swiper-slide')) {
        target = target.querySelector('img');
      }

      if (target.id !== `img-${this.swiper.activeIndex}`) { return }

      this.setState({ targ: target });

      if (target.id !== `img-${this.swiper.activeIndex}`) { return }
      const marginTop = parseInt(target.style.marginTop) || 0;
      const marginLeft = parseInt(target.style.marginLeft) || 0;
      this.setState({
        coordX: parseInt(e.clientX),
        coordY: parseInt(e.clientY),
        drag: true,
        marginTop,
{'fraction_non_alphanumeric': 0.1533879374534624, 'fraction_numerical': 0.010176222387689253, 'mean_word_length': 3.2465753424657535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2888503', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1270, 'n_words': 267}