Skip to content

Commit 9ba5dd4

Browse files
committed
update, prepare for flattener
1 parent e786622 commit 9ba5dd4

11 files changed

Lines changed: 249 additions & 177 deletions

File tree

back/db/app/app_setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function recreateAppTable(tx: Transaction): Promise<void> {
2222
}
2323

2424
export async function createFakeApps(tx: Transaction): Promise<void> {
25-
const fakeNames = await pTimes(50, fakeCompanyName);
25+
const fakeNames = await pTimes(0, fakeCompanyName);
2626
const appNames: string[] = ['One', ...fakeNames.map(({ name }) => name)];
2727
await pMap(
2828
appNames,

back/db/db.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,14 @@ import knex, { Knex } from 'knex';
33
import log from '../../common/log';
44
import { isDevelopment, isTest } from '../util/env';
55
import { formatSQL } from './db_format';
6-
7-
/*
8-
psql -U postgres
9-
10-
-- Main
11-
CREATE DATABASE robot;
12-
CREATE USER robot WITH ENCRYPTED PASSWORD 'robot';
13-
GRANT ALL ON DATABASE robot TO robot;
14-
ALTER DATABASE robot OWNER TO robot;
15-
GRANT ALL PRIVILEGES ON DATABASE robot TO robot;
16-
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO robot;
17-
18-
-- Test
19-
CREATE DATABASE robot_test;
20-
CREATE USER robot_test WITH ENCRYPTED PASSWORD 'robot_test';
21-
GRANT ALL ON DATABASE robot_test TO robot_test;
22-
ALTER DATABASE robot_test OWNER TO robot_test;
23-
GRANT ALL PRIVILEGES ON DATABASE robot_test TO robot_test;
24-
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO robot_test;
25-
*/
6+
import { getDatabaseInitSQL } from './db_setup';
267

278
const key = isTest() ? 'robot_test' : 'robot';
289

10+
if (isDevelopment() || isTest()) {
11+
log.debug(formatSQL(getDatabaseInitSQL(key)));
12+
}
13+
2914
export type Transaction = Knex.Transaction;
3015
export type DB = knex.Knex<any, unknown[]> | Transaction;
3116
export type QueryBuilder = Knex.QueryBuilder;
@@ -49,7 +34,8 @@ export const db = knex({
4934

5035
db.on('query', async ({ sql }) => {
5136
if (isDevelopment()) {
52-
log.info(formatSQL(sql));
37+
log.debug(formatSQL(getDatabaseInitSQL(key)));
38+
log.debug(formatSQL(sql));
5339
}
5440
});
5541

back/db/db_format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const FORMAT_PARAMS: FormatOptionsWithLanguage = {
77
keywordCase: 'upper',
88
functionCase: 'upper',
99
expressionWidth: 100,
10-
linesBetweenQueries: 2,
10+
linesBetweenQueries: 0,
1111
};
1212

1313
export function formatSQL(sql: string): string {

back/db/db_setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function getDatabaseInitSQL(key: string): string {
2+
return `
3+
psql -U postgres
4+
CREATE DATABASE ${key};
5+
CREATE USER robot WITH ENCRYPTED PASSWORD '${key}';
6+
GRANT ALL ON DATABASE robot TO ${key};
7+
ALTER DATABASE ${key} OWNER TO ${key};
8+
GRANT ALL PRIVILEGES ON DATABASE ${key} TO ${key};
9+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ${key};
10+
`;
11+
}

back/db/user/user_setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function createFakeUsers(tx: Transaction): Promise<void> {
4343
},
4444
tx,
4545
});
46-
const fakeNames = await pTimes(50, fakePersonName);
46+
const fakeNames = await pTimes(2, fakePersonName);
4747

4848
await pMap(
4949
fakeNames,

common/log.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
const log = {
22
// eslint-disable-next-line no-console
33
info: (...args: any[]) => console.info(...args),
4+
// eslint-disable-next-line no-console, @typescript-eslint/no-unused-vars
5+
debug: (...args: any[]) => {
6+
// do nothing
7+
},
8+
// debug: (...args: any[]) => console.debug(...args),
49
// eslint-disable-next-line no-console
510
warn: (...args: any[]) => console.warn(...args),
611
// eslint-disable-next-line no-console

front/Login.tsx

Whitespace-only changes.

front/components/modal/Modal.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ interface ModalProps {
1212
title: string;
1313
}
1414

15+
const root = document.getElementById('modal-root');
16+
if (!root) {
17+
throw Error('missing modal root');
18+
}
19+
1520
export function Modal({ children, title, onClose, visible }: ModalProps) {
16-
const root = document.getElementById('modal-root');
17-
if (!root) {
18-
throw Error('missing modal root');
19-
}
2021
return (
2122
<Dialog
2223
prefixCls="modal"
@@ -25,6 +26,9 @@ export function Modal({ children, title, onClose, visible }: ModalProps) {
2526
visible={visible}
2627
getContainer={root}
2728
destroyOnClose
29+
keyboard={true}
30+
animation="fade"
31+
maskAnimation="fade"
2832
>
2933
{children}
3034
</Dialog>

front/components/modal/modal.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
bottom: 0;
210210
background-color: #373737;
211211
background-color: #37373799;
212+
background-color: #ffffff55;
212213
height: 100%;
213214
filter: alpha(opacity=50);
214215
z-index: 1050;

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
make:
2-
vim makefile
2+
vim -o `fzf`
33

44
deps:
55
npm i

0 commit comments

Comments
 (0)