-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CP-3310][MC] Implement Refresh Functionality for FilesManager Data (…
…by feature key) - proof
- Loading branch information
Showing
13 changed files
with
185 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
libs/device/feature/src/lib/api-features/get-file-manager-data.request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { ResultObject } from "Core/core/builder" | ||
import { ipcRenderer } from "electron-better-ipc" | ||
import { APIFeaturesServiceEvents } from "device/models" | ||
import { DeviceId } from "Core/device/constants/device-id" | ||
import { McFileManagerData } from "generic-view/models" | ||
|
||
export const getFileManagerDataRequest = ( | ||
deviceId: DeviceId | ||
): Promise<ResultObject<McFileManagerData>> => { | ||
return ipcRenderer.callMain(APIFeaturesServiceEvents.GetFileManagerData, { | ||
deviceId, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libs/generic-view/store/src/lib/features/get-file-manager-data.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { createAsyncThunk } from "@reduxjs/toolkit" | ||
import { ReduxRootState } from "Core/__deprecated__/renderer/store" | ||
import { DeviceId } from "Core/device/constants/device-id" | ||
import { selectConfiguredDevice } from "../selectors/select-configured-devices" | ||
import { FeaturesActions } from "./featues-action-keys" | ||
import { getFileManagerDataRequest } from "../../../../../device/feature/src/lib/api-features/get-file-manager-data.request" | ||
import { generateFileManagerData } from "../../../../views/src/lib/file-manager" | ||
|
||
export const getFileManagerData = createAsyncThunk< | ||
{ | ||
deviceId: DeviceId | ||
data: Record<string, unknown> | ||
}, | ||
{ deviceId: DeviceId }, | ||
{ state: ReduxRootState } | ||
>( | ||
FeaturesActions.GetFileManagerData, | ||
async ({ deviceId }, { rejectWithValue, getState }) => { | ||
const apiConfig = selectConfiguredDevice(getState(), deviceId)?.apiConfig | ||
|
||
if (apiConfig === undefined) { | ||
return rejectWithValue("no device") | ||
} | ||
|
||
const features = selectConfiguredDevice(getState(), deviceId)?.features | ||
const fileManagerConfig = features?.["fileManager"]?.config | ||
console.log(fileManagerConfig) | ||
const response = await getFileManagerDataRequest(deviceId) | ||
|
||
if (response.ok) { | ||
return { | ||
deviceId, | ||
data: generateFileManagerData(response.data), | ||
} | ||
} | ||
return rejectWithValue(response.error) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { McFileManagerData } from "generic-view/models" | ||
|
||
export const generateFileManagerData = (data: McFileManagerData) => { | ||
return { | ||
otherFilesListChildProof: { | ||
text: `used space: loading ${data.storageInformation[0].usedSpaceBytes}`, | ||
}, | ||
} | ||
} |