Skip to content

Commit

Permalink
Added inverted grid feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime ROBIN committed Mar 4, 2021
1 parent 571d68a commit 7b275a7
Show file tree
Hide file tree
Showing 14 changed files with 17,754 additions and 17,730 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
'.template-lintrc.js',
'ember-cli-build.js',
'testem.js',
'testem-electron.js',
'testem-electron.js',

'blueprints/*/index.js',
'config/**/*.js',
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/github-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
run: yarn run make-exe

- name: Create Release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ install:
- npm install
- bower install
- 'export DISPLAY='':99.0'''
- 'Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &'
- cd electron-app && npm install
- cd electron-app && npm install
- 'Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &'
- cd electron-app && npm install
- cd electron-app && npm install
- cd electron-app && npm install

script:
Expand Down
7 changes: 1 addition & 6 deletions app/components/acc-results-import-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
import {inject as service} from '@ember/service';

const fs = requireNode('fs-extra');
const R = requireNode('ramda');

export default class accResultsImportComp extends Component {
Expand All @@ -15,11 +14,7 @@ export default class accResultsImportComp extends Component {
@action
async importJson(f) {
this.applicationStore.savePath(f.files[0].path, true);
await R.forEach(
async (file) =>
this.resultsStore.save(await fs.readFile(file.path, 'utf8')),
f.files
);
await R.forEach(async (file) => this.resultsStore.save(file.path), f.files);
this.isLoaded = true;
this.paperToaster.show('Results imported');
}
Expand Down
3 changes: 3 additions & 0 deletions app/components/export-comp.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{{#paper-button raised=true accent=true onClick=(action "exportCSV")}}
Export to CSV
{{/paper-button}}
{{#paper-button raised=true accent=true onClick=(action "invertedGrid")}}
Export to inverted grid
{{/paper-button}}
{{#paper-button raised=true onClick=(action "clearData")}}
Clear Data
{{/paper-button}}
Expand Down
13 changes: 13 additions & 0 deletions app/components/export-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import moment from 'moment';
import resultsToCSV from '../utils/results-to-csv';
import resultsToInvertedGrid from '../utils/results-to-entry-list';

const fs = requireNode('fs-extra');

Expand All @@ -21,6 +22,18 @@ export default class ExportComp extends Component {
this.paperToaster.show(`Exported to CSV (${path})`);
}

@action
async invertedGrid() {
const path = `${this.applicationStore.getPath()}\\entrylist.json`;

fs.writeJson(
path,
resultsToInvertedGrid(this.resultsStore.get()),
'utf16le'
);
this.paperToaster.show(`Inverted Grid written (${path})`);
}

@action
async clearData() {
this.resultsStore.clear();
Expand Down
4 changes: 2 additions & 2 deletions app/components/toolbar-comp.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#paper-toolbar as |toolbar|}}
{{#toolbar.tools}}
<h2>SW Runes Tracker</h2>
<h2>ACC Json to CSV</h2>
{{#paper-button href=(href-to "import")}}
{{paper-icon "swap-vert"}}
Import / Export
Expand All @@ -10,7 +10,7 @@
View Results
{{/paper-button}}
<span class="flex"></span>
v0.2.1
v0.3.0
{{/toolbar.tools}}
{{/paper-toolbar}}

Expand Down
24 changes: 12 additions & 12 deletions app/router.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import EmberRouter from '@ember/routing/router';
import config from 'acc-results-json-to-csv/config/environment';

export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function() {
this.route('import');
this.route('view-results');
});
import EmberRouter from '@ember/routing/router';
import config from 'acc-results-json-to-csv/config/environment';

export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function() {
this.route('import');
this.route('view-results');
});
4 changes: 2 additions & 2 deletions app/services/results-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const R = requireNode('ramda');
export default class ResultsStoreService extends Service {
jsonImport = {};

save(json) {
const results = parseResults(json);
async save(path) {
const results = await parseResults(path);
if (results.sessionType !== 'Q') {
this.jsonImport = results;
} else {
Expand Down
7 changes: 2 additions & 5 deletions app/utils/parse-results.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const R = requireNode('ramda');
const fs = requireNode('fs-extra');

const parseResults = R.pipe(
R.replace(/[^a-zA-Z\u00C0-\u024F\u1E00-\u1EFF0-9",{}.\[\]:-]/g, ''),
JSON.parse
);
const parseResults = (filename) => fs.readJson(filename, 'utf16le');

export default parseResults;
17 changes: 17 additions & 0 deletions app/utils/results-to-entry-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const R = requireNode('ramda');

const addReversePosition = (length) => (v, idx) =>
R.assoc('defaultGridPosition', length - idx, v);

const resultsToInvertedGrid = R.pipe(
R.path(['sessionResult', 'leaderBoardLines']),
R.pluck('currentDriver'),
R.map(R.assoc('driverCategory', 1)),
R.converge(R.addIndex(R.map), [
R.pipe(R.length, addReversePosition),
R.identity
]),
R.applySpec({entries: {drivers: R.identity}})
);

export default resultsToInvertedGrid;

0 comments on commit 7b275a7

Please sign in to comment.