Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lilidworkin committed Sep 13, 2022
2 parents fe5b141 + 47b3a83 commit 08dd17d
Show file tree
Hide file tree
Showing 142 changed files with 28,785 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

35 changes: 35 additions & 0 deletions publisher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<<<<<<< HEAD
# justice-counts
Technical infrastructure for the Justice Counts initiative
=======
# Justice Counts Control Panel: Frontend

Welcome to the Justice Counts Control Panel - a tool that allows agencies to report Justice Counts metrics.

The frontend of this application, which lives in this directory, was bootstrapped with [Create React App](https://github.com/facebook/create-react-app), written in [TypeScript](https://www.typescriptlang.org/docs), and authenticated via [Auth0](https://auth0.com/). The backend of the application lives in [recidiviz-data/justice_counts/control_panel](https://github.com/Recidiviz/recidiviz-data/tree/main/recidiviz/justice_counts/control_panel).

To run the app locally, you need to spin up both the backend and frontend simultaneously. Instructions for spinning up the frontend are below; instructions for spinning up the backend can be found in its directory's README.

## Running the app frontend

1. Install dependencies

##### For all Yarn installation options, see [Yarn Installation](https://yarnpkg.com/en/docs/install).

```sh
yarn install
```

2. Run the local development server

```sh
yarn run dev
```

3. Test your development environment

```sh
yarn test
yarn lint
```
>>>>>>> 47b3a8316fb088dc90672a36eefb3e8feb4385c1
103 changes: 103 additions & 0 deletions publisher/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"name": "recidiviz-justice-counts-control-panel",
"version": "0.1.0",
"description": "A tool that allows agencies to report Justice Counts metrics",
"private": true,
"author": "Recidiviz <[email protected]>",
"license": "GNU General Public License v3",
"dependencies": {
"@auth0/auth0-react": "^1.9.0",
"@recidiviz/design-system": "^2.7.0",
"@testing-library/dom": "^8.11.3",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"lodash.debounce": "^4.0.8",
"lodash.mapvalues": "^4.6.0",
"lodash.pickby": "^4.6.0",
"mobx": "^6.4.2",
"mobx-persist-store": "^1.0.6",
"mobx-react-lite": "^3.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"react-router-dom": "^6",
"react-scripts": "5.0.0",
"recharts": "^2.1.13",
"styled-components": "^5.3.3",
"typescript": "^4.4.2",
"web-vitals": "^2.1.0"
},
"scripts": {
"dev": "react-scripts start",
"build": "react-scripts build",
"lint": "tsc && eslint '**/*.{ts,tsx}'",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"@recidiviz/eslint-config",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "/",
"proxy": "http://localhost:5001",
"devDependencies": {
"@auth0/auth0-spa-js": "^1.20.1",
"@babel/core": "^7.0.0-0",
"@babel/plugin-syntax-flow": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@recidiviz/eslint-config": "^2.0.0",
"@recidiviz/tsconfig": "^1.0.0",
"@types/auth0": "^2.34.13",
"@types/jest": "^27.0.1",
"@types/lodash": "^4.14.182",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "^16.7.13",
"@types/qs": "^6.9.7",
"@types/reach__router": "^1.3.10",
"@types/react": "^17.0.20",
"@types/react-dom": "^17.0.9",
"@types/react-modal": "^3.13.1",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.24",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"autoprefixer": "^10.0.2",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.3",
"eslint": "^8.11.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest-fetch-mock": "^3.0.3",
"postcss": "^8.1.0",
"prettier": "^2.6.0",
"react-modal": "^3.14.4"
},
"jest": {
"moduleNameMapper": {
"^d3-(.*)$": "d3-$1/dist/d3-$1"
}
}
}
Binary file added publisher/public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publisher/public/android-chrome-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publisher/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publisher/public/assets/COURTS_AND_PRETRIAL.xlsx
Binary file not shown.
Binary file added publisher/public/assets/DEFENSE.xlsx
Binary file not shown.
Binary file added publisher/public/assets/JAILS.xlsx
Binary file not shown.
Binary file added publisher/public/assets/LAW_ENFORCEMENT.xlsx
Binary file not shown.
Binary file added publisher/public/assets/PRISONS.xlsx
Binary file not shown.
Binary file added publisher/public/assets/PROSECUTION.xlsx
Binary file not shown.
Binary file added publisher/public/assets/SUPERVISION.xlsx
Binary file not shown.
Binary file added publisher/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publisher/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publisher/public/favicon.ico
Binary file not shown.
50 changes: 50 additions & 0 deletions publisher/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Justice Counts | Control Panel</title>

<script src="%PUBLIC_URL%/app_public_config.js"></script>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">

</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
20 changes: 20 additions & 0 deletions publisher/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"short_name": "Control Panel",
"name": "Control Panel by Recidiviz",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": ".",
"display": "browser",
"theme_color": "#014c48",
"background_color": "#014c48"
}
3 changes: 3 additions & 0 deletions publisher/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
55 changes: 55 additions & 0 deletions publisher/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Recidiviz - a data platform for criminal justice reform
// Copyright (C) 2022 Recidiviz, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =============================================================================

import createAuth0Client from "@auth0/auth0-spa-js";
import { render, screen } from "@testing-library/react";
import React from "react";

import App from "./App";
import AuthWall from "./components/Auth";
import { StoreProvider } from "./stores";

jest.mock("@auth0/auth0-spa-js");

const mockCreateAuth0Client = createAuth0Client as jest.Mock;
const mockIsAuthenticated = jest.fn();
const mockLoginWithRedirect = jest.fn();

beforeEach(() => {
mockCreateAuth0Client.mockResolvedValue({
isAuthenticated: mockIsAuthenticated,
loginWithRedirect: mockLoginWithRedirect,
});
});

afterEach(() => {
jest.resetAllMocks();
});

test("renders loading on load", () => {
render(
<StoreProvider>
<AuthWall>
<App />
</AuthWall>
</StoreProvider>
);
const loader = screen.getByTestId("loading");
expect(loader).toBeInTheDocument();

expect.hasAssertions();
});
56 changes: 56 additions & 0 deletions publisher/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Recidiviz - a data platform for criminal justice reform
// Copyright (C) 2022 Recidiviz, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =============================================================================

import { observer } from "mobx-react-lite";
import React, { ReactElement, useEffect } from "react";
import { Route, Routes, useLocation } from "react-router-dom";

import { trackNavigation } from "./analytics";
import { DataUpload } from "./components/DataUpload";
import { PageWrapper } from "./components/Forms";
import Header from "./components/Header";
import { MetricsView } from "./components/MetricsView";
import CreateReports from "./components/Reports/CreateReport";
import ReportDataEntry from "./components/Reports/ReportDataEntry";
import AccountSettings from "./pages/AccountSettings";
import Reports from "./pages/Reports";

const App: React.FC = (): ReactElement => {
const location = useLocation();
useEffect(() => {
trackNavigation(location.pathname + location.search);
}, [location]);

return (
<>
<PageWrapper>
<Header />

<Routes>
<Route path="/" element={<Reports />} />
<Route path="/reports/create" element={<CreateReports />} />
<Route path="/reports/:id" element={<ReportDataEntry />} />
<Route path="/settings" element={<AccountSettings />} />
<Route path="/metrics" element={<MetricsView />} />
<Route path="/upload" element={<DataUpload />} />
</Routes>
</PageWrapper>
</>
);
};

export default observer(App);
Loading

0 comments on commit 08dd17d

Please sign in to comment.