ImageDetailsDialog.tsx 3.7 KB
Newer Older
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as React from 'react';
import { translate } from 'react-i18next';
import { withStyles } from '@material-ui/core/styles';

import RepositoryImage from 'model/repository/RepositoryImage';

import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import { Properties, PropertiesItem } from 'ui/common/Properties';

/*tslint:disable*/
const styles = (theme) => ({
  root: {
    height: '100%',
  },
  createButton: {
    position: 'absolute' as 'absolute',
    right: 0,
    bottom: 0,
    fontSize: '10px',
Matija Obreza's avatar
Matija Obreza committed
23
24
    // padding: '4px',
    // minHeight: '30px',
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
25
26
    background: '#e7e5df',
    border: 'solid gray',
Matija Obreza's avatar
Matija Obreza committed
27
28
    // borderWidth: '1px 0 0 1px',
    borderWidth: '0 0 0 0',
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    textTransform: 'initial' as 'initial',
    '&:hover': {
      background: '#e7e5df',
    },
  },
});
/*tslint:enable*/

interface IImageDetailsDialog extends React.ClassAttributes<any> {
  image: RepositoryImage;
  classes?: any;
  t?: any;
}

class ImageDetailsDialog extends React.Component<IImageDetailsDialog, any> {

  public state = {
    open: false,
  };

  public render() {
    const { classes, t, image } = this.props;

Matija Obreza's avatar
Matija Obreza committed
52
    const buttonText = `©`;
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

    return image ? (
      <span className={ classes.root }>
        <Button className={ classes.createButton } onClick={ this.show }>{ buttonText }</Button>
        { this.state.open &&
        <Dialog open={ this.state.open } onClose={ this.hide } maxWidth="md" fullWidth onClick={ (e) => e.preventDefault() }>
          <DialogTitle>{ t(`repository.public.c.imageDetailsDialog.details`) }</DialogTitle>
          <DialogContent>
           <Properties>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.title') }>{ image.title || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.originalFilename') }>{ image.originalFilename || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.contentType') }>{ image.contentType || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.extension') }>{ image.extension || 'Not specified' }</PropertiesItem>
              <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.creator') }>{ image.creator || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.license') }>{ image.license || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.height') }>{ image.height || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.width') }>{ image.width || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.orientation') }>{ image.orientation || 'Not specified' }</PropertiesItem>
            <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.description') }>{ image.description || 'Not specified' }</PropertiesItem>
             <PropertiesItem title={ t('repository.public.c.imageDetailsDialog.thumbnailPath') }>{ image.thumbnailPath || 'Not specified' }</PropertiesItem>
           </Properties>
          </DialogContent>
        </Dialog>
        }
    </span>
    ) : null;
  }

  private show = (e) => {
    e.preventDefault();
    this.setState(
      (state) => ({ ...state, open: true }));
  }

  private hide = (e) => {
    e.preventDefault();
    this.setState({ open: false });
  }
}


export default translate()(withStyles(styles)(ImageDetailsDialog));