Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ Open the browser console and run:

```js
localStorage.setItem('lichessHost', 'http://localhost:8080');

localStorage.setItem('lichessHost', 'https://lichess.dev');
```

Modify the CSP meta tag in `index.html` to add that domain. For example, change `lichess.org` to `localhost:8080`.
Modify the CSP meta tag in `index.html` to include that domain.

Refresh and verify the configuration value in the footer.

To reset back to prod default, log out and it will clear localStorage.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"license": "GPL-3.0-or-later",
"dependencies": {
"@bity/oauth2-auth-code-pkce": "~2.13.0",
"@lichess-org/types": "^2.0.86",
"bootstrap": "~5.3.8",
"cheerio": "^1.1.2",
"openapi-fetch": "^0.15.0",
"page": "~1.11.6",
"snabbdom": "~3.6.3"
},
Expand Down
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 39 additions & 1 deletion src/page/bulkNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import page from 'page';
import { App } from '../app';
import type { Me } from '../auth';
import { type Feedback, formData, isSuccess, responseToFeedback } from '../form';
import { gameRuleKeys, gameRules } from '../util';
import { gameRuleKeys, gameRules, sleep } from '../util';
import * as form from '../view/form';
import layout from '../view/layout';
import { type Pairing, filterRound, getPairings, getPlayers, saveUrls } from '../scraper/scraper';
import { bulkPairing } from '../endpoints';
import { href } from '../view/util';
import createClient from 'openapi-fetch';
import type { paths } from '@lichess-org/types';

interface Tokens {
[username: string]: string;
Expand Down Expand Up @@ -111,6 +113,38 @@ export class BulkNew {
this.feedback = await responseToFeedback(req);

if (isSuccess(this.feedback)) {
if (!!get('armageddon')) {
await sleep(3000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can now be removed

const addTimeResponses = new Map<string, number>();
for (const game of this.feedback.result.games) {
const client = createClient<paths>({
baseUrl: this.app.config.lichessHost,
headers: {
Authorization: `Bearer ${tokens[game.white]}`,
},
});
const resp = await client.POST('/api/round/{gameId}/add-time/{seconds}', {
params: {
path: {
gameId: game.id,
seconds: 60,
},
},
});
addTimeResponses.set(game.id, resp.response.status);
}

const alerts: string[] = [];
addTimeResponses.forEach((status, gameId) => {
if (status !== 200) {
alerts.push(`Failed to add armageddon time to game ${gameId}, status ${status}`);
}
});
if (alerts.length) {
alert(alerts.join('\n'));
}
}

saveUrls(this.feedback.result.id, get('cr-pairings-url'), get('cr-players-url'));
page(`/endpoint/schedule-games/${this.feedback.result.id}`);
}
Expand Down Expand Up @@ -197,6 +231,10 @@ export class BulkNew {
]),
]),
form.clock(),
h(
'div.form-check.form-switch.mb-3',
form.checkboxWithLabel('armageddon', 'Armageddon? (+60 seconds for black)'),
),
h('div.form-check.form-switch.mb-3', form.checkboxWithLabel('rated', 'Rated games', true)),
form.variant(),
form.fen(),
Expand Down