@selkirk-systems/attachments 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +0 -0
  2. package/dist/actions/AttachmentActions.js +11 -0
  3. package/dist/actions/FileActions.js +37 -0
  4. package/dist/actions/ImageUploadActions.js +99 -0
  5. package/dist/actions/PhotoActions.js +53 -0
  6. package/dist/components/FileDeleteIcon.js +30 -0
  7. package/dist/components/FileDownloadIcon.js +34 -0
  8. package/dist/components/FileList.js +111 -0
  9. package/dist/components/Icons/ExcelFileTypeImage.js +8 -0
  10. package/dist/components/Icons/HTMLFileTypeImage.js +7 -0
  11. package/dist/components/Icons/JSONFileTypeImage.js +7 -0
  12. package/dist/components/Icons/PDFFileTypeImage.js +7 -0
  13. package/dist/components/Icons/PhotoFileTypeImage.js +6 -0
  14. package/dist/components/Icons/PowerPointTypeImage.js +7 -0
  15. package/dist/components/Icons/TextFileTypeImage.js +7 -0
  16. package/dist/components/Icons/UnknownFileTypeImage.js +7 -0
  17. package/dist/components/Icons/WordFileTypeImage.js +7 -0
  18. package/dist/components/Icons/ZipFileTypeImage.js +7 -0
  19. package/dist/components/ImageViewerDialog.js +78 -0
  20. package/dist/components/MimeTypeIcons.js +28 -0
  21. package/dist/components/PhotoGallery.js +130 -0
  22. package/dist/components/ResponsiveImageUploadList.js +57 -0
  23. package/dist/components/UploadImageDialog.js +85 -0
  24. package/dist/constants/MessageConstants.js +5 -0
  25. package/dist/constants/PhotosConstants.js +18 -0
  26. package/dist/css/attachments.css +143 -0
  27. package/dist/css/image-viewer.css +45 -0
  28. package/dist/img/PowerPoint-filetype.png +0 -0
  29. package/dist/img/blue-pattern-bg.jpg +0 -0
  30. package/dist/img/excel-filetype.png +0 -0
  31. package/dist/img/html-filetype.png +0 -0
  32. package/dist/img/json-filetype.png +0 -0
  33. package/dist/img/pdf-filetype.png +0 -0
  34. package/dist/img/photo-filetype.png +0 -0
  35. package/dist/img/txt-filetype.png +0 -0
  36. package/dist/img/unknown-filetype.png +0 -0
  37. package/dist/img/word-filetype.png +0 -0
  38. package/dist/img/zip-filetype.png +0 -0
  39. package/dist/index.js +19 -0
  40. package/dist/stores/DownloadStore.js +16 -0
  41. package/dist/stores/ImageUploadStore.js +24 -0
  42. package/dist/stores/PhotosStore.js +59 -0
  43. package/lib/actions/AttachmentActions.js +14 -0
  44. package/lib/actions/FileActions.js +34 -0
  45. package/lib/actions/ImageUploadActions.js +134 -0
  46. package/lib/actions/PhotoActions.js +65 -0
  47. package/lib/components/FileDeleteIcon.jsx +42 -0
  48. package/lib/components/FileDownloadIcon.jsx +42 -0
  49. package/lib/components/FileList.jsx +111 -0
  50. package/lib/components/Icons/ExcelFileTypeImage.jsx +6 -0
  51. package/lib/components/Icons/HTMLFileTypeImage.jsx +5 -0
  52. package/lib/components/Icons/JSONFileTypeImage.jsx +5 -0
  53. package/lib/components/Icons/PDFFileTypeImage.jsx +5 -0
  54. package/lib/components/Icons/PhotoFileTypeImage.jsx +5 -0
  55. package/lib/components/Icons/PowerPointTypeImage.jsx +5 -0
  56. package/lib/components/Icons/TextFileTypeImage.jsx +5 -0
  57. package/lib/components/Icons/UnknownFileTypeImage.jsx +5 -0
  58. package/lib/components/Icons/WordFileTypeImage.jsx +5 -0
  59. package/lib/components/Icons/ZipFileTypeImage.jsx +5 -0
  60. package/lib/components/ImageViewerDialog.jsx +72 -0
  61. package/lib/components/MimeTypeIcons.jsx +30 -0
  62. package/lib/components/PhotoGallery.jsx +160 -0
  63. package/lib/components/ResponsiveImageUploadList.jsx +61 -0
  64. package/lib/components/UploadImageDialog.jsx +93 -0
  65. package/lib/constants/MessageConstants.js +5 -0
  66. package/lib/constants/PhotosConstants.js +21 -0
  67. package/lib/css/attachments.css +143 -0
  68. package/lib/css/image-viewer.css +45 -0
  69. package/lib/img/PowerPoint-filetype.png +0 -0
  70. package/lib/img/blue-pattern-bg.jpg +0 -0
  71. package/lib/img/excel-filetype.png +0 -0
  72. package/lib/img/html-filetype.png +0 -0
  73. package/lib/img/json-filetype.png +0 -0
  74. package/lib/img/pdf-filetype.png +0 -0
  75. package/lib/img/photo-filetype.png +0 -0
  76. package/lib/img/txt-filetype.png +0 -0
  77. package/lib/img/unknown-filetype.png +0 -0
  78. package/lib/img/word-filetype.png +0 -0
  79. package/lib/img/zip-filetype.png +0 -0
  80. package/lib/index.js +19 -0
  81. package/lib/stores/DownloadStore.js +23 -0
  82. package/lib/stores/ImageUploadStore.js +31 -0
  83. package/lib/stores/PhotosStore.js +81 -0
  84. package/package.json +50 -0
package/README.md ADDED
File without changes
@@ -0,0 +1,11 @@
1
+ import { HIDE_IMAGE_VIEWER_DIALOG, SHOW_IMAGE_VIEWER_DIALOG } from "../constants/PhotosConstants";
2
+ import { dispatch } from "@selkirk-systems/state-management";
3
+ export const showImageViewerDialog = (name, url) => {
4
+ dispatch(SHOW_IMAGE_VIEWER_DIALOG, {
5
+ name: name,
6
+ url: url
7
+ });
8
+ };
9
+ export const hideImageViewerDialog = () => {
10
+ dispatch(HIDE_IMAGE_VIEWER_DIALOG);
11
+ };
@@ -0,0 +1,37 @@
1
+ import { FILE_DELETE, FILE_DELETED, FILE_DOWNLOAD, FILE_DOWNLOADED } from "../constants/PhotosConstants";
2
+ import DownloadStore from "../stores/DownloadStore";
3
+ import { fetch } from "@selkirk-systems/fetch";
4
+ import { dispatch } from "@selkirk-systems/state-management";
5
+ export const downloadFile = (url, mimeType, fileName) => {
6
+ const {
7
+ downloading
8
+ } = DownloadStore.getState();
9
+ if (downloading) return;
10
+ dispatch(FILE_DOWNLOAD, {
11
+ url: url,
12
+ mimeType: mimeType,
13
+ fileName: fileName
14
+ });
15
+ return fetch(url, {
16
+ contentType: mimeType,
17
+ downloadFileName: fileName
18
+ }).finally(() => {
19
+ dispatch(FILE_DOWNLOADED);
20
+ });
21
+ };
22
+ export const deleteFile = (url, fileName) => {
23
+ const {
24
+ deleting
25
+ } = DownloadStore.getState();
26
+ if (deleting) return;
27
+ dispatch(FILE_DELETE, {
28
+ fileName: fileName
29
+ });
30
+ return fetch(url, {
31
+ method: "DELETE"
32
+ }).finally(() => {
33
+ dispatch(FILE_DELETED, {
34
+ fileName: fileName
35
+ });
36
+ });
37
+ };
@@ -0,0 +1,99 @@
1
+ /* eslint-disable no-loop-func */
2
+ import { dispatch } from "@selkirk-systems/state-management";
3
+ import { CLEAR_UPLOADS, DELETED_IMAGE, DELETE_IMAGE, HIDE_IMAGE_UPLOAD_DIALOG, IMAGE_UPLOAD_COMPLETE, SET_UPLOAD_PROGRESS, SHOW_IMAGE_UPLOAD_DIALOG } from "../constants/PhotosConstants";
4
+ import { ADD_ERROR, fetch } from "@selkirk-systems/fetch";
5
+ import { createProxiedURL } from "@selkirk-systems/selkirk-utils";
6
+ import PhotoStore from "../stores/PhotosStore";
7
+ import { confirmDialog } from "primereact/confirmdialog";
8
+ import { extractDataArray } from "@selkirk-systems/selkirk-utils";
9
+ export const closeImageUploadDialog = () => {
10
+ dispatch(HIDE_IMAGE_UPLOAD_DIALOG);
11
+ dispatch(CLEAR_UPLOADS);
12
+ };
13
+ export const showImageUploadDialog = tag => {
14
+ dispatch(SHOW_IMAGE_UPLOAD_DIALOG, tag);
15
+ };
16
+ export const invokeUploadInput = () => {
17
+ const element = document.querySelector("input[type='file']");
18
+ if (!element) return;
19
+ element.click();
20
+ };
21
+ export const deleteImageById = id => {
22
+ dispatch(DELETE_IMAGE, id);
23
+ return fetch(`/image/${id}`, {
24
+ method: "DELETE"
25
+ }).then(response => {
26
+ dispatch(DELETED_IMAGE, id);
27
+ });
28
+ };
29
+ export const uploadFiles = (url, files) => {
30
+ return new Promise((resolve, reject) => {
31
+ const uploads = [];
32
+ const {
33
+ photos
34
+ } = PhotoStore.getState();
35
+ if (!url) return;
36
+ for (let file of files) {
37
+ const exists = photos.find(p => p.name === file.name);
38
+ if (exists) {
39
+ confirmDialog({
40
+ message: `${file.name} already exists. \n Do you want to replace it?`,
41
+ header: 'Confirm Upload',
42
+ position: 'center',
43
+ accept: () => {
44
+ uploadFinalFile(file);
45
+ }
46
+ });
47
+ } else {
48
+ uploadFinalFile(file);
49
+ }
50
+ }
51
+ function uploadFinalFile(file) {
52
+ const caption = file.name;
53
+ const formData = new FormData();
54
+ const finalURL = new URL(`${url}?force=true&name=${file.name}`);
55
+ formData.append("file", file, file.name);
56
+ const options = {
57
+ headers: {
58
+ accept: "*/*",
59
+ 'content-length': file.size
60
+ },
61
+ form: formData,
62
+ method: "POST"
63
+ };
64
+ dispatch(SET_UPLOAD_PROGRESS, {
65
+ id: caption,
66
+ title: caption,
67
+ mimeType: file.type,
68
+ progress: 10,
69
+ response: null
70
+ });
71
+ uploads.push(fetch(finalURL, options).then(([response]) => {
72
+ if (response.status.code > 299 || response.status.code < 200) {
73
+ throw response;
74
+ }
75
+ response.data = extractDataArray(response.data);
76
+ dispatch(SET_UPLOAD_PROGRESS, {
77
+ id: caption,
78
+ title: caption,
79
+ mimeType: file.type,
80
+ progress: 100,
81
+ response: response
82
+ });
83
+ }).catch(response => {
84
+ dispatch(SET_UPLOAD_PROGRESS, {
85
+ id: caption,
86
+ title: caption,
87
+ mimeType: file.type,
88
+ progress: 100,
89
+ error: response.data
90
+ });
91
+ return dispatch(ADD_ERROR, response);
92
+ }));
93
+ }
94
+ Promise.all(uploads).finally(() => {
95
+ dispatch(IMAGE_UPLOAD_COMPLETE);
96
+ resolve();
97
+ });
98
+ });
99
+ };
@@ -0,0 +1,53 @@
1
+ import { fetch } from "@selkirk-systems/fetch";
2
+ import { DELETED_IMAGE, DELETE_IMAGE, FETCHED_PHOTOS, FETCH_PHOTOS } from "../constants/PhotosConstants";
3
+ import { dispatch } from "@selkirk-systems/state-management";
4
+ import { hideImageViewerDialog } from "./AttachmentActions";
5
+ import { ADD_IGNORE_ERROR, REMOVE_IGNORE_ERROR_BY_ID } from "../constants/MessageConstants";
6
+ export const fetchPhotos = url => {
7
+ dispatch(FETCH_PHOTOS);
8
+
9
+ //Filestore requires both of these set to application/json to get json details
10
+ //Proxy web server defaults to accept:'*/*' which does not work so we have to override here.
11
+ const options = {
12
+ skipCache: true,
13
+ headers: {
14
+ 'Accept': "application/json",
15
+ 'content-type': 'application/json'
16
+ }
17
+ };
18
+ dispatch(ADD_IGNORE_ERROR, [{
19
+ id: url.toString(),
20
+ statusCodes: [404]
21
+ }]);
22
+ return fetch(url, options).then(([response]) => {
23
+ dispatch(REMOVE_IGNORE_ERROR_BY_ID, [{
24
+ id: url.toString()
25
+ }]);
26
+ if (response.status.code > 299 || response.status.code < 200) {
27
+ dispatch(FETCHED_PHOTOS, []);
28
+ return;
29
+ }
30
+ const onlyFiles = getAllFiles(response.data.children);
31
+ dispatch(FETCHED_PHOTOS, onlyFiles);
32
+ });
33
+ };
34
+ export const clearPhotos = () => {
35
+ dispatch(FETCHED_PHOTOS, []);
36
+ };
37
+ export const deleteImage = (url, name) => {
38
+ dispatch(DELETE_IMAGE, name);
39
+ return fetch(url, {
40
+ method: "DELETE"
41
+ }).then(response => {
42
+ dispatch(DELETED_IMAGE, name);
43
+ hideImageViewerDialog();
44
+ });
45
+ };
46
+ function getAllFiles(children) {
47
+ let ret = [];
48
+ children.forEach(c => {
49
+ if (c.nodeType === 'FILE') ret.push(c);
50
+ if (c.children && c.children.length) ret = ret.concat(getAllFiles(c.children));
51
+ });
52
+ return ret;
53
+ }
@@ -0,0 +1,30 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import * as React from 'react';
3
+ import { Connect } from '@selkirk-systems/state-management';
4
+ import { Trash2 } from 'lucide-react';
5
+ import { ProgressSpinner } from '@selkirk-systems/selkirk-components';
6
+ import { Button } from 'primereact/button';
7
+ import DownloadStore from '../stores/DownloadStore';
8
+ class FileDownloadIcon extends React.Component {
9
+ static subscribe = [DownloadStore];
10
+ static defaultProps = {
11
+ deleting: false,
12
+ name: ''
13
+ };
14
+ static storeStateToProps = {
15
+ deleting: (props, state) => state.deleting
16
+ };
17
+ render() {
18
+ const {
19
+ deleting,
20
+ name,
21
+ ...other
22
+ } = this.props;
23
+ const isDeleting = deleting && deleting.fileName === name;
24
+ return /*#__PURE__*/React.createElement(Button, _extends({
25
+ text: true,
26
+ type: "button"
27
+ }, other), isDeleting && /*#__PURE__*/React.createElement(ProgressSpinner, null), !isDeleting && /*#__PURE__*/React.createElement(Trash2, null));
28
+ }
29
+ }
30
+ export default Connect(FileDownloadIcon);
@@ -0,0 +1,34 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import * as React from 'react';
3
+ import { Connect } from '@selkirk-systems/state-management';
4
+ import { Download } from 'lucide-react';
5
+ import { ProgressSpinner } from '@selkirk-systems/selkirk-components';
6
+ import { Button } from 'primereact/button';
7
+ import DownloadStore from '../stores/DownloadStore';
8
+ class FileDownloadIcon extends React.Component {
9
+ static subscribe = [DownloadStore];
10
+ static defaultProps = {
11
+ downloading: false,
12
+ name: ''
13
+ };
14
+ static storeStateToProps = {
15
+ downloading: (props, state) => state.downloading
16
+ };
17
+ render() {
18
+ const {
19
+ downloading,
20
+ name,
21
+ ...other
22
+ } = this.props;
23
+ const isDownloading = downloading && downloading.fileName === name;
24
+ return /*#__PURE__*/React.createElement(Button, _extends({
25
+ text: true,
26
+ type: "button"
27
+ }, other), isDownloading && /*#__PURE__*/React.createElement(ProgressSpinner, {
28
+ style: {
29
+ color: 'inherit'
30
+ }
31
+ }), !isDownloading && /*#__PURE__*/React.createElement(Download, null));
32
+ }
33
+ }
34
+ export default Connect(FileDownloadIcon);
@@ -0,0 +1,111 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { Component } from "react";
3
+ import { Connect } from '@selkirk-systems/state-management';
4
+ import PhotoStore from "../stores/PhotosStore";
5
+ import { FileIcon, Trash2 } from "lucide-react";
6
+ import { Column, Row } from "@selkirk-systems/layout";
7
+ import { Skeleton } from "primereact/skeleton";
8
+ import memoizee from "memoizee";
9
+ import { fetchPhotos } from "../actions/PhotoActions";
10
+ import { Typography, Paper } from "@selkirk-systems/selkirk-components";
11
+ import UploadImageDialog from "./UploadImageDialog";
12
+ import { deleteFile, downloadFile } from "../actions/FileActions";
13
+ import { createProxiedURL } from "@selkirk-systems/selkirk-utils";
14
+ import FileDownloadIcon from "./FileDownloadIcon";
15
+ import UnknownFileTypeImage from "./Icons/UnknownFileTypeImage";
16
+ import MIME_TYPE_ICONS from "./MimeTypeIcons";
17
+ import { sortByProp } from "@selkirk-systems/selkirk-utils";
18
+ import { Button } from "primereact/button";
19
+ import FileDeleteIcon from "./FileDeleteIcon";
20
+ class PhotoGallery extends React.Component {
21
+ static subscribe = [PhotoStore];
22
+ static defaultProps = {
23
+ baseURL: "",
24
+ items: [],
25
+ fetching: false
26
+ };
27
+ static storeStateToProps = {
28
+ items: (props, state) => filesOnly(state.photos),
29
+ fetching: (props, state) => state.fetching
30
+ };
31
+ handleFileClick = file => e => {
32
+ e.stopPropagation();
33
+ downloadFile(createProxiedURL(file._links.self.href), file.mimeType, file.name);
34
+ };
35
+ handleFileDelete = file => e => {
36
+ e.stopPropagation();
37
+ const href = file.links ? file.links[0].href : file._links.self.href;
38
+ deleteFile(createProxiedURL(href), file.name);
39
+ };
40
+ render() {
41
+ const {
42
+ baseURL,
43
+ items,
44
+ fetching,
45
+ ...other
46
+ } = this.props;
47
+ const count = items.length;
48
+ return /*#__PURE__*/React.createElement("div", _extends({
49
+ className: "file-gallery paralax-content"
50
+ }, other), count < 1 && !fetching && /*#__PURE__*/React.createElement(Column, {
51
+ center: true,
52
+ className: "text-secondary"
53
+ }, /*#__PURE__*/React.createElement(FileIcon, {
54
+ mt: "-xxxl",
55
+ mb: "sm",
56
+ style: {
57
+ width: '75px',
58
+ height: '75px',
59
+ strokeWidth: 1
60
+ }
61
+ }), /*#__PURE__*/React.createElement(Typography, {
62
+ style: {
63
+ fontWeight: 500
64
+ },
65
+ variant: "subtitle2"
66
+ }, "NO FILES FOUND.")), fetching && /*#__PURE__*/React.createElement(Skeleton, {
67
+ width: "100%",
68
+ height: window.innerHeight - 300
69
+ }), count > 0 && /*#__PURE__*/React.createElement("div", {
70
+ p: "md",
71
+ style: {
72
+ flex: "1 1 auto"
73
+ }
74
+ }, items.map((f, i) => {
75
+ return /*#__PURE__*/React.createElement(Paper, _extends({
76
+ mb: "sm",
77
+ p: "sm",
78
+ key: f.id,
79
+ elevation: 1
80
+ }, other), /*#__PURE__*/React.createElement(Row, {
81
+ align: "center",
82
+ xs: "auto 1fr auto auto"
83
+ }, MIME_TYPE_ICONS[f.mimeType] || /*#__PURE__*/React.createElement(UnknownFileTypeImage, null), /*#__PURE__*/React.createElement(Column, {
84
+ gap: "xs",
85
+ ml: "sm"
86
+ }, /*#__PURE__*/React.createElement(Typography, {
87
+ variant: "body1"
88
+ }, f.name), /*#__PURE__*/React.createElement(Row, {
89
+ className: "text-secondary",
90
+ gap: "sm",
91
+ justify: "left"
92
+ }, /*#__PURE__*/React.createElement(Typography, {
93
+ variant: "caption"
94
+ }, "Size: "), /*#__PURE__*/React.createElement(Typography, {
95
+ variant: "caption"
96
+ }, f.sizeInKB < 1000 ? `${f.sizeInKB.toFixed(3)} KB` : `${(f.sizeInKB / 1000).toFixed(3)} MB`))), /*#__PURE__*/React.createElement(FileDownloadIcon, {
97
+ size: "small",
98
+ onClick: this.handleFileClick(f),
99
+ name: f.name
100
+ }), /*#__PURE__*/React.createElement(FileDeleteIcon, {
101
+ size: "small",
102
+ onClick: this.handleFileDelete(f),
103
+ name: f.name
104
+ })));
105
+ })));
106
+ }
107
+ }
108
+ const filesOnly = memoizee(files => {
109
+ return sortByProp(files.filter(f => f.mimeType.indexOf("image") < 0), "name").reverse();
110
+ });
111
+ export default Connect(PhotoGallery);
@@ -0,0 +1,8 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/excel-filetype.png';
3
+ import React from "react";
4
+ const ExcelFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
5
+ alt: "Excel",
6
+ src: SRC
7
+ }, props));
8
+ export default ExcelFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/html-filetype.png';
3
+ const HTMLFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "HTML",
5
+ src: SRC
6
+ }, props));
7
+ export default HTMLFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/json-filetype.png';
3
+ const JsonFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "JSON",
5
+ src: SRC
6
+ }, props));
7
+ export default JsonFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/pdf-filetype.png';
3
+ const PDFMimeTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "PDF",
5
+ src: SRC
6
+ }, props));
7
+ export default PDFMimeTypeImage;
@@ -0,0 +1,6 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/photo-filetype.png';
3
+ const PhotoFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ src: SRC
5
+ }, props));
6
+ export default PhotoFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/PowerPoint-filetype.png';
3
+ const PowerPointTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "Power Point",
5
+ src: SRC
6
+ }, props));
7
+ export default PowerPointTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/txt-filetype.png';
3
+ const TextFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "Text",
5
+ src: SRC
6
+ }, props));
7
+ export default TextFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/unknown-filetype.png';
3
+ const UnknownFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "Unknown",
5
+ src: SRC
6
+ }, props));
7
+ export default UnknownFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/word-filetype.png';
3
+ const WordFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "Word",
5
+ src: SRC
6
+ }, props));
7
+ export default WordFileTypeImage;
@@ -0,0 +1,7 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import SRC from '../../img/zip-filetype.png';
3
+ const ZipFileTypeImage = props => /*#__PURE__*/React.createElement("img", _extends({
4
+ alt: "Zip",
5
+ src: SRC
6
+ }, props));
7
+ export default ZipFileTypeImage;
@@ -0,0 +1,78 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import * as React from 'react';
3
+ import { deleteImage } from '../actions/PhotoActions';
4
+ import PhotosStore from '../stores/PhotosStore';
5
+ import { Connect } from '@selkirk-systems/state-management';
6
+ import { Dialog } from 'primereact/dialog';
7
+ import { Trash2, XIcon } from 'lucide-react';
8
+ import { Button } from 'primereact/button';
9
+ import { ProgressSpinner, Typography } from '@selkirk-systems/selkirk-components';
10
+ import '../css/image-viewer.css';
11
+ import { Row } from '@selkirk-systems/layout';
12
+ import { hideImageViewerDialog } from '../actions/AttachmentActions';
13
+ class ImageViewerDialog extends React.Component {
14
+ static subscribe = [PhotosStore];
15
+ static defaultProps = {
16
+ imageViewer: {},
17
+ deleting: false
18
+ };
19
+ static storeStateToProps = {
20
+ imageViewer: (props, state) => state.imageViewer,
21
+ deleting: (props, state) => state.deleting
22
+ };
23
+ render() {
24
+ const {
25
+ imageViewer,
26
+ deleting,
27
+ ...other
28
+ } = this.props;
29
+ return /*#__PURE__*/React.createElement(Dialog, _extends({
30
+ visible: imageViewer.name,
31
+ maximized: true,
32
+ onHide: hideImageViewerDialog,
33
+ transitionOptions: {
34
+ onExited: this.handledExited
35
+ }
36
+ }, other), /*#__PURE__*/React.createElement("div", {
37
+ className: "image-viewer"
38
+ }, /*#__PURE__*/React.createElement(Row, {
39
+ className: "top actions",
40
+ align: "center",
41
+ xs: "1fr auto",
42
+ gap: "md",
43
+ fill: false
44
+ }, /*#__PURE__*/React.createElement(Typography, {
45
+ ml: "sm",
46
+ className: "title",
47
+ variant: "body1"
48
+ }, imageViewer.name), /*#__PURE__*/React.createElement(Button, {
49
+ mr: "-sm",
50
+ type: "button",
51
+ style: {
52
+ color: 'inherit'
53
+ },
54
+ onClick: hideImageViewerDialog,
55
+ text: true
56
+ }, /*#__PURE__*/React.createElement(XIcon, null))), /*#__PURE__*/React.createElement(Row, {
57
+ className: "bottom actions",
58
+ center: true,
59
+ fill: false
60
+ }, /*#__PURE__*/React.createElement(Button, {
61
+ disabled: deleting,
62
+ type: "button",
63
+ onClick: () => deleteImage(imageViewer.url, imageViewer.name),
64
+ text: true,
65
+ className: "delete icon"
66
+ }, deleting ? /*#__PURE__*/React.createElement(ProgressSpinner, {
67
+ style: {
68
+ width: 18,
69
+ height: 18,
70
+ color: 'white'
71
+ }
72
+ }) : /*#__PURE__*/React.createElement(Trash2, null))), /*#__PURE__*/React.createElement("img", {
73
+ alt: "test",
74
+ src: imageViewer.url
75
+ })));
76
+ }
77
+ }
78
+ export default Connect(ImageViewerDialog);
@@ -0,0 +1,28 @@
1
+ import PDFFileTypeImage from "./Icons/PDFFileTypeImage";
2
+ import TextFileTypeImage from "./Icons/TextFileTypeImage";
3
+ import WordFileTypeImage from "./Icons/WordFileTypeImage";
4
+ import ExcelFileTypeImage from "./Icons/ExcelFileTypeImage";
5
+ import PowerPointTypeImage from "./Icons/PowerPointTypeImage";
6
+ import HTMLFileTypeImage from "./Icons/HTMLFileTypeImage";
7
+ import JsonFileTypeImage from "./Icons/JSONFileTypeImage";
8
+ import ZipFileTypeImage from "./Icons/ZipFileTypeImage";
9
+ import React from "react";
10
+ const MIME_TYPE_ICONS = {
11
+ 'application/pdf': /*#__PURE__*/React.createElement(PDFFileTypeImage, null),
12
+ 'application/msword': /*#__PURE__*/React.createElement(WordFileTypeImage, null),
13
+ 'application/vnd.ms-word': /*#__PURE__*/React.createElement(WordFileTypeImage, null),
14
+ 'application/vnd.oasis.opendocument.text': /*#__PURE__*/React.createElement(WordFileTypeImage, null),
15
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml': /*#__PURE__*/React.createElement(WordFileTypeImage, null),
16
+ 'application/vnd.ms-excel': /*#__PURE__*/React.createElement(ExcelFileTypeImage, null),
17
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml': /*#__PURE__*/React.createElement(ExcelFileTypeImage, null),
18
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': /*#__PURE__*/React.createElement(ExcelFileTypeImage, null),
19
+ 'application/vnd.oasis.opendocument.spreadsheet': /*#__PURE__*/React.createElement(ExcelFileTypeImage, null),
20
+ 'application/vnd.ms-powerpoint': /*#__PURE__*/React.createElement(PowerPointTypeImage, null),
21
+ 'application/vnd.openxmlformats-officedocument.presentationml': /*#__PURE__*/React.createElement(PowerPointTypeImage, null),
22
+ 'application/vnd.oasis.opendocument.presentation': /*#__PURE__*/React.createElement(PowerPointTypeImage, null),
23
+ 'text/plain': /*#__PURE__*/React.createElement(TextFileTypeImage, null),
24
+ 'text/html': /*#__PURE__*/React.createElement(HTMLFileTypeImage, null),
25
+ 'application/json': /*#__PURE__*/React.createElement(JsonFileTypeImage, null),
26
+ 'application/zip': /*#__PURE__*/React.createElement(ZipFileTypeImage, null)
27
+ };
28
+ export default MIME_TYPE_ICONS;