MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / Statistics

Function Statistics

web/pgadmin/misc/statistics/static/js/Statistics.jsx:130–231  ·  view source on GitHub ↗
({ nodeData, nodeItem, node, treeNodeInfo, isActive, isStale, setIsStale })

Source from the content-addressed store, hash-verified

128}
129
130function Statistics({ nodeData, nodeItem, node, treeNodeInfo, isActive, isStale, setIsStale }) {
131 const [tableData, setTableData] = React.useState([]);
132 const [msg, setMsg] = React.useState('');
133 const [loaderText, setLoaderText] = React.useState('');
134 const [columns, setColumns] = React.useState([
135 {
136 header: 'Statictics',
137 accessorKey: 'name',
138 enableSorting: true,
139 enableResizing: true,
140 enableFilters: true,
141 },
142 {
143 header: 'Value',
144 accessorKey: 'value',
145 enableSorting: true,
146 enableResizing: true,
147 enableFilters: true,
148 },
149 ]);
150 const pgAdmin = usePgAdmin();
151
152 useEffect(() => {
153 if(!isStale || !isActive) {
154 return;
155 }
156
157 let url,
158 message = gettext('Please select an object in the tree view.');
159
160 if (node) {
161 url = getURL(nodeData, true, treeNodeInfo, node, nodeItem, 'stats');
162
163 message = gettext('No statistics are available for the selected object.');
164
165 const api = getApiInstance();
166 if (node.hasStatistics) {
167 setLoaderText('Loading...');
168 api({
169 url: url,
170 type: 'GET',
171 })
172 .then((res) => {
173 let [nodeStats, colData] = getTableData(res, node);
174 setTableData(nodeStats);
175 if (!_.isUndefined(colData)) {
176 setColumns(colData);
177 }
178 setLoaderText('');
179 })
180 .catch((err) => {
181 // show failed message.
182 setLoaderText('');
183
184 if (err?.response?.data?.info == 'CRYPTKEY_MISSING') {
185 pgAdmin.Browser.notifier.pgNotifier('error', err.request, 'The master password is not set', function(mesg) {
186 setTimeout(function() {
187 if (mesg == 'CRYPTKEY_SET') {

Callers

nothing calls this directly

Calls 9

usePgAdminFunction · 0.90
getURLFunction · 0.90
parseApiErrorFunction · 0.90
gettextFunction · 0.85
getApiInstanceFunction · 0.85
setLoaderTextFunction · 0.85
getTableDataFunction · 0.85
pgNotifierMethod · 0.80
alertTextMethod · 0.80

Tested by

no test coverage detected