Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana Link and Namespace Fix #140

Merged
merged 7 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ jobs:
EXTERNAL_URL:
value: 'https://api-services-portal-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}.apps.silver.devops.gov.bc.ca'
NEXT_PUBLIC_API_ROOT:
value: 'https://api-services-portal-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}.apps.silver.devops.gov.bc.ca'
value: 'https://api-services-portal-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}.apps.silver.devops.gov.bc.ca'
NEXT_PUBLIC_GRAFANA_URL:
value: 'https://grafana-apps-gov-bc-ca.dev.api.gov.bc.ca'
GWA_API_URL:
value: 'https://gwa-api-gov-bc-ca.dev.api.gov.bc.ca'
GWA_RES_SVR_CLIENT_ID:
Expand Down
6 changes: 2 additions & 4 deletions src/auth/auth-oauth2-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ class Oauth2ProxyAuthStrategy {
const name = oauthUser['name'];
const email = oauthUser['email'];
const username = oauthUser['preferred_username'];
const namespace = oauthUser['namespace'];
const groups = JSON.stringify(oauthUser['groups']);
const _roles = [];
const clientId = process.env.GWA_RES_SVR_CLIENT_ID;
Expand Down Expand Up @@ -342,8 +341,8 @@ class Oauth2ProxyAuthStrategy {
logger.debug('Temporary Credential NOT FOUND - CREATING AUTOMATICALLY');
const { errors } = await this.keystone.executeGraphQL({
context: this.keystone.createContext({ skipAccessControl: true }),
query: `mutation ($jti: String, $sub: String, $name: String, $email: String, $username: String, $namespace: String, $groups: String, $roles: String, $scopes: String, $userId: String) {
createTemporaryIdentity(data: {jti: $jti, sub: $sub, name: $name, username: $username, email: $email, isAdmin: false, namespace: $namespace, groups: $groups, roles: $roles, scopes: $scopes, userId: $userId }) {
query: `mutation ($jti: String, $sub: String, $name: String, $email: String, $username: String, $groups: String, $roles: String, $scopes: String, $userId: String) {
createTemporaryIdentity(data: {jti: $jti, sub: $sub, name: $name, username: $username, email: $email, isAdmin: false, groups: $groups, roles: $roles, scopes: $scopes, userId: $userId }) {
id
} }`,
variables: {
Expand All @@ -352,7 +351,6 @@ class Oauth2ProxyAuthStrategy {
name,
email,
username,
namespace,
groups,
roles,
scopes: '[]',
Expand Down
226 changes: 109 additions & 117 deletions src/nextapp/pages/manager/services/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import * as React from 'react';
import {
Badge,
Box,
Button,
Container,
Divider,
Heading,
Icon,
Skeleton,
Table,
Tbody,
Td,
Text,
Th,
Thead,
Tr,
Wrap,
WrapItem,
Expand All @@ -24,16 +20,15 @@ import PageHeader from '@/components/page-header';
import api, { useApi } from '@/shared/services/api';
import { dateRange } from '@/components/services-list/utils';
import { GET_GATEWAY_SERVICE } from '@/shared/queries/gateway-service-queries';
import { FaExternalLinkSquareAlt } from 'react-icons/fa';
import EnvironmentBadge from '@/components/environment-badge';
import MetricGraph from '@/components/services-list/metric-graph';
import ServiceRoutes from '@/components/service-routes';
import { dehydrate } from 'react-query/hydration';
import { QueryClient } from 'react-query';
import { GetServerSideProps, InferGetServerSidePropsType } from 'next';
import { Query } from '@/shared/types/query.types';

import breadcrumbs from '@/components/ns-breadcrumb';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import Head from 'next/head';

export const getServerSideProps: GetServerSideProps = async (context) => {
const queryClient = new QueryClient();
Expand Down Expand Up @@ -61,6 +56,9 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const ServicePage: React.FC<
InferGetServerSidePropsType<typeof getServerSideProps>
> = ({ id }) => {
const breadcrumb = useNamespaceBreadcrumbs([
{ href: '/manager/services', text: 'Services' },
]);
const range = dateRange();
const { data } = useApi(
['gateway-service', id],
Expand All @@ -72,82 +70,43 @@ const ServicePage: React.FC<
},
{ enabled: Boolean(id), suspense: false }
);
const breadcrumb = breadcrumbs([
{ href: '/manager/services', text: 'Services' },
]);
const tags: string[] = !isEmpty(data?.GatewayService?.tags)
? (JSON.parse(data.GatewayService.tags) as string[])
: [];

return (
<Container maxW="6xl">
<PageHeader
actions={
<Button
as="a"
variant="primary"
href="https://grafana.apps.gov.bc.ca/"
rightIcon={<Icon as={FaExternalLinkSquareAlt} mt={-1} />}
>
View Full Metrics
</Button>
}
breadcrumb={breadcrumb}
title={
<Box as="span">
{data?.GatewayService.name}
<EnvironmentBadge
data={data?.GatewayService.environment}
ml={2}
fontSize="1rem"
/>
</Box>
}
/>
<Box bgColor="white" mb={4}>
<Box
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Heading size="md">Metrics</Heading>
</Box>
<Divider />
<Box minHeight="100px" p={4}>
{id && data && (
<ClientRequest fallback={<Skeleton width="100%" height="100%" />}>
<MetricGraph
days={range}
height={100}
id={data?.GatewayService.name}
service={data?.GatewayService}
<>
<Head>
<title>{`API Program Services | Services | ${data?.GatewayService.name}`}</title>
</Head>
<Container maxW="6xl">
<PageHeader
breadcrumb={breadcrumb}
title={
<Box as="span">
{data?.GatewayService.name}
<EnvironmentBadge
data={data?.GatewayService.environment}
ml={2}
fontSize="1rem"
/>
</ClientRequest>
)}
</Box>
</Box>
<Box display="grid" gridGap={4} gridTemplateColumns="repeat(12, 1fr)">
<Box
bgColor="white"
gridColumn="span 4"
display="flex"
flexDir="column"
>
</Box>
}
/>
<Box bgColor="white" mb={4}>
<Box
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Heading size="md">Stats</Heading>
<Heading size="md">Metrics</Heading>
</Box>
<Divider />
<Box p={4} display="flex" alignItems="center" flex={1}>
<Box minHeight="100px" p={4}>
{id && data && (
<ClientRequest fallback={<Skeleton width="100%" height="100%" />}>
<MetricGraph
alt
days={range}
height={100}
id={data?.GatewayService.name}
Expand All @@ -157,67 +116,100 @@ const ServicePage: React.FC<
)}
</Box>
</Box>
<Box bgColor="white" gridColumn="span 5">
<Box display="grid" gridGap={4} gridTemplateColumns="repeat(12, 1fr)">
<Box
p={4}
bgColor="white"
gridColumn="span 4"
display="flex"
alignItems="center"
justifyContent="space-between"
flexDir="column"
>
<Heading size="md">Routes</Heading>
<Box
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Heading size="md">Stats</Heading>
</Box>
<Divider />
<Box p={4} display="flex" alignItems="center" flex={1}>
{id && data && (
<ClientRequest
fallback={<Skeleton width="100%" height="100%" />}
>
<MetricGraph
alt
days={range}
height={100}
id={data?.GatewayService.name}
service={data?.GatewayService}
/>
</ClientRequest>
)}
</Box>
</Box>
<Divider />
<Table variant="simple">
<Tbody>
<Tr>
<Td>
<ServiceRoutes routes={data?.GatewayService.routes} />
</Td>
</Tr>
</Tbody>
</Table>
</Box>
<Box bgColor="white" gridColumn="span 3">
<Box
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Heading size="md">Details</Heading>
<Box bgColor="white" gridColumn="span 5">
<Box
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Heading size="md">Routes</Heading>
</Box>
<Divider />
<Table variant="simple">
<Tbody>
<Tr>
<Td>
<ServiceRoutes routes={data?.GatewayService.routes} />
</Td>
</Tr>
</Tbody>
</Table>
</Box>
<Divider />
<Box p={4}>
<Box bgColor="white" gridColumn="span 3">
<Box
as="dl"
display="grid"
fontSize="sm"
flexWrap="wrap"
gridColumnGap={4}
gridRowGap={2}
gridTemplateColumns="1fr 2fr"
p={4}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Text as="dt" fontWeight="bold">
Host
</Text>
<Text as="dd">{data?.GatewayService.host}</Text>
<Text as="dt" fontWeight="bold">
Tags
</Text>
<Text as="dd">
<Wrap>
{tags.map((t) => (
<WrapItem key={t}>
<Badge>{t}</Badge>
</WrapItem>
))}
</Wrap>
</Text>
<Heading size="md">Details</Heading>
</Box>
<Divider />
<Box p={4}>
<Box
as="dl"
display="grid"
fontSize="sm"
flexWrap="wrap"
gridColumnGap={4}
gridRowGap={2}
gridTemplateColumns="1fr 2fr"
>
<Text as="dt" fontWeight="bold">
Host
</Text>
<Text as="dd">{data?.GatewayService.host}</Text>
<Text as="dt" fontWeight="bold">
Tags
</Text>
<Text as="dd">
<Wrap>
{tags.map((t) => (
<WrapItem key={t}>
<Badge>{t}</Badge>
</WrapItem>
))}
</Wrap>
</Text>
</Box>
</Box>
</Box>
</Box>
</Box>
</Container>
</Container>
</>
);
};

Expand Down
Loading