Skip to content

Commit

Permalink
Fjern familie historikk (#1760)
Browse files Browse the repository at this point in the history
* Gå mot tilbake for å hente historikk

* Fjern config for familie-historikk

---------

Co-authored-by: Uy Quang Nguyen <uy.quang.nguyen@nav.no>
Co-authored-by: Uy Nguyen <110383605+UyQuangNguyen@users.noreply.github.com>
  • Loading branch information
3 people committed May 9, 2024
1 parent 9f61d4b commit 264dc6c
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 101 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Saksbehandlerapplikasjon for tilbakekreving av ytelsene barnetrygd, konstantstø
* Starte dev-server `yarn start:dev`
* Åpne `http://localhost:8000` i nettleseren din

Med default miljøvariabler krever appen at applikasjonene [familie-tilbake](https://github.com/navikt/familie-tilbake) og [familie-historikk](https://github.com/navikt/familie-historikk) kjører lokalt.
For å generere testdata må du kjøre `familie-tilbake`, `familie-historikk` og kjøre en test i [familie-tilbake-e2e](https://github.com/navikt/familie-tilbake-e2e)
Med default miljøvariabler krever appen at applikasjonen [familie-tilbake](https://github.com/navikt/familie-tilbake) kjører lokalt.
For å generere testdata må du kjøre `familie-tilbake` og kjøre en test i [familie-tilbake-e2e](https://github.com/navikt/familie-tilbake-e2e)

## Miljøvariabler

Expand Down
3 changes: 0 additions & 3 deletions build_n_deploy/naiserator/naiserator_dev_gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ spec:
outbound:
rules:
- application: familie-tilbake
- application: familie-historikk
env:
- name: ENV
value: preprod
- name: APP_VERSION
value: {{ VERSION }}
- name: TILBAKE_SCOPE
value: api://dev-gcp.teamfamilie.familie-tilbake/.default
- name: FAMILIE_HISTORIKK_CLIENT_ID
value: dev-gcp.teamfamilie.familie-historikk
envFrom:
- secret: familie-tilbake-frontend
resources:
Expand Down
3 changes: 0 additions & 3 deletions build_n_deploy/naiserator/naiserator_prod_gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ spec:
outbound:
rules:
- application: familie-tilbake
- application: familie-historikk
env:
- name: ENV
value: production
- name: APP_VERSION
value: {{ VERSION }}
- name: TILBAKE_SCOPE
value: api://prod-gcp.teamfamilie.familie-tilbake/.default
- name: FAMILIE_HISTORIKK_CLIENT_ID
value: prod-gcp.teamfamilie.familie-historikk
envFrom:
- secret: familie-tilbake-frontend
resources:
Expand Down
6 changes: 1 addition & 5 deletions hent-og-lagre-miljøvariabler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ function get_secrets() {
}

TILBAKE_FRONTEND_LOKAL_SECRETS=$(get_secrets azuread-familie-tilbake-frontend-lokal)
HISTORIKK_LOKAL_SECRETS=$(get_secrets azuread-familie-historikk-lokal)

TILBAKE_FRONTEND_CLIENT_ID=$(echo "$TILBAKE_FRONTEND_LOKAL_SECRETS" | jq -r '.AZURE_APP_CLIENT_ID')
TILBAKE_FRONTEND_CLIENT_SECRET=$(echo "$TILBAKE_FRONTEND_LOKAL_SECRETS" | jq -r '.AZURE_APP_CLIENT_SECRET')

HISTORIKK_CLIENT_ID=$(echo "$HISTORIKK_LOKAL_SECRETS" | jq -r '.AZURE_APP_CLIENT_ID')

# Generate random 32 character strings for the cookie and session keys
COOKIE_KEY1=$(openssl rand -hex 16)
COOKIE_KEY2=$(openssl rand -hex 16)
Expand All @@ -34,15 +31,14 @@ SESSION_SECRET='$SESSION_SECRET'
CLIENT_ID='$TILBAKE_FRONTEND_CLIENT_ID'
CLIENT_SECRET='$TILBAKE_FRONTEND_CLIENT_SECRET'
FAMILIE_TILBAKE_CLIENT_ID=$TILBAKE_CLIENT_ID
# Lokalt
ENV=local
FAMILIE_HISTORIKK_CLIENT_ID=$HISTORIKK_CLIENT_ID
TILBAKE_SCOPE=api://dev-gcp.teamfamilie.familie-tilbake-lokal/.default
# Lokalt mot preprod
#ENV=lokalt-mot-preprod
#FAMILIE_HISTORIKK_CLIENT_ID=dev-gcp.teamfamilie.familie-historikk
#TILBAKE_SCOPE=api://dev-gcp.teamfamilie.familie-tilbake/.default
APP_VERSION=0.0.1
Expand Down
14 changes: 0 additions & 14 deletions src/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const Environment = () => {
buildPath: 'frontend_development',
namespace: 'local',
proxyUrl: 'http://localhost:8030/api',
historikkUrl: 'http://localhost:8050/api',
baSakUrl: 'http://localhost:8001',
efSakUrl: 'http://localhost:8002/ekstern',
ksSakUrl: 'http://localhost:8003',
Expand All @@ -18,7 +17,6 @@ const Environment = () => {
buildPath: 'frontend_production',
namespace: 'e2e',
proxyUrl: 'http://familie-tilbake:8030/api',
historikkUrl: 'http://familie-historikk:8050/api',
baSakUrl: 'http://familie-ba-sak-frontend:8000',
efSakUrl: 'http://familie-ef-sak-frontend:8000/ekstern',
ksSakUrl: 'http://familie-ks-sak-frontend:8000',
Expand All @@ -28,7 +26,6 @@ const Environment = () => {
buildPath: 'frontend_production',
namespace: 'preprod',
proxyUrl: 'http://familie-tilbake/api',
historikkUrl: 'http://familie-historikk/api',
baSakUrl: 'https://barnetrygd.intern.dev.nav.no',
efSakUrl: 'https://ensligmorellerfar.intern.dev.nav.no/ekstern',
ksSakUrl: 'https://kontantstotte.intern.dev.nav.no',
Expand All @@ -49,7 +46,6 @@ const Environment = () => {
buildPath: 'frontend_production',
namespace: 'production',
proxyUrl: 'http://familie-tilbake/api',
historikkUrl: 'http://familie-historikk/api',
baSakUrl: 'https://barnetrygd.intern.nav.no',
efSakUrl: 'https://ensligmorellerfar.intern.nav.no/ekstern',
ksSakUrl: 'https://kontantstotte.intern.nav.no',
Expand All @@ -75,23 +71,13 @@ if (!process.env.TILBAKE_SCOPE) {
throw new Error('Scope mot familie-tilbake er ikke konfigurert');
}

if (!process.env.FAMILIE_HISTORIKK_CLIENT_ID) {
throw new Error('Konfig mot familie-historikk er ikke konfigurert');
}

export const oboTilbakeConfig: IApi = {
clientId: appConfig.clientId,
scopes: [process.env.TILBAKE_SCOPE],
};

export const oboHistorikkConfig: IApi = {
clientId: process.env.FAMILIE_HISTORIKK_CLIENT_ID,
scopes: [],
};

export const buildPath = env.buildPath;
export const proxyUrl = env.proxyUrl;
export const historikkUrl = env.historikkUrl;
export const namespace = env.namespace;

export const redirectRecords: Record<string, string> = {
Expand Down
23 changes: 1 addition & 22 deletions src/backend/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createProxyMiddleware } from 'http-proxy-middleware';
import { Client, getOnBehalfOfAccessToken, IApi } from '@navikt/familie-backend';
import { stdoutLogger } from '@navikt/familie-logging';

import { proxyUrl, historikkUrl, redirectRecords } from './config';
import { proxyUrl, redirectRecords } from './config';

const restream = (proxyReq: ClientRequest, req: IncomingMessage, _res: OutgoingMessage): void => {
const requestBody = (req as Request).body;
Expand Down Expand Up @@ -44,27 +44,6 @@ export const doRedirectProxy = () => {
};
};

// eslint-disable-next-line
export const doHistorikkApiProxy: any = () => {
return createProxyMiddleware({
changeOrigin: true,
on: { proxyReq: restream },
secure: true,
target: `${historikkUrl}`,
logger: stdoutLogger,
});
};

// eslint-disable-next-line
export const doHistorikkStreamProxy: any = () => {
return createProxyMiddleware({
changeOrigin: true,
secure: true,
target: `${historikkUrl}`,
logger: stdoutLogger,
});
};

export const attachToken = (authClient: Client, oboConfig: IApi) => {
return async (req: Request, _res: Response, next: NextFunction) => {
getOnBehalfOfAccessToken(authClient, req, oboConfig).then((accessToken: string) => {
Expand Down
23 changes: 2 additions & 21 deletions src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ import webpackHotMiddleware from 'webpack-hot-middleware';
import backend, { IApp, ensureAuthenticated, envVar } from '@navikt/familie-backend';
import { logInfo } from '@navikt/familie-logging';

import { oboHistorikkConfig, oboTilbakeConfig, sessionConfig } from './config';
import { oboTilbakeConfig, sessionConfig } from './config';
import { prometheusTellere } from './metrikker';
import {
attachToken,
doHistorikkApiProxy,
doHistorikkStreamProxy,
doProxy,
doRedirectProxy,
} from './proxy';
import { attachToken, doProxy, doRedirectProxy } from './proxy';
import setupRouter from './router';
import config from '../webpack/webpack.dev';

Expand Down Expand Up @@ -50,19 +44,6 @@ backend(sessionConfig, prometheusTellere).then(({ app, azureAuthClient, router }
next();
});

app.use(
'/familie-historikk/stream',
ensureAuthenticated(azureAuthClient, true),
attachToken(azureAuthClient, oboHistorikkConfig),
doHistorikkStreamProxy()
);
app.use(
'/familie-historikk/api',
ensureAuthenticated(azureAuthClient, true),
attachToken(azureAuthClient, oboHistorikkConfig),
doHistorikkApiProxy()
);

app.use(
'/familie-tilbake/api',
ensureAuthenticated(azureAuthClient, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { IHistorikkInnslag } from '../../../../typer/historikk';
import { ISide } from '../../../Felleskomponenter/Venstremeny/sider';
import { Menysider } from '../Menykontainer';

const APPLIKASJON = 'FAMILIE_TILBAKE';

interface IProps {
behandling: IBehandling;
fagsak: IFagsak;
Expand All @@ -30,31 +28,14 @@ const [HistorikkProvider, useHistorikk] = createUseContext(
useEffect(() => {
if (valgtMenyside === Menysider.HISTORIKK) {
hentHistorikkinnslag();

// const eventSource = new EventSource(
// `/familie-historikk/stream/historikk/stream/applikasjon/${APPLIKASJON}/behandling/${behandling.eksternBrukId}`,
// { withCredentials: true }
// );
// eventSource.onmessage = e => {
// const newFluxData = fluxData;
// const newData: IHistorikkInnslag = JSON.parse(e.data);
// console.log('ny flux ', newData);
// newFluxData.unshift(newData);
// settFluxData(newFluxData);
// settNonUsedKey(Date.now().toString());
// };

// return () => {
// eventSource.close();
// };
}
}, [behandling, valgtMenyside]);

const hentHistorikkinnslag = (): void => {
settHistorikkInnslag(byggHenterRessurs());
request<void, IHistorikkInnslag[]>({
method: 'GET',
url: `/familie-historikk/api/historikk/applikasjon/${APPLIKASJON}/behandling/${behandling.eksternBrukId}`,
url: `/familie-tilbake/api/behandlinger/${behandling.behandlingId}/historikk`,
})
.then((hentetHistorikk: Ressurs<IHistorikkInnslag[]>) => {
settHistorikkInnslag(hentetHistorikk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Behandlingssteg } from '../../../../typer/behandling';
import {
Aktør,
aktører,
applikasjoner,
Historikkinnslagstype,
IHistorikkInnslag,
} from '../../../../typer/historikk';
Expand Down Expand Up @@ -120,7 +119,7 @@ const HistorikkInnslag: React.FC<IProps> = ({ innslag }) => {
<Detail>
{`${formatterDatoOgTidstring(innslag.opprettetTid)} | `}
{innslag.aktør === Aktør.VEDTAKSLØSNING
? applikasjoner[innslag.applikasjon]
? 'System'
: `${innslag.aktørIdent.toLocaleLowerCase()} (${aktører[
innslag.aktør
].toLocaleLowerCase()})`}
Expand Down
9 changes: 0 additions & 9 deletions src/frontend/typer/historikk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ export enum Historikkinnslagstype {
BREV = 'BREV',
}

export enum Applikasjon {
FAMILIE_TILBAKE = 'FAMILIE_TILBAKE',
}

export const applikasjoner: Record<Applikasjon, string> = {
FAMILIE_TILBAKE: 'familie-tilbake',
};

export interface IHistorikkInnslag {
behandlingId?: string;
applikasjon: Applikasjon;
aktør: Aktør;
aktørIdent: string;
tittel: string;
Expand Down

0 comments on commit 264dc6c

Please sign in to comment.