New version 2.0

This commit is contained in:
Chrystian Huot 2019-11-18 13:06:09 -05:00
parent b2925eef3e
commit c6d1da662b
191 changed files with 22676 additions and 7355 deletions

4
.gitignore vendored
View file

@ -1,2 +1,2 @@
node_modules/
.DS_Store
.DS_Store
.vscode

View file

@ -1,18 +0,0 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.
notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1.4.3-split-account-service-packages
1.5-add-dynamic-import-package
1.7-split-underscore-from-meteor-base

1
.meteor/.gitignore vendored
View file

@ -1 +0,0 @@
local

View file

@ -1,7 +0,0 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics
1u9fl6o1biafva9x89vl

View file

@ -1,19 +0,0 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-base@1.4.0 # Packages every Meteor app needs to have
mobile-experience@1.0.5 # Packages for a great mobile UX
mongo@1.6.2 # The database Meteor supports right now
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.2.0 # Meteor's client-side reactive programming library
standard-minifier-css@1.5.3 # CSS minifier run for production mode
standard-minifier-js@2.4.1 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.12.4 # Enable ECMAScript2015+ syntax in app code
shell-server@0.4.0 # Server-side component of the `meteor shell` command
angular-compilers

View file

@ -1,2 +0,0 @@
browser
server

View file

@ -1 +0,0 @@
METEOR@1.8.1

View file

@ -1,63 +0,0 @@
allow-deny@1.1.0
angular-compilers@0.3.4
angular-html-compiler@0.3.4
angular-scss-compiler@0.3.4
angular-typescript-compiler@0.3.4
autoupdate@1.6.0
babel-compiler@7.3.4
babel-runtime@1.3.0
base64@1.0.12
binary-heap@1.0.11
boilerplate-generator@1.6.0
callback-hook@1.1.0
check@1.3.1
ddp@1.4.0
ddp-client@2.3.3
ddp-common@1.4.0
ddp-server@2.3.0
diff-sequence@1.1.1
dynamic-import@0.5.1
ecmascript@0.12.7
ecmascript-runtime@0.7.0
ecmascript-runtime-client@0.8.0
ecmascript-runtime-server@0.7.1
ejson@1.1.0
es5-shim@4.8.0
fetch@0.1.1
geojson-utils@1.0.10
hot-code-push@1.0.4
id-map@1.1.0
inter-process-messaging@0.1.0
launch-screen@1.1.1
livedata@1.0.18
logging@1.1.20
meteor@1.9.3
meteor-base@1.4.0
minifier-css@1.4.2
minifier-js@2.4.1
minimongo@1.4.5
mobile-experience@1.0.5
mobile-status-bar@1.0.14
modern-browsers@0.1.4
modules@0.13.0
modules-runtime@0.10.3
mongo@1.6.3
mongo-decimal@0.1.1
mongo-dev-server@1.1.0
mongo-id@1.0.7
npm-mongo@3.1.2
ordered-dict@1.1.0
promise@0.11.2
random@1.1.0
reactive-var@1.0.11
reload@1.3.0
retry@1.1.0
routepolicy@1.1.0
shell-server@0.4.0
socket-stream-client@0.2.2
standard-minifier-css@1.5.3
standard-minifier-js@2.4.1
tracker@1.2.0
underscore@1.0.10
webapp@1.7.4
webapp-hashing@1.0.9

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +0,0 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.pythonPath": "/usr/bin/python"
}

320
README.md
View file

@ -1,146 +1,310 @@
# Rdio Scanner - v1.5.0
# Rdio Scanner v2.0
Rdio Scanner uses the files created by [Trunk Recorder](https://github.com/robotastic/trunk-recorder) and offers them in a nice web based interface, inspired by my own personnal use of police radio scanners.
*Rdio Scanner* is a progressive web interface designed to resemble an old school radio scanner. It integrates all frontend / backend components to manage audio files from different sources.
For now, only [Trunk Recorder](https://github.com/robotastic/trunk-recorder) software files can be used, but other audio sources can be added later on request.
## What's new in this version
The version 2.0 of *Rdio Scanner* is a major rewrite in which Meteor has been replaced by [The Apollo Data Graph Platform](https://www.apollographql.com/) for its API. MongoDB is also replaced by [SQLite](https://www.sqlite.org/) to facilitate the entire installation process. It is still possible to use another database by changing [Sequelize ORM](https://sequelize.org/) settings accordingly.
These changes bring many *performance benefits* to *Rdio scanner* and make it *much easier to install*.
For those of you who are already running a previous version of *Rdio Scanner*, there is no way to upgrade your current database to the new version of *Rdio Scanner*.
## Features
* Built to act as a real police radio scanner
* Listen to live calls queued to listen
* Hold a single system or a single talkgroup
* Select talkgroups to listen to when live feed is enabled
* Search past calls stored in the database
* Just upload Trunk Recorder files with Curl
* Designed to look like a real police radio scanner
* Incoming calls are queued for lossless listening
* Temporarily hold a single system or a single talkgroup
* Select the newsgroups you want to listen to in live streaming mode
* Easily retrieve and replay past calls
* Easy to install and configure
This is the first version and many features still need to be developed, such as controlling user access, creating mobile apps. Yes, the same code can be used with the integration of Cordova in Meteor, you can use the same code and run it on an iOS or Android device.
## Demo
There is no demo site for Rdio Scanner yet, but we are working on it. We will update this section with an actual URL as it becomes available. For now, you can refer to the following section to get an idea of what is *Rdio Scanner*.
## Screenshots
The main screen displays information on associated calls, such as on a real police radio scanner:
### Main screen
* Real time clock
* (Q:) calls waiting to listen
* System name, alpha tag, tag, group, call time and talkgroup description
* (F:) trunk frequency that changes during the call
* (S:) Spikes from trunk Recorder
* (E:) Errors from Trunk Recorder
* (TGID:) Talkgroup Id
* (UID:) Unit Id which changes throughout the call
* Call history containing the last five calls
Here's where incoming calls are displayed, as long as *LIVE FEED* is enabled.
![Main Screen](./docs/images/rdio_scanner_main.png?raw=true "Main Screen")
The talkgroups selection pane which can be opened by clicking the SELECT TG button on the main screen. You can toggle individual talkgroups, or by group. This only has impact on the live feed.
* LED area
* is *ON* when playing a call
* is *Blinking* when pause is *ON* and a call is currently playing
* Display area
* Real time clock
* (Q :) Number of calls in the listening queue
* System name, alpha tag, tag, group, call duration and focus group description
* (F :) Call frequency
* (S :) Spike errors
* (E :) Decoding errors
* (TGID :) Talkgroup ID
* (UID :) Unit ID
* Call history of the last five calls
* Control area
* LIVE FEED: When enabled, incoming calls are place in the queue for playback. The queue will be emptied if it is disabled
* HOLD SYS: Temporarily hold the current call system, depending on the current talkgroups selection
* HOLD TG: Same has HOLD SYS, but for the current talkgroup
* REPLAY LAST: Replay the current call or the previous call if there is none playing
* SKIP NEXT: Ignore the current call and immediately play the next call in queue
* AVOID: Toggle the current talkgroup from the talkgroups selection. Calls from avoided talkgroups will be removed from the call queue
* SEARCH CALL: Brings the search call screen
* PAUSE: Pause playing of queued calls
* SELECT TG: Bring the talkgroups selection screen
Note that if you change the talkgroups selection while holding a system or a talkgroup, it will replace the current talkgroups selection by those that are currently holded.
### Talkgroups selection screen
The talkgroups selection screen is where you select the talkgroups. You can either select them individually, by system or globally.
Enabled talkgroup calls will be queued for listening.
![Talkgroups Selection](./docs/images/rdio_scanner_select.png?raw=true "Talkgroups Selection")
The call search pane is opens by clicking the SEARCH CALL button of the main screen. You can search for calls thrughout the database, regardless of the talkgroups selected in the talkgroups selection pane.
### Search call screen
This screen allows you to browse past calls. You can filter the list by date, system and newsgroup.
![Call Search](./docs/images/rdio_scanner_search.png?raw=true "Call Search")
## Build and Install
Search filters at the bottom of this screen are self explanatory.
Please follow the [Meteor Guide for Custom Deployment](https://guide.meteor.com/deployment.html#custom-deployment) instructions to have your own running installation.
## Quick start
Everything was built on a Fedora workstation and run in staging/production on a Debian server.
It is fairly easy to have *Rdio Scanner* up and running.
### Requirements for your development workstation
You first need to make sure that *Rdio Scanner* prerequesites are install:
* Git
* Node.js
* Meteor
* [Git](https://git-scm.com/downloads)
* [Node.js](https://nodejs.org/en/download/)
### Requirements for your staging/production server
* Apache Web Server (NGINX can also be used)
* Node.js
* MongoDB
### Development workstation quickstart
Then clone the *Rdio Scanner* code and run it:
```bash
$ git clone https://github.com/chuot/rdio-scanner.git
Cloning into 'rdio-scanner'...
remote: Enumerating objects: 1384, done.
remote: Counting objects: 100% (1384/1384), done.
remote: Compressing objects: 100% (1284/1284), done.
remote: Total 1384 (delta 752), reused 112 (delta 24)
Receiving objects: 100% (1384/1384), 1010.15 KiB | 4.83 MiB/s, done.
Resolving deltas: 100% (752/752), done.
$ cd rdio-scanner
$ npm i
$ npm start
$ node run.js
Default configuration created at /home/chuot/Temp/rdio-scanner/server/.env
Make sure your upload scripts use this API key: 1b0800a0-2b5d-422c-a4e3-972d5c1d32ff
Building client app... done
Creating SQLITE database at /home/chuot/Temp/rdio-scanner/server/database.sqlite... done
Rdio Scanner is running at http://0.0.0.0:3000/
```
You now have a running Rdio Scanner local instance running at `http://localhost:3000/` with a built-in MongoDB.
Note that the first time you start *Rdio Scanner8, it will be longer to do so as it has to install required node modules and build the progressive web app.
The runtime settings, like like those for the API upload key(s), are located in the `private/settings.json` folder.
A default configuration file `rdio-scanner/server/.env` will be created. A new random API key will be generated where it will have to be use in your upload scripts.
If your Trunk Recorder instance is installed on an other server and you want to test your Rdio Scanner development instance, you can actually create a SSH tunnel to this server from your development workstation.
At this point, you should be able to access to *Rdio Scanner* with a browser; just enter the above URL.
However, you won't see anything as you need first to upload your configuration (systems/talkgroup) to *Rdio Scanner*. For that, you can refer the to the upload scripts from the *examples section* below.
## Configuration file
*Rdio Scanner* configuration file is located at `rdio-scanner/server/.env`.
You can setup the following variables to suit your needs.
### Node environment parameters
```bash
$ ssh -R 3000:localhost:3000 *your remote server*
#
# Default values are:
#
# NODE_ENV=production
# NODE_HOST=0.0.0.0
# NODE_PORT=3000
#
# Node environment
NODE_ENV=development
# Node host
NODE_HOST=127.0.0.1
# Node port
NODE_PORT=3000
```
Then use the upload scripts to upload on `http://localhost:3000/` from your Trunk Recorder server, as if an instance of Rdio Scanner was running on that same server.
### Build a staging/production package
Building a package is as simple as this, make sure you are in the Rdio Scanner git folder.
### Database related parameters
```bash
$ meteor build ../build
#
# Default values are:
#
# DB_DIALECT=sqlite
# DB_STORAGE=database.sqlite
#
# Database host
DB_HOST=127.0.0.1
# Database port
DB_PORT=3306
# Sequelize ORM dialect
DB_DIALECT=mariadb
# Database name
DB_NAME=rdio_scanner
# Database user
DB_USER=rdio_scanner
# Database password
DB_PASS=password
# Database storage location
DB_STORAGE=
```
This will create a `rdio-scanner.tar.gz` file in `../build` that you will need to transfer to your staging/production server.
### Rdio Scanner parameters
### Staging/production installation
```bash
#
# Default values are:
#
# RDIO_APIKEYS=["b29eb8b9-9bcd-4e6e-bb4f-d244ada12736"] (randomly generated)
# RDIO_PRUNEDAYS=7
#
Remember that your staging/production instance should(must) run behind a reverse proxy server. The examples folder contains files that will help you in this process.
# Rdio Scanner API KEYS
#
# Note: The value has to be in JSON parsable format.
#
# You can either provide an array of API keys. This will allow the uploader to upload to any system/talkgroup
RDIO_APIKEYS=["b29eb8b9-9bcd-4e6e-bb4f-d244ada12736"]
# Or an array of object that tells Rdio Scanner the systems the uploader can upload.
RDIO_APIKEYS=[{"key":"b29eb8b9-9bcd-4e6e-bb4f-d244ada12736","systems":[11,15,21]}]
# Or an array of object that tells Rdio Scanner the systems and the talkgroup the uploader can upload.
RDIO_APIKEYS=[{"key":"b29eb8b9-9bcd-4e6e-bb4f-d244ada12736","systems":[{"system":11,"talkgroups":[54125,54129,54241]}]}]
# You can also provide an array of the 3 different formats mixed all together.
#### examples/rdio-scanner.service
# Rdio Scanner database pruning
#
# Calls older than this number of days will be expunge from the database.
RDIO_PRUNEDAYS=30
```
This is a systemd unit file that you willl need to copy (as root) to `/etc/systemd/system` and modify it according to your configuration. Runtime settings for Rdio Scanner are also included in this file. Make sure the API key(s) and the MongoDB url are correct.
## Updating Rdio Scanner thereafter
With simplicity, you can update *Rdio Scanner* with one command:
```bash
$ node update.js
Pulling new version from github... done
Updating node modules... done
Migrating database... done
Building client app... done
Please restart Rdio Scanner
```
## Examples
Those examples files are provided as-is to help you with *Rdio Scanner* system integration.
### docs/examples/rdio-scanner/dotenv
If the automaticaly generated `server/.env` file is not enough for you, this file contains all the parameters you can tweak to your needs.
### docs/examples/rdio-scanner/rdio-scanner.service
If you want *Rdio Scanner* to starts automaticaly upon reboots, this systemd unit file will help you with that. Just copy it as root to `/etc/systemd/system` and modify it to match your own configuration. Make sure that the paths, user and group are the correct one.
Then activate it and start it.
```bash
$ sudo systemctl daemon-reload
$ sudo systemctl enable rdio-scanner
$ sudo systemctl start rdio-scanner
```
#### examples/htpasswd
### docs/examples/trunk-recorder
This is an example of a `.htpasswd` file that you can use with an Apache Web Server to create a quick reverse proxy situation for your staging/production Rdio Scanner instance.
The folowing files assumes that you're using this folder layout. It isn't mandatory, but it helps keepings things well organized.
#### Unpack your Rdio Scanner package
Transfer the package on your server and unpack it somewhere. The example folder uses the `/home/radio/rdio-scanner` folder for it.
```bash
$ pwd
/home/radio/rdio-scanner
$ ls rdio-scanner.tar.gz
rdio-scanner.tar.gz
$ tar -xvzf rdio-scanner.tar.gz --strip-components 1
...
$ cd programs/server
$ npm i --production
$ sudo systemctl start rdio-scanner.service
```
~/trunk-recorder
~/trunk-recorder/audio_files
~/trunk-recorder/configs/*.json
~/trunk-recorder/scripts/upload-*.sh
~/trunk-recorder/talkgroups/*.csv
```
## Trunk Recorder upload
### docs/examples/trunk-recorder/configs
### AUDIO and JSON files
Those files are provided only for example purposes.
Refer to the examples folder for upload scripts, and so on. Be careful, the first argument of the upload scripts is the system number.
However, it is important to note that each system is configured to **not record** unknown talkgroups (not listed in related CSV file).
Also, notice how we pass the *arbitrary* system number to the `uploadScript`.
```bash
$ ./upload.sh 2 /home/radio/trunk-recorder/audio_files/SERAM/2019/6/12/60067-1560345651_7.73431e+08.wav
{
"systems": [{
...
"recordUnknown": false
...
"uploadScript": "scripts/upload-call.sh 11"
...
}]
}
```
### Talkgroups files
### docs/examples/trunk-recorder/scripts/upload-call.sh
The main display information are obtained from the database. You must provision the database by uploading each CSV file to Rdio Scanner with the talkgroups script from the examples folder.
This is the upload script for *Trunk Recorder*, It needs to be called with a **system number as the first argument**, then the **full path to the audio file as the second argument**.
```bash
$ ./upload.sh 2 /home/radio/trunk-recorder/SERAM.csv
$ upload-call.sh 11 .../trunk-recorder/audio_files/...
```
## Android and background apps
This script use [fdkaac](https://github.com/nu774/fdkaac) to convert audio files. It should be avaiable from your linux distro (debian and redhat based). Same goes for `curl` which is use to upload *Trunk Recorder* data to *Rdio Scanner*.
For those of you who want to let Rdio Scanner run in the background, make sure Android does not kill your browser when it is in the background.
**Please change the API key inside it for the one that has been created above within the *quick start section*. Same for the URL where to upload to Rdio Scanner instance**
For example, on my Samsung S9+, I need to configure Android to not kill Chrome when it is running in the background. Then everything works like a charm, unless another application wants to broadcast sound. But even in this case, Rdio Scanner will stop the current call if there is one and resume as soon as there is a new call to play in the queue.
```bash
curl -s http://127.0.0.1:3000/api/trunk-recorder-call-upload \
...
-F "key=b29eb8b9-9bcd-4e6e-bb4f-d244ada12736" \
...
```
### docs/examples/trunk-recorder/scripts/upload-systems.sh
Much like the previous script, this one is in charge of feeding *Rdio Scanner* with *Trunk Recorder* systems and talkgroups.
You need to upload systems and talkgroups definitions to *Rdio Scanner*, the first time you have installed it, and each time you change any *Trunk Recorder*'s configuration.
**Same here, please change the API key inside it for the one that has been created above within the *quick start section*. Same for the URL where to upload to Rdio Scanner instance**
Once uploaded, you should have your systems and talkgroups listed on *Rdio Scanner* talkgroups selection screen.
### docs/examples/trunk-recorder/systemd
Provided as complimentary files, `trunk-recorder@.service` and `trunk-recorder@.timer` can be use to manage multiple *Trunk Recorder* instances. For example, if you have more that 1 system that requires different *gains* / *tuners* each.
you can either just enable the `trunk-recorder@[config_name].service` or the `trunk-recorder@[config_name].timer`. The later one starts *Trunk Recorder* a minute after the system has booted up. This allows the *rtl-sdr* dongle to warm up a little bit before going crazy (less control channel decoding rate errors in my case).
### docs/examples/trunk-recorder/talkgroups
Since *Trunk Recorder* should only records **knowed** talkgroups, they should be well configured in each CSV files.
**Not having talkgroups well defined will make *Rdio Scanner* display calls with much less informations on screen.**

46
client/.gitignore vendored Normal file
View file

@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

674
client/LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

83
client/angular.json Normal file
View file

@ -0,0 +1,83 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"rdio-scanner": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/main.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/main.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "rdio-scanner:build",
"proxyConfig": "src/proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "rdio-scanner:build:production"
}
}
}
}
}
},
"defaultProject": "rdio-scanner"
}

12
client/browserslist Normal file
View file

@ -0,0 +1,12 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# You can see what browsers were selected by your queries by running:
# npx browserslist
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.

View file

@ -1 +0,0 @@
<router-outlet></router-outlet>

View file

@ -1,7 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'app',
templateUrl: 'app.component.html'
})
export class AppComponent { }

View file

@ -1,67 +0,0 @@
$color-dark: rgb(50, 50, 60);
$color-light: rgb(240, 240, 250);
$color-off: rgb(230, 50, 50);
$color-on: rgb(100, 230, 50);
button.radio-button {
align-items: center;
background: $color-dark;
border: none;
border-radius: 4px;
box-shadow: 1px 1px 2px $color-light inset, -1px -1px 1px $color-dark inset, 0 0 8px 2px black;
box-sizing: border-box;
color: $color-light;
display: inline-flex;
flex-direction: column;
font-family: Roboto, 'Helvetica Neue', sans-serif;
font-size: 12px;
font-weight: 500;
height: 40px;
justify-content: center;
line-height: 14px;
margin: 4px;
overflow: hidden;
position: relative;
text-shadow: 0 0 2px $color-dark;
text-transform: uppercase;
width: 70px;
&:active,
&:focus {
outline: 0;
}
&:active {
top: 4px;
}
&.off::after,
&.on::after {
content: '';
border-radius: 4px;
display: block;
height: 6px;
position: absolute;
right: 6px;
top: 6px;
width: 6px;
}
&.off::after {
background: $color-off;
box-shadow: 1px 1px 1px $color-light inset, 0 0 3px 2px $color-off;
}
&.on::after {
background: $color-on;
box-shadow: 1px 1px 1px $color-light inset, 0 0 3px 2px $color-on;
}
>div {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: inherit;
}
}

View file

@ -1,33 +0,0 @@
<div class="radio-button-group">
<button class="radio-button" (click)="toggleLiveFeed()" [ngClass]="{ off: !liveFeed, on: liveFeed }">
LIVE<br>FEED
</button>
<button class="radio-button" (click)="holdSystem()" [ngClass]="{ off: !systemHold, on: systemHold }">
HOLD<br>SYS
</button>
<button class="radio-button" (click)="holdTalkgroup()" [ngClass]="{ off: !talkgroupHold, on: talkgroupHold }">
HOLD<br>TG
</button>
</div>
<div class="radio-button-group">
<button class="radio-button" (click)="replayLast()">
REPLAY<br>LAST
</button>
<button class="radio-button" (click)="skipNext()">
SKIP<br>NEXT
</button>
<button class="radio-button" (click)="avoid()">
AVOID
</button>
</div>
<div class="radio-button-group">
<button class="radio-button" (click)="searchCall()">
SEARCH<br>CALL
</button>
<button class="radio-button" (click)="pause()" [ngClass]="{ off: !paused, on: paused }">
PAUSE
</button>
<button class="radio-button" (click)="selectTalkgroups()">
SELECT<br>TG
</button>
</div>

View file

@ -1,15 +0,0 @@
:host {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
padding: 3px;
}
.radio-button {
line-height: normal;
}
div:not(:last-child) {
margin-bottom: 12px;
}

View file

@ -1,109 +0,0 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { RadioEvent } from '../radio';
import { AppRadioService } from '../radio.service';
@Component({
selector: 'app-radio-control',
styleUrls: [
'../radio.scss',
'./radio-control.component.scss',
],
templateUrl: './radio-control.component.html',
})
export class AppRadioControlComponent implements OnDestroy, OnInit {
liveFeed: boolean = this.appRadioService.live;
paused = false;
systemHold = false;
talkgroupHold = false;
private subscriptions: Subscription[] = [];
constructor(private appRadioService: AppRadioService) { }
ngOnInit(): void {
this.subscribe();
}
ngOnDestroy(): void {
this.unsubscribe();
}
avoid(): void {
this.appRadioService.avoid();
}
holdSystem(): void {
this.appRadioService.holdSystem();
}
holdTalkgroup(): void {
this.appRadioService.holdTalkgroup();
}
pause(): void {
this.appRadioService.pause();
}
replayLast(): void {
this.appRadioService.replay();
}
searchCall(): void {
this.appRadioService.search();
}
selectTalkgroups(): void {
this.appRadioService.select();
}
skipNext(): void {
this.appRadioService.skip(true);
}
toggleLiveFeed(): void {
this.appRadioService.liveFeed();
}
private handlePauseEvent(event: RadioEvent): void {
if ('pause' in event) {
this.paused = event.pause;
}
}
private handleRadioEvent(event: RadioEvent): void {
if ('hold' in event) {
switch (event.hold) {
case '-sys':
this.systemHold = false;
break;
case '+sys':
this.systemHold = true;
break;
case '-tg':
this.talkgroupHold = false;
break;
case '+tg':
this.talkgroupHold = true;
break;
}
} else if ('live' in event) {
this.liveFeed = event.live;
}
}
private subscribe(): void {
this.subscriptions.push(
this.appRadioService.event.subscribe((event: RadioEvent) => {
this.handlePauseEvent(event);
this.handleRadioEvent(event);
}),
);
}
private unsubscribe(subscriptions: Subscription[] = this.subscriptions): void {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
}

View file

@ -1,83 +0,0 @@
<div>
<div>
<span>{{ clock | date:'HH' }}{{ clock.getSeconds() % 2 ? ' ' : ':' }}{{ clock | date:'mm' }}</span>
</div>
<div>
<span>Q: {{ queueLength }}</span>
</div>
</div>
<div>
<div>
<span>{{ currentCall ? currentCall.systemData?.name || currentCall.system : 'System'}}</span>
</div>
<div>
<span>{{ currentCall ? currentCall.talkgroupData?.tag : 'Tag' }}</span>
</div>
</div>
<div>
<div>
<span>{{ currentCall ? currentCall.talkgroupData?.alphaTag : 'Alpha Tag' }}</span>
</div>
<div>
<span>{{ currentCall ? (currentTime | date:'HH:mm') : '00:00' }}</span>
</div>
</div>
<div>
<span>{{ currentCall ? currentCall.talkgroupData?.description || (currentFrequency | freq) : 'Idle' }}</span>
</div>
<div>
<div>
<span>F: {{ currentFrequency | freq }}</span>
</div>
<div>
<span *ngIf="!currentCall || !(currentCall.talkgroupData?.mode === 'A')">
TGID: {{ currentCall ? currentCall.talkgroup : 0 }}
</span>
</div>
</div>
<div>
<div>
<span *ngIf="!currentCall || !(currentCall.talkgroupData?.mode === 'A')">
E: {{ currentError }} S: {{ currentSpike }}
</span>
</div>
<div>
<span *ngIf="!currentCall || !(currentCall.talkgroupData?.mode === 'A')">
UID: {{ currentUnit }}
</span>
</div>
</div>
<table>
<thead>
<tr>
<th>
<span>Time</span>
</th>
<th>
<span>System</span>
</th>
<th>
<span>Tag</span>
</th>
<th>
<span>Description</span>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let call of history">
<td>
<span>{{ call?.startTime | date:'HH:mm' }}</span>
</td>
<td>
<span>{{ call?.systemData?.name || call?.system}}</span>
</td>
<td>
<span>{{ call?.talkgroupData?.alphaTag || call?.talkgroup }}</span>
</td>
<td>
<span>{{ call?.talkgroupData?.description || (call?.freq | freq) }}</span>
</td>
</tr>
</tbody>
</table>

View file

@ -1,90 +0,0 @@
:host {
background: #f0ffff;
border-radius: 4px;
box-shadow: 2px 2px 4px rgb(0, 0, 0) inset, 1px 1px 2px 1px rgb(255, 255, 255);
box-sizing: border-box;
color: rgba(0, 0, 0, .8);
display: block;
font-family: Roboto, "Helvetica Neue", sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 20px;
padding: 8px;
>div {
align-items: flex-start;
display: flex;
flex-direction: row;
height: 20px;
&:nth-child(1),
&:nth-child(6) {
margin-bottom: 12px;
}
&:nth-child(4) {
font-size: 24px;
height: 32px;
line-height: 32px;
}
>div {
align-items: flex-start;
display: flex;
flex: auto;
flex-direction: row;
&:last-child {
justify-content: flex-end;
}
&:first-child {
justify-content: flex-start;
}
&:not(:first-child):not(:last-child) {
justify-content: center;
}
}
}
>table {
border-collapse: collapse;
font-size: 11px;
table-layout: fixed;
width: 100%;
td,
th {
overflow: hidden;
padding: 0;
text-align: start;
text-overflow: ellipsis;
white-space: nowrap;
&:nth-child(4) {
width: 50%;
}
}
th {
color: rgba(0, 0, 0, .4);
font-weight: 400;
text-transform: uppercase;
}
tr {
height: 21px;
}
tbody>tr {
border-top: 1px solid rgba(0, 0, 0, .2);
}
}
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

View file

@ -1,117 +0,0 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { RadioCall, RadioCallFreq, RadioCallSrc, RadioEvent } from '../radio';
import { AppRadioService } from '../radio.service';
@Component({
selector: 'app-radio-display',
styleUrls: [
'../radio.scss',
'./radio-display.component.scss',
],
templateUrl: './radio-display.component.html',
})
export class AppRadioDisplayComponent implements OnDestroy, OnInit {
clock = new Date();
currentCall: RadioCall;
currentError = 0;
currentFrequency = 0;
currentSpike = 0;
currentTime: Date;
currentUnit = 0;
history = new Array<RadioCall>(5);
live = false;
queueLength = 0;
private clockInterval: NodeJS.Timeout;
private subscriptions: Subscription[] = [];
constructor(private appRadioService: AppRadioService) { }
ngOnInit(): void {
this.clockInterval = setInterval(() => this.clock = new Date(), 1000);
this.subscribe();
}
ngOnDestroy(): void {
this.unsubscribe();
clearInterval(this.clockInterval);
}
private handleRadioCallEvent(event: RadioEvent): void {
if (
'call' in event &&
event.call !== null &&
event.call !== this.currentCall &&
!this.history.find((call) => call === event.call)
) {
this.history.pop();
this.history.unshift(this.currentCall);
this.currentCall = event.call;
this.currentTime = event.call.startTime;
}
}
private handleRadioLiveEvent(event: RadioEvent): void {
if ('live' in event) {
this.live = event.live;
}
}
private handleRadioQueueEvent(event: RadioEvent): void {
if ('queue' in event) {
this.queueLength = event.queue;
}
}
private handleRadioTimeEvent(event: RadioEvent): void {
if ('time' in event) {
const currentFreq = this.currentCall.freqList
.reduce((cur: RadioCallFreq, freq: RadioCallFreq) => freq.pos <= event.time ? freq : cur, null);
const currentSrc = this.currentCall.srcList
.reduce((cur: RadioCallSrc, src: RadioCallSrc) => src.pos <= event.time ? src : cur, null);
const currentError = currentFreq && currentFreq.errorCount;
const currentFrequency = (currentFreq && currentFreq.freq);
const currentSpike = currentFreq && currentFreq.spikeCount;
const currentUnit = currentSrc && currentSrc.src;
this.currentError = typeof currentError === 'number' ? currentError : 0;
this.currentFrequency = typeof currentFrequency === 'number' ? currentFrequency : this.currentCall.freq;
this.currentSpike = typeof currentSpike === 'number' ? currentSpike : 0;
this.currentUnit = typeof currentUnit === 'number' ? currentUnit : 0;
if (this.currentCall && this.currentCall.startTime instanceof Date) {
this.currentTime = new Date(
this.currentCall.startTime.getFullYear(),
this.currentCall.startTime.getMonth(),
this.currentCall.startTime.getDate(),
this.currentCall.startTime.getHours(),
this.currentCall.startTime.getMinutes(),
this.currentCall.startTime.getSeconds() + event.time
);
}
}
}
private subscribe(): void {
this.subscriptions.push(
this.appRadioService.event.subscribe((event: RadioEvent) => {
this.handleRadioCallEvent(event);
this.handleRadioLiveEvent(event);
this.handleRadioQueueEvent(event);
this.handleRadioTimeEvent(event);
}),
);
}
private unsubscribe(subscriptions: Subscription[] = this.subscriptions): void {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
}

View file

@ -1,32 +0,0 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'freq',
})
export class AppRadioFrequencyPipe implements PipeTransform {
formated: string;
value: number;
constructor() { }
transform(value: number): string {
if (typeof value !== 'number') {
return value;
} else if (value === this.value) {
return this.formated;
} else {
this.value = value;
this.formated = (typeof value === 'number' ? value : 0)
.toString()
.padStart(9, '0')
.replace(/(\d)(?=(\d{3})+$)/g, '$1 ')
.concat(' Hz');
return this.formated;
}
}
}

View file

@ -1 +0,0 @@
<div [ngClass]="{ off: !rx, on: rx, paused: rx && paused }"></div>

View file

@ -1,37 +0,0 @@
$color-off: rgb(80, 80, 80);
$color-on: rgb(100, 230, 50);
:host {
align-items: center;
display: flex;
flex-direction: row;
justify-content: flex-end;
>div {
background: $color-off;
border-radius: 2px;
height: 12px;
margin: 6px;
width: 24px;
&:not(:last-child) {
margin-right: 4px;
}
&.on {
background: $color-on;
box-shadow: 0 0 6px 3px $color-on;
}
&.paused {
animation: blink 2s step-end infinite;
}
}
}
@keyframes blink {
50% {
background: $color-off;
box-shadow: none;
}
}

View file

@ -1,54 +0,0 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { RadioEvent } from '../radio';
import { AppRadioService } from '../radio.service';
@Component({
selector: 'app-radio-led',
styleUrls: [
'../radio.scss',
'./radio-led.component.scss',
],
templateUrl: './radio-led.component.html',
})
export class AppRadioLedComponent implements OnDestroy, OnInit {
paused = false;
rx = false;
private subcriptions: Subscription[] = [];
constructor(private appRadioService: AppRadioService) { }
ngOnInit(): void {
this.subscribe();
}
ngOnDestroy(): void {
this.unsubscribe();
}
private handleCallEvent(event: RadioEvent): void {
if ('call' in event) {
this.rx = event.call === null ? false : true;
}
}
private handlePauseEvent(event: RadioEvent): void {
if ('pause' in event) {
this.paused = event.pause;
}
}
private subscribe(): void {
this.subcriptions.push(this.appRadioService.event.subscribe((event: RadioEvent) => {
this.handleCallEvent(event);
this.handlePauseEvent(event);
}));
}
private unsubscribe(subscriptions: Subscription[] = this.subcriptions): void {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
}

View file

@ -1,123 +0,0 @@
<div class="radio-body">
<div class="radio-button-group">
<div class="radio-button-spacer"></div>
<button (click)="close()" mat-icon-button>
<mat-icon>arrow_forward</mat-icon>
</button>
</div>
<div class="radio-list">
<mat-table [dataSource]="calls">
<ng-container matColumnDef="control">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let call">
<button (click)="play(call)" mat-icon-button>
<mat-icon>play_arrow</mat-icon>
</button>
</mat-cell>
</ng-container>
<ng-container matColumnDef="date">
<mat-header-cell *matHeaderCellDef>
<span>Date</span>
</mat-header-cell>
<mat-cell *matCellDef="let call">
<span>{{ call.startTime | date:'MM/dd' }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="time">
<mat-header-cell *matHeaderCellDef>
<span>Time</span>
</mat-header-cell>
<mat-cell *matCellDef="let call">
<span>{{ call.startTime | date:'HH:mm' }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="system">
<mat-header-cell *matHeaderCellDef>
<span>System</span>
</mat-header-cell>
<mat-cell *matCellDef="let call">
<span>{{ call.systemData?.name || call.system }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="alpha">
<mat-header-cell *matHeaderCellDef>
<span>Tag</span>
</mat-header-cell>
<mat-cell *matCellDef="let call">
<span>{{ call.talkgroupData?.alphaTag || call.talkgroup }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="description">
<mat-header-cell *matHeaderCellDef>
<span>Description</span>
</mat-header-cell>
<mat-cell *matCellDef="let call">
<span>{{ call.talkgroupData?.description || (call.freq | freq) }}</span>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="columns"></mat-header-row>
<mat-row *matRowDef="let call; columns: columns"></mat-row>
</mat-table>
<mat-paginator [length]="count" [hidePageSize]="true" (page)="onPage($event)" [pageSize]="actualPageSize"
[showFirstLastButtons]="true">
</mat-paginator>
</div>
<form class="radio-filters" [formGroup]="form" autocomplete="off">
<div>
<mat-form-field>
<mat-label>
Sort order
</mat-label>
<mat-select formControlName="sort">
<mat-option [value]="1">
Ascending
</mat-option>
<mat-option [value]="-1">
Descending
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>
Date
</mat-label>
<input (focus)="date.open()" formControlName="date" [matDatepicker]="date" matInput [max]="dateMax" [min]="dateMin" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker>
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-label>
System
</mat-label>
<mat-select formControlName="system">
<mat-option [value]="-1">
All Systems
</mat-option>
<mat-option *ngFor="let system of systems" [value]="system.system">
{{ system.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>
Talkgroup
</mat-label>
<mat-select formControlName="talkgroup">
<mat-option [value]="-1">
All Talkgroups
</mat-option>
<mat-option *ngFor="let talkgroup of talkgroups" [value]="talkgroup.dec">
{{ talkgroup.alphaTag }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div>
<button (click)="resetFilters()" mat-raised-button type="button">
Reset
</button>
</div>
</form>
</div>

View file

@ -1,76 +0,0 @@
:host {
display: flex;
flex-direction: row;
min-height: 100%;
}
.mat-cell,
.mat-header-cell {
&:first-of-type {
padding-left: 0;
}
&:last-of-type {
padding-right: 8px;
}
&:nth-child(1) {
flex: 0 0 40px;
}
&:nth-child(2),
&:nth-child(3) {
flex: 0 0 50px;
}
&:nth-child(4),
&:nth-child(5) {
flex: 0 0 20%;
}
}
.mat-table {
width: 100%;
}
.radio-body {
min-width: 100%;
padding: 12px;
>*:not(:last-child) {
margin-bottom: 12px;
}
}
.radio-filters,
.radio-list {
background: rgb(255, 255, 255);
border-radius: 4px;
color: rgba(0, 0, 0, .87);
overflow: hidden;
}
.radio-filters {
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 8px 24px;
>* {
display: flex;
flex-direction: column;
justify-content: center;
&:not(:last-child) {
flex: 1;
margin-right: 1em;
}
}
}
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

View file

@ -1,328 +0,0 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatTable } from '@angular/material/table';
import { MeteorObservable } from 'meteor-rxjs';
import { BehaviorSubject, combineLatest, Subscription } from 'rxjs';
import { debounceTime, finalize } from 'rxjs/operators';
import { RadioCall, RadioCalls, RadioEvent, RadioSystem, RadioTalkgroup } from '../radio';
import { AppRadioService } from '../radio.service';
const DEFAULT_FILTERS = {
date: null,
sort: -1,
system: -1,
talkgroup: -1,
};
@Component({
selector: 'app-radio-search',
styleUrls: [
'../radio.scss',
'./radio-search.component.scss',
],
templateUrl: './radio-search.component.html',
})
export class AppRadioSearchComponent implements OnDestroy, OnInit {
calls: RadioCall[] = [];
count = 0;
dateMax: Date;
dateMin: Date;
form: FormGroup = this.ngFormBuilder.group({
date: [],
sort: [],
system: [],
talkgroup: [],
});
systems: RadioSystem[] = [];
talkgroups: RadioTalkgroup[] = [];
readonly columns = ['control', 'date', 'time', 'system', 'alpha', 'description'];
get actualPageSize() {
return this.pageSize.value;
}
@ViewChild(MatPaginator, { static: true }) private matPaginator: MatPaginator;
@ViewChild(MatTable, { static: true }) private matTable: MatTable<RadioCall[]>;
private active = false;
private filterDate: BehaviorSubject<Date> = new BehaviorSubject<Date>(DEFAULT_FILTERS.date);
private filterSystem: BehaviorSubject<number> = new BehaviorSubject<number>(DEFAULT_FILTERS.system);
private filterTalkgroup: BehaviorSubject<number> = new BehaviorSubject<number>(DEFAULT_FILTERS.talkgroup);
private pageCurrent: BehaviorSubject<number> = new BehaviorSubject<number>(1);
private pageSize: BehaviorSubject<number> = new BehaviorSubject<number>(10);
private pageSort: BehaviorSubject<number> = new BehaviorSubject<number>(DEFAULT_FILTERS.sort);
private subscriptions: {
calls: Subscription[];
dateLimits: Subscription[];
form: Subscription[];
radio: Subscription[];
} = {
calls: [],
dateLimits: [],
form: [],
radio: [],
};
constructor(public appRadioService: AppRadioService, public ngFormBuilder: FormBuilder) {
this.resetFilters();
if (this.form.get('system').value === -1) {
this.form.get('talkgroup').disable();
}
}
ngOnInit(): void {
this.subscribeFormChanges();
this.subscribeRadioEvent();
}
ngOnDestroy(): void {
this.unsubscribe();
}
close(): void {
this.appRadioService.search();
}
onPage(event: PageEvent): void {
this.pageCurrent.next(event.pageIndex + 1);
}
play(call: RadioCall): void {
if (call) {
if (call.audio) {
this.appRadioService.play(call);
} else {
this.loadAudio(call).then(() => this.appRadioService.play(call));
}
}
}
resetFilters(): void {
this.form.reset(DEFAULT_FILTERS);
}
private handleSearchEvent(event: RadioEvent): void {
if ('search' in event) {
this.active = !this.active;
if (this.active) {
this.subscribeCalls();
this.subscribeDateLimits();
} else {
this.unsubscribeCalls();
this.unsubscribeDateLimits();
}
}
}
private handleSystemsEvent(event: RadioEvent): void {
if ('systems' in event) {
this.systems.splice(0, this.systems.length, ...event.systems);
}
}
private loadAudio(call: RadioCall): Promise<RadioCall> {
return new Promise((resolve) => {
if (call) {
MeteorObservable.call('call-audio', call._id).subscribe((audio: string) => {
call.audio = audio;
resolve(call);
});
} else {
resolve(call);
}
});
}
private subscribeCalls(): void {
const subscriptions: Subscription[] = [];
this.subscriptions.calls.push(combineLatest(
this.filterDate,
this.filterSystem,
this.filterTalkgroup,
this.pageCurrent,
this.pageSize,
this.pageSort,
)
.pipe(
debounceTime(100),
finalize(() => this.unsubscribe(subscriptions)),
)
.subscribe(([
date,
system,
talkgroup,
current,
size,
sort,
]) => {
const selector: any = {};
if (date instanceof Date) {
selector.$and = [
{
startTime: {
$gte: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
},
},
{
startTime: {
$lt: new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1),
},
},
];
}
if (system !== -1) {
selector.system = system;
}
if (talkgroup !== -1) {
selector.talkgroup = talkgroup;
}
this.unsubscribe(subscriptions);
subscriptions.push(MeteorObservable.subscribe('calls', selector, {
fields: {
audio: 0,
},
limit: size,
skip: (current - 1) * size,
sort: { startTime: sort },
}).subscribe(() => {
subscriptions.push(RadioCalls
.find(selector, {
limit: size,
sort: { startTime: sort },
transform: (call: RadioCall) => this.appRadioService.transform(call),
})
.pipe(debounceTime(100))
.subscribe((calls: RadioCall[]) => {
this.calls.splice(0, this.calls.length, ...calls);
this.matTable.renderRows();
MeteorObservable.call('calls-count', selector).subscribe((count: number) => this.count = count);
}));
}));
}));
}
private subscribeDateLimits(): void {
this.subscriptions.dateLimits.push(
MeteorObservable.subscribe('calls', {}, {
fields: { audio: 0 },
limit: 1,
sort: { startTime: -1 },
}).subscribe(() => {
const call = RadioCalls.findOne({}, {
sort: { startTime: -1 },
});
if (call) {
this.dateMax = call.startTime;
}
}),
MeteorObservable.subscribe('calls', {}, {
fields: { audio: 0 },
limit: 1,
sort: { startTime: 1 },
}).subscribe(() => {
const call = RadioCalls.findOne({}, {
sort: { startTime: 1 },
});
if (call) {
this.dateMin = call.startTime;
}
}),
);
}
private subscribeFormChanges(): void {
const dateForm = this.form.get('date');
const sortForm = this.form.get('sort');
const systemForm = this.form.get('system');
const talkgroupForm = this.form.get('talkgroup');
this.subscriptions.form.push(dateForm.valueChanges.subscribe((date: Date) => {
this.filterDate.next(date);
}));
this.subscriptions.form.push(systemForm.valueChanges.subscribe((sys: number) => {
if (sys === -1) {
this.talkgroups.splice(0, this.talkgroups.length);
if (talkgroupForm.enabled) {
talkgroupForm.disable();
}
} else {
const system = this.systems.find((_system: RadioSystem) => _system.system === sys);
if (system) {
this.talkgroups.splice(0, this.talkgroups.length, ...system.talkgroups);
}
if (talkgroupForm.disabled) {
talkgroupForm.enable();
}
}
talkgroupForm.reset(-1);
this.filterSystem.next(sys);
this.matPaginator.firstPage();
}));
this.subscriptions.form.push(talkgroupForm.valueChanges.subscribe((tg: number) => {
this.filterTalkgroup.next(tg);
this.matPaginator.firstPage();
}));
this.subscriptions.form.push(sortForm.valueChanges.subscribe((sort: number) => {
this.pageSort.next(sort);
this.matPaginator.firstPage();
}));
}
private subscribeRadioEvent(): void {
this.subscriptions.radio.push(this.appRadioService.event.subscribe((event: RadioEvent) => {
this.handleSearchEvent(event);
this.handleSystemsEvent(event);
}));
}
private unsubscribe(subscriptions: Subscription[] = [
...this.subscriptions.calls,
...this.subscriptions.dateLimits,
...this.subscriptions.form,
...this.subscriptions.radio,
]): void {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
private unsubscribeCalls(): void {
this.unsubscribe(this.subscriptions.calls);
}
private unsubscribeDateLimits(): void {
this.unsubscribe(this.subscriptions.dateLimits);
}
}

View file

@ -1,34 +0,0 @@
<div class="radio-body">
<div class="radio-button-group">
<button (click)="close()" mat-icon-button>
<mat-icon>arrow_back</mat-icon>
</button>
<ng-container *ngIf="systems.length > 1">
<button class="radio-button-mini all-off" (click)="avoid(null, null, true)">
OFF
</button>
<button class="radio-button-mini all-on" (click)="avoid(null, null, false)">
ON
</button>
</ng-container>
</div>
<fieldset *ngFor="let system of systems" class="radio-system">
<legend>
{{ system.name }}
</legend>
<div class="radio-button-group">
<button *ngFor="let talkgroup of system.talkgroups" class="radio-button" (click)="avoid(system, talkgroup)"
[ngClass]="{ off: avoids[system.system][talkgroup.dec], on: !avoids[system.system][talkgroup.dec] }">
{{ talkgroup.alphaTag }}
</button>
<ng-container *ngIf="system.talkgroups.length > 1">
<button class="radio-button-mini all-off" (click)="avoid(system, null, true)">
OFF
</button>
<button class="radio-button-mini all-on" (click)="avoid(system, null, false)">
ON
</button>
</ng-container>
</div>
</fieldset>
</div>

View file

@ -1,74 +0,0 @@
:host {
display: flex;
flex-direction: row;
min-height: 100%;
}
.radio-body {
min-width: 100%;
padding: 12px;
>div:first-child {
padding-right: 14.5px;
}
}
.radio-button-group {
justify-content: flex-start;
*:nth-last-child(2) {
margin-left: auto;
}
}
.radio-button-mini {
&.all-off {
background: rgb(100, 50, 50);
}
&.all-on {
background: rgb(50, 100, 50);
}
}
.radio-system {
font-family: Roboto, 'Helvetica Neue', sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 20px;
&:not(:last-child) {
margin-bottom: 12px;
}
legend {
opacity: .8;
padding: 0 12px;
}
}
@media (min-width: 720px) {
.radio-button-group {
.radio-button,
.radio-button-none {
width: calc(20% - 8px);
}
.radio-button-mini {
width: calc(10% - 8px);
}
}
}
@media (min-width: 1200px) {
.radio-button-group {
.radio-button,
.radio-button-none {
width: calc(10% - 8px);
}
.radio-button-mini {
width: calc(5% - 8px);
}
}
}

View file

@ -1,77 +0,0 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { RadioAvoids, RadioEvent, RadioSystem, RadioTalkgroup } from '../radio';
import { AppRadioService } from '../radio.service';
@Component({
selector: 'app-radio-select',
styleUrls: [
'../radio.scss',
'./radio-select.component.scss',
],
templateUrl: './radio-select.component.html',
})
export class AppRadioSelectComponent implements OnDestroy, OnInit {
avoids: RadioAvoids;
systems: RadioSystem[] = [];
private subscriptions: Subscription[] = [];
constructor(private appRadioService: AppRadioService) {
this.avoids = this.appRadioService.getAvoids();
}
ngOnInit(): void {
this.subscribe();
}
ngOnDestroy(): void {
this.unsubscribe();
}
avoid(system: RadioSystem | null, talkgroup: RadioTalkgroup | null, status: boolean): void {
if (system) {
this.appRadioService.avoid({ system, talkgroup, status });
} else {
this.appRadioService.avoid({ all: true, status });
}
}
close(): void {
this.appRadioService.select();
}
private handleAvoidEvent(event: RadioEvent): void {
if ('avoid' in event) {
this.avoids[event.avoid.sys][event.avoid.tg] = event.avoid.status;
}
}
private handleAvoidsEvent(event: RadioEvent): void {
if ('avoids' in event) {
this.avoids = event.avoids;
}
}
private handleSystemsEvent(event: RadioEvent): void {
if ('systems' in event) {
this.systems.splice(0, this.systems.length, ...event.systems);
}
}
private subscribe(): void {
this.subscriptions.push(
this.appRadioService.event.subscribe((event: RadioEvent) => {
this.handleAvoidEvent(event);
this.handleSystemsEvent(event);
})
);
}
private unsubscribe(subscriptions: Subscription[] = this.subscriptions) {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
}

View file

@ -1,17 +0,0 @@
<mat-sidenav-container class="radio-body">
<mat-sidenav #searchPanel [autoFocus]="false" [disableClose]="true" mode="push" [opened]="searchPanelOpened"
position="start">
<app-radio-search class="radio-search"></app-radio-search>
</mat-sidenav>
<mat-sidenav #selectPanel [autoFocus]="false" [disableClose]="true" mode="push" [opened]="selectPanelOpened"
position="end">
<app-radio-select class="radio-select"></app-radio-select>
</mat-sidenav>
<mat-sidenav-content>
<div class="radio-bezel">
<app-radio-led class="radio-led"></app-radio-led>
<app-radio-display class="radio-display"></app-radio-display>
<app-radio-control class="radio-control"></app-radio-control>
</div>
</mat-sidenav-content>
</mat-sidenav-container>

View file

@ -1,76 +0,0 @@
:host {
bottom: 0;
display: flex;
flex-direction: column;
left: 0;
position: fixed;
right: 0;
top: 0;
>* {
user-select: none;
}
}
.mat-sidenav {
width: 100%;
}
.mat-sidenav-container {
height:100%;
}
.mat-sidenav-content {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
}
.radio-bezel {
box-sizing: border-box;
max-width: 640px;
min-height: 0;
padding: 24px;
width: 100%;
}
.radio-control,
.radio-display,
.radio-led {
flex: 100%;
max-width: 100%;
}
.radio-display,
.radio-led {
margin-bottom: 24px;
}
@media (orientation: landscape) and (max-width: 640px) {
.radio-bezel {
flex-direction: row;
flex-wrap: wrap;
}
.radio-control {
flex: calc(50% - 24px);
max-width: calc(50% - 24px);
margin-left: 24px;
}
.radio-display {
flex: 50%;
max-width: 50%;
}
.radio-display,
.radio-led {
margin: 0;
}
.radio-led {
flex: 100%;
max-width: 100%;
}
}

View file

@ -1,58 +0,0 @@
import { Component, HostListener, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { RadioEvent } from './radio';
import { AppRadioService } from './radio.service';
@Component({
selector: 'app-radio',
styleUrls: [
'./radio.scss',
'./radio.component.scss',
],
templateUrl: './radio.component.html',
})
export class AppRadioComponent implements OnDestroy, OnInit {
searchPanelOpened = false;
selectPanelOpened = false;
private subscriptions: Subscription[] = [];
constructor(private appRadioService: AppRadioService) { }
ngOnInit(): void {
this.subscribe();
}
ngOnDestroy(): void {
this.unsubscribe();
}
@HostListener('window:beforeunload', ['$event'])
private exitNotification(event: BeforeUnloadEvent): void {
if (this.appRadioService.live) {
event.preventDefault();
event.returnValue = false;
}
}
private subscribe(): void {
this.subscriptions.push(
this.appRadioService.event.subscribe((event: RadioEvent) => {
if ('search' in event) {
this.searchPanelOpened = !this.searchPanelOpened;
this.selectPanelOpened = false;
}
if ('select' in event) {
this.selectPanelOpened = !this.selectPanelOpened;
this.searchPanelOpened = false;
}
}),
);
}
private unsubscribe(subscriptions: Subscription[] = this.subscriptions): void {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
}

View file

@ -1,35 +0,0 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppSharedModule } from '../shared/shared.module';
import { AppRadioControlComponent } from './radio-control/radio-control.component';
import { AppRadioDisplayComponent } from './radio-display/radio-display.component';
import { AppRadioFrequencyPipe } from './radio-frequency.pipe';
import { AppRadioLedComponent } from './radio-led/radio-led.component';
import { AppRadioSearchComponent } from './radio-search/radio-search.component';
import { AppRadioSelectComponent } from './radio-select/radio-select.component';
import { AppRadioComponent } from './radio.component';
import { AppRadioService } from './radio.service';
@NgModule({
declarations: [
AppRadioComponent,
AppRadioControlComponent,
AppRadioDisplayComponent,
AppRadioFrequencyPipe,
AppRadioLedComponent,
AppRadioSearchComponent,
AppRadioSelectComponent,
],
exports: [AppRadioComponent],
imports: [
AppSharedModule,
RouterModule.forChild([
{
component: AppRadioComponent,
path: '',
}
])
],
providers: [AppRadioService],
})
export class AppRadioModule { }

View file

@ -1,92 +0,0 @@
.radio-body {
background: rgb(30, 30, 30);
box-sizing: border-box;
color: rgb(255, 255, 255);
}
.radio-button,
.radio-button-mini,
.radio-button-none {
margin: 4px;
}
.radio-button,
.radio-button-mini {
background: rgb(45, 45, 45);
border: none;
border-radius: 4px;
box-shadow: 1px 1px 2px rgb(255, 255, 255) inset, -1px -1px 1px rgb(0, 0, 0) inset, 0 0 2px 2px rgb(0, 0, 0);
box-sizing: border-box;
color: rgb(255, 255, 255);
font-family: Roboto, 'Helvetica Neue', sans-serif;
font-size: 12px;
font-weight: 500;
height: 40px;
line-height: 40px;
overflow: hidden;
position: relative;
text-overflow: ellipsis;
text-shadow: 0 0 4px rgb(0, 0, 0);
user-select: none;
white-space: nowrap;
width: auto;
&:active,
&:focus {
outline: 0;
}
&:active {
top: 4px;
}
&.off::after,
&.on::after {
content: '';
border-radius: 4px;
display: block;
height: 6px;
position: absolute;
right: 6px;
top: 6px;
width: 6px;
}
&.off::after {
background: rgb(230, 50, 50);
box-shadow: 1px 1px 1px rgb(255, 255, 255) inset, 0 0 3px 2px rgb(230, 50, 50);
}
&.on::after {
background: rgb(100, 230, 50);
box-shadow: 1px 1px 1px rgb(255, 255, 255) inset, 0 0 3px 2px rgb(100, 230, 50);
}
}
.radio-button,
.radio-button-none {
min-width: 64px;
}
.radio-button-group {
align-items: center;
display: flex;
flex: auto;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
.radio-button,
.radio-button-none {
width: calc(25% - 8px);
}
.radio-button-mini {
width: calc(12.5% - 8px);
}
}
.radio-button-mini {
font-size: 10px;
min-width: 30px;
}

View file

@ -1,603 +0,0 @@
import { EventEmitter, Injectable, OnDestroy } from '@angular/core';
import { MeteorObservable } from 'meteor-rxjs';
import { Subscription } from 'rxjs';
import { debounceTime, filter, skip } from 'rxjs/operators';
import { RadioAvoids, RadioCall, RadioCalls, RadioEvent, RadioSystem, RadioSystems, RadioTalkgroup } from './radio';
declare var webkitAudioContext: any;
const EVENTS = ['mousedown', 'touchdown'];
const LOCAL_STORAGE_KEY = {
avoids: 'radio-avoids',
};
@Injectable()
export class AppRadioService implements OnDestroy {
readonly event = new EventEmitter<RadioEvent>();
get live() {
return !!this.subscriptions.liveFeed.length;
}
private audioContext: AudioContext;
private audioSource: AudioBufferSourceNode = null;
private audioStartTime = NaN;
private audioTimer: any = null;
private avoids: RadioAvoids = {};
private call: {
current: RadioCall | null;
previous: RadioCall | null;
queue: RadioCall[];
} = {
current: null,
previous: null,
queue: [],
};
private hold: {
system: RadioSystem | number | null,
talkgroup: RadioTalkgroup | number | null,
} = {
system: null,
talkgroup: null,
};
private paused = false;
private subscriptions: {
liveFeed: Subscription[];
systems: Subscription[];
} = {
liveFeed: [],
systems: [],
};
private systems: RadioSystem[] = [];
constructor() {
this.bootstrap();
this.readAvoids();
this.subscribeSystems();
}
ngOnDestroy(): void {
if (this.audioContext) {
this.audioContext.close();
}
this.event.complete();
this.unsubscribe();
}
avoid(parms: {
all?: boolean;
call?: RadioCall;
system?: RadioSystem;
talkgroup?: RadioTalkgroup;
status?: boolean
} = {}): void {
if (typeof parms.all === 'boolean') {
Object.keys(this.avoids).map((sys: string) => +sys).forEach((sys: number) => {
Object.keys(this.avoids[sys]).map((tg: string) => +tg).forEach((tg: number) => {
this.avoids[sys][tg] = typeof parms.status === 'boolean' ? parms.status : !this.avoids[sys][tg];
this.emitAvoidEvent(sys, tg);
});
});
} else if (parms.call) {
const sys = parms.call.system;
const tg = parms.call.talkgroup;
this.avoids[sys][tg] = typeof parms.status === 'boolean' ? parms.status : !this.avoids[sys][tg];
this.emitAvoidEvent(sys, tg);
} else if (parms.system && parms.talkgroup) {
const sys = parms.system.system;
const tg = parms.talkgroup.dec;
this.avoids[sys][tg] = typeof parms.status === 'boolean' ? parms.status : !this.avoids[sys][tg];
this.emitAvoidEvent(sys, tg);
} else if (parms.system && !parms.talkgroup) {
const sys = parms.system.system;
Object.keys(this.avoids[sys]).map((tg: string) => +tg).forEach((tg: number) => {
this.avoids[sys][tg] = typeof parms.status === 'boolean' ? parms.status : !this.avoids[sys][tg];
this.emitAvoidEvent(sys, tg);
});
} else {
const call = this.call.current || this.call.previous;
if (call) {
const sys = call.system;
const tg = call.talkgroup;
this.avoids[sys][tg] = typeof parms.status === 'boolean' ? parms.status : !this.avoids[sys][tg];
this.emitAvoidEvent(sys, tg);
}
}
this.cleanQueue();
if (this.call.current && this.callFiltered()) {
this.skip();
}
if (this.live) {
this.unsubscribeLiveFeed();
this.subscribeLiveFeed();
}
this.writeAvoids();
}
getAvoids(): RadioAvoids {
return this.avoids;
}
holdSystem(): void {
const call = this.call.current || this.call.previous;
if (call) {
this.hold.system = this.hold.system === null ? call.systemData || call.system : null;
this.emitHoldEvent(this.hold.system === null ? '-sys' : '+sys');
if (this.hold.system !== null) {
this.cleanQueue();
}
}
}
holdTalkgroup(): void {
const call = this.call.current || this.call.previous;
if (call) {
this.hold.talkgroup = this.hold.talkgroup === null ? call.talkgroupData || call.talkgroup : null;
this.emitHoldEvent(this.hold.talkgroup === null ? '-tg' : '+tg');
if (this.hold.talkgroup !== null) {
this.cleanQueue();
}
}
}
liveFeed(status = !this.live): void {
if (status) {
this.subscribeLiveFeed();
} else {
this.unsubscribeLiveFeed();
this.emitLiveEvent();
this.flushQueue();
this.stop();
}
}
pause(): void {
this.paused = !this.paused;
this.emitPauseEvent();
if (this.audioContext) {
if (this.paused) {
this.audioContext.suspend();
} else {
this.audioContext.resume();
this.play();
}
}
}
play(call?: RadioCall): void {
if (this.audioContext && !this.paused) {
if (!call && !this.call.current && this.call.queue.length) {
call = this.call.queue.shift();
this.emitQueueEvent();
}
if (call && call.audio) {
this.stop();
this.call.current = call;
this.emitCallEvent();
this.emitTimeEvent();
const audio = /^data:[^;]+;base64,/.test(call.audio) ? atob(call.audio.replace(/^[^,]*,/, '')) : call.audio;
const arrayBuffer = new ArrayBuffer(audio.length);
const arrayBufferView = new Uint8Array(arrayBuffer);
for (let i = 0; i < audio.length; i++) {
arrayBufferView[i] = audio.charCodeAt(i);
}
this.audioContext.decodeAudioData(arrayBuffer, (buffer) => {
if (this.call.current) {
this.audioContext.resume().then(() => {
this.audioSource = this.audioContext.createBufferSource();
this.audioSource.buffer = buffer;
this.audioSource.connect(this.audioContext.destination);
this.audioSource.onended = () => this.skip();
this.audioSource.start();
this.audioTimer = setInterval(() => this.emitTimeEvent(), 500);
});
}
}, () => this.skip());
}
}
}
queue(call: RadioCall | RadioCall[]): void {
if (Array.isArray(call)) {
call.forEach((_call: RadioCall) => this.queue(_call));
} else if (!this.callFiltered(call)) {
this.call.queue.push(call);
this.emitQueueEvent();
this.play();
}
}
replay(): void {
if (!this.paused) {
this.play(this.call.current || this.call.previous);
}
}
search(): void {
this.emitSearchEvent();
}
select(): void {
this.emitSelectEvent();
}
skip(nodelay = false): void {
this.stop();
if (nodelay) {
this.play();
} else {
setTimeout(() => this.play(), 1000);
}
}
stop(): void {
if (this.call.current) {
if (this.audioTimer !== null) {
clearInterval(this.audioTimer);
this.audioTimer = null;
}
if (this.audioSource) {
this.audioSource.onended = null;
this.audioSource.stop();
this.audioSource.disconnect();
}
this.audioStartTime = NaN;
this.call.previous = this.call.current;
this.call.current = null;
this.emitCallEvent();
}
}
transform(call: RadioCall): RadioCall {
call.systemData = (call && this.systems
.find((system: RadioSystem) => system.system === call.system)) || null;
call.talkgroupData = (call && call.systemData && call.systemData.talkgroups
.find((talkgroup: RadioTalkgroup) => talkgroup.dec === call.talkgroup)) || null;
return call;
}
private bootstrap(): void {
const bootstrap = () => {
if (!this.audioContext) {
if ('webkitAudioContext' in window) {
this.audioContext = new webkitAudioContext();
} else {
this.audioContext = new AudioContext();
}
}
if (this.audioContext) {
this.audioContext.resume().then(() => {
EVENTS.forEach((event) => document.body.removeEventListener(event, bootstrap));
});
}
};
EVENTS.forEach((event) => document.body.addEventListener(event, bootstrap));
}
private callFiltered(call: RadioCall = this.call.current): boolean {
if (
this.hold.system !== null &&
(typeof this.hold.system === 'object' && this.hold.system !== call.systemData) ||
(typeof this.hold.system === 'number' && this.hold.system !== call.system)
) {
return true;
} else if (
this.hold.talkgroup !== null &&
(typeof this.hold.talkgroup === 'object' && this.hold.talkgroup !== call.talkgroupData) ||
(typeof this.hold.talkgroup === 'number' && this.hold.talkgroup !== call.talkgroup)
) {
return true;
} else {
const sys = call.system;
const tg = call.talkgroup;
const avoided = this.avoids[sys] && this.avoids[sys][tg];
return typeof avoided === 'boolean' ? avoided : false;
}
}
private cleanQueue(): void {
const queueLength = this.call.queue.length;
this.call.queue = this.call.queue.filter((call: RadioCall) => !this.callFiltered(call));
if (queueLength !== this.call.queue.length) {
this.emitQueueEvent();
}
}
private emitAvoidEvent(sys: number, tg: number): void {
this.event.emit({ avoid: { sys, tg, status: this.avoids[sys][tg] } });
}
private emitAvoidsEvent(): void {
this.event.emit({ avoids: this.avoids });
}
private emitCallEvent(): void {
this.event.emit({ call: this.call.current });
}
private emitHoldEvent(value: RadioEvent['hold']): void {
this.event.emit({ hold: value });
}
private emitLiveEvent(): void {
this.event.emit({ live: this.live });
}
private emitPauseEvent(): void {
this.event.emit({ pause: this.paused });
}
private emitQueueEvent(): void {
this.event.emit({ queue: this.call.queue.length });
}
private emitSearchEvent(): void {
this.event.emit({ search: null });
}
private emitSelectEvent(): void {
this.event.emit({ select: null });
}
private emitSystemsEvent(): void {
this.event.emit({ systems: this.systems });
}
private emitTimeEvent(): void {
if (!this.paused && !isNaN(this.audioContext.currentTime)) {
if (isNaN(this.audioStartTime)) {
this.audioStartTime = this.audioContext.currentTime;
}
this.event.emit({ time: this.audioContext.currentTime - this.audioStartTime });
}
}
private flushQueue() {
this.call.queue.splice(0, this.call.queue.length);
this.emitQueueEvent();
}
private readAvoids(): void {
const avoids = this.readLocalStorage(LOCAL_STORAGE_KEY.avoids);
if (avoids) {
Object.keys(avoids).map((sys: string) => +sys).forEach((sys: number) => {
if (Array.isArray(avoids[sys])) {
avoids[sys].forEach((tg: number) => {
if (!this.avoids[sys]) {
this.avoids[sys] = {};
}
this.avoids[sys][tg] = true;
});
}
});
}
this.emitAvoidsEvent();
}
private readLocalStorage(key: string): any {
if (window instanceof Window && window.localStorage instanceof Storage) {
try {
return JSON.parse(window.localStorage.getItem(key));
} catch (e) {
return null;
}
}
}
private subscribeLiveFeed(): void {
if (!this.subscriptions.liveFeed.length) {
const options = {
limit: 1,
sort: {
createdAt: -1,
},
transform: (call: RadioCall) => this.transform(call),
};
const avoids = Object.keys(this.avoids)
.map((sys: string) => +sys)
.reduce((sel: any, sys: number) => {
const tgs = Object.keys(this.avoids[sys])
.map((tg: string) => +tg)
.filter((tg: number) => this.avoids[sys][tg]);
if (tgs.length) {
sel.push({
$and: [
{
system: { $ne: sys },
},
{
talkgroup: { $nin: tgs },
},
],
});
}
return sel;
}, []);
const selector = avoids.length ? { $or: avoids } : {};
this.subscriptions.liveFeed.push(MeteorObservable
.subscribe('calls', selector, options)
.subscribe(() => {
this.subscriptions.liveFeed.push(RadioCalls
.find(selector, options)
.pipe(
filter((calls: RadioCall[]) => !!calls.length),
skip(2),
)
.subscribe((calls: RadioCall[]) => this.queue(calls)));
}));
this.emitLiveEvent();
}
}
private subscribeSystems(): void {
if (!this.subscriptions.systems.length) {
this.subscriptions.systems.push(MeteorObservable
.subscribe('systems')
.subscribe());
this.subscriptions.systems.push(RadioSystems
.find({}, {
sort: {
system: 1,
},
})
.pipe(debounceTime(100))
.subscribe((systems: RadioSystem[]) => {
if (systems.length) {
this.systems.splice(0, this.systems.length, ...systems);
this.emitSystemsEvent();
this.syncAvoids();
this.writeAvoids();
}
}));
}
}
private syncAvoids(): void {
this.systems.forEach((system: RadioSystem) => {
const sys = system.system;
if (typeof this.avoids[sys] !== 'object') {
this.avoids[sys] = {};
}
system.talkgroups.forEach((talkgroup: RadioTalkgroup) => {
const tg = talkgroup.dec;
if (typeof this.avoids[sys][tg] !== 'boolean') {
this.avoids[sys][tg] = false;
}
});
});
Object.keys(this.avoids).map((sys: string) => +sys).forEach((sys: number) => {
const system = this.systems.find((_system: RadioSystem) => _system.system === +sys);
if (system) {
Object.keys(this.avoids[sys]).map((tg: string) => +tg).forEach((tg: number) => {
const talkgroup = system.talkgroups.find((_talkgroup: RadioTalkgroup) => _talkgroup.dec === +tg);
if (!talkgroup) {
delete this.avoids[sys][tg];
}
});
} else {
delete this.avoids[sys];
}
});
}
private unsubscribe(subscriptions: Subscription[] = [
...this.subscriptions.liveFeed,
...this.subscriptions.systems,
]) {
while (subscriptions.length) {
subscriptions.pop().unsubscribe();
}
}
private unsubscribeLiveFeed(): void {
this.unsubscribe(this.subscriptions.liveFeed);
}
private writeAvoids(): void {
const avoids: { [sys: number]: number[] } = {};
Object.keys(this.avoids).map((sys: string) => +sys).forEach((sys: number) => {
Object.keys(this.avoids[sys]).map((tg: string) => +tg).forEach((tg: number) => {
if (this.avoids[sys][tg]) {
if (Array.isArray(avoids[sys])) {
avoids[sys].push(tg);
} else {
avoids[sys] = [tg];
}
}
});
});
this.writeLocalStorage(LOCAL_STORAGE_KEY.avoids, avoids);
}
private writeLocalStorage(key: string, value: any): void {
if (window instanceof Window && window.localStorage instanceof Storage) {
window.localStorage.setItem(key, JSON.stringify(value));
}
}
}

View file

@ -1,39 +0,0 @@
import { Call } from '../../../../imports/models/call';
import { System as RadioSystem } from '../../../../imports/models/system';
import { Talkgroup as RadioTalkgroup } from '../../../../imports/models/talkgroup';
export { Calls as RadioCalls} from '../../../../imports/collections/calls';
export { Systems as RadioSystems} from '../../../../imports/collections/systems';
export { CallFreq as RadioCallFreq, CallSrc as RadioCallSrc } from '../../../../imports/models/call';
export { System as RadioSystem } from '../../../../imports/models/system';
export { Talkgroup as RadioTalkgroup } from '../../../../imports/models/talkgroup';
export interface RadioAvoids {
[key: number]: {
[key: number]: boolean;
};
}
export interface RadioCall extends Call {
alphaTag?: string;
description?: string;
mode?: string;
tag?: string;
group?: string;
systemData?: RadioSystem;
talkgroupData?: RadioTalkgroup;
}
export interface RadioEvent {
avoid?: { sys: number, tg: number, status: boolean };
avoids?: RadioAvoids;
call?: RadioCall | null;
hold?: '-sys' | '+sys' | '-tg' | '+tg';
live?: boolean;
pause?: boolean;
queue?: number;
search?: null;
select?: null;
systems?: RadioSystem[];
time?: number;
}

View file

@ -1,14 +0,0 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppMaterialModule } from './material/material.module';
@NgModule({
exports: [
AppMaterialModule,
CommonModule,
FormsModule,
ReactiveFormsModule,
],
})
export class AppSharedModule { }

View file

@ -1,3 +0,0 @@
import 'zone.js';
import 'core-js/proposals/reflect-metadata';

View file

@ -1,30 +0,0 @@
<head>
<base href="/">
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="stylesheet" href="///fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons">
<meta name="msapplication-TileColor" content="rgb(30, 30, 30)">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="rgb(30, 30, 30)">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Rdio Scanner</title>
</head>
<body>
<app></app>
<noscript>
You must have JavaScript enabled to use this app.
</noscript>
</body>

View file

@ -1,10 +0,0 @@
@font-face {
font-family: 'DSEG7Modern-Regular';
src: url('/fonts/DSEG_v045/DSEG7-Modern/DSEG7Modern-Regular.woff');
}
@import '@angular/material/prebuilt-themes/indigo-pink';
body {
margin: 0;
}

View file

@ -1,17 +0,0 @@
import './imports/polyfills';
import { Meteor } from 'meteor/meteor';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './imports/app/app.module';
Meteor.startup(() => {
if (Meteor.isProduction) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
});

11476
client/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

47
client/package.json Normal file
View file

@ -0,0 +1,47 @@
{
"name": "rdio-scanner-client",
"version": "2.0.0",
"private": true,
"scripts": {
"build": "ng build --cross-origin use-credentials --prod $*",
"start": "ng serve"
},
"author": "Chrystian Huot",
"license": "LICENSE",
"dependencies": {
"@angular/animations": "^8.2.14",
"@angular/cdk": "^8.2.3",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "~8.2.14",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"apollo-angular": "^1.8.0",
"apollo-angular-link-http": "^1.9.0",
"apollo-cache-inmemory": "^1.6.3",
"apollo-client": "^2.6.4",
"apollo-link": "^1.2.13",
"apollo-link-ws": "^1.0.19",
"graphql": "^14.5.8",
"graphql-tag": "^2.10.1",
"rxjs": "~6.5.3",
"subscriptions-transport-ws": "^0.9.16",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.19",
"@angular/cli": "~8.3.19",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@types/node": "~12.12.8",
"codelyzer": "^5.2.0",
"ts-node": "~8.5.2",
"tslint": "~5.20.1",
"typescript": "~3.5.3"
}
}

View file

@ -0,0 +1 @@
<app-rdio-scanner></app-rdio-scanner>

View file

@ -0,0 +1,5 @@
:host {
display: block;
height: 100%;
width: 100%;
}

View file

@ -0,0 +1,8 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
styleUrls: ['./app.component.scss'],
templateUrl: './app.component.html',
})
export class AppComponent { }

View file

@ -1,29 +1,18 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { AppRdioScannerModule } from './components/rdio-scanner/rdio-scanner.module';
import { AppSharedModule } from './shared/shared.module';
@NgModule({
bootstrap: [AppComponent],
declarations: [AppComponent],
imports: [
AppSharedModule,
AppRdioScannerModule,
AppSharedModule.forRoot(),
BrowserAnimationsModule,
BrowserModule,
RouterModule.forRoot([
{
// loadChildren: () => import('./radio/radio.module').then((m) => m.AppRadioModule),
loadChildren: './radio/radio.module#AppRadioModule',
path: '',
},
{
path: '**',
pathMatch: 'full',
redirectTo: '',
},
]),
],
})
export class AppModule { }

View file

@ -0,0 +1,70 @@
import { Injectable } from '@angular/core';
import { Query } from 'apollo-angular';
import gql from 'graphql-tag';
import { RdioScannerSystem, RdioScannerTalkgroup } from './rdio-scanner-systems-query.service';
export interface RdioScannerCall {
audio?: {
type?: 'Buffer';
data?: number[];
};
emergency?: boolean;
freq?: number;
freqList?: RdioScannerCallFreq[];
id?: string;
startTime?: Date;
stopTime?: Date;
srcList?: RdioScannerCallSrc[];
system?: number;
talkgroup?: number;
talkgroupData?: RdioScannerTalkgroup;
systemData?: RdioScannerSystem;
}
export interface RdioScannerCallFreq {
errorCount?: number;
freq?: number;
len?: number;
pos?: number;
spikeCount?: number;
}
export interface RdioScannerCallSrc {
pos?: number;
src?: number;
}
export interface RdioScannerCallQueryResponse {
rdioScannerCall: RdioScannerCall;
}
@Injectable({
providedIn: 'root',
})
export class AppRdioScannerCallQueryService extends Query<RdioScannerCallQueryResponse> {
document = gql`
query rdioScannerCall($id: String) {
rdioScannerCall(id: $id) {
id
audio
emergency
freq
freqList {
errorCount
freq
len
pos
spikeCount
}
startTime
stopTime
srcList {
pos
src
}
system
talkgroup
}
}
`;
}

View file

@ -0,0 +1,70 @@
import { Injectable } from '@angular/core';
import { Subscription } from 'apollo-angular';
import gql from 'graphql-tag';
import { RdioScannerSystem, RdioScannerTalkgroup } from './rdio-scanner-systems-subscription.service';
export interface RdioScannerCall {
audio?: {
type?: 'Buffer';
data?: number[];
};
emergency?: boolean;
freq?: number;
freqList?: RdioScannerCallFreq[];
id?: string;
startTime?: Date;
stopTime?: Date;
srcList?: RdioScannerCallSrc[];
system?: number;
talkgroup?: number;
talkgroupData?: RdioScannerTalkgroup;
systemData?: RdioScannerSystem;
}
export interface RdioScannerCallFreq {
errorCount?: number;
freq?: number;
len?: number;
pos?: number;
spikeCount?: number;
}
export interface RdioScannerCallSrc {
pos?: number;
src?: number;
}
export interface RdioScannerCallSubscriptionResponse {
rdioScannerCall: RdioScannerCall;
}
@Injectable({
providedIn: 'root',
})
export class AppRdioScannerCallSubscriptionService extends Subscription<RdioScannerCallSubscriptionResponse> {
document = gql`
subscription rdioScannerCall($selection: String) {
rdioScannerCall(selection: $selection) {
id
audio
emergency
freq
freqList {
errorCount
freq
len
pos
spikeCount
}
startTime
stopTime
srcList {
pos
src
}
system
talkgroup
}
}
`;
}

View file

@ -0,0 +1,91 @@
import { Injectable } from '@angular/core';
import { Query } from 'apollo-angular';
import gql from 'graphql-tag';
import { RdioScannerSystem, RdioScannerTalkgroup } from './rdio-scanner-systems-query.service';
export interface RdioScannerCall {
emergency?: boolean;
freq?: number;
freqList?: RdioScannerCallFreq[];
id?: string;
startTime?: Date;
stopTime?: Date;
srcList?: RdioScannerCallSrc[];
system?: number;
talkgroup?: number;
talkgroupData?: RdioScannerTalkgroup;
systemData?: RdioScannerSystem;
}
export interface RdioScannerCallFreq {
errorCount?: number;
freq?: number;
len?: number;
pos?: number;
spikeCount?: number;
}
export interface RdioScannerCallSrc {
pos?: number;
src?: number;
}
export interface RdioScannerCallsQueryResponse {
rdioScannerCalls: {
count: number;
dateStart: string;
dateStop: string;
results: RdioScannerCall[];
};
}
@Injectable({
providedIn: 'root',
})
export class AppRdioScannerCallsQueryService extends Query<RdioScannerCallsQueryResponse> {
document = gql`
query rdioScannerCalls(
$date: Date
$first: Int
$last: Int
$skip: Int
$sort: Int
$system: Int
$talkgroup: Int
) {
rdioScannerCalls(
date: $date
first: $first
last: $last
skip: $skip
sort: $sort
system: $system
talkgroup: $talkgroup
) {
count
dateStart
dateStop
results {
id
emergency
freq
freqList {
errorCount
freq
len
pos
spikeCount
}
startTime
stopTime
srcList {
pos
src
}
system
talkgroup
}
}
}
`;
}

View file

@ -0,0 +1,46 @@
import { Injectable } from '@angular/core';
import { Query } from 'apollo-angular';
import gql from 'graphql-tag';
export interface RdioScannerSystem {
id?: string;
name?: string;
system?: number;
talkgroups?: RdioScannerTalkgroup[];
}
export interface RdioScannerTalkgroup {
alphaTag?: string;
dec?: number;
description?: string;
group?: string;
mode?: string;
tag?: string;
}
export interface RdioScannerSystemsQueryResponse {
rdioScannerSystems: RdioScannerSystem[];
}
@Injectable({
providedIn: 'root',
})
export class AppRdioScannerSystemsQueryService extends Query<RdioScannerSystemsQueryResponse> {
document = gql`
query rdioScannerSystems {
rdioScannerSystems {
id
name
system
talkgroups {
alphaTag
dec
description
group
mode
tag
}
}
}
`;
}

View file

@ -0,0 +1,46 @@
import { Injectable } from '@angular/core';
import { Subscription } from 'apollo-angular';
import gql from 'graphql-tag';
export interface RdioScannerSystem {
id?: string;
name?: string;
system?: number;
talkgroups?: RdioScannerTalkgroup[];
}
export interface RdioScannerTalkgroup {
alphaTag?: string;
dec?: number;
description?: string;
group?: string;
mode?: string;
tag?: string;
}
export interface RdioScannerSystemsSubscriptionResponse {
rdioScannerSystems: RdioScannerSystem[];
}
@Injectable({
providedIn: 'root',
})
export class AppRdioScannerSystemsSubscriptionService extends Subscription<RdioScannerSystemsSubscriptionResponse> {
document = gql`
subscription rdioScannerSystems {
rdioScannerSystems {
id
name
system
talkgroups {
alphaTag
dec
description
group
mode
tag
}
}
}
`;
}

View file

@ -0,0 +1,331 @@
<mat-sidenav-container>
<mat-sidenav #searchPanel [autoFocus]="false" [disableClose]="true" mode="push" [opened]="searchPanelOpened"
position="start">
<div class="rdio-search">
<mat-toolbar>
<div fxFlex></div>
<div>
<button (click)="toggleSearchPanel(false)" mat-icon-button>
<mat-icon>arrow_forward</mat-icon>
</button>
</div>
</mat-toolbar>
<div class="rdio-search-results">
<mat-table [dataSource]="searchResults">
<ng-container matColumnDef="control">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let row">
<ng-container *ngIf="row">
<button (click)="row === call ? skip() : loadAndPlay(row)" mat-icon-button>
<ng-container *ngIf="row === call">
<mat-icon>stop</mat-icon>
</ng-container>
<ng-container *ngIf="row !== call">
<mat-icon>play_arrow</mat-icon>
</ng-container>
</button>
</ng-container>
</mat-cell>
</ng-container>
<ng-container matColumnDef="date">
<mat-header-cell *matHeaderCellDef>
<span>Date</span>
</mat-header-cell>
<mat-cell *matCellDef="let row">
<span>{{ row?.startTime | date:'MM/dd' }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="time">
<mat-header-cell *matHeaderCellDef>
<span>Time</span>
</mat-header-cell>
<mat-cell *matCellDef="let row">
<span>{{ row?.startTime | date:'HH:mm' }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="system">
<mat-header-cell *matHeaderCellDef>
<span>System</span>
</mat-header-cell>
<mat-cell *matCellDef="let row">
<span>{{ row?.systemData?.name || row?.system }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="alpha">
<mat-header-cell *matHeaderCellDef>
<span>Tag</span>
</mat-header-cell>
<mat-cell *matCellDef="let row">
<span>{{ row?.talkgroupData?.alphaTag || row?.talkgroup }}</span>
</mat-cell>
</ng-container>
<ng-container matColumnDef="description">
<mat-header-cell *matHeaderCellDef>
<span>Description</span>
</mat-header-cell>
<mat-cell *matCellDef="let row">
<span>{{ row?.talkgroupData?.description }}</span>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="['control', 'date', 'time', 'system', 'alpha', 'description']">
</mat-header-row>
<mat-row
*matRowDef="let row; columns: ['control', 'date', 'time', 'system', 'alpha', 'description']">
</mat-row>
</mat-table>
<mat-progress-bar color="primary" [mode]="searchResultsPending ? 'query' : 'determinate'">
</mat-progress-bar>
<mat-paginator [disabled]="searchResultsPending" [length]="searchResultsCount" [hidePageSize]="true"
pageSize="10" [showFirstLastButtons]="true">
</mat-paginator>
</div>
<form class="rdio-search-form" [formGroup]="searchForm" autocomplete="off">
<div>
<mat-form-field fxFlex>
<mat-label>
Sort order
</mat-label>
<mat-select formControlName="sort">
<mat-option [value]="1">
Ascending
</mat-option>
<mat-option [value]="-1">
Descending
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>
Date
</mat-label>
<input (click)="date.open()" formControlName="date" [matDatepicker]="date" matInput
[max]="searchFormDateStop" [min]="searchFormDateStart" placeholder="Choose a date" readonly>
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker>
</mat-form-field>
</div>
<div>
<mat-form-field fxFlex>
<mat-label>
System
</mat-label>
<mat-select formControlName="system">
<mat-option [value]="-1">
All Systems
</mat-option>
<mat-option *ngFor="let system of systems" [value]="system.system">
{{ system.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>
Talkgroup
</mat-label>
<mat-select formControlName="talkgroup">
<mat-option [value]="-1">
All Talkgroups
</mat-option>
<mat-option *ngFor="let talkgroup of getSearchFormTalkgroups()" [value]="talkgroup.dec">
{{ talkgroup.alphaTag }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div>
<button (click)="resetSearchForm()" [disabled]="searchResultsPending" mat-raised-button
type="button">
Reset
</button>
</div>
</form>
</div>
</mat-sidenav>
<mat-sidenav #selectPanel [autoFocus]="false" [disableClose]="true" mode="push" [opened]="selectPanelOpened"
position="end">
<div class="rdio-select">
<mat-toolbar>
<button (click)="toggleSelectPanel(false)" mat-icon-button>
<mat-icon>arrow_back</mat-icon>
</button>
<ng-container *ngIf="systems.length > 1">
<button class="rdio-button-mini all-off" (click)="avoid({ all: false })">
OFF
</button>
<button class="rdio-button-mini all-on" (click)="avoid({ all: true })">
ON
</button>
</ng-container>
</mat-toolbar>
<fieldset *ngFor="let system of systems">
<legend>
{{ system.name }}
</legend>
<div fxLayout="row wrap" fxLayoutAlign="space-between">
<button *ngFor="let talkgroup of system.talkgroups" class="rdio-button on"
(click)="avoid({ system: system, talkgroup: talkgroup })"
[ngClass]="{ off: !(selection[system.system] && selection[system.system][talkgroup.dec]), on: selection[system.system] && selection[system.system][talkgroup.dec] }">
{{ talkgroup.alphaTag }}
</button>
<ng-container *ngIf="system.talkgroups.length > 1">
<button class="rdio-button-mini all-off" (click)="avoid({ system: system, status: false })">
OFF
</button>
<button class="rdio-button-mini all-on" (click)="avoid({ system: system, status: true })">
ON
</button>
</ng-container>
</div>
</fieldset>
</div>
</mat-sidenav>
<mat-sidenav-content>
<div class="rdio-main">
<div class="rdio-status" fxLayout="row" fxLayoutAlign="end">
<span class="rdio-led" [ngClass]="{ off: !call, on: call, paused: call && livefeedPaused }"></span>
</div>
<div class="rdio-display">
<div fxLayout="row" fxLayoutAlign="space-between">
<div>
<span>
{{ displayClock | date:'HH' }}{{ displayClock.getSeconds() % 2 ? ' ' : ':' }}{{ displayClock | date:'mm' }}
</span>
</div>
<div>
<span>
Q: {{ callQueue.length }}
</span>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<div>
<span>
{{ displaySystem }}
</span>
</div>
<div>
<span>
{{ displayTag }}
</span>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<div>
<span>
{{ displayAlphaTag }}
</span>
</div>
<div>
<span>
{{ displayProgress | date:'HH:mm' }}
</span>
</div>
</div>
<div>
<span>
{{ displayDescription }}
</span>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<div>
<span>
F: {{ displayFrequency }}
</span>
</div>
<div>
<span *ngIf="displayMode !== 'A'">
TGID: {{ displayTalkgroup }}
</span>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<div>
<span *ngIf="displayMode !== 'A'">
E: {{ displayErrorCount }} S: {{ displaySpikeCount }}
</span>
</div>
<div>
<span *ngIf="displayMode !== 'A'">
UID: {{ displayUnit }}
</span>
</div>
</div>
<table>
<thead>
<tr>
<th>
<span>Time</span>
</th>
<th>
<span>System</span>
</th>
<th>
<span>Tag</span>
</th>
<th>
<span>Description</span>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let previousCall of callHistory">
<td>
<span>{{ previousCall?.startTime | date:'HH:mm' }}</span>
</td>
<td>
<span>{{ previousCall?.systemData?.name || previousCall?.system}}</span>
</td>
<td>
<span>{{ previousCall?.talkgroupData?.alphaTag || previousCall?.talkgroup }}</span>
</td>
<td>
<span>{{ previousCall?.talkgroupData?.description || previousCall?.freq }}</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="rdio-control" fxLayout="column" fxLayoutGap="12px">
<div fxLayout="row" fxLayoutAlign="space-between">
<button class="rdio-button" (click)="livefeed()"
[ngClass]="{ off: !livefeedStatus, on: livefeedStatus }">
LIVE<br>FEED
</button>
<button class="rdio-button" (click)="holdSystem()"
[ngClass]="{ off: !selectionSystemHold, on: selectionSystemHold }">
HOLD<br>SYS
</button>
<button class="rdio-button" (click)="holdTalkgroup()"
[ngClass]="{ off: !selectionTalkgroupHold, on: selectionTalkgroupHold }">
HOLD<br>TG
</button>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<button class="rdio-button" (click)="replay()">
REPLAY<br>LAST
</button>
<button class="rdio-button" (click)="skip(true)">
SKIP<br>NEXT
</button>
<button class="rdio-button" (click)="avoid()">
AVOID
</button>
</div>
<div fxLayout="row" fxLayoutAlign="space-between">
<button class="rdio-button" (click)="toggleSearchPanel(true)">
SEARCH<br>CALL
</button>
<button class="rdio-button" (click)="pause()"
[ngClass]="{ off: !livefeedPaused, on: livefeedPaused }">
PAUSE
</button>
<button class="rdio-button" (click)="toggleSelectPanel(true)">
SELECT<br>TG
</button>
</div>
</div>
</div>
</mat-sidenav-content>
</mat-sidenav-container>

View file

@ -0,0 +1,314 @@
:host {
align-items: center;
background-color: rgb(30, 30, 30);
color: rgb(255, 255, 255);
display: flex;
flex-direction: row;
font-family: Roboto, 'Helvetica Neue', sans-serif;
justify-content: center;
* {
user-select: none;
}
&,
.mat-sidenav,
.mat-sidenav-container {
height: 100%;
width: 100%;
}
.mat-sidenav,
.mat-sidenav-container,
.mat-toolbar {
background-color: inherit;
color: inherit;
padding: 0;
}
.rdio-button,
.rdio-button-mini,
.rdio-button-none {
margin: 4px;
}
.rdio-button,
.rdio-button-mini {
background: rgb(45, 45, 45);
border: none;
border-radius: 4px;
box-shadow: 1px 1px 2px rgb(255, 255, 255) inset, -1px -1px 1px rgb(0, 0, 0) inset, 0 0 2px 2px rgb(0, 0, 0);
box-sizing: border-box;
color: rgb(255, 255, 255);
font-family: inherit;
font-weight: 500;
height: 40px;
line-height: 40px;
overflow: hidden;
position: relative;
text-overflow: ellipsis;
text-shadow: 0 0 4px rgb(0, 0, 0);
user-select: none;
white-space: nowrap;
width: auto;
&:active,
&:focus {
outline: 0;
}
&:active {
top: 4px;
}
&.off::after,
&.on::after {
content: '';
border-radius: 4px;
display: block;
height: 6px;
position: absolute;
right: 6px;
top: 6px;
width: 6px;
}
&.off::after {
background: rgb(230, 50, 50);
box-shadow: 1px 1px 1px rgb(255, 255, 255) inset, 0 0 3px 2px rgb(230, 50, 50);
}
&.on::after {
background: rgb(100, 230, 50);
box-shadow: 1px 1px 1px rgb(255, 255, 255) inset, 0 0 3px 2px rgb(100, 230, 50);
}
}
.rdio-button {
font-size: 12px;
min-width: 64px;
width: calc(25% - 8px);
}
.rdio-button-mini {
font-size: 10px;
min-width: 30px;
width: calc(12.5% - 8px);
}
.rdio-control {
.rdio-button {
line-height: normal;
}
}
.rdio-display,
.rdio-search-results {
* {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.rdio-display {
background: rgb(240, 255, 255);
border-radius: 4px;
box-shadow: 2px 2px 4px rgb(0, 0, 0) inset, 1px 1px 2px 1px rgb(255, 255, 255);
box-sizing: border-box;
color: rgba(0, 0, 0, .8);
display: block;
font-size: 14px;
font-weight: 400;
line-height: 20px;
padding: 8px;
> div {
height: 20px;
&:nth-child(1),
&:nth-child(6) {
margin-bottom: 12px;
}
&:nth-child(4) {
font-size: 24px;
height: 32px;
line-height: 32px;
}
}
> table {
border-collapse: collapse;
font-size: 11px;
table-layout: fixed;
width: 100%;
td,
th {
padding: 0;
text-align: start;
&:nth-child(4) {
width: 50%;
}
}
th {
color: rgba(0, 0, 0, .4);
font-weight: 400;
text-transform: uppercase;
}
tr {
height: 21px;
}
tbody > tr {
border-top: 1px solid rgba(0, 0, 0, .2);
}
}
}
.rdio-control,
.rdio-display,
.rdio-status {
margin-bottom: 24px;
}
.rdio-led {
background: rgb(80, 80, 80);
border-radius: 2px;
display: block;
height: 12px;
width: 24px;
&.on {
background: rgb(100, 230, 50);
box-shadow: 0 0 6px 3px rgb(100, 230, 50);
}
&.paused {
animation: led-blink 2s step-end infinite;
}
@keyframes led-blink {
50% {
background: rgb(80, 80, 80);
box-shadow: none;
}
}
}
.rdio-main {
box-sizing: border-box;
margin: auto;
display: flex;
flex-direction: column;
justify-content: center;
max-width: 640px;
min-height: 100%;
min-width: 270px;
padding: 24px;
}
.rdio-search,
.rdio-select {
padding: 16px;
}
.rdio-search-form,
.rdio-search-results {
background-color: rgb(255, 255, 255);
border-radius: 4px;
color: rgba(0, 0, 0, .87);
margin-bottom: 16px;
overflow: hidden;
}
.rdio-search-form {
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 8px 24px;
> * {
display: flex;
flex-direction: column;
justify-content: center;
&:not(:last-child) {
flex: 1;
margin-right: 1em;
}
}
}
.rdio-search-results {
.mat-cell,
.mat-header-cell {
&:first-of-type {
padding-left: 0;
}
&:last-of-type {
padding-right: 8px;
}
&:nth-child(1) {
flex: 0 0 40px;
}
&:nth-child(2),
&:nth-child(3) {
flex: 0 0 50px;
}
&:nth-child(4),
&:nth-child(5) {
flex: 0 0 20%;
}
}
}
.rdio-select {
.mat-toolbar {
padding: 14.5px;
*:first-child {
left: -14.5px;
}
}
.rdio-button-mini {
&:nth-last-child(2) {
margin-left: auto;
}
&.all-off {
background: rgb(100, 50, 50);
}
&.all-on {
background: rgb(50, 100, 50);
}
}
fieldset {
font-family: inherit;
font-size: 14px;
font-weight: 400;
line-height: 20px;
&:not(:last-child) {
margin-bottom: 12px;
}
legend {
opacity: .8;
padding: 0 12px;
}
}
}
}

View file

@ -0,0 +1,777 @@
import { AfterViewInit, Component, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatTable, MatTableDataSource } from '@angular/material/table';
import { Subscription } from 'rxjs';
import { AppRdioScannerCallQueryService } from './rdio-scanner-call-query.service';
import { AppRdioScannerCallSubscriptionService, RdioScannerCall } from './rdio-scanner-call-subscription.service';
import { AppRdioScannerCallsQueryService } from './rdio-scanner-calls-query.service';
import { AppRdioScannerSystemsQueryService } from './rdio-scanner-systems-query.service';
import { AppRdioScannerSystemsSubscriptionService, RdioScannerSystem, RdioScannerTalkgroup } from './rdio-scanner-systems-subscription.service';
declare var webkitAudioContext: any;
const LOCAL_STORAGE_KEY = 'rdio-scanner';
interface RdioScannerSelection {
[key: string]: {
[key: string]: boolean;
};
}
@Component({
selector: 'app-rdio-scanner',
styleUrls: ['./rdio-scanner.component.scss'],
templateUrl: './rdio-scanner.component.html',
})
export class AppRdioScannerComponent implements AfterViewInit, OnDestroy, OnInit {
get call() { return this._call; }
get callHistory() { return this._callHistory; }
get callPrevious() { return this._callPrevious; }
get callQueue() { return this._callQueue; }
get displayAlphaTag() { return this._displayAlphaTag; }
get displayClock() { return this._displayClock; }
get displayDescription() { return this._displayDescription; }
get displayErrorCount() { return this._displayErrorCount; }
get displayFrequency() { return this._displayFrequency; }
get displayMode() { return this._displayMode; }
get displayProgress() { return this._displayProgress; }
get displaySpikeCount() { return this._displaySpikeCount; }
get displaySystem() { return this._displaySystem; }
get displayTag() { return this._displayTag; }
get displayTalkgroup() { return this._displayTalkgroup; }
get displayUnit() { return this._displayUnit; }
get livefeedPaused() { return this._livefeedPaused; }
get livefeedStatus() { return !!this.livefeedSubscription; }
get searchForm() { return this._searchForm; }
get searchFormDateStart() { return this._searchFormDateStart; }
get searchFormDateStop() { return this._searchFormDateStop; }
get searchPanelOpened() { return this._searchPanelOpened; }
get searchResults() { return this._searchResults; }
get searchResultsCount() { return this._searchResultsCount; }
get searchResultsPending() { return this._searchResultsPending; }
get selection() { return this._selection; }
get selectionSystemHold() { return this._selectionSystemHold; }
get selectionTalkgroupHold() { return this._selectionTalkgroupHold; }
get selectPanelOpened() { return this._selectPanelOpened; }
get systems() { return this._systems; }
private _call: RdioScannerCall | null = null;
private _callHistory: RdioScannerCall[] = new Array<RdioScannerCall>(5);
private _callPrevious: RdioScannerCall | null = null;
private _callQueue: RdioScannerCall[] = [];
private _displayAlphaTag = 'Alpha tag';
private _displayClock = new Date();
private _displayDescription = 'Idle';
private _displayErrorCount = 0;
private _displayFrequency = this.formatFrequency(0);
private _displayMode = 'D';
private _displayProgress = new Date(0, 0, 0, 0, 0, 0);
private _displaySpikeCount = 0;
private _displaySystem = 'System';
private _displayTag = 'Tag';
private _displayTalkgroup = 0;
private _displayUnit = 0;
private _livefeedPaused = false;
private _searchForm: FormGroup = this.ngFormBuilder.group({
date: [null],
sort: [-1],
system: [-1],
talkgroup: [-1],
});
private _searchFormDateStart = '';
private _searchFormDateStop = '';
private _searchPanelOpened = false;
private _searchResults = new MatTableDataSource<RdioScannerCall>();
private _searchResultsCount = 0;
private _searchResultsPending = false;
private _selection: RdioScannerSelection = {};
private _selectionSystemHold: RdioScannerSelection | null = null;
private _selectionTalkgroupHold: RdioScannerSelection | null = null;
private _selectPanelOpened = false;
private _systems: RdioScannerSystem[] = [];
private audioContext: AudioContext | null = null;
private audioSource: AudioBufferSourceNode | null = null;
private audioStartTime = NaN;
private clockInterval: any = null;
private livefeedSubscription: Subscription;
private searchFormSubscription: Subscription;
private searchPaginatorSubscription: Subscription;
private systemsSubscription: Subscription;
@ViewChild(MatPaginator, { static: true }) private matPaginator: MatPaginator;
@ViewChild(MatTable, { static: true }) private matTable: MatTable<RdioScannerCall>;
constructor(
private appRdioScannerCallQuery: AppRdioScannerCallQueryService,
private appRdioScannerCallsQuery: AppRdioScannerCallsQueryService,
private appRdioScannerCallSubscription: AppRdioScannerCallSubscriptionService,
private appRdioScannerSystemsQuery: AppRdioScannerSystemsQueryService,
private appRdioScannerSystemsSubscription: AppRdioScannerSystemsSubscriptionService,
private ngFormBuilder: FormBuilder,
private ngZone: NgZone,
) { }
avoid(options: {
all?: boolean;
call?: RdioScannerCall;
system?: RdioScannerSystem;
talkgroup?: RdioScannerTalkgroup;
status?: boolean
} = {}): void {
if (this.selectionSystemHold) {
this._selectionSystemHold = null;
}
if (this.selectionTalkgroupHold) {
this._selectionTalkgroupHold = null;
}
if (typeof options.all === 'boolean') {
Object.keys(this.selection).map((sys: string) => +sys).forEach((sys: number) => {
Object.keys(this.selection[sys]).map((tg: string) => +tg).forEach((tg: number) => {
this._selection[sys][tg] = typeof options.status === 'boolean' ? options.status : options.all;
});
});
} else if (options.call) {
const sys = options.call.system;
const tg = options.call.talkgroup;
this._selection[sys][tg] = typeof options.status === 'boolean' ? options.status : !this.selection[sys][tg];
} else if (options.system && options.talkgroup) {
const sys = options.system.system;
const tg = options.talkgroup.dec;
this._selection[sys][tg] = typeof options.status === 'boolean' ? options.status : !this.selection[sys][tg];
} else if (options.system && !options.talkgroup) {
const sys = options.system.system;
Object.keys(this.selection[sys]).map((tg: string) => +tg).forEach((tg: number) => {
this._selection[sys][tg] = typeof options.status === 'boolean' ? options.status : !this.selection[sys][tg];
});
} else {
const call = this.call || this.callPrevious;
if (call) {
const sys = call.system;
const tg = call.talkgroup;
this._selection[sys][tg] = typeof options.status === 'boolean' ? options.status : !this.selection[sys][tg];
}
}
if (this.call && !(this.selection && this.selection[this.call.system] &&
this._selection[this.call.system][this.call.talkgroup])) {
this.skip();
}
if (this.livefeedStatus) {
this.unsubscribeLivefeed();
this.subscribeLivefeed();
}
this.writeSelection();
this.cleanQueue();
}
@HostListener('window:beforeunload', ['$event'])
exitNotification(event: BeforeUnloadEvent): void {
if (this.livefeedStatus) {
event.preventDefault();
event.returnValue = 'Live feed is ON, do you really want to leave this page?';
}
}
getSearchFormTalkgroups(): RdioScannerTalkgroup[] {
const system = this.systems.find((sys) => sys.system === this.searchForm.get('system').value);
return system ? system.talkgroups : [];
}
holdSystem(resubscribe = true): void {
const call = this.call || this.callPrevious;
if (call && this.selection) {
if (this.selectionSystemHold) {
this._selection = this._selectionSystemHold;
this._selectionSystemHold = null;
} else {
if (this.selectionTalkgroupHold) {
this.holdTalkgroup(false);
}
this._selectionSystemHold = this.selection;
this._selection = Object.keys(this.selection).map((sys) => +sys).reduce((sa, sv) => {
const allOn = Object.keys(this.selection[sv]).every((key) => !this.selection[sv][key]);
sa[sv] = Object.keys(this.selection[sv]).map((tg) => +tg).reduce((ta, tv) => {
if (sv === call.system) {
ta[tv] = allOn || this.selection[sv][tv];
} else {
ta[tv] = false;
}
return ta;
}, {});
return sa;
}, {});
this.cleanQueue();
}
if (resubscribe && this.livefeedStatus) {
this.unsubscribeLivefeed();
this.subscribeLivefeed();
}
}
}
holdTalkgroup(resubscribe = true): void {
const call = this.call || this.callPrevious;
if (call && this.selection) {
if (this.selectionTalkgroupHold) {
this._selection = this._selectionTalkgroupHold;
this._selectionTalkgroupHold = null;
} else {
if (this.selectionSystemHold) {
this.holdSystem(false);
}
this._selectionTalkgroupHold = this.selection;
this._selection = Object.keys(this.selection).map((sys) => +sys).reduce((sa, sv) => {
sa[sv] = Object.keys(this.selection[sv]).map((tg) => +tg).reduce((ta, tv) => {
if (sv === call.system) {
ta[tv] = tv === call.talkgroup;
} else {
ta[tv] = false;
}
return ta;
}, {});
return sa;
}, {});
this.cleanQueue();
}
if (resubscribe && this.livefeedStatus) {
this.unsubscribeLivefeed();
this.subscribeLivefeed();
}
}
}
livefeed(status = !this.livefeedStatus): void {
if (status) {
this.subscribeLivefeed();
} else {
this.unsubscribeLivefeed();
this._callQueue.splice(0, this.callQueue.length);
this.stop();
}
}
loadAndPlay(call: RdioScannerCall): void {
this.appRdioScannerCallQuery.fetch({ id: call.id }).subscribe(({ data }) => {
if (data.rdioScannerCall) {
Object.assign(call, data.rdioScannerCall);
this.play(call);
}
});
}
ngAfterViewInit(): void {
if (this.matPaginator instanceof MatPaginator) {
this.searchResults.paginator = this.matPaginator;
}
}
ngOnDestroy(): void {
this.unsubscribeLivefeed();
this.unsubscribeSearchForm();
this.unsubscribeSearchPaginator();
this.unsubscribeSystems();
clearInterval(this.clockInterval);
}
ngOnInit(): void {
this.clockInterval = setInterval(() => this._displayClock = new Date(), 1000);
this.bootstrapAudio();
this.subscribeSystems().then(() => {
this.subscribeSearchForm();
this.subscribeSearchPaginator();
});
}
pause(status = !this.livefeedPaused): void {
this._livefeedPaused = status;
if (this.audioContext) {
if (this.livefeedPaused) {
this.audioContext.suspend();
} else {
this.audioContext.resume();
this.play();
}
}
}
play(call?: RdioScannerCall): void {
if (this.audioContext && !this.livefeedPaused) {
if (!call && !this.call && this.callQueue.length) {
call = this.callQueue.shift();
}
if (call && call.audio) {
this.stop();
if (this.callPrevious && this.callPrevious !== call && !this.callHistory.find((c) => c === this.callPrevious)) {
this._callHistory.pop();
this._callHistory.unshift(this.callPrevious);
}
this._call = call;
const arrayBuffer = new ArrayBuffer(call.audio.data.length);
const arrayBufferView = new Uint8Array(arrayBuffer);
for (let i = 0; i < call.audio.data.length; i++) {
arrayBufferView[i] = call.audio.data[i];
}
this.updateDisplay();
this.ngZone.run(() => this.audioContext.decodeAudioData(arrayBuffer, (buffer) => {
this.audioContext.resume().then(() => {
const displayInterval = setInterval(() => this.updateDisplay(), 500);
this.audioSource = this.audioContext.createBufferSource();
this.audioSource.buffer = buffer;
this.audioSource.connect(this.audioContext.destination);
this.audioSource.onended = () => this.ngZone.runTask(() => {
clearInterval(displayInterval);
this.skip();
});
this.audioSource.start();
});
}, () => this.skip()));
}
}
}
queue(call: RdioScannerCall): void {
const selection = this.selection;
const sys = call.system;
const tg = call.talkgroup;
if (selection && selection[sys] && selection[sys][tg]) {
this.callQueue.push(call);
this.play();
}
}
replay(): void {
if (!this.livefeedPaused) {
this.play(this.call || this.callPrevious);
}
}
resetSearchForm(): void {
this.searchForm.reset({
date: null,
sort: -1,
system: -1,
talkgroup: -1,
});
if (this.matPaginator.pageIndex > 0) {
this.matPaginator.firstPage();
}
}
skip(nodelay = false): void {
this.stop();
setTimeout(() => this.play(), nodelay ? 0 : 1000);
}
stop(): void {
if (this.audioSource && this.call) {
this.audioSource.onended = null;
this.audioSource.stop();
this.audioSource.disconnect();
this.audioSource = null;
this.audioStartTime = NaN;
this._callPrevious = this._call;
this._call = null;
}
}
toggleSearchPanel(opened = !this.searchPanelOpened): void {
if (opened) {
this.searchCalls();
}
this._searchPanelOpened = opened;
}
toggleSelectPanel(opened = !this.selectPanelOpened): void {
this._selectPanelOpened = opened;
}
private bootstrapAudio(): void {
const events = ['mousedown', 'touchdown'];
const bootstrap = () => {
if (!this.audioContext) {
if ('webkitAudioContext' in window) {
this.audioContext = new webkitAudioContext();
} else {
this.audioContext = new AudioContext();
}
}
if (this.audioContext) {
this.audioContext.resume().then(() => {
events.forEach((event) => document.body.removeEventListener(event, bootstrap));
});
}
};
events.forEach((event) => document.body.addEventListener(event, bootstrap));
}
private cleanQueue(): void {
const queueLength = this.callQueue.length;
this._callQueue = this.callQueue.filter((call: RdioScannerCall) => {
return this.selection && this.selection[call.system] && this.selection[call.system][call.talkgroup];
});
}
private formatFrequency(frequency: number): string {
return (typeof frequency === 'number' ? frequency : 0)
.toString()
.padStart(9, '0')
.replace(/(\d)(?=(\d{3})+$)/g, '$1 ')
.concat(' Hz');
}
private processCall(call: RdioScannerCall): void {
if (call !== null && typeof call === 'object') {
call = this.transformCall(call);
this.queue(call);
}
}
private processSystems(systems: RdioScannerSystem[]): void {
if (Array.isArray(systems)) {
this.systems.splice(0, this.systems.length, ...systems);
this.readSelection();
this.rebuildSelection();
this.writeSelection();
}
}
private readSelection(): any {
if (window instanceof Window && window.localStorage instanceof Storage) {
try {
this._selection = JSON.parse(window.localStorage.getItem(LOCAL_STORAGE_KEY));
} catch (err) {
this._selection = {};
}
}
}
private rebuildSelection(): void {
this._selection = this.systems.reduce((sa, sv) => {
const tgs = sv.talkgroups.map((tg) => tg.dec.toString());
if (Array.isArray(sa[sv.system])) {
Object.keys(sa[sv.system]).forEach((tg) => {
if (!tgs.includes(tg)) {
delete sa[sv.system][tg];
}
});
}
sa[sv.system] = sv.talkgroups.reduce((ta, tv) => {
ta[tv.dec] = typeof ta[tv.dec] === 'boolean' ? ta[tv.dec] : true;
return ta;
}, sa[sv.system] || {});
return sa;
}, this.selection || {});
}
private searchCalls(paginator: {
first?: boolean | number;
last?: boolean | number;
skip?: number;
} = {}): void {
const options: {
date?: Date;
first?: number;
last?: number;
skip?: number;
sort?: number;
system?: number;
talkgroup?: number;
} = {};
const count = 200;
const form = this.searchForm.value;
if (form.date instanceof Date) {
options.date = form.date;
}
if (typeof paginator.first === 'boolean') {
options.first = count;
} else if (typeof paginator.first === 'number') {
options.first = paginator.first;
} else if (typeof paginator.last === 'boolean') {
options.last = count;
} else if (typeof paginator.last === 'number') {
options.last = paginator.last;
} else {
options.first = count;
}
if (typeof paginator.skip === 'number' && paginator.skip > 0) {
options.skip = paginator.skip;
}
if (typeof form.sort === 'number') {
options.sort = form.sort;
}
if (typeof form.system === 'number' && form.system !== -1) {
options.system = form.system;
}
if (typeof form.talkgroup === 'number' && form.talkgroup !== -1) {
options.talkgroup = form.talkgroup;
}
this._searchResultsPending = true;
this.searchForm.disable();
this.appRdioScannerCallsQuery.fetch(options, { fetchPolicy: 'no-cache' }).subscribe(({ data }) => {
const results = data.rdioScannerCalls.results.map((call) => this.transformCall(call));
if (this.searchResults.data.length < data.rdioScannerCalls.count) {
const ar = new Array<RdioScannerCall>(data.rdioScannerCalls.count - this.searchResults.data.length);
if (options.sort < 0) {
this.searchResults.data.unshift(...ar);
} else if (options.sort > 0) {
this.searchResults.data.push(...ar);
}
}
if (options.last) {
this.searchResults.data.splice((options.skip || this.searchResults.data.length) - results.length,
results.length, ...results);
} else {
this.searchResults.data.splice(options.skip || 0, results.length, ...results);
}
this._searchResultsCount = data.rdioScannerCalls.count;
this._searchFormDateStart = data.rdioScannerCalls.dateStart;
this._searchFormDateStop = data.rdioScannerCalls.dateStop;
this.matTable.renderRows();
this.searchResults.data = this.searchResults.data.slice(); // because renderRow() doesn't want to work
this.searchForm.enable();
this._searchResultsPending = false;
});
}
private async subscribeLivefeed(): Promise<void> {
if (!this.livefeedSubscription) {
const selection = JSON.stringify(this.selection);
this.livefeedSubscription = this.appRdioScannerCallSubscription.subscribe({ selection })
.subscribe(({ data }) => this.processCall(data.rdioScannerCall));
}
}
private subscribeSearchForm(): void {
let lastValue = this.searchForm.value;
if (!this.searchFormSubscription) {
this.searchFormSubscription = this.searchForm.valueChanges.subscribe((value) => {
if (!this.searchResultsPending) {
if (!Object.keys(value).every((key) => value[key] === lastValue[key])) {
if (value.system !== lastValue.system) {
this.searchForm.get('talkgroup').setValue(-1, { emitEvent: false });
}
lastValue = this.searchForm.value;
this.searchResults.data.splice(0, this.searchResults.data.length,
...new Array<RdioScannerCall>(this.matPaginator.pageSize));
this.searchCalls();
if (this.matPaginator.pageIndex > 0) {
this.matPaginator.firstPage();
}
}
}
});
}
}
private subscribeSearchPaginator(): void {
if (!this.searchPaginatorSubscription) {
this.searchPaginatorSubscription = this.matPaginator.page.subscribe((event: PageEvent) => {
const sortOrder = this.searchForm.get('sort').value;
if (sortOrder < 0 && event.pageIndex === 0) {
this.searchCalls({ first: true });
} else if (sortOrder > 0 && event.pageIndex >= event.length / event.pageSize - 1) {
this.searchCalls({ last: true });
} else if (event.length - event.pageIndex * event.pageSize < event.pageSize) {
const needMore = !this.searchResults.data
.slice(event.pageIndex * event.pageSize, event.pageIndex * event.pageSize + event.pageSize)
.every((call) => call);
if (needMore) {
this.searchCalls({ last: true, skip: event.length });
}
} else if (event.pageIndex > event.previousPageIndex) {
const needMore = !this.searchResults.data
.slice(event.pageIndex * event.pageSize, event.pageIndex * event.pageSize + event.pageSize)
.every((call) => call);
if (needMore) {
this.searchCalls({ first: true, skip: event.pageIndex * event.pageSize });
}
} else if (event.pageIndex < event.previousPageIndex) {
const needMore = !this.searchResults.data
.slice(event.pageIndex * event.pageSize - 1, event.pageIndex * event.pageSize + event.pageSize - 1)
.every((call) => call);
if (needMore) {
this.searchCalls({ last: true, skip: event.pageIndex * event.pageSize + event.pageSize - 1 });
}
}
});
}
}
private async subscribeSystems(): Promise<void> {
if (!this.systemsSubscription) {
this.appRdioScannerSystemsQuery.watch().valueChanges
.subscribe(({ data }) => this.processSystems(data.rdioScannerSystems));
this.systemsSubscription = this.appRdioScannerSystemsSubscription.subscribe()
.subscribe(({ data }) => this.processSystems(data.rdioScannerSystems));
}
}
private transformCall(call: RdioScannerCall): RdioScannerCall {
call.systemData = (call && this.systems
.find((system: RdioScannerSystem) => system.system === call.system)) || {};
call.talkgroupData = (call && call.systemData && Array.isArray(call.systemData.talkgroups) && call.systemData.talkgroups
.find((talkgroup: RdioScannerTalkgroup) => talkgroup.dec === call.talkgroup)) || {};
return call;
}
private unsubscribeSearchForm(): void {
if (this.searchFormSubscription) {
this.searchFormSubscription.unsubscribe();
this.searchFormSubscription = null;
}
}
private unsubscribeSearchPaginator(): void {
if (this.searchPaginatorSubscription) {
this.searchPaginatorSubscription.unsubscribe();
this.searchPaginatorSubscription = null;
}
}
private unsubscribeLivefeed(): void {
if (this.livefeedSubscription) {
this.livefeedSubscription.unsubscribe();
this.livefeedSubscription = null;
}
}
private unsubscribeSystems(): void {
if (this.systemsSubscription) {
this.systemsSubscription.unsubscribe();
this.systemsSubscription = null;
}
}
private updateDisplay(): void {
if (this.call) {
if (isNaN(this.audioStartTime)) {
this.audioStartTime = isNaN(this.audioContext.currentTime) ? Date.now() : this.audioContext.currentTime;
}
const diffTime = this.audioContext.currentTime - this.audioStartTime;
const currentFreq = this.call.freqList.reduce((r, v) => v.pos <= diffTime ? v : r, {});
const currentSrc = this.call.srcList.reduce((r, v) => v.pos <= diffTime ? v : r, {});
this._displayAlphaTag = this.call.talkgroupData.alphaTag || '';
this._displayDescription = this.call.talkgroupData.description || this.formatFrequency(this.call.freq);
this._displayErrorCount = currentFreq.errorCount || 0;
this._displayFrequency = this.formatFrequency(currentFreq.freq || this.call.freq);
this._displayMode = this.call.talkgroupData.mode || 'A';
this._displayProgress = new Date(this.call.startTime);
this._displayProgress.setSeconds(this.displayProgress.getSeconds() + this.audioContext.currentTime - this.audioStartTime);
this._displaySpikeCount = currentFreq.spikeCount || 0;
this._displaySystem = this.call.systemData.name || '';
this._displayTag = this.call.talkgroupData.tag || '';
this._displayTalkgroup = this.call.talkgroup || 0;
this._displayUnit = currentSrc.src || 0;
}
}
private writeSelection(): any {
if (window instanceof Window && window.localStorage instanceof Storage) {
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(this.selection));
}
}
}

View file

@ -0,0 +1,30 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { MatSidenavModule } from '@angular/material/sidenav';
import { AppSharedModule } from '../../shared/shared.module';
import { AppRdioScannerCallQueryService } from './rdio-scanner-call-query.service';
import { AppRdioScannerCallSubscriptionService } from './rdio-scanner-call-subscription.service';
import { AppRdioScannerCallsQueryService } from './rdio-scanner-calls-query.service';
import { AppRdioScannerSystemsQueryService } from './rdio-scanner-systems-query.service';
import { AppRdioScannerSystemsSubscriptionService } from './rdio-scanner-systems-subscription.service';
import { AppRdioScannerComponent } from './rdio-scanner.component';
@NgModule({
declarations: [AppRdioScannerComponent],
exports: [AppRdioScannerComponent],
imports: [
AppSharedModule,
CommonModule,
FlexLayoutModule,
MatSidenavModule,
],
providers: [
AppRdioScannerCallQueryService,
AppRdioScannerCallsQueryService,
AppRdioScannerCallSubscriptionService,
AppRdioScannerSystemsQueryService,
AppRdioScannerSystemsSubscriptionService,
],
})
export class AppRdioScannerModule { }

View file

@ -0,0 +1,52 @@
import { HttpClientModule } from '@angular/common/http';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { split } from 'apollo-link';
import { WebSocketLink } from 'apollo-link-ws';
import { getMainDefinition } from 'apollo-utilities';
export const httpLinkFactory = (httpLink: HttpLink) => ({
cache: new InMemoryCache(),
link: split(
({ query }) => {
const def = getMainDefinition(query);
return def.kind === 'OperationDefinition' && def.operation === 'subscription';
},
new WebSocketLink({
options: {
reconnect: true,
},
uri: window.location.href.replace(/^http/, 'ws') + 'graphql',
}),
httpLink.create({
uri: window.location.href + 'graphql',
}),
),
});
@NgModule({
imports: [
ApolloModule,
HttpClientModule,
HttpLinkModule,
],
})
export class AppApolloModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: AppApolloModule,
providers: [
{
deps: [HttpLink],
provide: APOLLO_OPTIONS,
useFactory: httpLinkFactory,
},
],
};
}
}

View file

@ -0,0 +1,21 @@
import { registerLocaleData } from '@angular/common';
import locale from '@angular/common/locales/en-CA';
import { LOCALE_ID as NG_LOCALE_ID, ModuleWithProviders, NgModule } from '@angular/core';
const LOCALE_ID = 'en-CA'; // Because we need dates as yyyy-mm-dd
@NgModule()
export class AppLocaleModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: AppLocaleModule,
providers: [
{ provide: NG_LOCALE_ID, useValue: LOCALE_ID },
],
};
}
constructor() {
registerLocaleData(locale, LOCALE_ID);
}
}

View file

@ -1,33 +1,31 @@
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatSelectModule } from '@angular/material/select';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
@NgModule({
exports: [
MatButtonModule,
MatButtonToggleModule,
MatCheckboxModule,
MatDatepickerModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatSelectModule,
MatSidenavModule,
MatTableModule,
MatToolbarModule,
],
})
export class AppMaterialModule { }

View file

@ -0,0 +1,30 @@
import { CommonModule } from '@angular/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppApolloModule } from './apollo/apollo.module';
import { AppLocaleModule } from './locale/locale.module';
import { AppMaterialModule } from './material/material.module';
@NgModule({
exports: [
AppApolloModule,
AppLocaleModule,
AppMaterialModule,
CommonModule,
FlexLayoutModule,
FormsModule,
ReactiveFormsModule,
],
})
export class AppSharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: AppSharedModule,
providers: [
...AppApolloModule.forRoot().providers,
...AppLocaleModule.forRoot().providers,
],
};
}
}

View file

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 4 KiB

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 4 KiB

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/assets/ms-icon-70x70.png" />
<square150x150logo src="/assets/ms-icon-150x150.png" />
<square310x310logo src="/assets/ms-icon-310x310.png" />
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -2,37 +2,37 @@
"name": "Rdio Scanner",
"icons": [
{
"src": "\/android-icon-36x36.png",
"src": "\/assets\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"src": "\/assets\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"src": "\/assets\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"src": "\/assets\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"src": "\/assets\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"src": "\/assets\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View file

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -0,0 +1,3 @@
export const environment = {
production: true,
};

View file

@ -0,0 +1,3 @@
export const environment = {
production: false,
};

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

36
client/src/main.html Normal file
View file

@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">
<head>
<base href="/">
<link rel="apple-touch-icon" sizes="57x57" href="assets/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="assets/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon-16x16.png">
<link rel="manifest" href="assets/manifest.json">
<link rel="stylesheet" href="///fonts.googleapis.com/css?family=Roboto:400,500|Material+Icons&display=swap">
<meta charset="utf-8">
<meta name="msapplication-TileColor" content="rgb(30, 30, 30)">
<meta name="msapplication-TileImage" content="assets/ms-icon-144x144.png">
<meta name="theme-color" content="rgb(30, 30, 30)">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Rdio Scanner</title>
</head>
<body>
<app-root></app-root>
<noscript>
You must have JavaScript enabled to use this app.
</noscript>
</body>
</html>

24
client/src/main.scss Normal file
View file

@ -0,0 +1,24 @@
@import '~@angular/material/theming';
$font-family: Roboto, 'Helvetica Neue', sans-serif;
$custom-typography: mat-typography-config($font-family: $font-family);
@include mat-core($custom-typography);
$primary: mat-palette($mat-grey, 800, 50);
$accent: mat-palette($mat-green);
$theme: mat-light-theme($primary, $accent);
@include angular-material-theme($theme);
body {
font-family: $font-family;
margin: 0;
}
body,
html {
height: 100%;
}

11
client/src/main.ts Normal file
View file

@ -0,0 +1,11 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.error(err));

63
client/src/polyfills.ts Normal file
View file

@ -0,0 +1,63 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

Some files were not shown because too many files have changed in this diff Show more