@anji-dashing/dam-solution-v2 5.8.173
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/README.md +53 -0
- package/build/AssetType/AddFieldProperties.d.ts +10 -0
- package/build/AssetType/AddFieldProperties.js +359 -0
- package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
- package/build/AssetType/AssetTemplatesTable.js +172 -0
- package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
- package/build/AssetType/CreateAssetTemplate.js +70 -0
- package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
- package/build/AssetType/CreateOrEditAssetTemplate.js +100 -0
- package/build/AssetType/DraggedField.d.ts +14 -0
- package/build/AssetType/DraggedField.js +58 -0
- package/build/AssetType/EditAssetTemplate.d.ts +5 -0
- package/build/AssetType/EditAssetTemplate.js +257 -0
- package/build/AssetType/FieldsSection.d.ts +14 -0
- package/build/AssetType/FieldsSection.js +268 -0
- package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
- package/build/AssetType/assetTemplatesContainer.js +71 -0
- package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
- package/build/AssetType/fieldProperties/DateField.js +23 -0
- package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
- package/build/AssetType/fieldProperties/NumberField.js +91 -0
- package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
- package/build/AssetType/fieldProperties/OptionsField.js +55 -0
- package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
- package/build/AssetType/fieldProperties/TextField.js +92 -0
- package/build/AssetType/index.d.ts +11 -0
- package/build/AssetType/index.js +25 -0
- package/build/AssetType/routes.d.ts +3 -0
- package/build/AssetType/routes.js +17 -0
- package/build/BookView/ProductDescription.d.ts +4 -0
- package/build/BookView/ProductDescription.js +20 -0
- package/build/BookView/bookDetail.d.ts +4 -0
- package/build/BookView/bookDetail.js +106 -0
- package/build/BookView/bookInfo.d.ts +4 -0
- package/build/BookView/bookInfo.js +17 -0
- package/build/BookView/description.d.ts +4 -0
- package/build/BookView/description.js +5 -0
- package/build/BookView/index.d.ts +10 -0
- package/build/BookView/index.js +23 -0
- package/build/CreateClient/CreateClientBtn.d.ts +14 -0
- package/build/CreateClient/CreateClientBtn.js +54 -0
- package/build/CreateClient/CreateClientForm.d.ts +15 -0
- package/build/CreateClient/CreateClientForm.js +347 -0
- package/build/CreateClient/index.d.ts +20 -0
- package/build/CreateClient/index.js +18 -0
- package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
- package/build/ImagePicker/MetaFieldOptions.js +75 -0
- package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
- package/build/ImagePicker/TestImagePickerModal.js +72 -0
- package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
- package/build/ImagePicker/TestImgFromMetaData.js +82 -0
- package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
- package/build/ImagePicker/imagePickerComponent.js +63 -0
- package/build/ImagePicker/index.d.ts +13 -0
- package/build/ImagePicker/index.js +24 -0
- package/build/ImagePicker/routes.d.ts +6 -0
- package/build/ImagePicker/routes.js +17 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
- package/build/ImagePickerFilters/index.d.ts +12 -0
- package/build/ImagePickerFilters/index.js +19 -0
- package/build/MyDrive/ActionBar.d.ts +8 -0
- package/build/MyDrive/ActionBar.js +190 -0
- package/build/MyDrive/AddDrive.d.ts +5 -0
- package/build/MyDrive/AddDrive.js +189 -0
- package/build/MyDrive/AddFolder.d.ts +11 -0
- package/build/MyDrive/AddFolder.js +165 -0
- package/build/MyDrive/BreadCrumbList.d.ts +10 -0
- package/build/MyDrive/BreadCrumbList.js +81 -0
- package/build/MyDrive/BulkUploadModal.d.ts +2 -0
- package/build/MyDrive/BulkUploadModal.js +324 -0
- package/build/MyDrive/DriveContainer.d.ts +14 -0
- package/build/MyDrive/DriveContainer.js +343 -0
- package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
- package/build/MyDrive/FileDownloadHistory.js +107 -0
- package/build/MyDrive/FileMenuOptions.d.ts +11 -0
- package/build/MyDrive/FileMenuOptions.js +450 -0
- package/build/MyDrive/FilesGridView.d.ts +9 -0
- package/build/MyDrive/FilesGridView.js +25 -0
- package/build/MyDrive/FolderGridView.d.ts +20 -0
- package/build/MyDrive/FolderGridView.js +95 -0
- package/build/MyDrive/FolderListView.d.ts +26 -0
- package/build/MyDrive/FolderListView.js +226 -0
- package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
- package/build/MyDrive/FolderMenuOptions.js +350 -0
- package/build/MyDrive/FolderTree.d.ts +8 -0
- package/build/MyDrive/FolderTree.js +479 -0
- package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
- package/build/MyDrive/ImageEditor/EditImage.js +97 -0
- package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
- package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
- package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
- package/build/MyDrive/ImagePickerDrive.js +41 -0
- package/build/MyDrive/MyDriveMainContainer.d.ts +6 -0
- package/build/MyDrive/MyDriveMainContainer.js +63 -0
- package/build/MyDrive/SearchFilter.d.ts +8 -0
- package/build/MyDrive/SearchFilter.js +73 -0
- package/build/MyDrive/ShareBtn.d.ts +5 -0
- package/build/MyDrive/ShareBtn.js +19 -0
- package/build/MyDrive/ToggleView.d.ts +4 -0
- package/build/MyDrive/ToggleView.js +12 -0
- package/build/MyDrive/UploadStatusModal.d.ts +12 -0
- package/build/MyDrive/UploadStatusModal.js +52 -0
- package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
- package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
- package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
- package/build/MyDrive/fileDetails/Comments.js +65 -0
- package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
- package/build/MyDrive/fileDetails/Compliance.js +18 -0
- package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
- package/build/MyDrive/fileDetails/CreateComment.js +48 -0
- package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
- package/build/MyDrive/fileDetails/Editor.js +55 -0
- package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
- package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
- package/build/MyDrive/fileDetails/FileDetails.d.ts +11 -0
- package/build/MyDrive/fileDetails/FileDetails.js +125 -0
- package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
- package/build/MyDrive/fileDetails/FileHeader.js +27 -0
- package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileViewer.js +17 -0
- package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
- package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
- package/build/MyDrive/fileDetails/ImageViewer.d.ts +6 -0
- package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
- package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
- package/build/MyDrive/fileDetails/ManageFile.js +34 -0
- package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
- package/build/MyDrive/fileDetails/MetaForm.js +199 -0
- package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
- package/build/MyDrive/fileDetails/Metadata.js +52 -0
- package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
- package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
- package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
- package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
- package/build/MyDrive/fileDetails/Previewdetails.d.ts +10 -0
- package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
- package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
- package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
- package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
- package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
- package/build/MyDrive/files/FolderTabs.d.ts +6 -0
- package/build/MyDrive/files/FolderTabs.js +90 -0
- package/build/MyDrive/files/MapFile.d.ts +9 -0
- package/build/MyDrive/files/MapFile.js +239 -0
- package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
- package/build/MyDrive/files/MoveToAnotherFolder.js +67 -0
- package/build/MyDrive/filesListView.d.ts +2 -0
- package/build/MyDrive/filesListView.js +57 -0
- package/build/MyDrive/index.d.ts +16 -0
- package/build/MyDrive/index.js +50 -0
- package/build/MyDrive/routes.d.ts +10 -0
- package/build/MyDrive/routes.js +12 -0
- package/build/PenView/PenDetails.d.ts +4 -0
- package/build/PenView/PenDetails.js +114 -0
- package/build/PenView/ProductDescription.d.ts +5 -0
- package/build/PenView/ProductDescription.js +51 -0
- package/build/PenView/index.d.ts +10 -0
- package/build/PenView/index.js +23 -0
- package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
- package/build/RefreshKey/RefreshKeyBtn.js +42 -0
- package/build/RefreshKey/index.d.ts +9 -0
- package/build/RefreshKey/index.js +23 -0
- package/build/ShoesView/ProductDescription.d.ts +4 -0
- package/build/ShoesView/ProductDescription.js +25 -0
- package/build/ShoesView/ShoeDetails.d.ts +4 -0
- package/build/ShoesView/ShoeDetails.js +96 -0
- package/build/ShoesView/index.d.ts +10 -0
- package/build/ShoesView/index.js +23 -0
- package/build/common/Button.d.ts +2 -0
- package/build/common/Button.js +18 -0
- package/build/common/CustomElements.d.ts +98 -0
- package/build/common/CustomElements.js +77 -0
- package/build/common/LoadMoreItems.d.ts +7 -0
- package/build/common/LoadMoreItems.js +33 -0
- package/build/common/RenderFormItem.d.ts +42 -0
- package/build/common/RenderFormItem.js +98 -0
- package/build/common/RenderThumnail.d.ts +7 -0
- package/build/common/RenderThumnail.js +6 -0
- package/build/common/deleteModal.d.ts +1 -0
- package/build/common/deleteModal.js +12 -0
- package/build/common/folders/TypeAndDateFilters.d.ts +13 -0
- package/build/common/folders/TypeAndDateFilters.js +66 -0
- package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
- package/build/common/folders/getFolderOrFileIcon.js +41 -0
- package/build/common/loader/CustomLoader.d.ts +7 -0
- package/build/common/loader/CustomLoader.js +8 -0
- package/build/common/loader/loader.d.ts +1 -0
- package/build/common/loader/loader.js +6 -0
- package/build/common/notifications.d.ts +2 -0
- package/build/common/notifications.js +30 -0
- package/build/common/steps.d.ts +4 -0
- package/build/common/steps.js +7 -0
- package/build/hocs/AppProvider.d.ts +3 -0
- package/build/hocs/AppProvider.js +11 -0
- package/build/hocs/DamConfigContext.d.ts +2 -0
- package/build/hocs/DamConfigContext.js +153 -0
- package/build/hocs/ThemeContext.d.ts +15 -0
- package/build/hocs/ThemeContext.js +131 -0
- package/build/hocs/ToastProvider.d.ts +2 -0
- package/build/hocs/ToastProvider.js +6 -0
- package/build/hocs/appConstants.d.ts +124 -0
- package/build/hocs/appConstants.js +211 -0
- package/build/hocs/configureAxios.d.ts +2 -0
- package/build/hocs/configureAxios.js +65 -0
- package/build/hocs/helpers.d.ts +17 -0
- package/build/hocs/helpers.js +201 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +12 -0
- package/build/react-query/hooks/brand-hooks.d.ts +3 -0
- package/build/react-query/hooks/brand-hooks.js +10 -0
- package/build/react-query/hooks/folder-hooks.d.ts +7 -0
- package/build/react-query/hooks/folder-hooks.js +119 -0
- package/build/react-query/services/brand-services.d.ts +4 -0
- package/build/react-query/services/brand-services.js +41 -0
- package/build/react-query/services/file-services.d.ts +43 -0
- package/build/react-query/services/file-services.js +69 -0
- package/build/react-query/services/folder-services.d.ts +46 -0
- package/build/react-query/services/folder-services.js +87 -0
- package/build/react-query/services/image-picker-services.d.ts +5 -0
- package/build/react-query/services/image-picker-services.js +47 -0
- package/build/settings/InviteTeamModal.d.ts +12 -0
- package/build/settings/InviteTeamModal.js +174 -0
- package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
- package/build/settings/UpdateInvitationAccessType.js +96 -0
- package/build/settings/getUserAvatar.d.ts +7 -0
- package/build/settings/getUserAvatar.js +11 -0
- package/build/style.css +1 -0
- package/build/types/assetType.d.ts +8 -0
- package/build/types/assetType.js +1 -0
- package/build/ui/pageTitle.d.ts +3 -0
- package/build/ui/pageTitle.js +4 -0
- package/build/utilities/FoldersContext.d.ts +16 -0
- package/build/utilities/FoldersContext.js +15 -0
- package/build/utilities/NavigatorProvider.d.ts +2 -0
- package/build/utilities/NavigatorProvider.js +10 -0
- package/build/utilities/constants/apiUrls.d.ts +97 -0
- package/build/utilities/constants/apiUrls.js +117 -0
- package/build/utilities/constants/imageUrls.d.ts +6 -0
- package/build/utilities/constants/imageUrls.js +6 -0
- package/build/utilities/constants/interface.d.ts +371 -0
- package/build/utilities/constants/interface.js +142 -0
- package/build/utilities/constants/messages.d.ts +55 -0
- package/build/utilities/constants/messages.js +55 -0
- package/build/utilities/constants/queryKeys.d.ts +16 -0
- package/build/utilities/constants/queryKeys.js +33 -0
- package/build/utilities/constants/routes.d.ts +22 -0
- package/build/utilities/constants/routes.js +22 -0
- package/build/utilities/helpers/validators.d.ts +12 -0
- package/build/utilities/helpers/validators.js +89 -0
- package/build/utilities/useAppNavigate.d.ts +2 -0
- package/build/utilities/useAppNavigate.js +35 -0
- package/build/utilities/useAppParams.d.ts +8 -0
- package/build/utilities/useAppParams.js +72 -0
- package/package.json +93 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import _, { filter, find, first, flatMap, get, includes, isEmpty, merge, } from "lodash";
|
|
13
|
+
import FolderListView from "./FolderListView";
|
|
14
|
+
import FolderGridView from "./FolderGridView";
|
|
15
|
+
import TypeAndDateFilters from "../common/folders/TypeAndDateFilters";
|
|
16
|
+
import { Button, Upload } from "antd";
|
|
17
|
+
import { addQueryParams, getDateRangeFromKey, getDateRangeLabel } from "../hocs/helpers";
|
|
18
|
+
import { useFolders } from "../react-query/services/folder-services";
|
|
19
|
+
import { DATE_FORMAT, DEFAULT_PAGE } from "../hocs/appConstants";
|
|
20
|
+
import dayjs from "dayjs";
|
|
21
|
+
import Loader from "../common/loader/loader";
|
|
22
|
+
import ToggleView from "./ToggleView";
|
|
23
|
+
import AddDrive from "./AddDrive";
|
|
24
|
+
import BreadCrumbList from "./BreadCrumbList";
|
|
25
|
+
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
26
|
+
import { DriveModes, EntityType, FileTypes, NotificationStatus, SortByKeys, SortOrders, } from "../utilities/constants/interface";
|
|
27
|
+
import { generateFoldersQueryKey } from "../utilities/constants/queryKeys";
|
|
28
|
+
import CustomButton from "../common/Button";
|
|
29
|
+
import { BsUpload } from "react-icons/bs";
|
|
30
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
31
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
32
|
+
import { NOT_FOUND_IMAGE_URL } from "../utilities/constants/imageUrls";
|
|
33
|
+
import ImagePickerBreadCrumbList from "./ImagePickerBreadCrumbList";
|
|
34
|
+
import { FETCH_ASSETS_URL, FETCH_IMAGE_PCIKER_THUMBNAIL_URL, UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, } from "../utilities/constants/apiUrls";
|
|
35
|
+
import { showNotification } from "../common/notifications";
|
|
36
|
+
import useAppParams from "../utilities/useAppParams";
|
|
37
|
+
import { RefetchFoldersProvider } from "../utilities/FoldersContext";
|
|
38
|
+
const BsUploadIcon = BsUpload;
|
|
39
|
+
function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pickerFolderId, selectedPickerFile, imagePicker, globalSearch, setGlobalSearch, setSelectedKeys, }) {
|
|
40
|
+
const damConfig = useDamConfig();
|
|
41
|
+
const { rootFolderId, brand, isAdmin } = damConfig;
|
|
42
|
+
const brandId = get(brand, "_id");
|
|
43
|
+
const { folderId, type, id } = useAppParams();
|
|
44
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
45
|
+
const [state, setState] = useState({
|
|
46
|
+
selectedType: "",
|
|
47
|
+
selectedDateKey: "",
|
|
48
|
+
customDateRange: null,
|
|
49
|
+
showGrid: false,
|
|
50
|
+
loadingType: "",
|
|
51
|
+
selectedItems: {},
|
|
52
|
+
assets: [],
|
|
53
|
+
sortBy: SortByKeys.UPDATED_AT,
|
|
54
|
+
sortOrder: SortOrders.DESCEND,
|
|
55
|
+
searchKey: "",
|
|
56
|
+
searchValue: "",
|
|
57
|
+
metadataKey: "",
|
|
58
|
+
metadataValue: "",
|
|
59
|
+
folderSearch: "",
|
|
60
|
+
});
|
|
61
|
+
const { selectedType, selectedDateKey, customDateRange, showGrid, loadingType, selectedItems, assets, sortBy, sortOrder, searchKey, searchValue, metadataKey, metadataValue, folderSearch, } = state;
|
|
62
|
+
const getSearchParams = () => {
|
|
63
|
+
const params = {};
|
|
64
|
+
if (searchKey === "name") {
|
|
65
|
+
params["search"] = searchValue;
|
|
66
|
+
}
|
|
67
|
+
else if (searchKey === "extensionType") {
|
|
68
|
+
params["extensionType"] = searchValue;
|
|
69
|
+
}
|
|
70
|
+
else if (searchKey === "assetName") {
|
|
71
|
+
params["assetName"] = searchValue;
|
|
72
|
+
}
|
|
73
|
+
return params;
|
|
74
|
+
};
|
|
75
|
+
const effectiveFolderId = parentFolderId || folderId || id || rootFolderId || '';
|
|
76
|
+
const prevEffectiveFolderIdRef = useRef(null);
|
|
77
|
+
const folderIdChanged = prevEffectiveFolderIdRef.current !== null &&
|
|
78
|
+
prevEffectiveFolderIdRef.current !== effectiveFolderId;
|
|
79
|
+
prevEffectiveFolderIdRef.current = effectiveFolderId;
|
|
80
|
+
const folderParams = merge({}, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ page: DEFAULT_PAGE }, (type ? { category: type } : {})), (!!imagePicker
|
|
81
|
+
? {
|
|
82
|
+
includeSubFolders: get(imagePicker, "includeSubFolders", true),
|
|
83
|
+
teamVisibility: get(imagePicker, "teamVisibility", true),
|
|
84
|
+
}
|
|
85
|
+
: {})), (!folderIdChanged && !!searchKey && !!searchValue ? getSearchParams() : {})), (!folderIdChanged && !!metadataKey && !!metadataValue
|
|
86
|
+
? { metadataKey: metadataKey, metadataValue: metadataValue }
|
|
87
|
+
: {})), (!folderIdChanged && !!folderSearch ? { name: folderSearch } : {})), (!folderIdChanged && !!globalSearch && ((parentFolderId || folderId || id) === rootFolderId || !(parentFolderId || folderId || id))
|
|
88
|
+
? { globalSearch }
|
|
89
|
+
: {})), { sortBy: sortBy, sortOrder: sortOrder }), Object.assign(Object.assign({}, (!folderIdChanged && selectedDateKey === "custom" && customDateRange && customDateRange[0] && customDateRange[1]
|
|
90
|
+
? {
|
|
91
|
+
startDate: dayjs(customDateRange[0]).format(DATE_FORMAT),
|
|
92
|
+
endDate: dayjs(customDateRange[1]).format(DATE_FORMAT),
|
|
93
|
+
}
|
|
94
|
+
: folderIdChanged ? {} : getDateRangeFromKey(selectedDateKey))), (!folderIdChanged && !!selectedType ? { type: selectedType } : {})));
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (folderIdChanged) {
|
|
97
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { selectedType: "", selectedDateKey: "", customDateRange: null, searchKey: "", searchValue: "", metadataKey: "", metadataValue: "", folderSearch: "" })));
|
|
98
|
+
if (setGlobalSearch)
|
|
99
|
+
setGlobalSearch("");
|
|
100
|
+
}
|
|
101
|
+
}, [effectiveFolderId, folderIdChanged, setGlobalSearch]);
|
|
102
|
+
const { data: foldersPaginatedData, isLoading, hasNextPage, fetchNextPage, refetch, isFetching, error, } = useFolders(api, generateFoldersQueryKey(type), folderParams, effectiveFolderId);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (typeof window !== "undefined") {
|
|
105
|
+
const isMobile = window.innerWidth < 768;
|
|
106
|
+
if (isMobile) {
|
|
107
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { showGrid: true })));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, []);
|
|
111
|
+
const folders = useMemo(() => {
|
|
112
|
+
return !!foldersPaginatedData
|
|
113
|
+
? flatMap(get(foldersPaginatedData, "pages"), "folders")
|
|
114
|
+
: [];
|
|
115
|
+
}, [foldersPaginatedData]);
|
|
116
|
+
const onDateMenuClick = ({ key }) => {
|
|
117
|
+
const { startDate, endDate } = getDateRangeFromKey(key);
|
|
118
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { selectedDateKey: key, customDateRange: null, loadingType: "date" })));
|
|
119
|
+
};
|
|
120
|
+
const onTypeMenuClick = ({ key }) => {
|
|
121
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { selectedType: key, loadingType: "type" })));
|
|
122
|
+
};
|
|
123
|
+
const prevDateKeyRef = useRef();
|
|
124
|
+
const prevCustomDateRangeRef = useRef();
|
|
125
|
+
const prevTypeKeyRef = useRef();
|
|
126
|
+
const prevParentRef = useRef();
|
|
127
|
+
const prevSortByKeyRef = useRef();
|
|
128
|
+
const prevSortOrderRef = useRef();
|
|
129
|
+
const prevSearchValueRef = useRef();
|
|
130
|
+
const prevMetadataKeyRef = useRef();
|
|
131
|
+
const prevMetadataValueRef = useRef();
|
|
132
|
+
const prevFolderSearchRef = useRef();
|
|
133
|
+
const prevGlobalSearchRef = useRef();
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const prevDateKeyState = prevDateKeyRef.current;
|
|
136
|
+
const prevCustomDateRangeState = prevCustomDateRangeRef.current;
|
|
137
|
+
const prevTypeKeyState = prevTypeKeyRef.current;
|
|
138
|
+
const prevSortByKeyState = prevSortByKeyRef.current;
|
|
139
|
+
const prevSortOrderState = prevSortOrderRef.current;
|
|
140
|
+
const prevSearchValueState = prevSearchValueRef.current;
|
|
141
|
+
const prevMetadataKeyState = prevMetadataKeyRef.current;
|
|
142
|
+
const prevMetadataValueState = prevMetadataValueRef.current;
|
|
143
|
+
const prevFolderSearchState = prevFolderSearchRef.current;
|
|
144
|
+
const prevGlobalSearchState = prevGlobalSearchRef.current;
|
|
145
|
+
const customDateRangeChanged = selectedDateKey === "custom" && customDateRange !== prevCustomDateRangeState;
|
|
146
|
+
const shouldRefetch = selectedDateKey !== prevDateKeyState ||
|
|
147
|
+
customDateRangeChanged ||
|
|
148
|
+
selectedType !== prevTypeKeyState ||
|
|
149
|
+
sortBy !== prevSortByKeyState ||
|
|
150
|
+
sortOrder !== prevSortOrderState ||
|
|
151
|
+
searchValue !== prevSearchValueState ||
|
|
152
|
+
metadataKey !== prevMetadataKeyState ||
|
|
153
|
+
metadataValue !== prevMetadataValueState ||
|
|
154
|
+
folderSearch !== prevFolderSearchState ||
|
|
155
|
+
globalSearch !== prevGlobalSearchState;
|
|
156
|
+
if (shouldRefetch) {
|
|
157
|
+
refetch();
|
|
158
|
+
}
|
|
159
|
+
prevDateKeyRef.current = selectedDateKey;
|
|
160
|
+
prevCustomDateRangeRef.current = customDateRange;
|
|
161
|
+
prevTypeKeyRef.current = selectedType;
|
|
162
|
+
prevSortByKeyRef.current = sortBy;
|
|
163
|
+
prevSortOrderRef.current = sortOrder;
|
|
164
|
+
prevSearchValueRef.current = searchValue;
|
|
165
|
+
prevMetadataKeyRef.current = metadataKey;
|
|
166
|
+
prevMetadataValueRef.current = metadataValue;
|
|
167
|
+
prevFolderSearchRef.current = folderSearch;
|
|
168
|
+
prevGlobalSearchRef.current = globalSearch;
|
|
169
|
+
}, [
|
|
170
|
+
selectedDateKey,
|
|
171
|
+
customDateRange,
|
|
172
|
+
selectedType,
|
|
173
|
+
sortBy,
|
|
174
|
+
sortOrder,
|
|
175
|
+
searchValue,
|
|
176
|
+
metadataKey,
|
|
177
|
+
metadataValue,
|
|
178
|
+
folderSearch,
|
|
179
|
+
globalSearch,
|
|
180
|
+
]);
|
|
181
|
+
const parentFolder = useMemo(() => get(first(get(foldersPaginatedData, "pages", [])), "folder", {}), [foldersPaginatedData]);
|
|
182
|
+
const onSelectNewFile = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
try {
|
|
184
|
+
setState((prevState) => {
|
|
185
|
+
return Object.assign(Object.assign({}, prevState), { loadingType: "NEW_FILE_UPLOAD" });
|
|
186
|
+
});
|
|
187
|
+
const response = yield api.post(UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, {
|
|
188
|
+
brandId,
|
|
189
|
+
folderId: parentFolderId || folderId || rootFolderId,
|
|
190
|
+
name: file.name,
|
|
191
|
+
size: file.size,
|
|
192
|
+
});
|
|
193
|
+
// console.log(response);
|
|
194
|
+
const [name, extension] = file.name.split(".");
|
|
195
|
+
const filePath = get(response, "data.filePath");
|
|
196
|
+
const url = get(response, "data.url");
|
|
197
|
+
fetch(url, {
|
|
198
|
+
method: "PUT",
|
|
199
|
+
body: file,
|
|
200
|
+
})
|
|
201
|
+
.then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
// setSelectedFile()
|
|
203
|
+
const fileResponse = yield api.post(FETCH_IMAGE_PCIKER_THUMBNAIL_URL, {
|
|
204
|
+
brandId,
|
|
205
|
+
folderId: parentFolderId || folderId || rootFolderId,
|
|
206
|
+
name: file.name,
|
|
207
|
+
mimetype: `image/${extension}`,
|
|
208
|
+
s3Path: filePath,
|
|
209
|
+
});
|
|
210
|
+
// console.log(fileResponse);
|
|
211
|
+
if (setSelectedFile) {
|
|
212
|
+
setSelectedFile(fileResponse === null || fileResponse === void 0 ? void 0 : fileResponse.data, true);
|
|
213
|
+
}
|
|
214
|
+
}))
|
|
215
|
+
.catch((err) => {
|
|
216
|
+
console.log(err);
|
|
217
|
+
setState((prevState) => {
|
|
218
|
+
return Object.assign(Object.assign({}, prevState), { loadingType: "" });
|
|
219
|
+
});
|
|
220
|
+
showNotification(get(err, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
console.error("Error uploading file:", error);
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loadingType: "" })));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (brandId) {
|
|
232
|
+
fetchAssets();
|
|
233
|
+
}
|
|
234
|
+
}, [brandId]);
|
|
235
|
+
const fetchAssets = () => __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { assetsLoading: true })));
|
|
237
|
+
try {
|
|
238
|
+
const response = yield api.get(`${FETCH_ASSETS_URL.replace(":brandId", brandId)}?${addQueryParams({
|
|
239
|
+
isActive: true,
|
|
240
|
+
isPagination: false,
|
|
241
|
+
})}`);
|
|
242
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { assets: get(response, "data.data", []) })));
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { assets: [] })));
|
|
246
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
const onSearch = (filters) => {
|
|
250
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), filters)));
|
|
251
|
+
};
|
|
252
|
+
const hasActiveFilters = !!(searchKey && searchValue) ||
|
|
253
|
+
!!(metadataKey && metadataValue) ||
|
|
254
|
+
!!folderSearch ||
|
|
255
|
+
!!globalSearch ||
|
|
256
|
+
!!selectedType ||
|
|
257
|
+
!!selectedDateKey;
|
|
258
|
+
const activeFiltersSummary = useMemo(() => {
|
|
259
|
+
const items = [];
|
|
260
|
+
if (searchKey && searchValue) {
|
|
261
|
+
const searchLabels = {
|
|
262
|
+
name: "Name",
|
|
263
|
+
extensionType: "File type",
|
|
264
|
+
assetName: "Asset Template",
|
|
265
|
+
};
|
|
266
|
+
items.push({
|
|
267
|
+
label: searchLabels[searchKey] || searchKey,
|
|
268
|
+
value: searchValue,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (metadataKey && metadataValue) {
|
|
272
|
+
const metaField = find(flatMap(assets, (a) => get(a, "metadataFields", [])), (f) => get(f, "_id") === metadataKey);
|
|
273
|
+
const fieldName = metaField ? get(metaField, "name", metadataKey) : metadataKey;
|
|
274
|
+
items.push({
|
|
275
|
+
label: fieldName,
|
|
276
|
+
value: Array.isArray(metadataValue) ? metadataValue.join(", ") : String(metadataValue),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (folderSearch) {
|
|
280
|
+
items.push({ label: "Folder search", value: folderSearch });
|
|
281
|
+
}
|
|
282
|
+
if (globalSearch) {
|
|
283
|
+
items.push({ label: "Global search", value: globalSearch });
|
|
284
|
+
}
|
|
285
|
+
if (selectedType) {
|
|
286
|
+
const typeLabels = {
|
|
287
|
+
[FileTypes.IMAGES]: "Images",
|
|
288
|
+
[FileTypes.VIDEOS]: "Videos",
|
|
289
|
+
[FileTypes.DOCUMENTS]: "Documents",
|
|
290
|
+
[FileTypes.MUSIC]: "Music",
|
|
291
|
+
[FileTypes.OTHER]: "Other",
|
|
292
|
+
};
|
|
293
|
+
items.push({ label: "Type", value: typeLabels[selectedType] || selectedType });
|
|
294
|
+
}
|
|
295
|
+
if (selectedDateKey) {
|
|
296
|
+
const label = selectedDateKey === "custom" && (customDateRange === null || customDateRange === void 0 ? void 0 : customDateRange[0]) && (customDateRange === null || customDateRange === void 0 ? void 0 : customDateRange[1])
|
|
297
|
+
? `Custom: ${dayjs(customDateRange[0]).format("MMM D, YYYY")} - ${dayjs(customDateRange[1]).format("MMM D, YYYY")}`
|
|
298
|
+
: getDateRangeLabel(selectedDateKey);
|
|
299
|
+
items.push({ label: "Modified", value: label });
|
|
300
|
+
}
|
|
301
|
+
return items;
|
|
302
|
+
}, [
|
|
303
|
+
searchKey,
|
|
304
|
+
searchValue,
|
|
305
|
+
metadataKey,
|
|
306
|
+
metadataValue,
|
|
307
|
+
folderSearch,
|
|
308
|
+
globalSearch,
|
|
309
|
+
selectedType,
|
|
310
|
+
selectedDateKey,
|
|
311
|
+
customDateRange,
|
|
312
|
+
assets,
|
|
313
|
+
]);
|
|
314
|
+
const clearAllFilters = () => {
|
|
315
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { searchKey: "", searchValue: "", metadataKey: "", metadataValue: "", folderSearch: "", selectedType: "", selectedDateKey: "", customDateRange: null, loadingType: "date" })));
|
|
316
|
+
if (setGlobalSearch)
|
|
317
|
+
setGlobalSearch("");
|
|
318
|
+
};
|
|
319
|
+
return (_jsx(RefetchFoldersProvider, { value: refetch, children: _jsxs("div", { className: "md-lib-h-[inherit]", children: [type !== DriveModes.FILE && (_jsx(_Fragment, { children: _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-px-4 md-lib-h-20 md-lib-justify-between md-lib-border-b md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-mb-4", children: [imagePicker ? (_jsx(ImagePickerBreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId })) : (_jsx(_Fragment, { children: _jsx(BreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId, globalSearch: globalSearch, setSelectedKeys: setSelectedKeys }) })), isAdmin && _jsx(AddDrive, { parentFolderId: parentFolderId }), get(imagePicker, "allowNewFiles") && (_jsx(Upload, { beforeUpload: (file) => {
|
|
320
|
+
onSelectNewFile(file);
|
|
321
|
+
}, showUploadList: false, accept: "image/*", children: _jsx(CustomButton, { loading: loadingType === "NEW_FILE_UPLOAD", label: "Select File", icon: _jsx(BsUploadIcon, {}) }) }))] }) })), _jsxs("div", { className: `md-lib-px-4 md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-flex ${!includes([DriveModes.FOLDERS, DriveModes.FILE], type)
|
|
322
|
+
? "md-lib-justify-between"
|
|
323
|
+
: "md-lib-justify-end md-lib-my-4"}`, children: [!includes([DriveModes.FOLDERS, DriveModes.FILE], type) && (_jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4 md-lib-mb-4", children: _jsx(TypeAndDateFilters, { selectedDateKey: selectedDateKey, selectedType: selectedType, customDateRange: customDateRange, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
324
|
+
if (dates) {
|
|
325
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
326
|
+
}
|
|
327
|
+
}, onCancelCustomDate: () => {
|
|
328
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { selectedDateKey: "", customDateRange: null, loadingType: "date" })));
|
|
329
|
+
}, loading: isFetching, loadingType: loadingType }) })), _jsx(ToggleView, { showGrid: showGrid, toggleView: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGrid: value }))) })] }), _jsx("div", { className: "md-lib-border-b md-lib-border-borderColor md-lib-mb-4" }), isLoading ? (_jsx(Loader, {})) : isEmpty(folders) ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center md-lib-py-8", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: error
|
|
330
|
+
? get(error, "message", SOMETHING_WENT_WRONG)
|
|
331
|
+
: includes(Object.values(DriveModes), type)
|
|
332
|
+
? "No data found"
|
|
333
|
+
: hasActiveFilters
|
|
334
|
+
? "No results found"
|
|
335
|
+
: "No files has been created yet" }), hasActiveFilters && activeFiltersSummary.length > 0 && (_jsxs("div", { className: "md-lib-mt-4 md-lib-p-4 md-lib-rounded-lg md-lib-bg-secondaryColor dark:md-lib-bg-darkSecondaryColor md-lib-max-w-md md-lib-w-full", children: [_jsx("p", { className: "md-lib-text-xs md-lib-font-medium md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-mb-2", children: "Active filters:" }), _jsx("ul", { className: "md-lib-text-sm md-lib-space-y-1", children: activeFiltersSummary.map((item, idx) => (_jsxs("li", { className: "md-lib-flex md-lib-gap-2", children: [_jsxs("span", { className: "md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor", children: [item.label, ":"] }), _jsx("span", { className: "md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-truncate", children: item.value })] }, idx))) })] })), hasActiveFilters && (_jsx(Button, { type: "primary", className: "md-lib-mt-4", onClick: clearAllFilters, children: "Clear Filters" }))] })) : (_jsx("div", { className: "md-lib-p-4 md-lib-max-h-[calc(100%-161px)] md-lib-overflow-x-auto", children: state.showGrid ? (_jsx(FolderGridView, { folders: filter(folders, (item) => get(item, "type") !== EntityType.FILE), files: _.filter(folders, (item) => get(item, "type") === EntityType.FILE), foldersFetching: isFetching, hasNextPage: !!hasNextPage, fetchNextPage: fetchNextPage, selectedFolderIds: get(selectedItems, "folderIds", []), selectedFileIds: get(selectedItems, "fileIds", []), setSelectedItems: (updateFnOrValue = {}) => setState((prevState) => {
|
|
336
|
+
const prevSelected = prevState.selectedItems;
|
|
337
|
+
return Object.assign(Object.assign({}, prevState), { selectedItems: Object.assign(Object.assign({}, prevSelected), updateFnOrValue) });
|
|
338
|
+
}), isImagePicker: !!pickerFolderId, setSelectedFile: setSelectedFile, setParentFolderId: setParentFolderId, selectedPickerFile: selectedPickerFile, sortBy: sortBy, sortOrder: sortOrder, setSortOrders: (newSortBy, newSortOrder) => setState((prev) => (Object.assign(Object.assign({}, prev), { sortBy: newSortBy, sortOrder: newSortOrder }))), setSelectedKeys: setSelectedKeys })) : (_jsx(FolderListView, { folders: folders, foldersFetching: isFetching, hasNextPage: !!hasNextPage, fetchNextPage: fetchNextPage, selectedFolderIds: get(selectedItems, "folderIds", []), selectedFileIds: get(selectedItems, "fileIds", []), setSelectedItems: (updateFnOrValue = {}) => setState((prevState) => {
|
|
339
|
+
const prevSelected = prevState.selectedItems;
|
|
340
|
+
return Object.assign(Object.assign({}, prevState), { selectedItems: Object.assign(Object.assign({}, prevSelected), updateFnOrValue) });
|
|
341
|
+
}), isImagePicker: !!pickerFolderId, setSelectedFile: setSelectedFile, setParentFolderId: setParentFolderId, selectedPickerFile: selectedPickerFile, location: get(parentFolder, "name"), assets: assets, sortByKey: sortBy, sortOrder: sortOrder, setSortOrders: (newSortBy, newSortOrder) => setState((prev) => (Object.assign(Object.assign({}, prev), { sortBy: newSortBy, sortOrder: newSortOrder }))), onSearch: onSearch, searchKey: searchKey, searchValue: searchValue, metadataKey: metadataKey, metadataValue: metadataValue, setSelectedKeys: setSelectedKeys })) }))] }) }));
|
|
342
|
+
}
|
|
343
|
+
export default DriveContainer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FileEntity, FolderEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function FileDownloadHistory({ open, onClose, file, }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
file: FileEntity | FolderEntity;
|
|
6
|
+
}): JSX.Element;
|
|
7
|
+
export default FileDownloadHistory;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { NotificationStatus, } from "../utilities/constants/interface";
|
|
12
|
+
import { Drawer, Table } from "antd";
|
|
13
|
+
import { CloseOutlined } from "@ant-design/icons";
|
|
14
|
+
import { find, get } from "lodash";
|
|
15
|
+
import { useEffect, useMemo, useState } from "react";
|
|
16
|
+
import { showNotification } from "../common/notifications";
|
|
17
|
+
import moment from "moment-timezone";
|
|
18
|
+
import { RenderAvatar } from "../common/CustomElements";
|
|
19
|
+
import CustomLoader from "../common/loader/CustomLoader";
|
|
20
|
+
import { FETCH_BRAND_URL, FETCH_FILE_DOWNLOAD_LOGS_URL, } from "../utilities/constants/apiUrls";
|
|
21
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
22
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
23
|
+
import { addQueryParams } from "../hocs/helpers";
|
|
24
|
+
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
25
|
+
import { APP_DATE_TIME_FORMAT, DEFAULT_PAGE, LOCAL_TIMEZONE, } from "../hocs/appConstants";
|
|
26
|
+
function FileDownloadHistory({ open, onClose, file, }) {
|
|
27
|
+
const damConfig = useDamConfig();
|
|
28
|
+
const { brand } = damConfig;
|
|
29
|
+
const brandId = get(brand, "_id");
|
|
30
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
31
|
+
const [state, setState] = useState({
|
|
32
|
+
loading: false,
|
|
33
|
+
logs: [],
|
|
34
|
+
currentPage: DEFAULT_PAGE,
|
|
35
|
+
totalCount: 0,
|
|
36
|
+
totalPages: 0,
|
|
37
|
+
brandUsers: [],
|
|
38
|
+
});
|
|
39
|
+
const { logs, currentPage, totalCount, totalPages, loading, brandUsers } = state;
|
|
40
|
+
const onFetchHistory = (...args_1) => __awaiter(this, [...args_1], void 0, function* (params = {}) {
|
|
41
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
42
|
+
try {
|
|
43
|
+
const response = yield api.get(`${FETCH_FILE_DOWNLOAD_LOGS_URL}?${addQueryParams(Object.assign({ accessType: get(file, "type"), accessId: get(file, "_id") }, params))}`);
|
|
44
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false, logs: get(response, "data.downloadActivity", []), totalPages: get(response, "data.totalPages", DEFAULT_PAGE), currentPage: get(response, "data.currentPage", DEFAULT_PAGE), totalCount: get(response, "data.totalCount", DEFAULT_PAGE) })));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
48
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!!get(file, "_id") && !!get(file, "type")) {
|
|
53
|
+
onFetchHistory();
|
|
54
|
+
fetchBrand(brandId);
|
|
55
|
+
}
|
|
56
|
+
}, [file]);
|
|
57
|
+
function fetchBrand(brandId) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
try {
|
|
60
|
+
const response = yield api.get(FETCH_BRAND_URL.replace(":brandId", brandId));
|
|
61
|
+
setState((prevState) => {
|
|
62
|
+
return Object.assign(Object.assign({}, prevState), { brandUsers: Array.isArray(get(response, "data.users"))
|
|
63
|
+
? get(response, "data.users")
|
|
64
|
+
: Array.isArray(get(response, "data"))
|
|
65
|
+
? get(response, "data")
|
|
66
|
+
: [] });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const columns = [
|
|
75
|
+
{
|
|
76
|
+
title: "User",
|
|
77
|
+
dataIndex: "createdBy",
|
|
78
|
+
key: "createdBy",
|
|
79
|
+
render: (createdBy) => {
|
|
80
|
+
const userId = get(createdBy, "_id");
|
|
81
|
+
const userName = get(createdBy, "name", "Unknown User");
|
|
82
|
+
const profileFromApi = get(createdBy, "profilePicture", "");
|
|
83
|
+
const brandUser = userId
|
|
84
|
+
? find(brandUsers, (user) => get(user, "_id") === userId)
|
|
85
|
+
: null;
|
|
86
|
+
const profilePicture = profileFromApi || get(brandUser, "profilePicture", "");
|
|
87
|
+
return (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx(RenderAvatar, { name: userName, profilePicture: profilePicture, size: 30 }), _jsx("span", { className: "md-lib-max-w-[200px] md-lib-truncate", title: userName, children: userName })] }));
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: "Downloaded At",
|
|
92
|
+
dataIndex: "createdAt",
|
|
93
|
+
key: "createdAt",
|
|
94
|
+
render: (createdAt) => moment.utc(createdAt).tz(LOCAL_TIMEZONE).format(APP_DATE_TIME_FORMAT),
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
const fileOrFolderName = get(file, "name", "File/Folder");
|
|
98
|
+
return (_jsx(Drawer, { title: _jsxs("span", { className: "md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-truncate md-lib-block md-lib-max-w-[280px]", title: `${fileOrFolderName} - Download history`, children: [fileOrFolderName, " - Download history"] }), onClose: onClose, open: open, footer: null, closable: true, closeIcon: _jsx(CloseOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-text-lg", "aria-label": "Close" }), children: _jsx(Table, { rowKey: "_id", dataSource: logs, columns: columns, loading: { indicator: _jsx(CustomLoader, {}), spinning: loading }, pagination: totalPages > 1
|
|
99
|
+
? {
|
|
100
|
+
current: currentPage,
|
|
101
|
+
total: totalCount,
|
|
102
|
+
showSizeChanger: false,
|
|
103
|
+
onChange: (page) => onFetchHistory({ page }),
|
|
104
|
+
}
|
|
105
|
+
: false }) }));
|
|
106
|
+
}
|
|
107
|
+
export default FileDownloadHistory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FileEntity, FolderEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function FileMenuOptions({ file, folderIds, fileIds, folder, onCloseSelection, readOnly, fileModal, }: {
|
|
3
|
+
file: (FileEntity & FolderEntity) | null;
|
|
4
|
+
fileIds?: string[];
|
|
5
|
+
folderIds?: string[];
|
|
6
|
+
folder?: FolderEntity | null;
|
|
7
|
+
onCloseSelection?: () => void;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
fileModal?: boolean;
|
|
10
|
+
}): JSX.Element;
|
|
11
|
+
export default FileMenuOptions;
|