Skip to content

Commit f8273f0

Browse files
committed
Merge branch 'main' into feature/browser-vector-type-viz
2 parents c37a838 + 0bd631c commit f8273f0

File tree

25 files changed

+200
-64
lines changed

25 files changed

+200
-64
lines changed

redisinsight/api/config/features-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
"cloudSsoRecommendedSettings": {
5151
"flag": true,
52-
"perc": [[0, 50]],
52+
"perc": [[0, 100]],
5353
"filters": [
5454
{
5555
"name": "config.server.buildType",

redisinsight/api/src/modules/browser/stream/services/stream.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { ClientMetadata } from 'src/common/models';
2929
import { DatabaseClientFactory } from 'src/modules/database/providers/database.client.factory';
3030
import { RedisClient } from 'src/modules/redis/client';
3131
import { checkIfKeyExists, checkIfKeyNotExists } from 'src/modules/browser/utils';
32+
import { convertArrayReplyToObject } from 'src/modules/redis/utils';
3233

3334
@Injectable()
3435
export class StreamService {
@@ -55,10 +56,10 @@ export class StreamService {
5556

5657
await checkIfKeyNotExists(keyName, client);
5758

58-
const info = await client.sendCommand([
59+
const info = convertArrayReplyToObject(await client.sendCommand([
5960
BrowserToolStreamCommands.XInfoStream,
6061
keyName,
61-
]);
62+
]) as string[]);
6263

6364
let entries = [];
6465
if (sortOrder && sortOrder === SortOrder.Asc) {
@@ -71,10 +72,10 @@ export class StreamService {
7172

7273
return plainToClass(GetStreamEntriesResponse, {
7374
keyName,
74-
total: info[1],
75-
lastGeneratedId: info[7].toString(),
76-
firstEntry: StreamService.formatArrayToDto(info[11]),
77-
lastEntry: StreamService.formatArrayToDto(info[13]),
75+
total: info['length'],
76+
lastGeneratedId: info['last-generated-id'].toString(),
77+
firstEntry: StreamService.formatArrayToDto(info['first-entry']),
78+
lastEntry: StreamService.formatArrayToDto(info['last-entry']),
7879
entries,
7980
});
8081
} catch (error) {

redisinsight/api/src/modules/redis/utils/reply.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const convertArrayReplyToObject = (input: string[]): { [key: string]: any
2626
2,
2727
).reduce((prev: any, current: string[]) => {
2828
const [key, value] = current;
29-
return { ...prev, [key.toLowerCase()]: value };
29+
return { ...prev, [key.toString().toLowerCase()]: value };
3030
}, {});
3131

3232
/**

redisinsight/desktop/src/lib/window/browserWindow.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import contextMenu from 'electron-context-menu'
2-
import { BrowserWindow } from 'electron'
2+
import { BrowserWindow, Rectangle } from 'electron'
33
import { v4 as uuidv4 } from 'uuid'
44

55
import { IParsedDeepLink } from 'desktopSrc/lib/app/deep-link.handlers'
66
import { configMain as config } from 'desktopSrc/config'
7-
import { updateTray } from 'desktopSrc/lib'
8-
import { resolveHtmlPath } from 'desktopSrc/utils'
7+
import { electronStore, updateTray } from 'desktopSrc/lib'
8+
import { resolveHtmlPath, getFittedBounds } from 'desktopSrc/utils'
9+
import { ElectronStorageItem } from 'uiSrc/electron/constants'
910
import { initWindowHandlers } from './window.handlers'
1011

1112
export const windows = new Map<string, BrowserWindow>()
@@ -14,6 +15,7 @@ export const focusWindow = (win: BrowserWindow) => {
1415
if (win.isMinimized()) win.restore()
1516
win.focus()
1617
}
18+
export const NEW_WINDOW_OFFSET = 24
1719

1820
export enum WindowType {
1921
Splash = 'splash',
@@ -37,17 +39,26 @@ export const createWindow = async ({
3739
}: ICreateWindow) => {
3840
let x
3941
let y
42+
let { width, height } = options
43+
4044
const currentWindow = BrowserWindow.getFocusedWindow()
45+
const isNewMainWindow = currentWindow && currentWindow?.getTitle() !== config.splashWindow.title
4146

42-
if (currentWindow && currentWindow?.getTitle() !== config.splashWindow.title) {
47+
if (isNewMainWindow) {
4348
const [currentWindowX, currentWindowY] = currentWindow.getPosition()
44-
x = currentWindowX + 24
45-
y = currentWindowY + 24
49+
const [currentWindowWidth, currentWindowHeight] = currentWindow?.getSize()
50+
x = currentWindowX + NEW_WINDOW_OFFSET
51+
y = currentWindowY + NEW_WINDOW_OFFSET
52+
width = currentWindowWidth
53+
height = currentWindowHeight
4654
}
55+
4756
const newWindow: BrowserWindow | null = new BrowserWindow({
4857
...options,
4958
x,
5059
y,
60+
width,
61+
height,
5162
webPreferences: {
5263
...options.webPreferences,
5364
preload: options.preloadPath
@@ -59,6 +70,14 @@ export const createWindow = async ({
5970
return newWindow
6071
}
6172

73+
const savedBounds = electronStore?.get(ElectronStorageItem.bounds)
74+
if (!isNewMainWindow && savedBounds) {
75+
const bounds = getFittedBounds(savedBounds as Rectangle)
76+
if (bounds) {
77+
newWindow.setBounds(bounds)
78+
}
79+
}
80+
6281
newWindow.loadURL(resolveHtmlPath(htmlFileName, options?.parsedDeepLink))
6382

6483
initWindowHandlers(newWindow, prevWindow, windows, id)

redisinsight/desktop/src/lib/window/window.handlers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export const initWindowHandlers = (
5555
})
5656

5757
newWindow.on('close', (event) => {
58+
electronStore?.set(ElectronStorageItem.bounds, newWindow.getNormalBounds())
59+
5860
if (!getIsQuiting() && getDisplayAppInTrayValue() && windows.size === 1) {
5961
event.preventDefault()
6062
newWindow?.hide()

redisinsight/desktop/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './resolveHtmlPath'
22
export * from './wrapErrorSensitiveData'
33
export * from './getAssetPath'
44
export * from './showOrCreateWindow'
5+
export * from './window-size'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Rectangle, screen } from 'electron'
2+
3+
export const getFittedBounds = (bounds: Rectangle): Rectangle | null => {
4+
try {
5+
const options: any = {}
6+
const area = screen.getDisplayMatching(bounds).workArea
7+
8+
if (
9+
bounds.x >= area.x
10+
&& bounds.y >= area.y
11+
&& bounds.x + bounds.width <= area.x + area.width
12+
&& bounds.y + bounds.height <= area.y + area.height
13+
) {
14+
options.x = bounds.x
15+
options.y = bounds.y
16+
} else return null
17+
18+
// If the saved size is still valid, use it.
19+
if (bounds.width <= area.width) {
20+
options.width = bounds.width
21+
} else return null
22+
23+
if (bounds.height <= area.height) {
24+
options.height = bounds.height
25+
} else return null
26+
27+
return options as Rectangle
28+
} catch {
29+
return null
30+
}
31+
}

redisinsight/ui/src/constants/texts.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ export const NoResultsFoundText = (
99
No results found.
1010
</EuiText>
1111
)
12+
13+
export const LoadingText = (
14+
<EuiText size="m" data-testid="loading-keys" style={{ lineHeight: 1.4 }}>
15+
loading...
16+
</EuiText>
17+
)
18+
1219
export const NoSelectedIndexText = (
1320
<EuiText size="m" data-testid="no-result-select-index">
1421
Select an index and enter a query to search per values of keys.

redisinsight/ui/src/electron/constants/storageElectron.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum ElectronStorageItem {
77
updatePreviousVersion = 'updatePreviousVersion',
88
zoomFactor = 'zoomFactor',
99
themeSource = 'themeSource',
10+
bounds = 'bounds'
1011
}
1112

1213
export default ElectronStorageItem

redisinsight/ui/src/pages/browser/components/browser-left-panel/BrowserLeftPanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const BrowserLeftPanel = (props: Props) => {
6767

6868
const isDataLoaded = searchMode === SearchMode.Pattern ? isDataPatternLoaded : isDataRedisearchLoaded
6969
const keysState = searchMode === SearchMode.Pattern ? patternKeysState : redisearchKeysState
70-
const loading = searchMode === SearchMode.Pattern ? patternLoading : redisearchLoading || redisearchListLoading
70+
const loading = searchMode === SearchMode.Pattern ? patternLoading : redisearchLoading
71+
const headerLoading = searchMode === SearchMode.Pattern ? patternLoading : redisearchListLoading
7172
const isSearched = searchMode === SearchMode.Pattern ? patternIsSearched : redisearchIsSearched
7273
const scrollTopPosition = searchMode === SearchMode.Pattern ? scrollPatternTopPosition : scrollRedisearchTopPosition
7374
const commonFilterType = searchMode === SearchMode.Pattern ? filter : keysState.keys?.[0]?.type
@@ -123,7 +124,7 @@ const BrowserLeftPanel = (props: Props) => {
123124
<div className={styles.container}>
124125
<KeysHeader
125126
keysState={keysState}
126-
loading={loading}
127+
loading={headerLoading}
127128
isSearched={isSearched}
128129
loadKeys={loadKeys}
129130
handleScanMoreClick={handleScanMoreClick}

0 commit comments

Comments
 (0)