Skip to content

Commit be02e61

Browse files
authored
Add new project templates with sample data, add docs link to blank page and embed video on blank page (#253)
* Add sample project option * Add video * Fix for tsc * Fix for fmt * Finish up styling * Finish up links and docs * Fix sample projects * Clarify text * Fix linkt * Add sqlite sample * Fix for format * Clean up help page, dark styles * Add basic tests * Fix for format
1 parent 24b9d38 commit be02e61

32 files changed

+55126
-324
lines changed

.eslintrc

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"plugins": [
5-
"@typescript-eslint",
6-
"jest"
7-
],
8-
"extends": [
9-
"eslint:recommended",
10-
"plugin:react/recommended",
11-
"plugin:@typescript-eslint/eslint-recommended",
12-
"plugin:@typescript-eslint/recommended",
13-
"plugin:react-hooks/recommended"
14-
],
15-
"rules": {
16-
"react/jsx-no-target-blank": 'off',
17-
"react/no-children-prop": 'off',
18-
"@typescript-eslint/no-explicit-any": 'off',
19-
'@typescript-eslint/no-unused-vars': [
20-
'error',
21-
{
22-
argsIgnorePattern: '^_',
23-
varsIgnorePattern: '^_',
24-
caughtErrorsIgnorePattern: '^_',
25-
},
26-
]
27-
}
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint", "jest"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:react/recommended",
8+
"plugin:@typescript-eslint/eslint-recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:react-hooks/recommended"
11+
],
12+
"rules": {
13+
"react/jsx-no-target-blank": "off",
14+
"react/no-children-prop": "off",
15+
"react/no-unescaped-entities": "off",
16+
"@typescript-eslint/no-explicit-any": "off",
17+
"@typescript-eslint/no-unused-vars": [
18+
"error",
19+
{
20+
"argsIgnorePattern": "^_",
21+
"varsIgnorePattern": "^_",
22+
"caughtErrorsIgnorePattern": "^_"
23+
}
24+
]
25+
}
2826
}

desktop/project.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ export async function openWindow(
131131
return { action: 'deny' };
132132
});
133133

134+
win.webContents.on('did-navigate', function resizeIfFromCreateView() {
135+
if (!win) {
136+
return;
137+
}
138+
139+
let proj = '';
140+
try {
141+
proj = new URL(win.webContents.getURL()).searchParams.get('projectId');
142+
} catch (_e) {
143+
/* pass */
144+
}
145+
146+
const [width, height] = win.getSize();
147+
148+
if (proj && width === 600 && height === 600) {
149+
win.setSize(1400, 800);
150+
win.center();
151+
}
152+
});
153+
134154
const menu = Menu.buildFromTemplate(
135155
menuTemplate as MenuItemConstructorOptions[]
136156
);

desktop/rpc.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ export function registerRPCHandlers<EndpointT extends string>(
204204
const responseChannel = `${RPC_ASYNC_RESPONSE}:${payload.messageNumber}`;
205205
try {
206206
const rsp = await dispatch(payload, true);
207-
const win = OPEN_WINDOWS[payload.projectId];
208-
if (payload.resource === 'makeProject' && win) {
209-
win.setSize(1400, 800);
210-
win.center();
211-
}
212207
sendIPCRendererResponse(event, responseChannel, {
213208
kind: 'response',
214209
body: rsp,

desktop/store.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
ServerInfo,
2525
TablePanelInfo,
2626
} from '../shared/state';
27-
import { DISK_ROOT, PROJECT_EXTENSION } from './constants';
27+
import { CODE_ROOT, DISK_ROOT, PROJECT_EXTENSION } from './constants';
2828
import {
2929
connectorCrud,
3030
GenericCrud,
@@ -378,14 +378,38 @@ GROUP BY panel_id
378378
},
379379
};
380380

381+
cleanupSampleProject(sampleProject: ProjectState) {
382+
for (const page of sampleProject.pages || []) {
383+
for (const panel of page.panels || []) {
384+
if (panel.type === 'file') {
385+
const fp = panel as FilePanelInfo;
386+
if (fp.file.name.startsWith('sampledata')) {
387+
fp.file.name = path.join(CODE_ROOT, fp.file.name);
388+
}
389+
}
390+
}
391+
}
392+
}
393+
381394
makeProjectHandler: MakeProjectHandler = {
382395
resource: 'makeProject',
383396

384397
// NOTE: unlike elsewhere projectId is actually the file name not a uuid.
385-
handler: async (_: string, { projectId }: MakeProjectRequest) => {
386-
const newProject = new ProjectState();
398+
handler: async (_: string, request: MakeProjectRequest) => {
399+
const { projectId } = request;
400+
401+
const newProject = request.project
402+
? ProjectState.fromJSON(request.project)
403+
: new ProjectState();
387404
newProject.projectName = ensureProjectFile(projectId);
388405

406+
// Sample projects get submitted and written as JSON. They get ported to SQLite on first read.
407+
if (request.project) {
408+
this.cleanupSampleProject(newProject);
409+
fs.writeFileSync(newProject.projectName, JSON.stringify(newProject));
410+
return;
411+
}
412+
389413
// File already exists, ok and appropriate to do nothing since
390414
// this merely handles creation not loading.
391415
if (fs.existsSync(newProject.projectName)) {

sampledata/Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv

Lines changed: 2793 additions & 0 deletions
Large diffs are not rendered by default.

sampledata/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Sample Data
2+
3+
## Hudson River Park Flora - Plantings: 1997 - 2015
4+
5+
File: [Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv](./Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv)
6+
7+
Source: https://catalog.data.gov/dataset/hudson-river-park-flora-plantings-beginning-1997.
8+
9+
No license.
10+
11+
## nginx JSON logs
12+
13+
File: [nginx_json_logs](./nginx_json_logs)
14+
15+
Source: https://github.com/elastic/examples/tree/master/Common%20Data%20Formats/nginx_json_logs
16+
17+
License: [Apache 2.0](https://github.com/elastic/examples/blob/master/LICENSE)
18+
19+
## Washington Broadband Speed Tests
20+
21+
File: [speedtests.db](./speedtests.db)
22+
23+
Source: https://catalog.data.gov/dataset/broadband-speed-tests
24+
25+
No license.

0 commit comments

Comments
 (0)