1 | "use strict";
|
2 |
|
3 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports["default"] = void 0;
|
9 |
|
10 | var _react = _interopRequireWildcard(require("react"));
|
11 |
|
12 | var _reactIntl = require("react-intl");
|
13 |
|
14 | var _axios = _interopRequireDefault(require("./axios"));
|
15 |
|
16 | var _YetkiKontrol = require("./YetkiKontrol");
|
17 |
|
18 | var _Dropzone = _interopRequireDefault(require("./Dropzone"));
|
19 |
|
20 | var _reactToastify = require("react-toastify");
|
21 |
|
22 | require("react-toastify/dist/ReactToastify.css");
|
23 |
|
24 | var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
25 |
|
26 | var _core = require("@material-ui/core");
|
27 |
|
28 | var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
29 |
|
30 | var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
|
31 |
|
32 | var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));
|
33 |
|
34 | var _DialogContent = _interopRequireDefault(require("@material-ui/core/DialogContent"));
|
35 |
|
36 | var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle"));
|
37 |
|
38 | var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
39 |
|
40 | var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
|
41 |
|
42 | var _CheckCircle = _interopRequireDefault(require("@material-ui/icons/CheckCircle"));
|
43 |
|
44 | var _Error = _interopRequireDefault(require("@material-ui/icons/Error"));
|
45 |
|
46 | var _Cancel = _interopRequireDefault(require("@material-ui/icons/Cancel"));
|
47 |
|
48 | var _Replay = _interopRequireDefault(require("@material-ui/icons/Replay"));
|
49 |
|
50 | var _Publish = _interopRequireDefault(require("@material-ui/icons/Publish"));
|
51 |
|
52 | var _FolderOpenOutlined = _interopRequireDefault(require("@material-ui/icons/FolderOpenOutlined"));
|
53 |
|
54 | var _inlineScan = _interopRequireDefault(require("inline-scan"));
|
55 |
|
56 | var _muiDatatables = _interopRequireDefault(require("mui-datatables"));
|
57 |
|
58 | var _Language = require("./Language");
|
59 |
|
60 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
61 |
|
62 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
63 |
|
64 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
65 |
|
66 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
67 |
|
68 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
69 |
|
70 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
71 |
|
72 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
73 |
|
74 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
75 |
|
76 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
77 |
|
78 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
79 |
|
80 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
81 |
|
82 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
83 |
|
84 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
85 |
|
86 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
87 |
|
88 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
89 |
|
90 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
91 |
|
92 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
93 |
|
94 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
95 |
|
96 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
97 |
|
98 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
99 |
|
100 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
101 |
|
102 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
103 |
|
104 | var CustomizedFileUpload = function (_React$Component) {
|
105 | _inherits(CustomizedFileUpload, _React$Component);
|
106 |
|
107 | var _super = _createSuper(CustomizedFileUpload);
|
108 |
|
109 | function CustomizedFileUpload(props) {
|
110 | var _this;
|
111 |
|
112 | _classCallCheck(this, CustomizedFileUpload);
|
113 |
|
114 | _this = _super.call(this, props);
|
115 |
|
116 | _defineProperty(_assertThisInitialized(_this), "addProperty", function (fieldName, fieldValue) {
|
117 | return {
|
118 | fieldName: fieldName,
|
119 | fieldValue: fieldValue.toString()
|
120 | };
|
121 | });
|
122 |
|
123 | _defineProperty(_assertThisInitialized(_this), "getFilesFromServer", function () {
|
124 | var fillState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
125 | var getUrl = "";
|
126 |
|
127 | if (_this.kvkkGoruntulemeYetkili) {
|
128 | getUrl = process.env.REACT_APP_FILE_SERVICE_HOST + "/api/v1/filehandler/";
|
129 | } else {
|
130 | getUrl = process.env.REACT_APP_FILE_SERVICE_HOST + "/api/v1/filehandler/GetModelListRestricted/";
|
131 | }
|
132 |
|
133 | _axios["default"].get(getUrl + _this.props.fieldName + "/" + _this.props.fieldValue).then(function (res) {
|
134 | var files = [];
|
135 | var copy = {};
|
136 | res.data.forEach(function (item) {
|
137 | files.push({
|
138 | data: {
|
139 | data: null,
|
140 | name: item.fileName,
|
141 | id: item.fileId,
|
142 | documentType: item.documentType,
|
143 | documentPath: item.path !== undefined && typeof item.path !== "undefined" && item.path !== null && item.path !== "" ? "/download" + item.path : ""
|
144 | },
|
145 | status: "loaded"
|
146 | });
|
147 | copy[item.fileName] = {
|
148 | state: "done",
|
149 | percentage: 100
|
150 | };
|
151 | });
|
152 |
|
153 | if (fillState) {
|
154 | _this.setState({
|
155 | files: files
|
156 | });
|
157 | }
|
158 |
|
159 | return files;
|
160 | });
|
161 | });
|
162 |
|
163 | _defineProperty(_assertThisInitialized(_this), "onFilesAdded", function (files) {
|
164 | var newFiles = [];
|
165 | files.forEach(function (file) {
|
166 | var filename = file.data.name;
|
167 | var notAllowed = ".exe";
|
168 |
|
169 | if (filename.toLowerCase().includes(notAllowed.toLowerCase())) {
|
170 | _reactToastify.toast.error(_this.strings["INSERT_FAILED_NOT_ALLOWED"]);
|
171 |
|
172 | return;
|
173 | }
|
174 |
|
175 | if (_this.state.files.find(function (x) {
|
176 | return x.data.name == filename;
|
177 | }) === undefined) {
|
178 | newFiles.push({
|
179 | data: {
|
180 | data: file.data,
|
181 | name: filename,
|
182 | id: 0,
|
183 | documentType: typeof file.data.documentType === "undefined" ? _this.state.documentTypes[0]["type"] : file.data.documentType
|
184 | },
|
185 | status: "unLoaded"
|
186 | });
|
187 | } else {
|
188 | _reactToastify.toast.error(_this.strings["INSERT_FAILED_FILENAME_MATCHED"]);
|
189 | }
|
190 | });
|
191 |
|
192 | _this.setState(function (prevState) {
|
193 | return {
|
194 | files: prevState.files.concat(newFiles)
|
195 | };
|
196 | });
|
197 | });
|
198 |
|
199 | _defineProperty(_assertThisInitialized(_this), "sendRequest", function (file) {
|
200 | var formData = new FormData();
|
201 | formData.append("file", file.data.data, file.data.name);
|
202 | formData.append("fileinfo", JSON.stringify(_this.props.fileInfo));
|
203 | formData.append("username", localStorage.getItem("user_name"));
|
204 | formData.append("userid", localStorage.getItem("user_id"));
|
205 | formData.append("documenttype", file.data.documentType);
|
206 |
|
207 | _axios["default"].post(process.env.REACT_APP_FILE_SERVICE_HOST + "/dosyaerisim/upload", formData).then(function (res) {
|
208 | var index = _this.state.files.findIndex(function (f) {
|
209 | return f.data.name == file.data.name;
|
210 | });
|
211 |
|
212 | console.log(newFiles);
|
213 |
|
214 | var newFiles = _toConsumableArray(_this.state.files);
|
215 |
|
216 | newFiles[index].status = "loaded";
|
217 | newFiles[index].data.id = res.data.fileId;
|
218 |
|
219 | _this.setState({
|
220 | files: newFiles
|
221 | });
|
222 | })["catch"](function (err) {
|
223 | var index = _this.state.files.findIndex(function (f) {
|
224 | return f.data.name == file.data.name;
|
225 | });
|
226 |
|
227 | var newFiles = _toConsumableArray(_this.state.files);
|
228 |
|
229 | newFiles[index].status = "error";
|
230 | newFiles[index].data.documentType = file.data.documentType;
|
231 |
|
232 | _this.setState({
|
233 | files: newFiles
|
234 | });
|
235 |
|
236 | _reactToastify.toast.error(_this.strings["INSERT_FAILED"]);
|
237 | });
|
238 |
|
239 | return {
|
240 | success: true
|
241 | };
|
242 | });
|
243 |
|
244 | _defineProperty(_assertThisInitialized(_this), "sendDeleteRequest", function (file) {
|
245 | if (_this.docSilmeYetkili) {
|
246 | _axios["default"].post("/dosyaerisim/delete_by?uid=" + file.id).then(function () {
|
247 | _this.getFilesFromServer();
|
248 | })["catch"](function () {
|
249 | _reactToastify.toast.error(_this.strings["RECORD_NOT_FOUND"]);
|
250 | });
|
251 | }
|
252 | });
|
253 |
|
254 | _defineProperty(_assertThisInitialized(_this), "onDeleteButtonClick", function (file) {
|
255 | _this.sendDeleteRequest(file.data);
|
256 | });
|
257 |
|
258 | _defineProperty(_assertThisInitialized(_this), "onCancelButtonClick", function (file) {
|
259 | var index = _this.state.files.findIndex(function (f) {
|
260 | return f.data.name == file.data.name;
|
261 | });
|
262 |
|
263 | var newFiles = _toConsumableArray(_this.state.files);
|
264 |
|
265 | newFiles.splice(index, 1);
|
266 | delete newFiles[file.name];
|
267 |
|
268 | _this.setState({
|
269 | files: newFiles
|
270 | });
|
271 | });
|
272 |
|
273 | _defineProperty(_assertThisInitialized(_this), "handleSelectChange", function (event, file) {
|
274 | var index = _this.state.files.findIndex(function (f) {
|
275 | return f.data.name == file.data.name;
|
276 | });
|
277 |
|
278 | var newFiles = _toConsumableArray(_this.state.files);
|
279 |
|
280 | newFiles[index].data.documentType = event.target.value;
|
281 |
|
282 | _this.setState({
|
283 | files: newFiles
|
284 | });
|
285 | });
|
286 |
|
287 | _defineProperty(_assertThisInitialized(_this), "renderFileRowFileName", function (fileName, documentPath) {
|
288 | var html = "";
|
289 |
|
290 | if (documentPath === undefined || documentPath === null || typeof documentPath === "undefined" || documentPath === "") {
|
291 | html = _react["default"].createElement(_core.Tooltip, {
|
292 | title: _this.strings["DOWNLOAD_YOK"]
|
293 | }, _react["default"].createElement(_Button["default"], {
|
294 | variant: "link",
|
295 | className: "text-left",
|
296 | style: {
|
297 | color: "black"
|
298 | },
|
299 | disabled: true
|
300 | }, fileName));
|
301 | } else {
|
302 | html = _react["default"].createElement(_Button["default"], {
|
303 | variant: "link",
|
304 | className: "text-left",
|
305 | onClick: function onClick() {
|
306 | return _this.getFile(documentPath, fileName);
|
307 | }
|
308 | }, fileName);
|
309 | }
|
310 |
|
311 | return html;
|
312 | });
|
313 |
|
314 | _defineProperty(_assertThisInitialized(_this), "renderFileRowFileActions", function (file) {
|
315 | return _react["default"].createElement("div", null, file && file.status === "unLoaded" && !_this.unwritable && _react["default"].createElement(_react.Fragment, null, _react["default"].createElement(_core.Tooltip, {
|
316 | title: _this.strings["YUKLE"]
|
317 | }, _react["default"].createElement(_IconButton["default"], {
|
318 | "aria-label": "Upload",
|
319 | onClick: function onClick() {
|
320 | return _this.sendRequest(file);
|
321 | }
|
322 | }, _react["default"].createElement(_Publish["default"], null))), _react["default"].createElement(_core.Tooltip, {
|
323 | title: _this.strings["KALDIR"]
|
324 | }, _react["default"].createElement(_IconButton["default"], {
|
325 | "aria-label": "Cancel",
|
326 | onClick: function onClick() {
|
327 | return _this.onCancelButtonClick(file);
|
328 | }
|
329 | }, _react["default"].createElement(_Cancel["default"], null)))), file && file.status === "loaded" && _react["default"].createElement(_CheckCircle["default"], null), file && file.status == "loaded" && !_this.unwritable && _this.docSilmeYetkili && _react["default"].createElement(_core.Tooltip, {
|
330 | title: _this.strings["SIL"]
|
331 | }, _react["default"].createElement(_IconButton["default"], {
|
332 | "aria-label": "Delete",
|
333 | onClick: function onClick() {
|
334 | return _this.onDeleteButtonClick(file);
|
335 | }
|
336 | }, _react["default"].createElement(_Delete["default"], null))), file && file.status === "error" && !_this.unwritable && _react["default"].createElement(_core.Tooltip, {
|
337 | title: _this.strings["TEKRAR_GONDER"]
|
338 | }, _react["default"].createElement(_IconButton["default"], {
|
339 | "aria-label": "ReSend",
|
340 | onClick: function onClick() {
|
341 | return _this.sendRequest(file);
|
342 | }
|
343 | }, _react["default"].createElement(_Replay["default"], null))), file && file.status === "error" && _react["default"].createElement(_Error["default"], null), file && file.status == "error" && !_this.unwritable && _react["default"].createElement(_core.Tooltip, {
|
344 | title: _this.strings["KALDIR"]
|
345 | }, _react["default"].createElement(_IconButton["default"], {
|
346 | "aria-label": "Cancel",
|
347 | onClick: function onClick() {
|
348 | return _this.onCancelButtonClick(file);
|
349 | }
|
350 | }, _react["default"].createElement(_Cancel["default"], null))));
|
351 | });
|
352 |
|
353 | _defineProperty(_assertThisInitialized(_this), "renderFileRowFileType", function (file) {
|
354 | var textFieldStyle = {
|
355 | width: 200,
|
356 | marginTop: "1%"
|
357 | };
|
358 | var val = file.data.documentType;
|
359 |
|
360 | if (typeof file.data.documentType === "undefined") {
|
361 | val = _this.state.documentTypes[0]["type"];
|
362 | }
|
363 |
|
364 | return _react["default"].createElement("div", null, _react["default"].createElement(_core.TextField, {
|
365 | select: file && file.status === "unLoaded",
|
366 | size: "small",
|
367 | margin: "normal",
|
368 | name: "documentType",
|
369 | value: val,
|
370 | onChange: function onChange(event) {
|
371 | return _this.handleSelectChange(event, file);
|
372 | },
|
373 | style: textFieldStyle,
|
374 | InputProps: {
|
375 | readOnly: file.status === "loaded"
|
376 | }
|
377 | }, _this.state.documentTypes.length > 0 ? _this.state.documentTypes.map(function (fileType) {
|
378 | return _react["default"].createElement(_core.MenuItem, {
|
379 | value: fileType["type"]
|
380 | }, fileType["type"]);
|
381 | }) : _react["default"].createElement(_core.MenuItem, {
|
382 | val: 0
|
383 | }, _this.strings["HATA"])));
|
384 | });
|
385 |
|
386 | _defineProperty(_assertThisInitialized(_this), "getFile", function (documentPath, fileName) {
|
387 | (0, _axios["default"])({
|
388 | url: process.env.REACT_APP_FILE_SERVICE_HOST + "/dosyaerisim" + documentPath,
|
389 | method: "GET",
|
390 | responseType: "blob"
|
391 |
|
392 | }).then(function (response) {
|
393 | console.log(response);
|
394 | console.log(response.data);
|
395 | console.log(new Blob([response.data]));
|
396 | var url = window.URL.createObjectURL(new Blob([response.data]));
|
397 | var link = document.createElement("a");
|
398 | link.href = url;
|
399 | link.setAttribute("download", fileName);
|
400 | document.body.appendChild(link);
|
401 | link.click();
|
402 | })["catch"](function (er) {
|
403 | _this.strings["RECORD_NOT_FOUND"];
|
404 | });
|
405 | });
|
406 |
|
407 | _defineProperty(_assertThisInitialized(_this), "handleDialogClose", function () {
|
408 |
|
409 | var existUnloadedFile = false;
|
410 |
|
411 | _this.state.files.forEach(function (f) {
|
412 | if (f.status === "unLoaded" || f.status === "error") {
|
413 | existUnloadedFile = true;
|
414 | }
|
415 | });
|
416 |
|
417 | if (existUnloadedFile) {
|
418 | _reactToastify.toast.error(_this.strings["UNLOADED_FILE_EXIST"]);
|
419 | } else {
|
420 | _this.setState({
|
421 | popoverWillOpen: false
|
422 | });
|
423 | }
|
424 | });
|
425 |
|
426 | _defineProperty(_assertThisInitialized(_this), "handleDialogClickOpen", function () {
|
427 | if (_this.state.documentTypes.length < 1) {
|
428 | _reactToastify.toast.error(_this.strings["DOCTYPES_SERVICE_ERROR"]);
|
429 | } else {
|
430 | _this.setState({
|
431 | popoverWillOpen: true
|
432 | });
|
433 | }
|
434 | });
|
435 |
|
436 | _defineProperty(_assertThisInitialized(_this), "handleScan", function (obj) {
|
437 | var scanCounter = _this.state.scanCount + 1;
|
438 | var scanName = "Tarama ";
|
439 |
|
440 | if (scanCounter < 10) {
|
441 | scanName += "0";
|
442 | }
|
443 |
|
444 | scanName += scanCounter;
|
445 | scanName += ".jpg";
|
446 |
|
447 | _this.setState({
|
448 | scanCount: scanCounter
|
449 | });
|
450 |
|
451 | var file = {
|
452 | data: {
|
453 | data: obj,
|
454 | name: scanName,
|
455 | id: 0,
|
456 | documentType: ""
|
457 | },
|
458 | status: "unLoaded"
|
459 | };
|
460 | var index = _this.state.files.length;
|
461 |
|
462 | var newFiles = _toConsumableArray(_this.state.files);
|
463 |
|
464 | newFiles[index] = file;
|
465 |
|
466 | _this.setState({
|
467 | files: newFiles
|
468 | });
|
469 | });
|
470 |
|
471 | _this.state = {
|
472 | documentTypes: [],
|
473 | files: [],
|
474 | uploading: false,
|
475 | successfullUploaded: false,
|
476 | scanCount: 0,
|
477 | popoverWillOpen: false,
|
478 | anchorEl: null
|
479 | };
|
480 |
|
481 | if (!props.fieldName || !props.fieldValue || !props.fileInfo) {
|
482 | _reactToastify.toast.error(_this.strings["ERROR_PROPS_NOT_EXIST"]);
|
483 | }
|
484 |
|
485 |
|
486 | _this.locale = props.locale ? props.locale : "tr";
|
487 | _this.strings = (0, _Language.GetLocales)(_this.locale);
|
488 |
|
489 | _this.fileInfoArray = props.fileInfo;
|
490 | _this.fieldName = props.fieldName;
|
491 | _this.fieldValue = props.fieldValue;
|
492 | _this.fileInfo = typeof props.fileInfo === "undefined" ? {
|
493 | fieldName: _fieldName,
|
494 | fieldValue: _fieldName
|
495 | } : props.fileInfo;
|
496 | _this.unwritable = false;
|
497 |
|
498 | if (typeof props.unwritable !== "undefined") {
|
499 | _this.unwritable = props.unwritable;
|
500 | }
|
501 |
|
502 | _this.docGoruntelemeYetkili = !!(0, _YetkiKontrol.YetkiKontrol)("dosya#görüntüleme");
|
503 | _this.dialogProps = {
|
504 | fullWidth: props.fullWidth !== false,
|
505 | maxWidth: props.maxWidth ? props.maxWidth : "md",
|
506 | height: "450px",
|
507 | padding: "0 0",
|
508 | buttonVariant: props.buttonVariant ? props.buttonVariant : "contained",
|
509 | buttonColor: props.buttonColor ? props.buttonColor : "primary",
|
510 | btnUniqueName: props.btnUniqueName ? props.btnUniqueName : props.fieldName,
|
511 | buttonText: props.buttonText ? props.buttonText : _this.strings["BUTTON_TEXT"],
|
512 | closeButtonText: props.closeButtonText ? props.closeButtonText : _this.strings["CLOSE_BUTTON_TEXT"],
|
513 | dialogTitle: props.dialogTitle ? props.dialogTitle : "",
|
514 | locale: _this.locale
|
515 | };
|
516 | _this.properties = [];
|
517 | return _this;
|
518 | }
|
519 |
|
520 | _createClass(CustomizedFileUpload, [{
|
521 | key: "componentDidMount",
|
522 | value: function componentDidMount() {
|
523 | var _this2 = this;
|
524 |
|
525 | _axios["default"].get(process.env.REACT_APP_FILE_SERVICE_HOST + "/api/v1/filehandler/GetDocTypes").then(function (res) {
|
526 | _this2.setState({
|
527 | documentTypes: res.data
|
528 | });
|
529 | })["catch"](function (err) {});
|
530 |
|
531 | this.fileInfoArray.forEach(function (f) {
|
532 | return _this2.properties.push(_this2.addProperty(f["fieldName"], f["fieldValue"]));
|
533 | });
|
534 | this.getFilesFromServer(true);
|
535 | }
|
536 | }, {
|
537 | key: "render",
|
538 | value: function render() {
|
539 | var _this3 = this;
|
540 |
|
541 | var dialogTitleHtml = "";
|
542 |
|
543 | if (this.dialogProps.dialogTitle) {
|
544 | dialogTitleHtml = _react["default"].createElement(_DialogTitle["default"], null, this.dialogProps.dialogTitle);
|
545 | }
|
546 |
|
547 | var buttonHtml = "";
|
548 |
|
549 | if (this.dialogProps.buttonText) {
|
550 |
|
551 | buttonHtml = _react["default"].createElement(_core.Tooltip, {
|
552 | title: this.strings["OPEN_BUTTON_TOOLTIP"]
|
553 | }, _react["default"].createElement(_Button["default"], {
|
554 | name: "btn" + this.dialogProps.btnUniqueName + "OpenDialog",
|
555 | variant: this.dialogProps.buttonVariant,
|
556 | color: this.dialogProps.buttonColor,
|
557 | onClick: this.handleDialogClickOpen,
|
558 | className: "float-right"
|
559 | }, _react["default"].createElement(_FolderOpenOutlined["default"], null)));
|
560 | }
|
561 |
|
562 | var closeButtonHtml = "";
|
563 |
|
564 | if (this.dialogProps.closeButtonText) {
|
565 | closeButtonHtml = _react["default"].createElement(_Button["default"], {
|
566 | name: "btn" + this.dialogProps.btnUniqueName + "Kapat",
|
567 | onClick: this.handleDialogClose,
|
568 | color: this.dialogProps.buttonColor
|
569 | }, this.dialogProps.closeButtonText);
|
570 | }
|
571 |
|
572 | var muiDataTableColumns = [{
|
573 | name: this.strings["FILE_UPLOAD.LABEL.DOSYA_ADI"],
|
574 | options: {
|
575 | display: true,
|
576 | customHeadRender: function customHeadRender(_ref) {
|
577 | var index = _ref.index,
|
578 | column = _objectWithoutProperties(_ref, ["index"]);
|
579 |
|
580 | return _react["default"].createElement(_core.TableCell, {
|
581 | style: {
|
582 | width: "45%",
|
583 | cursor: "default"
|
584 | },
|
585 | key: index
|
586 | }, column.name);
|
587 | }
|
588 | }
|
589 | }, {
|
590 | name: this.strings["FILE_UPLOAD.LABEL.DOKUMENT_TIPI"],
|
591 | options: {
|
592 | display: true,
|
593 | customHeadRender: function customHeadRender(_ref2) {
|
594 | var index = _ref2.index,
|
595 | column = _objectWithoutProperties(_ref2, ["index"]);
|
596 |
|
597 | return _react["default"].createElement(_core.TableCell, {
|
598 | style: {
|
599 | width: "35%",
|
600 | cursor: "default"
|
601 | },
|
602 | key: index,
|
603 | align: "center"
|
604 | }, column.name);
|
605 | }
|
606 | }
|
607 | }, {
|
608 | name: " ",
|
609 | options: {
|
610 | display: true,
|
611 | filter: false,
|
612 | customHeadRender: function customHeadRender(_ref3) {
|
613 | var index = _ref3.index,
|
614 | column = _objectWithoutProperties(_ref3, ["index"]);
|
615 |
|
616 | return _react["default"].createElement(_core.TableCell, {
|
617 | style: {
|
618 | width: "20%",
|
619 | cursor: "default"
|
620 | },
|
621 | key: index
|
622 | }, column.name);
|
623 | }
|
624 | }
|
625 | }, {
|
626 | name: "file",
|
627 | options: {
|
628 | display: false,
|
629 | filter: false
|
630 | }
|
631 | }];
|
632 | var muiDataTableData = [];
|
633 | this.state.files.forEach(function (file) {
|
634 | var fileData = [file.data.name, file.documentType, file, file.data.documentPath];
|
635 | muiDataTableData.push(fileData);
|
636 | });
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 | var optionsDataTable = {
|
653 | selectableRows: false,
|
654 | pagination: false,
|
655 | stickyHeader: true,
|
656 | filter: false,
|
657 | textLabels: {
|
658 | body: {
|
659 | noMatch: this.strings["MUI_TABLE_NO_MATCH"],
|
660 | toolTip: this.strings["FILE_UPLOAD.TOOL_TIP.SORT"],
|
661 | columnHeaderTooltip: function columnHeaderTooltip(column) {
|
662 | return "".concat(column.label, " ") + _this3.strings["FILE_UPLOAD.TOOL_TIP.SORT"];
|
663 | }
|
664 | },
|
665 | toolbar: {
|
666 | search: this.strings["FILE_UPLOAD.TOOL_TIP.SEARCH"],
|
667 | downloadCsv: this.strings["DOWNLOAD"] + " CSV",
|
668 | print: this.strings["PRINT"],
|
669 | viewColumns: this.strings["FILE_UPLOAD.TOOL_TIP.SHOW_COLUMNS"],
|
670 | filterTable: this.strings["FILE_UPLOAD.TOOL_TIP.FILTER_TABLE"]
|
671 | },
|
672 | filter: {
|
673 | all: this.strings["ALL"],
|
674 | title: this.strings["FILTERS"],
|
675 | reset: this.strings["RESET"]
|
676 | },
|
677 | viewColumns: {
|
678 | title: this.strings["FILE_UPLOAD.TOOL_TIP.SHOW_COLUMNS"],
|
679 | titleAria: this.strings["FILE_UPLOAD.TOOL_TIP.SHOW_HIDE_COLUMNS"]
|
680 | }
|
681 | },
|
682 | customRowRender: function customRowRender(fileData, dataIndex, rowIndex) {
|
683 | var t1_style = {};
|
684 | var t2_style = {};
|
685 | var t3_style = {};
|
686 |
|
687 | if (fileData[3] === undefined || fileData[3] === null || fileData[3] === "") {
|
688 | t1_style = {
|
689 | cursor: "default",
|
690 | color: "black",
|
691 | width: "45%"
|
692 | };
|
693 | t2_style = {
|
694 | cursor: "default",
|
695 | color: "black",
|
696 | width: "30%"
|
697 | };
|
698 | t3_style = {
|
699 | cursor: "default",
|
700 | color: "black",
|
701 | width: "25%"
|
702 | };
|
703 | } else {
|
704 | t1_style = {
|
705 | cursor: "default",
|
706 | "text-decoration": "underline",
|
707 | width: "45%"
|
708 | };
|
709 | t2_style = {
|
710 | cursor: "default",
|
711 | width: "30%"
|
712 | };
|
713 | t3_style = {
|
714 | cursor: "default",
|
715 | width: "25%"
|
716 | };
|
717 | }
|
718 |
|
719 | return _react["default"].createElement(_core.TableRow, {
|
720 | key: rowIndex + "_" + dataIndex
|
721 | }, _react["default"].createElement(_core.TableCell, {
|
722 | style: t1_style
|
723 | }, _this3.renderFileRowFileName(fileData[0], fileData[3])), _react["default"].createElement(_core.TableCell, {
|
724 | style: t2_style
|
725 | }, _this3.renderFileRowFileType(fileData[2])), _react["default"].createElement(_core.TableCell, {
|
726 | style: t3_style,
|
727 | align: "right"
|
728 | }, _this3.renderFileRowFileActions(fileData[2])));
|
729 | },
|
730 | customToolbar: function customToolbar() {
|
731 | return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_inlineScan["default"], {
|
732 | outerFunction: _this3.handleScan,
|
733 | icon: true,
|
734 | locale: _this3.locale
|
735 | }));
|
736 | }
|
737 | };
|
738 | var uploadStyle = {
|
739 | display: "flex",
|
740 | "flex-direction": "column",
|
741 | flex: "1",
|
742 | "align-items": "flex-start",
|
743 | "text-align": "left",
|
744 | overflow: "hidden"
|
745 | };
|
746 | var contentStyle = {
|
747 | display: "flex",
|
748 | "flex-direction": "row",
|
749 | "padding-top": "12px",
|
750 | "box-sizing": "border-box",
|
751 | width: "100%"
|
752 | };
|
753 | var dropzoneContainerStyle = {
|
754 | "padding-top": "2%"
|
755 | };
|
756 | var filesStyle = {
|
757 | "align-items": "flex-start",
|
758 | "justify-items": "flex-start",
|
759 | flex: "1",
|
760 | "overflow-y": "auto"
|
761 | };
|
762 |
|
763 | var dropzone_html = _react["default"].createElement("div", {
|
764 | style: dropzoneContainerStyle
|
765 | }, _react["default"].createElement("div", {
|
766 | className: "container"
|
767 | }, _react["default"].createElement("div", {
|
768 | className: "row"
|
769 | }, _react["default"].createElement("div", {
|
770 | className: "col justify-content-center"
|
771 | }, _react["default"].createElement(_Dropzone["default"], {
|
772 | onFilesAdded: this.onFilesAdded,
|
773 | disabled: this.state.uploading,
|
774 | locale: this.locale
|
775 | })))));
|
776 |
|
777 | if (this.unwritable) {
|
778 | dropzone_html = "";
|
779 | }
|
780 |
|
781 | return this.docGoruntelemeYetkili ? _react["default"].createElement(_react.Fragment, null, _react["default"].createElement(_core.Table, {
|
782 | className: "align-right"
|
783 | }, _react["default"].createElement(_core.TableRow, null, _react["default"].createElement(_core.TableCell, null, buttonHtml))), _react["default"].createElement(_Dialog["default"], {
|
784 | fullWidth: this.dialogProps.fullWidth,
|
785 | maxWidth: this.dialogProps.maxWidth,
|
786 | open: this.state.popoverWillOpen,
|
787 | onClose: this.handleDialogClose,
|
788 | "aria-labelledby": "form-dialog-title",
|
789 | style: {
|
790 | height: "70vh"
|
791 | }
|
792 | }, dialogTitleHtml, _react["default"].createElement(_DialogContent["default"], null, _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("div", {
|
793 | style: uploadStyle
|
794 | }, _react["default"].createElement("div", {
|
795 | style: contentStyle
|
796 | }, dropzone_html, _react["default"].createElement("div", {
|
797 | style: filesStyle
|
798 | }, _react["default"].createElement(_muiDatatables["default"], {
|
799 | title: "Dosyalar",
|
800 | data: muiDataTableData,
|
801 | columns: muiDataTableColumns,
|
802 | options: optionsDataTable
|
803 | })))))), _react["default"].createElement(_DialogActions["default"], null, " ", closeButtonHtml, " "))) : _react["default"].createElement(_react.Fragment, null);
|
804 | }
|
805 | }]);
|
806 |
|
807 | return CustomizedFileUpload;
|
808 | }(_react["default"].Component);
|
809 |
|
810 | var _default = (0, _reactIntl.injectIntl)(CustomizedFileUpload);
|
811 |
|
812 | exports["default"] = _default; |
\ | No newline at end of file |