@iobroker/adapter-react-v5 4.10.1 → 4.10.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.
- package/Components/CustomModal.d.ts +24 -2
- package/Components/CustomModal.js +77 -145
- package/Components/FileBrowser.d.ts +68 -130
- package/Components/FileBrowser.js +1405 -1987
- package/Components/FileViewer.d.ts +9 -82
- package/Components/FileViewer.js +248 -321
- package/Components/IconSelector.d.ts +28 -22
- package/Components/IconSelector.js +2122 -2073
- package/Components/Loader.d.ts +8 -3
- package/Components/Loader.js +4 -2
- package/Components/Loaders/MV.d.ts +12 -0
- package/Components/Loaders/MV.js +51 -0
- package/Components/Loaders/PT.d.ts +19 -38
- package/Components/Loaders/PT.js +153 -78
- package/Components/Loaders/Vendor.d.ts +19 -31
- package/Components/Loaders/Vendor.js +61 -79
- package/Components/SelectWithIcon.d.ts +23 -20
- package/Components/SelectWithIcon.js +143 -204
- package/Components/types.d.ts +0 -47
- package/Dialogs/Error.d.ts +3 -5
- package/Dialogs/Error.js +1 -3
- package/Dialogs/SelectFile.d.ts +53 -170
- package/Dialogs/SelectFile.js +100 -257
- package/README.md +3 -0
- package/icons/IconClearFilter.js.map +1 -1
- package/icons/IconClosed.js.map +1 -1
- package/icons/IconCopy.js.map +1 -1
- package/icons/IconDocumentReadOnly.js.map +1 -1
- package/icons/IconExpert.d.ts +10 -36
- package/icons/IconExpert.js +8 -42
- package/index.d.ts +2 -0
- package/index.js +5 -2
- package/package.json +2 -2
- package/types.d.ts +9 -7
- package/Components/CustomModal.js.map +0 -1
- package/Components/FileBrowser.js.map +0 -1
- package/Components/FileViewer.js.map +0 -1
- package/Components/IconSelector.js.map +0 -1
- package/Components/Loaders/PT.js.map +0 -1
- package/Components/Loaders/Vendor.js.map +0 -1
- package/Components/SelectWithIcon.js.map +0 -1
- package/Dialogs/SelectFile.js.map +0 -1
- package/icons/IconExpert.js.map +0 -1
package/Components/FileViewer.js
CHANGED
|
@@ -1,350 +1,277 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
7
17
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _iconsMaterial = require("@mui/icons-material");
|
|
22
|
-
var _IconNoIcon = _interopRequireDefault(require("../icons/IconNoIcon"));
|
|
23
|
-
var _withWidth = _interopRequireDefault(require("./withWidth"));
|
|
24
|
-
var _Utils = _interopRequireDefault(require("./Utils"));
|
|
25
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
27
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
28
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // File viewer in adapter-react does not support write
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.EXTENSIONS = void 0;
|
|
30
|
+
// File viewer in adapter-react does not support write
|
|
29
31
|
// import { Buffer } from 'buffer';
|
|
32
|
+
const react_1 = __importStar(require("react"));
|
|
33
|
+
const styles_1 = require("@mui/styles");
|
|
34
|
+
const material_1 = require("@mui/material");
|
|
30
35
|
// Icons
|
|
36
|
+
const fa_1 = require("react-icons/fa");
|
|
37
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
38
|
+
const IconNoIcon_1 = __importDefault(require("../icons/IconNoIcon"));
|
|
39
|
+
const withWidth_1 = __importDefault(require("./withWidth"));
|
|
40
|
+
const Utils_1 = __importDefault(require("./Utils"));
|
|
31
41
|
// File viewer in adapter-react does not use ace editor
|
|
32
42
|
// import Editor from './Editor';
|
|
33
|
-
|
|
34
|
-
var styles = function styles() {
|
|
35
|
-
return {
|
|
43
|
+
const styles = {
|
|
36
44
|
dialog: {
|
|
37
|
-
|
|
45
|
+
height: '100%',
|
|
38
46
|
},
|
|
39
47
|
paper: {
|
|
40
|
-
|
|
48
|
+
height: 'calc(100% - 64px)',
|
|
41
49
|
},
|
|
42
50
|
content: {
|
|
43
|
-
|
|
51
|
+
textAlign: 'center',
|
|
44
52
|
},
|
|
45
53
|
textarea: {
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
width: '100%',
|
|
55
|
+
height: '100%',
|
|
48
56
|
},
|
|
49
57
|
img: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
width: 'auto',
|
|
59
|
+
height: 'calc(100% - 5px)',
|
|
60
|
+
objectFit: 'contain',
|
|
53
61
|
},
|
|
54
62
|
dialogTitle: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
};
|
|
63
|
+
justifyContent: 'space-between',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
},
|
|
59
66
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
exports.EXTENSIONS = {
|
|
68
|
+
images: ['png', 'jpg', 'svg', 'jpeg', 'bmp', 'gif', 'apng', 'avif', 'webp'],
|
|
69
|
+
code: ['js', 'json', 'json5', 'md'],
|
|
70
|
+
txt: ['log', 'txt', 'html', 'css', 'xml'],
|
|
71
|
+
audio: ['mp3', 'wav', 'ogg', 'acc'],
|
|
72
|
+
video: ['mp4', 'mov', 'avi'],
|
|
66
73
|
};
|
|
67
74
|
function bufferToBase64(buffer, isFull) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
let binary = '';
|
|
76
|
+
const bytes = new Uint8Array(buffer);
|
|
77
|
+
const len = bytes.byteLength;
|
|
78
|
+
for (let i = 0; i < len && (isFull || i < 50); i++) {
|
|
79
|
+
binary += String.fromCharCode(bytes[i]);
|
|
80
|
+
}
|
|
81
|
+
return window.btoa(binary);
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(0, _classCallCheck2["default"])(this, FileViewer);
|
|
96
|
-
_this = _callSuper(this, FileViewer, [props]);
|
|
97
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFileChanged", function (id, fileName, size) {
|
|
98
|
-
if (!_this.state.changed) {
|
|
99
|
-
_this.timeout && clearTimeout(_this.timeout);
|
|
100
|
-
_this.timeout = setTimeout(function () {
|
|
101
|
-
_this.timeout = null;
|
|
102
|
-
if (size === null) {
|
|
103
|
-
window.alert('Show file was deleted!');
|
|
104
|
-
} else if (_this.state.text !== null || _this.state.code !== null) {
|
|
105
|
-
_this.readFile();
|
|
106
|
-
} else {
|
|
107
|
-
_this.setState({
|
|
108
|
-
forceUpdate: Date.now()
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}, 300);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "writeFile64", function () {
|
|
115
|
-
/*
|
|
116
|
-
// File viewer in adapter-react does not support write
|
|
117
|
-
const parts = this.props.href.split('/');
|
|
118
|
-
const data = this.state.editingValue;
|
|
119
|
-
parts.splice(0, 2);
|
|
120
|
-
const adapter = parts[0];
|
|
121
|
-
const name = parts.splice(1).join('/');
|
|
122
|
-
this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))
|
|
123
|
-
.then(() => this.props.onClose())
|
|
124
|
-
.catch(e => window.alert(`Cannot write file: ${e}`));
|
|
125
|
-
*/
|
|
126
|
-
});
|
|
127
|
-
var ext = _Utils["default"].getFileExtension(_this.props.href);
|
|
128
|
-
_this.state = {
|
|
129
|
-
text: null,
|
|
130
|
-
code: null,
|
|
131
|
-
ext: ext,
|
|
132
|
-
// File viewer in adapter-react does not support write
|
|
133
|
-
editing: /* !!this.props.formatEditFile || */false,
|
|
134
|
-
editingValue: null,
|
|
135
|
-
copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),
|
|
136
|
-
forceUpdate: Date.now(),
|
|
137
|
-
changed: false,
|
|
138
|
-
imgError: false
|
|
139
|
-
};
|
|
140
|
-
return _this;
|
|
141
|
-
}
|
|
142
|
-
(0, _createClass2["default"])(FileViewer, [{
|
|
143
|
-
key: "readFile",
|
|
144
|
-
value: function readFile() {
|
|
145
|
-
var _this2 = this;
|
|
146
|
-
if (this.props.href) {
|
|
147
|
-
var parts = this.props.href.split('/');
|
|
148
|
-
parts.splice(0, 2);
|
|
149
|
-
var adapter = parts[0];
|
|
150
|
-
var name = parts.splice(1).join('/');
|
|
151
|
-
this.props.socket.readFile(adapter, name).then(function (data) {
|
|
152
|
-
if (data.file !== undefined) {
|
|
153
|
-
data = data.file;
|
|
154
|
-
}
|
|
155
|
-
var newState = {
|
|
156
|
-
copyPossible: _this2.state.copyPossible,
|
|
157
|
-
ext: _this2.state.ext
|
|
158
|
-
};
|
|
159
|
-
// try to detect valid extension
|
|
160
|
-
if (data.type === 'Buffer') {
|
|
161
|
-
if (name.toLowerCase().endsWith('.json5')) {
|
|
162
|
-
newState.ext = 'json5';
|
|
163
|
-
newState.copyPossible = true;
|
|
164
|
-
try {
|
|
165
|
-
data = atob(bufferToBase64(data.data, true));
|
|
166
|
-
} catch (e) {
|
|
167
|
-
console.error('Cannot convert base64 to string');
|
|
168
|
-
data = '';
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
var ext = _Utils["default"].detectMimeType(bufferToBase64(data.data));
|
|
172
|
-
if (ext) {
|
|
173
|
-
newState.ext = ext;
|
|
174
|
-
newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);
|
|
175
|
-
}
|
|
83
|
+
class FileViewer extends react_1.Component {
|
|
84
|
+
constructor(props) {
|
|
85
|
+
super(props);
|
|
86
|
+
this.timeout = null;
|
|
87
|
+
this.onFileChanged = (id, fileName, size) => {
|
|
88
|
+
if (!this.state.changed) {
|
|
89
|
+
this.timeout && clearTimeout(this.timeout);
|
|
90
|
+
this.timeout = setTimeout(() => {
|
|
91
|
+
this.timeout = null;
|
|
92
|
+
if (size === null) {
|
|
93
|
+
window.alert('Show file was deleted!');
|
|
94
|
+
}
|
|
95
|
+
else if (this.state.text !== null || this.state.code !== null) {
|
|
96
|
+
this.readFile();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.setState({ forceUpdate: Date.now() });
|
|
100
|
+
}
|
|
101
|
+
}, 300);
|
|
176
102
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
103
|
+
};
|
|
104
|
+
this.writeFile64 = () => {
|
|
105
|
+
/*
|
|
106
|
+
// File viewer in adapter-react does not support write
|
|
107
|
+
const parts = this.props.href.split('/');
|
|
108
|
+
const data = this.state.editingValue;
|
|
109
|
+
parts.splice(0, 2);
|
|
110
|
+
const adapter = parts[0];
|
|
111
|
+
const name = parts.splice(1).join('/');
|
|
112
|
+
this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))
|
|
113
|
+
.then(() => this.props.onClose())
|
|
114
|
+
.catch(e => window.alert(`Cannot write file: ${e}`));
|
|
115
|
+
*/
|
|
116
|
+
};
|
|
117
|
+
const ext = Utils_1.default.getFileExtension(props.href);
|
|
118
|
+
this.state = {
|
|
119
|
+
text: null,
|
|
120
|
+
code: null,
|
|
121
|
+
ext,
|
|
122
|
+
// File viewer in adapter-react does not support write
|
|
123
|
+
editing: /* !!this.props.formatEditFile || */ false,
|
|
124
|
+
editingValue: null,
|
|
125
|
+
copyPossible: !!ext && (exports.EXTENSIONS.code.includes(ext) || exports.EXTENSIONS.txt.includes(ext)),
|
|
126
|
+
forceUpdate: Date.now(),
|
|
127
|
+
changed: false,
|
|
128
|
+
imgError: false,
|
|
129
|
+
};
|
|
192
130
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
131
|
+
readFile() {
|
|
132
|
+
if (this.props.href) {
|
|
133
|
+
const parts = this.props.href.split('/');
|
|
134
|
+
parts.splice(0, 2);
|
|
135
|
+
const adapter = parts[0];
|
|
136
|
+
const name = parts.splice(1).join('/');
|
|
137
|
+
this.props.socket.readFile(adapter, name)
|
|
138
|
+
.then((data) => {
|
|
139
|
+
let fileData = '';
|
|
140
|
+
if (data.file !== undefined) {
|
|
141
|
+
fileData = data.file;
|
|
142
|
+
}
|
|
143
|
+
const newState = { copyPossible: this.state.copyPossible, ext: this.state.ext };
|
|
144
|
+
// try to detect valid extension
|
|
145
|
+
if (data.type === 'Buffer') {
|
|
146
|
+
if (name.toLowerCase().endsWith('.json5')) {
|
|
147
|
+
newState.ext = 'json5';
|
|
148
|
+
newState.copyPossible = true;
|
|
149
|
+
try {
|
|
150
|
+
fileData = atob(bufferToBase64(data.data, true));
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
console.error('Cannot convert base64 to string');
|
|
154
|
+
fileData = '';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const ext = Utils_1.default.detectMimeType(bufferToBase64(data.data));
|
|
159
|
+
if (ext) {
|
|
160
|
+
newState.ext = ext;
|
|
161
|
+
newState.copyPossible = exports.EXTENSIONS.code.includes(ext) || exports.EXTENSIONS.txt.includes(ext);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (newState.copyPossible) {
|
|
166
|
+
if (newState.ext && exports.EXTENSIONS.txt.includes(newState.ext)) {
|
|
167
|
+
newState.text = fileData;
|
|
168
|
+
newState.editingValue = fileData;
|
|
169
|
+
}
|
|
170
|
+
else if (newState.ext && exports.EXTENSIONS.code.includes(newState.ext)) {
|
|
171
|
+
newState.code = fileData;
|
|
172
|
+
newState.editingValue = fileData;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// @ts-expect-error I don't know how to fix it
|
|
176
|
+
this.setState(newState);
|
|
177
|
+
})
|
|
178
|
+
.catch(e => window.alert(`Cannot read file: ${e}`));
|
|
179
|
+
}
|
|
202
180
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
181
|
+
componentDidMount() {
|
|
182
|
+
this.readFile();
|
|
183
|
+
const parts = this.props.href.split('/');
|
|
184
|
+
parts.splice(0, 2);
|
|
185
|
+
const adapter = parts[0];
|
|
186
|
+
const name = parts.splice(1).join('/');
|
|
187
|
+
this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
|
|
188
|
+
}
|
|
189
|
+
componentWillUnmount() {
|
|
190
|
+
this.timeout && clearTimeout(this.timeout);
|
|
191
|
+
const parts = this.props.href.split('/');
|
|
192
|
+
parts.splice(0, 2);
|
|
193
|
+
const adapter = parts[0];
|
|
194
|
+
const name = parts.splice(1).join('/');
|
|
195
|
+
this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
|
|
212
196
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
static getEditFile(ext) {
|
|
198
|
+
switch (ext) {
|
|
199
|
+
case 'json':
|
|
200
|
+
return 'json';
|
|
201
|
+
case 'json5':
|
|
202
|
+
return 'json5';
|
|
203
|
+
case 'js':
|
|
204
|
+
return 'javascript';
|
|
205
|
+
case 'html':
|
|
206
|
+
return 'html';
|
|
207
|
+
case 'txt':
|
|
208
|
+
return 'html';
|
|
209
|
+
default:
|
|
210
|
+
return 'json';
|
|
222
211
|
}
|
|
223
|
-
return /*#__PURE__*/_react["default"].createElement("img", {
|
|
224
|
-
onError: function onError(e) {
|
|
225
|
-
e.target.onerror = null;
|
|
226
|
-
_this3.setState({
|
|
227
|
-
imgError: true
|
|
228
|
-
});
|
|
229
|
-
},
|
|
230
|
-
className: _Utils["default"].clsx(this.props.classes.img, this.props.getClassBackgroundImage()),
|
|
231
|
-
src: "".concat(this.props.href, "?ts=").concat(this.state.forceUpdate),
|
|
232
|
-
alt: this.props.href
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
if (this.state.code !== null || this.state.text !== null || this.state.editing) {
|
|
236
|
-
// File viewer in adapter-react does not support write
|
|
237
|
-
// return <AceEditor
|
|
238
|
-
// mode={FileViewer.getEditFile(this.props.formatEditFile)}
|
|
239
|
-
// width="100%"
|
|
240
|
-
// height="100%"
|
|
241
|
-
// theme={this.props.themeName === 'dark' ? 'clouds_midnight' : 'chrome'}
|
|
242
|
-
// value={this.state.editingValue || this.state.code || this.state.text}
|
|
243
|
-
// onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
|
|
244
|
-
// name="UNIQUE_ID_OF_DIV"
|
|
245
|
-
// readOnly={!this.state.editing}
|
|
246
|
-
// fontSize={14}
|
|
247
|
-
// setOptions={{
|
|
248
|
-
// enableBasicAutocompletion: true,
|
|
249
|
-
// enableLiveAutocompletion: true,
|
|
250
|
-
// enableSnippets: true,
|
|
251
|
-
// }}
|
|
252
|
-
// editorProps={{ $blockScrolling: true }}
|
|
253
|
-
// />;
|
|
254
|
-
return /*#__PURE__*/_react["default"].createElement(_material.TextField, {
|
|
255
|
-
variant: "standard",
|
|
256
|
-
className: this.props.classes.textarea,
|
|
257
|
-
multiline: true,
|
|
258
|
-
inputProps: {
|
|
259
|
-
readOnly: !this.state.editing
|
|
260
|
-
},
|
|
261
|
-
value: this.state.editingValue || this.state.code || this.state.text
|
|
262
|
-
// onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
|
|
263
|
-
,
|
|
264
|
-
InputProps: {
|
|
265
|
-
readOnly: !this.state.editing
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return null;
|
|
270
212
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text,
|
|
307
|
-
variant: "contained",
|
|
308
|
-
onClick: this.writeFile64,
|
|
309
|
-
startIcon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Save, null)
|
|
310
|
-
}, this.props.t('Save')) : null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
|
|
311
|
-
variant: "contained",
|
|
312
|
-
onClick: function onClick() {
|
|
313
|
-
return _this4.props.onClose();
|
|
314
|
-
},
|
|
315
|
-
color: "primary",
|
|
316
|
-
startIcon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Close, null)
|
|
317
|
-
}, this.props.t('Close'))));
|
|
213
|
+
getContent() {
|
|
214
|
+
if (this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext)) {
|
|
215
|
+
if (this.state.imgError) {
|
|
216
|
+
return react_1.default.createElement(IconNoIcon_1.default, { className: Utils_1.default.clsx(this.props.classes.img, this.props.getClassBackgroundImage()) });
|
|
217
|
+
}
|
|
218
|
+
return react_1.default.createElement("img", { onError: e => {
|
|
219
|
+
// @ts-ignore-error to check
|
|
220
|
+
e.target.onerror = null;
|
|
221
|
+
this.setState({ imgError: true });
|
|
222
|
+
}, className: Utils_1.default.clsx(this.props.classes.img, this.props.getClassBackgroundImage()), src: `${this.props.href}?ts=${this.state.forceUpdate}`, alt: this.props.href });
|
|
223
|
+
}
|
|
224
|
+
if (this.state.code !== null || this.state.text !== null || this.state.editing) {
|
|
225
|
+
// File viewer in adapter-react does not support write
|
|
226
|
+
// return <AceEditor
|
|
227
|
+
// mode={FileViewer.getEditFile(this.props.formatEditFile)}
|
|
228
|
+
// width="100%"
|
|
229
|
+
// height="100%"
|
|
230
|
+
// theme={this.props.themeName === 'dark' ? 'clouds_midnight' : 'chrome'}
|
|
231
|
+
// value={this.state.editingValue || this.state.code || this.state.text}
|
|
232
|
+
// onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
|
|
233
|
+
// name="UNIQUE_ID_OF_DIV"
|
|
234
|
+
// readOnly={!this.state.editing}
|
|
235
|
+
// fontSize={14}
|
|
236
|
+
// setOptions={{
|
|
237
|
+
// enableBasicAutocompletion: true,
|
|
238
|
+
// enableLiveAutocompletion: true,
|
|
239
|
+
// enableSnippets: true,
|
|
240
|
+
// }}
|
|
241
|
+
// editorProps={{ $blockScrolling: true }}
|
|
242
|
+
// />;
|
|
243
|
+
return react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.textarea, multiline: true, inputProps: { readOnly: !this.state.editing }, value: this.state.editingValue || this.state.code || this.state.text,
|
|
244
|
+
// onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
|
|
245
|
+
InputProps: { readOnly: !this.state.editing } });
|
|
246
|
+
}
|
|
247
|
+
return null;
|
|
318
248
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
249
|
+
render() {
|
|
250
|
+
return react_1.default.createElement(material_1.Dialog, { classes: { scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }, scroll: "paper", open: !!this.props.href, onClose: () => this.props.onClose(), fullWidth: true, maxWidth: "xl", "aria-labelledby": "ar_dialog_file_view_title" },
|
|
251
|
+
react_1.default.createElement("div", { className: this.props.classes.dialogTitle },
|
|
252
|
+
react_1.default.createElement(material_1.DialogTitle, { id: "ar_dialog_file_view_title" }, `${this.props.t(this.state.editing ? 'Edit' : 'View')}: ${this.props.href}`),
|
|
253
|
+
this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext) && react_1.default.createElement("div", null,
|
|
254
|
+
react_1.default.createElement(material_1.IconButton, { size: "large", color: "inherit", onClick: this.props.setStateBackgroundImage },
|
|
255
|
+
react_1.default.createElement(icons_material_1.Brightness6, null)))),
|
|
256
|
+
react_1.default.createElement(material_1.DialogContent, { className: this.props.classes.content }, this.getContent()),
|
|
257
|
+
react_1.default.createElement(material_1.DialogActions, null,
|
|
258
|
+
this.state.copyPossible ?
|
|
259
|
+
react_1.default.createElement(material_1.Button
|
|
260
|
+
// @ts-expect-error grey is valid color
|
|
261
|
+
, {
|
|
262
|
+
// @ts-expect-error grey is valid color
|
|
263
|
+
color: "grey", onClick: e => {
|
|
264
|
+
e.stopPropagation();
|
|
265
|
+
e.preventDefault();
|
|
266
|
+
Utils_1.default.copyToClipboard(this.state.text || this.state.code || '');
|
|
267
|
+
}, startIcon: react_1.default.createElement(fa_1.FaCopy, null) }, this.props.t('Copy content')) : null,
|
|
268
|
+
this.state.editing ?
|
|
269
|
+
react_1.default.createElement(material_1.Button
|
|
270
|
+
// @ts-expect-error grey is valid color
|
|
271
|
+
, {
|
|
272
|
+
// @ts-expect-error grey is valid color
|
|
273
|
+
color: "grey", disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text, variant: "contained", onClick: this.writeFile64, startIcon: react_1.default.createElement(icons_material_1.Save, null) }, this.props.t('Save')) : null,
|
|
274
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.props.onClose(), color: "primary", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('Close'))));
|
|
336
275
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}(_react.Component);
|
|
340
|
-
FileViewer.propTypes = {
|
|
341
|
-
t: _propTypes["default"].func,
|
|
342
|
-
onClose: _propTypes["default"].func,
|
|
343
|
-
href: _propTypes["default"].string.isRequired,
|
|
344
|
-
supportSubscribes: _propTypes["default"].bool
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
/** @type {typeof FileViewer} */
|
|
348
|
-
var _export = (0, _withWidth["default"])()((0, _styles.withStyles)(styles)(FileViewer));
|
|
349
|
-
var _default = exports["default"] = _export;
|
|
350
|
-
//# sourceMappingURL=FileViewer.js.map
|
|
276
|
+
}
|
|
277
|
+
exports.default = (0, withWidth_1.default)()((0, styles_1.withStyles)(styles)(FileViewer));
|