Skip to content

Commit

Permalink
Add new project templates with sample data, add docs link to blank pa…
Browse files Browse the repository at this point in the history
…ge 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
  • Loading branch information
eatonphil committed May 26, 2022
1 parent 24b9d38 commit be02e61
Show file tree
Hide file tree
Showing 32 changed files with 55,126 additions and 324 deletions.
50 changes: 24 additions & 26 deletions .eslintrc
@@ -1,28 +1,26 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],
"rules": {
"react/jsx-no-target-blank": 'off',
"react/no-children-prop": 'off',
"@typescript-eslint/no-explicit-any": 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
]
}
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],
"rules": {
"react/jsx-no-target-blank": "off",
"react/no-children-prop": "off",
"react/no-unescaped-entities": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
}
}
20 changes: 20 additions & 0 deletions desktop/project.ts
Expand Up @@ -131,6 +131,26 @@ export async function openWindow(
return { action: 'deny' };
});

win.webContents.on('did-navigate', function resizeIfFromCreateView() {
if (!win) {
return;
}

let proj = '';
try {
proj = new URL(win.webContents.getURL()).searchParams.get('projectId');
} catch (_e) {
/* pass */
}

const [width, height] = win.getSize();

if (proj && width === 600 && height === 600) {
win.setSize(1400, 800);
win.center();
}
});

const menu = Menu.buildFromTemplate(
menuTemplate as MenuItemConstructorOptions[]
);
Expand Down
5 changes: 0 additions & 5 deletions desktop/rpc.ts
Expand Up @@ -204,11 +204,6 @@ export function registerRPCHandlers<EndpointT extends string>(
const responseChannel = `${RPC_ASYNC_RESPONSE}:${payload.messageNumber}`;
try {
const rsp = await dispatch(payload, true);
const win = OPEN_WINDOWS[payload.projectId];
if (payload.resource === 'makeProject' && win) {
win.setSize(1400, 800);
win.center();
}
sendIPCRendererResponse(event, responseChannel, {
kind: 'response',
body: rsp,
Expand Down
30 changes: 27 additions & 3 deletions desktop/store.ts
Expand Up @@ -24,7 +24,7 @@ import {
ServerInfo,
TablePanelInfo,
} from '../shared/state';
import { DISK_ROOT, PROJECT_EXTENSION } from './constants';
import { CODE_ROOT, DISK_ROOT, PROJECT_EXTENSION } from './constants';
import {
connectorCrud,
GenericCrud,
Expand Down Expand Up @@ -378,14 +378,38 @@ GROUP BY panel_id
},
};

cleanupSampleProject(sampleProject: ProjectState) {
for (const page of sampleProject.pages || []) {
for (const panel of page.panels || []) {
if (panel.type === 'file') {
const fp = panel as FilePanelInfo;
if (fp.file.name.startsWith('sampledata')) {
fp.file.name = path.join(CODE_ROOT, fp.file.name);
}
}
}
}
}

makeProjectHandler: MakeProjectHandler = {
resource: 'makeProject',

// NOTE: unlike elsewhere projectId is actually the file name not a uuid.
handler: async (_: string, { projectId }: MakeProjectRequest) => {
const newProject = new ProjectState();
handler: async (_: string, request: MakeProjectRequest) => {
const { projectId } = request;

const newProject = request.project
? ProjectState.fromJSON(request.project)
: new ProjectState();
newProject.projectName = ensureProjectFile(projectId);

// Sample projects get submitted and written as JSON. They get ported to SQLite on first read.
if (request.project) {
this.cleanupSampleProject(newProject);
fs.writeFileSync(newProject.projectName, JSON.stringify(newProject));
return;
}

// File already exists, ok and appropriate to do nothing since
// this merely handles creation not loading.
if (fs.existsSync(newProject.projectName)) {
Expand Down
2,793 changes: 2,793 additions & 0 deletions sampledata/Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions sampledata/README.md
@@ -0,0 +1,25 @@
# Sample Data

## Hudson River Park Flora - Plantings: 1997 - 2015

File: [Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv](./Hudson_River_Park_Flora_-_Plantings___1997_-_2015.csv)

Source: https://catalog.data.gov/dataset/hudson-river-park-flora-plantings-beginning-1997.

No license.

## nginx JSON logs

File: [nginx_json_logs](./nginx_json_logs)

Source: https://github.com/elastic/examples/tree/master/Common%20Data%20Formats/nginx_json_logs

License: [Apache 2.0](https://github.com/elastic/examples/blob/master/LICENSE)

## Washington Broadband Speed Tests

File: [speedtests.db](./speedtests.db)

Source: https://catalog.data.gov/dataset/broadband-speed-tests

No license.

0 comments on commit be02e61

Please sign in to comment.