Skip to content
Snippets Groups Projects
Select Git revision
  • 3706d1337eece3bdffe39223cc64eb305e2dd83c
  • mui5-tetras-main-stable default protected
  • mui5-tetras-main-old-stable
  • preprod protected
  • 75-dernieres-ameliorations-avant-workshop-du-7-02
  • wip-fix-xywh
  • wip-positionement-annot
  • wip-surface-transformer
  • uploads-file
  • 69-la-video-demare-quand-on-fait-glisser-le-slider-et-le-clic-creer-un-decalage-entre-le-player
  • 61-recettage-des-outils-d-annotation
  • gestion_multiple_ouverture_pannel_annotation
  • autorisation_un_pannel_annotation
  • autorisation_un_pannel_edition_annotation
  • récupération_temps_video
  • save-shapes-and-position
  • fix-error-create-annotation-pannel
  • time-saving-on-annotation
  • tetras-main protected
  • fix-poc-mirador
  • tetras-antho-test
21 results

HMSInput.js

Blame
  • ManifestForm.js 1.73 KiB
    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    
    /**
     * Provides a form for user input of a manifest url
     * @prop {Function} fetchManifest
     * @prop {Function} setLastRequested
     */
    class ManifestForm extends Component {
      /**
       * constructor -
       */
      constructor(props) {
        super(props);
        this.state = {
          formValue: '',
        };
    
        this.formSubmit = this.formSubmit.bind(this);
        this.handleInputChange = this.handleInputChange.bind(this);
      }
    
      /**
       * formSubmit - triggers manifest update and sets lastRequested
       * @param  {Event} event
       * @private
       */
      formSubmit(event) {
        const { fetchManifest, setLastRequested } = this.props;
        const { formValue } = this.state;
        event.preventDefault();
        fetchManifest(formValue);
        setLastRequested(formValue);
      }
    
      /**
       * handleInputChange - sets state based on input change.
       * @param  {Event} event
       * @private
       */
      handleInputChange(event) {
        const that = this;
        event.preventDefault();
        that.setState({
          formValue: event.target.value,
        });
      }
    
      /**
       * render
       * @return {String} - HTML markup for the component
       */
      render() {
        const { formValue } = this.state;
        const { t } = this.props;
        return (
          <form onSubmit={this.formSubmit}>
            <input
              value={formValue}
              id="manifestURL"
              type="text"
              onChange={this.handleInputChange}
            />
            <button id="fetchBtn" type="submit">{t('fetchManifest')}</button>
          </form>
        );
      }
    }
    
    ManifestForm.propTypes = {