@@ -7,7 +7,9 @@ import React, { useEffect, useState } from "react";
77import { useDispatch , useSelector } from "react-redux" ;
88import { fetchCommonSettings , setCommonSettings } from "redux/reduxActions/commonSettingsActions" ;
99import { getCommonSettings } from "redux/selectors/commonSettingSelectors" ;
10+ import { fetchAPIUsageAction , fetchLastMonthAPIUsageAction } from "redux/reduxActions/orgActions" ;
1011import { getUser } from "redux/selectors/usersSelectors" ;
12+ import { getOrgApiUsage , getOrgLastMonthApiUsage } from "redux/selectors/orgSelectors" ;
1113import styled from "styled-components" ;
1214import { useShallowEqualSelector } from "util/hooks" ;
1315import { Level1SettingPageContent , Level1SettingPageTitle } from "../styled" ;
@@ -24,6 +26,7 @@ import { getGlobalSettings } from "comps/utils/globalSettings";
2426import { fetchJSLibrary } from "util/jsLibraryUtils" ;
2527import { evalFunc } from "lowcoder-core" ;
2628import { messageInstance } from "lowcoder-design" ;
29+ import Api from "@lowcoder-ee/api/api" ;
2730
2831const AdvancedSettingContent = styled . div `
2932 max-width: 840px;
@@ -76,6 +79,16 @@ export function AdvancedSetting() {
7679 label : app . name ,
7780 } ) ) ;
7881
82+ const apiUsage = useSelector ( getOrgApiUsage ) ;
83+ useEffect ( ( ) => {
84+ dispatch ( fetchAPIUsageAction ( currentUser . currentOrgId ) ) ;
85+ } , [ currentUser . currentOrgId ] )
86+
87+ const lastMonthApiUsage = useSelector ( getOrgLastMonthApiUsage ) ;
88+ useEffect ( ( ) => {
89+ dispatch ( fetchLastMonthAPIUsageAction ( currentUser . currentOrgId ) ) ;
90+ } , [ currentUser . currentOrgId ] )
91+
7992 useEffect ( ( ) => {
8093 dispatch ( fetchCommonSettings ( { orgId : currentUser . currentOrgId } ) ) ;
8194 dispatch ( fetchAllApplications ( { } ) ) ;
@@ -118,8 +131,8 @@ export function AdvancedSetting() {
118131
119132 const isNotChange = JSON . stringify ( commonSettings ) === JSON . stringify ( settings ) ;
120133 const extraAdvanceSettings = useExtraAdvanceSettings ( ) ;
121-
122134 const runJSInHost = getGlobalSettings ( ) . orgCommonSettings ?. runJavaScriptInHost ?? false ;
135+
123136 return (
124137 < Level1SettingPageContent >
125138 < Prompt
@@ -262,6 +275,12 @@ export function AdvancedSetting() {
262275 ) }
263276 </ div >
264277 { extraAdvanceSettings }
278+ < div className = "section-title" > { trans ( "advanced.APIConsumption" ) } </ div >
279+ < HelpText style = { { marginBottom : 12 } } > { trans ( "advanced.APIConsumptionDescription" ) } </ HelpText >
280+ < div className = "section-content" >
281+ { trans ( "advanced.overallAPIConsumption" ) } : { apiUsage ? Intl . NumberFormat ( 'en-GB' , { maximumFractionDigits : 2 } ) . format ( apiUsage ) + " API Calls." : 'Loading API usage data...' } < br />
282+ { trans ( "advanced.lastMonthAPIConsumption" ) } : { lastMonthApiUsage ? Intl . NumberFormat ( 'en-GB' , { maximumFractionDigits : 2 } ) . format ( lastMonthApiUsage ) + " API Calls." : 'Loading API usage data...' }
283+ </ div >
265284 </ AdvancedSettingContent >
266285 </ Level1SettingPageContent >
267286 ) ;
0 commit comments