WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7a5eb8f

Browse files
committed
ui
1 parent fba6f90 commit 7a5eb8f

File tree

6 files changed

+108
-127
lines changed

6 files changed

+108
-127
lines changed

agent/agent-pull-stub.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
$phpFileContent = '<?php $a=md5("' . str_repeat('4', 200) . '");';
1313

1414
for ($i = 0; $i < 200; $i++) {
15-
$path = sys_get_temp_dir() . '/opcache-dashboard-' . $i . '.php';
15+
$postfix = ($i % 10 === 1) ? '-' . str_repeat('42', 50) . '-' : '';
16+
17+
$path = sys_get_temp_dir() . '/opcache-dashboard-' . $i . $postfix . '.php';
1618

1719
if (!file_exists($path)) {
1820
file_put_contents($path, $phpFileContent);

ui/assets/components/pages/ScriptsPage.tsx

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import React from 'react';
22
import { connect } from 'react-redux';
3-
import { DataGrid, ValueGetterParams } from '@material-ui/data-grid';
3+
import MaterialTable from 'material-table';
44
import {DateTime} from 'luxon';
55
import prettyBytes from 'pretty-bytes';
66
import { Paper } from '@material-ui/core';
7-
import { makeStyles } from '@material-ui/core/styles';
8-
9-
const useStyles = makeStyles((theme) => ({
10-
dataGridRoot: {
11-
'& .MuiDataGrid-cell': {
12-
fontSize: '0.9em',
7+
import { createStyles, makeStyles, Theme } from '@material-ui/core';
8+
9+
const useStyles = makeStyles((theme: Theme) =>
10+
createStyles({
11+
dataGridRoot: {
12+
border: '1px solid red',
13+
background: 'red',
14+
'& .MuiTableCell-body': {
15+
padding: '6px 16px',
16+
fontSize: '0.8em',
17+
background: 'red',
18+
},
1319
},
14-
},
15-
}));
20+
}),
21+
);
1622

1723
const mapStateToProps = (state: Object) => {
1824
return {
@@ -69,75 +75,75 @@ const buildScriptAggregatedStatus = function(clusterOpcacheStatuses): Array<Obje
6975
return Object.values(scriptAggregatedStatus);
7076
}
7177

72-
function ScriptsDataGrid(props)
73-
{
78+
function ScriptsMaterialTable(props) {
7479
const columns = [
7580
{
7681
field: 'script',
77-
headerName: 'Script',
82+
title: 'Script',
7883
sortable: true,
79-
flex: 1,
8084
},
8185
{
8286
field: 'hits',
83-
headerName: 'Hits',
87+
title: 'Hits',
8488
sortable: true,
85-
width: 90,
86-
hide: false,
87-
type: 'number',
89+
headerStyle: {
90+
width: "90px",
91+
},
92+
hidden: false,
93+
type: 'numeric',
8894
},
8995
{
9096
field: 'memoryHumanReadable',
91-
headerName: 'Size',
97+
title: 'Size',
9298
sortable: true,
93-
width: 85,
94-
valueGetter: (params: ValueGetterParams) => {
95-
return prettyBytes(params.getValue('memory'));
99+
headerStyle: {
100+
width: "85px",
101+
},
102+
render: (row) => {
103+
return prettyBytes(row.memory);
96104
},
97-
hide: false,
98-
type: 'number',
105+
customSort: (a, b) => a.memory - b.memory,
106+
hidden: false,
99107
},
100108
{
101109
field: 'lastUsedDate',
102-
headerName: 'Last used',
110+
title: 'Last used',
103111
sortable: true,
104-
width: 170,
105-
valueGetter: (params: ValueGetterParams) => {
106-
return formatTime(params.getValue('lastUsedTimestamp'));
112+
headerStyle: {
113+
width: "170x"
107114
},
108-
hide: false,
109-
type: 'dateTime',
110-
},
111-
{
112-
field: 'createDate',
113-
headerName: 'Created',
114-
sortable: true,
115-
width: 170,
116-
valueGetter: (params: ValueGetterParams) => {
117-
return formatTime(params.getValue('createTimestamp'));
115+
render: (row) => {
116+
return formatTime(row.lastUsedTimestamp);
118117
},
119-
type: 'dateTime',
120-
hide: true,
121-
},
118+
customSort: (a, b) => a.lastUsedTimestamp - b.lastUsedTimestamp,
119+
hidden: false,
120+
type: 'datetime',
121+
}
122122
];
123123

124124
return (
125-
<DataGrid
126-
rows={props.rows}
125+
<MaterialTable
126+
title=""
127+
options={{
128+
search: true,
129+
sorting: true,
130+
pageSize: 100,
131+
pageSizeOptions: [20, 50, 100],
132+
rowStyle: {
133+
fontSize: '0.8em',
134+
},
135+
padding: "dense",
136+
tableLayout: "auto"
137+
}}
127138
columns={columns}
128-
autoHeight="true"
129-
autoPageSize="true"
130-
density="compact"
131-
className={props.className}
132-
></DataGrid>
139+
data={props.rows}
140+
></MaterialTable>
133141
);
134142
}
135143

136-
function ScriptsMaterialTable(props) {
137-
138-
}
139-
140144
function ScriptsPageComponent(props: Object) {
145+
const classes = useStyles();
146+
141147
if (props.selectedClusterName === null) {
142148
return <div>Loading</div>
143149
}
@@ -146,12 +152,8 @@ function ScriptsPageComponent(props: Object) {
146152
return <div>No scripts found</div>
147153
}
148154

149-
const classes = useStyles();
150-
151155
return <div style={{ minHeight: '400px', width: '100%' }}>
152-
<Paper>
153-
<ScriptsDataGrid rows={props.scriptAggregatedStatus} className={classes.dataGridRoot}></ScriptsDataGrid>
154-
</Paper>
156+
<ScriptsMaterialTable rows={props.scriptAggregatedStatus} className={classes.dataGridRoot}></ScriptsMaterialTable>
155157
</div>
156158
}
157159

ui/assets/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
1818
"@babel/plugin-syntax-import-meta": "^7.10.4",
1919
"@babel/preset-env": "^7.12.16",
20-
"@babel/preset-flow": "^7.12.13",
2120
"@babel/preset-react": "^7.12.13",
21+
"@babel/preset-typescript": "^7.13.0",
2222
"@material-ui/core": "^4.11.3",
23-
"@material-ui/data-grid": "^4.0.0-alpha.20",
2423
"@material-ui/icons": "^4.11.2",
2524
"@material-ui/lab": "^4.0.0-alpha.57",
2625
"babel-loader": "^8.2.2",
@@ -43,7 +42,7 @@
4342
"redux-thunk": "^2.3.0",
4443
"sass-loader": "^11.0.1",
4544
"style-loader": "^0.21.0",
46-
"typescript": "^4.1.5",
45+
"typescript": "^4.2.3",
4746
"webpack": "^5.22",
4847
"webpack-cli": "^4.5.0",
4948
"webpack-dev-server": "^3.11.2"

ui/assets/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"skipLibCheck": true,
1111
"esModuleInterop": true,
1212
"allowSyntheticDefaultImports": true,
13-
"strict": true,
13+
"strict": false,
1414
"forceConsistentCasingInFileNames": true,
1515
"module": "esnext",
1616
"moduleResolution": "node",

ui/assets/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ module.exports = {
7777
},
7878
],
7979
'@babel/preset-react',
80+
[
81+
"@babel/preset-typescript",
82+
{ isTSX: true, allExtensions: true }
83+
]
8084
],
8185
plugins: [
8286
'@babel/plugin-syntax-dynamic-import',

0 commit comments

Comments
 (0)