Skip to content

Commit

Permalink
Merge pull request #3 from haywalk/dev
Browse files Browse the repository at this point in the history
Cleaned up code and created separate file for QSO class
  • Loading branch information
haywalk authored Jul 7, 2023
2 parents be51853 + 43bda28 commit 2e70507
Show file tree
Hide file tree
Showing 9 changed files with 945 additions and 280 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# wzlog

Amateur radio logging application written in React.
Bare-bones ham radio logging application written in React.

![Screenshot from 2023-07-06](screenshots/wzlog_2023-07-06.png)
![Screenshot from 2023-07-06](screenshots/wzlog_2023-07-07.png)
Binary file added screenshots/wzlog_2023-07-07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
margin-top: 15px;
}

#log-entry-boxes {
text-align: center;
}

#logbuttons {
margin-top: 15px;
}
Expand Down
73 changes: 8 additions & 65 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,23 @@ import LogEntry from './LogEntry.jsx';
import LogTable from './LogTable.jsx';
import { Header } from './TextElements.jsx';

/**
* Store QSO data.
*/
class QSO {
/**
* Create a new QSO.
*/
constructor(date, time, call, qth, rstSent, rstRecd, name, comments) {
this.date = date;
this.time = time;
this.call = call;
this.qth = qth;
this.rstSent = rstSent;
this.rstRecd = rstRecd;
this.name = name;
this.comments = comments;
this.id = new Date().getTime;
}

/**
* Return the QSO as a dictionary (for the DataGrid).
*/
asDict() {
const newRow = {
id: new Date().getTime(),
date: this.date + " " + this.time,
utc: String(this.time),
call: String(this.call),
qth: String(this.qth),
rstSent: this.rstSent,
rstRcvd: this.rstRecd,
name: this.name,
comment: String(this.comments)
}

return newRow;
}
}

/**
* Create a new QSO from the form inputs.
*
* @returns New QSO
*/
function getQSOData() {
const newQSO = new QSO(
String(document.getElementById('date-field').value),
String(document.getElementById('time-field').value),
String(document.getElementById('call-field').value),
String(document.getElementById('qth-field').value),
String(document.getElementById('rst-sent-field').value),
String(document.getElementById('rst-received-field').value),
String(document.getElementById('name-field').value),
String(document.getElementById('comment-field').value)
);

return(newQSO);
}



function App() {
// create empty array of rows
const [rows, setRows] = useState(Array(0));
var loggedQSOs = Array(0);

// log a QSO
function submit() {
setRows(rows.concat([getQSOData().asDict()]));
/**
* Given a submitted QSO, add it to the logs
*/
function submit(qso) {
setRows(rows.concat([qso.asDict()]));
loggedQSOs.push(qso);
}

return(
<Container>
<Header />
<LogEntry onSubmit={submit} />
<LogEntry submitQSO={submit} />
<LogTable rows={rows} />
</Container>
);
Expand Down
Loading

0 comments on commit 2e70507

Please sign in to comment.