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
|
name: leafcutter-web
|
||||||
description: A Helm chart for Kubernetes
|
description: A Helm chart for Kubernetes
|
||||||
type: application
|
type: application
|
||||||
version: 0.1.51
|
version: 0.1.53
|
||||||
appVersion: "0.1.51"
|
appVersion: "0.1.53"
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,13 @@ export const VisualizationDetailDialog: FC<VisualizationDetailDialogProps> = ({
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
{!editing && (
|
||||||
|
<Grid item>
|
||||||
|
<Button sx={buttonStyles} onClick={deleteAndClose} size="small">
|
||||||
|
{t("delete")}
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
{editing && (
|
{editing && (
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Button sx={buttonStyles} onClick={saveAndClose} size="small">
|
<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 getCurrentUserIndex = async (email: string) => {
|
||||||
const userIndexName = email.replace(/[\W\d_]/g, "").toLowerCase();
|
const userIndexName = email.replace(/[\W\d_]/g, "").toLowerCase();
|
||||||
const client = createClient();
|
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({
|
const indicesResponse = await client.indices.get({
|
||||||
index: `.kibana_*_${userIndexName}_1`,
|
index: `.kibana_*_${userIndexName}_1`,
|
||||||
})
|
})
|
||||||
const currentUserIndex = Object.keys(indicesResponse.body)[0];
|
const currentUserIndex = Object.keys(indicesResponse.body)[0];
|
||||||
|
|
||||||
return currentUserIndex;
|
return currentUserIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
const getIndexPattern = async (index: string) => {
|
const getIndexPattern = async (index: string) => {
|
||||||
const client = createClient();
|
const client = createClient();
|
||||||
|
|
|
||||||
|
|
@ -181,5 +181,6 @@
|
||||||
"shareDescription": "Externally or internally",
|
"shareDescription": "Externally or internally",
|
||||||
"savedSearch": "Saved Search",
|
"savedSearch": "Saved Search",
|
||||||
"saveCurrentSearch": "Save Current Search",
|
"saveCurrentSearch": "Save Current Search",
|
||||||
"clear": "Clear"
|
"clear": "Clear",
|
||||||
|
"delete": "Delete"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "leafcutter",
|
"name": "leafcutter",
|
||||||
"version": "0.1.51",
|
"version": "0.1.53",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"login": "aws sso login --profile cdr-leafcutter-dashboard-prod-sso",
|
"login": "aws sso login --profile cdr-leafcutter-dashboard-prod-sso",
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
"react-iframe": "^1.8.4",
|
"react-iframe": "^1.8.4",
|
||||||
"react-markdown": "^8.0.3",
|
"react-markdown": "^8.0.3",
|
||||||
"react-polyglot": "^0.7.2",
|
"react-polyglot": "^0.7.2",
|
||||||
|
"sharp": "^0.31.3",
|
||||||
"swr": "^1.3.0",
|
"swr": "^1.3.0",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { AppProps } from "next/app";
|
import { AppProps } from "next/app";
|
||||||
import { SessionProvider } from "next-auth/react";
|
import { SessionProvider } from "next-auth/react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
import Head from "next/head";
|
||||||
import { CssBaseline } from "@mui/material";
|
import { CssBaseline } from "@mui/material";
|
||||||
import { CacheProvider, EmotionCache } from "@emotion/react";
|
import { CacheProvider, EmotionCache } from "@emotion/react";
|
||||||
import { CookiesProvider } from "react-cookie";
|
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 { LocalizationProvider } from "@mui/x-date-pickers-pro";
|
||||||
import { AppProvider } from "components/AppProvider";
|
import { AppProvider } from "components/AppProvider";
|
||||||
import createEmotionCache from "lib/createEmotionCache";
|
import createEmotionCache from "lib/createEmotionCache";
|
||||||
|
import Favicon from "images/favicon.ico";
|
||||||
import en from "locales/en.json";
|
import en from "locales/en.json";
|
||||||
import fr from "locales/fr.json";
|
import fr from "locales/fr.json";
|
||||||
import "@fontsource/poppins/400.css";
|
import "@fontsource/poppins/400.css";
|
||||||
|
|
@ -38,6 +40,10 @@ const LeafcutterWeb = (props: LeafcutterWebProps) => {
|
||||||
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
|
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<link rel="icon" type="image/png" href={Favicon.src} />
|
||||||
|
</Head>
|
||||||
<SessionProvider session={(pageProps as any).session}>
|
<SessionProvider session={(pageProps as any).session}>
|
||||||
<CacheProvider value={emotionCache}>
|
<CacheProvider value={emotionCache}>
|
||||||
<CookiesProvider>
|
<CookiesProvider>
|
||||||
|
|
@ -52,6 +58,7 @@ const LeafcutterWeb = (props: LeafcutterWebProps) => {
|
||||||
</CookiesProvider>
|
</CookiesProvider>
|
||||||
</CacheProvider>
|
</CacheProvider>
|
||||||
</SessionProvider>
|
</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;
|
||||||
55
package-lock.json
generated
55
package-lock.json
generated
|
|
@ -14,7 +14,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"apps/leafcutter": {
|
"apps/leafcutter": {
|
||||||
"version": "0.1.51",
|
"version": "0.1.53",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/cache": "^11.10.3",
|
"@emotion/cache": "^11.10.3",
|
||||||
"@emotion/react": "^11.10.4",
|
"@emotion/react": "^11.10.4",
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
"react-iframe": "^1.8.4",
|
"react-iframe": "^1.8.4",
|
||||||
"react-markdown": "^8.0.3",
|
"react-markdown": "^8.0.3",
|
||||||
"react-polyglot": "^0.7.2",
|
"react-polyglot": "^0.7.2",
|
||||||
|
"sharp": "^0.31.3",
|
||||||
"swr": "^1.3.0",
|
"swr": "^1.3.0",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
|
|
@ -173,6 +174,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/leafcutter/node_modules/lru-cache": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
|
"dependencies": {
|
||||||
|
"yallist": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apps/leafcutter/node_modules/material-ui-popup-state": {
|
"apps/leafcutter/node_modules/material-ui-popup-state": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/material-ui-popup-state/-/material-ui-popup-state-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/material-ui-popup-state/-/material-ui-popup-state-4.1.0.tgz",
|
||||||
|
|
@ -187,6 +199,42 @@
|
||||||
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/leafcutter/node_modules/semver": {
|
||||||
|
"version": "7.3.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
|
||||||
|
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^6.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/leafcutter/node_modules/sharp": {
|
||||||
|
"version": "0.31.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.31.3.tgz",
|
||||||
|
"integrity": "sha512-XcR4+FCLBFKw1bdB+GEhnUNXNXvnt0tDo4WsBsraKymuo/IAuPuCBVAL2wIkUw2r/dwFW5Q5+g66Kwl2dgDFVg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"color": "^4.2.3",
|
||||||
|
"detect-libc": "^2.0.1",
|
||||||
|
"node-addon-api": "^5.0.0",
|
||||||
|
"prebuild-install": "^7.1.1",
|
||||||
|
"semver": "^7.3.8",
|
||||||
|
"simple-get": "^4.0.1",
|
||||||
|
"tar-fs": "^2.1.1",
|
||||||
|
"tunnel-agent": "^0.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.15.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apps/leafcutter/node_modules/swr": {
|
"apps/leafcutter/node_modules/swr": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
@ -194,6 +242,11 @@
|
||||||
"react": "^16.11.0 || ^17.0.0 || ^18.0.0"
|
"react": "^16.11.0 || ^17.0.0 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/leafcutter/node_modules/yallist": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
||||||
|
},
|
||||||
"apps/link": {
|
"apps/link": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue