Skip to content

Commit

Permalink
Add versions to app object, add build time
Browse files Browse the repository at this point in the history
  • Loading branch information
squix78 committed Jun 24, 2024
1 parent 7a91482 commit 4f161c2
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 65 deletions.
10 changes: 0 additions & 10 deletions createBuildDate.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "node createBuildDate.js && ng build",
"build": "node updateEnvironmentInfo.js && ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
Expand Down
8 changes: 7 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
<router-outlet></router-outlet>
</div>
<footer class="flex-footer">
<span>{{getCurrentYear()}} By <a href="https://www.thingpulse.com">ThingPulse</a> 1.0.0</span>
<span>
{{getCurrentYear()}} By <a href="https://www.thingpulse.com">ThingPulse</a>
<div class="tooltip"> &nbsp;1.0.0
<span class="tooltiptext">{{environment?.buildDate}}</span>
</div>

</span>
</footer>
26 changes: 26 additions & 0 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,29 @@ a, a:visited {
padding: 16px;
}

.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}

/* Tooltip text */
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;

/* Position the tooltip text - see examples below! */
position: absolute;
z-index: 1;
}

/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}

17 changes: 15 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { EnvironmentService } from './services/environment.service';
import { Environment } from './models/environment';



Expand All @@ -7,12 +9,23 @@ import { Component } from '@angular/core';
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
export class AppComponent implements OnInit {

environment: Environment | undefined = undefined

constructor(public environmentService: EnvironmentService) { }

ngOnInit(): void {
this.environmentService.getEnvironment().subscribe((environment) => {
this.environment = environment;
});
}

getCurrentYear(): number {
return new Date().getFullYear();
}


}


2 changes: 1 addition & 1 deletion src/app/flasher/flasher.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


<div *ngIf="!progresses[0]">{{flasherConsole}}</div>
<div *ngFor="let partition of app?.partitions; index as i;" >
<div *ngFor="let partition of selectedVersion?.partitions; index as i;" >
<div *ngIf="progresses[i]?.progress">
{{ partition.name }} {{progresses[i].progress}}%
<mat-progress-bar mode="determinate" [value]="progresses[i].progress"></mat-progress-bar>
Expand Down
9 changes: 6 additions & 3 deletions src/app/flasher/flasher.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { App } from '../models/app';
import { EspPortService } from '../services/esp-port.service';
import { PartitionProgress } from '../services/utils.service';
import { Subscription } from 'rxjs';
import { AppVersion } from '../models/app-version';

@Component({
selector: 'app-flasher',
Expand All @@ -28,6 +29,7 @@ export class FlasherComponent implements OnInit{
messageArea: string = "";
messageCount = 0;
flasherConsole: string;
selectedVersion: AppVersion | undefined;
progresses: PartitionProgress[] = new Array();

constructor(private route: ActivatedRoute,
Expand All @@ -44,6 +46,7 @@ export class FlasherComponent implements OnInit{
console.log(this.device);
this.appService.findById(this.appId).subscribe((app) => {
this.app = app;
this.selectedVersion = this.app?.versions[0];
});
const portStateStreamSubscription = this.portService.portStateStream.subscribe(isConnected => {
console.log("isConnected: ", isConnected);
Expand Down Expand Up @@ -80,7 +83,7 @@ export class FlasherComponent implements OnInit{
this.messageArea = ""
this.messageCount = 0;
this.flasherConsole = "Ready";
this.progresses = new Array(this.app?.partitions.length);
this.progresses = new Array(this.selectedVersion?.partitions.length);
}

connect() {
Expand Down Expand Up @@ -118,7 +121,7 @@ export class FlasherComponent implements OnInit{
async flash() {
console.log("Flashing");
this.resetState();
if (this.app && this.app.partitions) {
if (this.app && this.selectedVersion?.partitions) {
try {
await this.portService.connect();
console.log("Connected");
Expand All @@ -128,7 +131,7 @@ export class FlasherComponent implements OnInit{
return;
}
console.log("Flashing");
await this.portService.flash(this.app.partitions);
await this.portService.flash(this.selectedVersion.partitions);
} else {
console.log("No app selected");
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/models/app-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Partition } from "../services/utils.service";

export interface AppVersion {
name: string;
partitions: Partition[];
}
3 changes: 2 additions & 1 deletion src/app/models/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Partition } from "../services/utils.service";
import { AppVersion } from "./app-version";

export interface App {
id: string;
Expand All @@ -9,6 +10,6 @@ export interface App {
appIcon: string;
instructions: string;
supportedDevices: string[];
partitions: Partition[];
versions: AppVersion[];
tags: string[];
}
3 changes: 3 additions & 0 deletions src/app/models/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface Environment {
buildDate: string;
}
20 changes: 20 additions & 0 deletions src/app/services/environment.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { App } from '../models/app';
import { Observable, map } from 'rxjs';
import { Environment } from '../models/environment';

@Injectable({
providedIn: 'root'
})
export class EnvironmentService {

constructor(public httpClient: HttpClient) {

}

getEnvironment(): Observable<Environment> {
return this.httpClient.get<Environment>('/assets/environment.json');
}

}
104 changes: 61 additions & 43 deletions src/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
"supportedDevices": [
"tp-pendrive-s3"
],
"partitions": [{
"name": "Firmware",
"data": [],
"offset": 0,
"url": "./assets/apps/super-wifi-duck/app-firmware.bin"
"versions": [{
"name": "1.0.0",
"partitions": [{
"name": "Firmware",
"data": [],
"offset": 0,
"url": "./assets/apps/super-wifi-duck/app-firmware.bin"
}]
}],

"tags": ["badusb", "keystroke-injection", "wifi-duck", "hid", "usb-rubber-ducky", "keyboard", "mouse"]
},
{
Expand All @@ -28,12 +32,16 @@
"supportedDevices": [
"tp-pendrive-s3"
],
"partitions": [{
"name": "Firmware",
"data": [],
"offset": 0,
"url": "./assets/apps/circuitpython/circuit-python-bootloader.bin"
"versions": [{
"name": "1.0.0",
"partitions": [{
"name": "Firmware",
"data": [],
"offset": 0,
"url": "./assets/apps/circuitpython/circuit-python-bootloader.bin"
}]
}],

"tags": ["circuit-python", "adafruit", "microcontroller", "embedded"]
},
{
Expand All @@ -47,22 +55,25 @@
"supportedDevices": [
"tp-pendrive-s3"
],
"partitions": [{
"name": "Bootloader",
"data": [],
"offset": "0x0",
"url": "./assets/apps/esp32-u2f/bootloader.bin"
},
{
"name": "Partition Table",
"data": [],
"offset": "0x8000",
"url": "./assets/apps/esp32-u2f/partition-table.bin"},
{
"name": "Firmware",
"data": [],
"offset": "0x10000",
"url": "./assets/apps/esp32-u2f/esp32_u2f.bin"
"versions": [{
"name": "1.0.0",
"partitions": [{
"name": "Bootloader",
"data": [],
"offset": "0x0",
"url": "./assets/apps/esp32-u2f/bootloader.bin"
},
{
"name": "Partition Table",
"data": [],
"offset": "0x8000",
"url": "./assets/apps/esp32-u2f/partition-table.bin"},
{
"name": "Firmware",
"data": [],
"offset": "0x10000",
"url": "./assets/apps/esp32-u2f/esp32_u2f.bin"
}]
}],
"tags": ["fido2", "u2f", "security", "authentication", "webauthn"]
},
Expand All @@ -77,22 +88,25 @@
"supportedDevices": [
"tp-pendrive-s3"
],
"partitions": [{
"name": "Bootloader",
"data": [],
"offset": "0x0",
"url": "./assets/apps/wifi-dongle/bootloader.bin"
},
{
"name": "Partition Table",
"data": [],
"offset": "0x8000",
"url": "./assets/apps/wifi-dongle/partition-table.bin"},
{
"name": "Firmware",
"data": [],
"offset": "0x10000",
"url": "./assets/apps/wifi-dongle/usb_dongle.bin"
"versions": [{
"name": "1.0.0",
"partitions": [{
"name": "Bootloader",
"data": [],
"offset": "0x0",
"url": "./assets/apps/wifi-dongle/bootloader.bin"
},
{
"name": "Partition Table",
"data": [],
"offset": "0x8000",
"url": "./assets/apps/wifi-dongle/partition-table.bin"},
{
"name": "Firmware",
"data": [],
"offset": "0x10000",
"url": "./assets/apps/wifi-dongle/usb_dongle.bin"
}]
}],
"tags": ["network", "wifi", "wifi-dongle"]
},
Expand All @@ -106,6 +120,10 @@
"supportedDevices": [
"tp-default-device"
],
"partitions": []
"versions": [{
"name": "1.0.0",
"partitions": []
}]

}
]
3 changes: 0 additions & 3 deletions src/assets/buildDate.json

This file was deleted.

3 changes: 3 additions & 0 deletions src/assets/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"buildDate": "TEST"
}
10 changes: 10 additions & 0 deletions updateEnvironmentInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { writeFileSync } = require('fs')
const { join } = require('path')

const ENV_PATH = join(__dirname, 'src/assets/environment.json');

const environment = {
buildDate: new Date()
}

writeFileSync(ENV_PATH, JSON.stringify(environment, null, 2));

0 comments on commit 4f161c2

Please sign in to comment.