Skip to content

Commit

Permalink
Merge pull request #86 from skounis/feat/issue-85-filename
Browse files Browse the repository at this point in the history
Feat/issue 85 filename
  • Loading branch information
skounis authored Jan 27, 2022
2 parents 685a061 + d477d62 commit 2846031
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class AppComponent implements OnInit {

openDownloadDialog() {
this.export();
const data = this.downloadJsonHref;
const data = {
filename: this.store.getResults().filename,
url: this.downloadJsonHref
};
const dialogRef = this.dialog.open(DownloadDialogComponent, {
data: data
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/download-dialog/download-dialog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ <h3>Download</h3>
<p>On pushing the Download Button the test results are copied to your standard download folder on your computer. File
name: <code>[2-digit country code]_[OS type]_[timestamp].json</code>.</p>

<p class="dcc-button-wrapper"><a *ngIf="!!data" mat-raised-button color="primary" title="Download JSON" [href]="data"
download="test-results.json" (click)="clear()">Download</a>
<p class="dcc-button-wrapper"><a *ngIf="!!data.url" mat-raised-button color="primary" title="Download JSON" [href]="data.url"
[download]="data.filename" (click)="clear()">Download</a>
</p>


Expand Down
17 changes: 13 additions & 4 deletions src/interfaces/model.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* `20220117-NL-ANDROID.json`
* `20220117-NL-IOS.json`
*/
import * as _ from 'lodash';
import * as _ from 'lodash';

/**
* Target platforms
Expand Down Expand Up @@ -71,8 +71,17 @@ export interface ITestResultEntry {
}

export class TestResult implements ITestResult {

metadata: ITestResultMetadata;
results: ITestResultEntry[];

get filename(): string {
const cc = this.metadata.country || 'country';
const pl = this.metadata.platform || 'platform';
const ts = this.metadata.completedOn || 'timestamp';
return `${cc}_${pl}_${ts}.json`;
}

constructor() {
this.metadata = new TestResultMetadata();
// TODO: Should this become a more smart collect?
Expand Down Expand Up @@ -127,7 +136,7 @@ export class TestResultMetadata implements ITestResultMetadata {
/**
* The Rich representation of an EU DCC
*/
export interface IQRCode {
export interface IQRCode {
/** Unique ID (is the same with the file) */
id: string;
/** The country issued this DCC. */
Expand All @@ -147,7 +156,7 @@ export class TestResultMetadata implements ITestResultMetadata {
}

export class Analytics {
constructor(private rqCodes: Array<IQRCode>, private results: TestResult) {}
constructor(private rqCodes: Array<IQRCode>, private results: TestResult) { }

/**
* @returns The number of all the QR Codes for testing.
Expand All @@ -163,6 +172,6 @@ export class Analytics {
public progress(category: TestResultEnum | null): number {
// Return all
if (!category) return this.results.results.length;
return this.results.results.filter(value => value.result === category).length
return this.results.results.filter(value => value.result === category).length
}
}

0 comments on commit 2846031

Please sign in to comment.