Add updated Leafcutter app
This commit is contained in:
parent
60f6061d49
commit
38343f4219
10 changed files with 3391 additions and 20 deletions
|
|
@ -2,5 +2,5 @@ apiVersion: v2
|
|||
name: leafcutter-web
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.51
|
||||
appVersion: "0.1.51"
|
||||
version: 0.1.53
|
||||
appVersion: "0.1.53"
|
||||
|
|
|
|||
|
|
@ -127,6 +127,13 @@ export const VisualizationDetailDialog: FC<VisualizationDetailDialogProps> = ({
|
|||
</Button>
|
||||
</Grid>
|
||||
)}
|
||||
{!editing && (
|
||||
<Grid item>
|
||||
<Button sx={buttonStyles} onClick={deleteAndClose} size="small">
|
||||
{t("delete")}
|
||||
</Button>
|
||||
</Grid>
|
||||
)}
|
||||
{editing && (
|
||||
<Grid item>
|
||||
<Button sx={buttonStyles} onClick={saveAndClose} size="small">
|
||||
|
|
|
|||
3239
apps/leafcutter/config/unRegions.json
Normal file
3239
apps/leafcutter/config/unRegions.json
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 72 KiB |
|
|
@ -119,12 +119,22 @@ export const saveUserMetadata = async (username: string, metadata: any) => {
|
|||
const getCurrentUserIndex = async (email: string) => {
|
||||
const userIndexName = email.replace(/[\W\d_]/g, "").toLowerCase();
|
||||
const client = createClient();
|
||||
const aliasesResponse = await client.indices.getAlias({
|
||||
name: `.kibana_*_${userIndexName}`,
|
||||
});
|
||||
|
||||
// prefer alias if it exists
|
||||
if (Object.keys(aliasesResponse.body).length > 0) {
|
||||
return Object.keys(aliasesResponse.body)[0];
|
||||
}
|
||||
|
||||
const indicesResponse = await client.indices.get({
|
||||
index: `.kibana_*_${userIndexName}_1`,
|
||||
})
|
||||
const currentUserIndex = Object.keys(indicesResponse.body)[0];
|
||||
|
||||
return currentUserIndex;
|
||||
};
|
||||
}
|
||||
|
||||
const getIndexPattern = async (index: string) => {
|
||||
const client = createClient();
|
||||
|
|
|
|||
|
|
@ -181,5 +181,6 @@
|
|||
"shareDescription": "Externally or internally",
|
||||
"savedSearch": "Saved Search",
|
||||
"saveCurrentSearch": "Save Current Search",
|
||||
"clear": "Clear"
|
||||
"clear": "Clear",
|
||||
"delete": "Delete"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "leafcutter",
|
||||
"version": "0.1.51",
|
||||
"version": "0.1.53",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"login": "aws sso login --profile cdr-leafcutter-dashboard-prod-sso",
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
"react-iframe": "^1.8.4",
|
||||
"react-markdown": "^8.0.3",
|
||||
"react-polyglot": "^0.7.2",
|
||||
"sharp": "^0.31.3",
|
||||
"swr": "^1.3.0",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import { AppProps } from "next/app";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
import Head from "next/head";
|
||||
import { CssBaseline } from "@mui/material";
|
||||
import { CacheProvider, EmotionCache } from "@emotion/react";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
|
|
@ -10,6 +11,7 @@ import { AdapterDateFns } from "@mui/x-date-pickers-pro/AdapterDateFns";
|
|||
import { LocalizationProvider } from "@mui/x-date-pickers-pro";
|
||||
import { AppProvider } from "components/AppProvider";
|
||||
import createEmotionCache from "lib/createEmotionCache";
|
||||
import Favicon from "images/favicon.ico";
|
||||
import en from "locales/en.json";
|
||||
import fr from "locales/fr.json";
|
||||
import "@fontsource/poppins/400.css";
|
||||
|
|
@ -38,20 +40,25 @@ const LeafcutterWeb = (props: LeafcutterWebProps) => {
|
|||
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
|
||||
|
||||
return (
|
||||
<SessionProvider session={(pageProps as any).session}>
|
||||
<CacheProvider value={emotionCache}>
|
||||
<CookiesProvider>
|
||||
<CssBaseline />
|
||||
<AppProvider>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<I18n locale={locale} messages={messages[locale]}>
|
||||
<Component {...pageProps} />
|
||||
</I18n>
|
||||
</LocalizationProvider>
|
||||
</AppProvider>
|
||||
</CookiesProvider>
|
||||
</CacheProvider>
|
||||
</SessionProvider>
|
||||
<>
|
||||
<Head>
|
||||
<link rel="icon" type="image/png" href={Favicon.src} />
|
||||
</Head>
|
||||
<SessionProvider session={(pageProps as any).session}>
|
||||
<CacheProvider value={emotionCache}>
|
||||
<CookiesProvider>
|
||||
<CssBaseline />
|
||||
<AppProvider>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<I18n locale={locale} messages={messages[locale]}>
|
||||
<Component {...pageProps} />
|
||||
</I18n>
|
||||
</LocalizationProvider>
|
||||
</AppProvider>
|
||||
</CookiesProvider>
|
||||
</CacheProvider>
|
||||
</SessionProvider>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
53
apps/leafcutter/pages/api/upload/index.ts
Normal file
53
apps/leafcutter/pages/api/upload/index.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* eslint-disable no-restricted-syntax */
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { Client } from "@opensearch-project/opensearch";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import taxonomy from "config/taxonomy.json";
|
||||
import unRegions from "config/unRegions.json";
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { headers: { authorization }, body: { tickets } } = req;
|
||||
const baseURL = `https://${process.env.OPENSEARCH_URL}`;
|
||||
const client = new Client({
|
||||
node: baseURL,
|
||||
ssl: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
headers: {
|
||||
authorization
|
||||
}
|
||||
});
|
||||
|
||||
const succeeded = [];
|
||||
const failed = [];
|
||||
|
||||
for await (const ticket of tickets) {
|
||||
const { id } = ticket;
|
||||
try {
|
||||
const country = ticket.country[0] ?? "none";
|
||||
const translatedCountry = taxonomy.country[country]?.display ?? "none";
|
||||
const countryDetails = unRegions.find((c) => c.name === translatedCountry);
|
||||
const augmentedTicket = {
|
||||
...ticket,
|
||||
region: countryDetails['sub-region']?.toLowerCase().replace(" ", "-") ?? null,
|
||||
continent: countryDetails.region?.toLowerCase().replace(" ", "-") ?? null,
|
||||
}
|
||||
const out = await client.create({
|
||||
id: uuid(),
|
||||
index: "sample_tagged_tickets",
|
||||
refresh: true,
|
||||
body: augmentedTicket,
|
||||
});
|
||||
console.log(out);
|
||||
succeeded.push(id);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
failed.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
const results = { succeeded, failed };
|
||||
return res.json(results)
|
||||
};
|
||||
|
||||
export default handler;
|
||||
Loading…
Add table
Add a link
Reference in a new issue