mirror of
https://github.com/gosticks/web.git
synced 2026-12-04 10:11:38 +00:00
Add long term stats support to the top domains table
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { WithNamespaces, withNamespaces } from "react-i18next";
|
||||
import api from "../../util/api";
|
||||
import TopTable from "./TopTable";
|
||||
import i18next from "i18next";
|
||||
import { TimeRangeContext } from "../common/context/TimeRangeContext";
|
||||
|
||||
export interface TopDomainsData {
|
||||
totalQueries: number;
|
||||
@@ -65,7 +66,11 @@ export const generateRows = (t: i18next.TranslationFunction) => (
|
||||
});
|
||||
};
|
||||
|
||||
const TopDomains = ({ t, ...props }: WithNamespaces) => (
|
||||
const TopDomains = ({
|
||||
apiCall,
|
||||
t,
|
||||
...props
|
||||
}: WithNamespaces & { apiCall: () => Promise<ApiTopDomains> }) => (
|
||||
<TopTable
|
||||
{...props}
|
||||
title={t("Top Permitted Domains")}
|
||||
@@ -76,10 +81,25 @@ const TopDomains = ({ t, ...props }: WithNamespaces) => (
|
||||
headers={[t("Domain"), t("Hits"), t("Frequency")]}
|
||||
emptyMessage={t("No Domains Found")}
|
||||
isEmpty={data => data.topDomains.length === 0}
|
||||
apiCall={api.getTopDomains}
|
||||
apiCall={apiCall}
|
||||
apiHandler={transformData}
|
||||
generateRows={generateRows(t)}
|
||||
/>
|
||||
);
|
||||
|
||||
export default withNamespaces(["common", "dashboard"])(TopDomains);
|
||||
const TopDomainsContainer = (props: WithNamespaces) => (
|
||||
<TimeRangeContext.Consumer>
|
||||
{context => (
|
||||
<TopDomains
|
||||
{...props}
|
||||
apiCall={() =>
|
||||
context.range
|
||||
? api.getTopDomainsDb(context.range)
|
||||
: api.getTopDomains()
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</TimeRangeContext.Consumer>
|
||||
);
|
||||
|
||||
export default withNamespaces(["common", "dashboard"])(TopDomainsContainer);
|
||||
|
||||
@@ -71,6 +71,9 @@ export default {
|
||||
getTopDomains(): Promise<ApiTopDomains> {
|
||||
return http.get("stats/top_domains");
|
||||
},
|
||||
getTopDomainsDb(range: TimeRange): Promise<ApiTopDomains> {
|
||||
return http.get("stats/database/top_domains?" + timeRangeToParams(range));
|
||||
},
|
||||
getTopBlocked(): Promise<ApiTopBlocked> {
|
||||
// The API uses a GET parameter to differentiate top domains from top
|
||||
// blocked, but the fake API is not able to handle GET parameters right now.
|
||||
|
||||
Reference in New Issue
Block a user