added amplify and websocket
@@ -1,8 +1,11 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
|
||||
|
||||
const routes: Routes = [];
|
||||
const routes: Routes = [
|
||||
{ path: '', component: HomeComponent}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
|
||||
@@ -1,21 +1,51 @@
|
||||
<!--The content below is only a placeholder and can be replaced.-->
|
||||
<div style="text-align:center">
|
||||
<h1>
|
||||
Welcome to {{ title }}!
|
||||
</h1>
|
||||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
||||
</div>
|
||||
<h2>Here are some links to help you start: </h2>
|
||||
<ul>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
<div class="container">
|
||||
<mat-sidenav-container
|
||||
fullscreen
|
||||
[hasBackdrop]="mobileQuery.matches">
|
||||
<mat-sidenav #lnav
|
||||
mode="over"
|
||||
class="sidenav">
|
||||
<div class="content">
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let route of nav">
|
||||
<a mat-button routerLink="{{route.path}}" routerLinkActive="active" (click)="toggleMobileNav(lnav)">{{route.title}}</a>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</div>
|
||||
</mat-sidenav>
|
||||
<mat-sidenav-content class="sidenav-content">
|
||||
<mat-toolbar
|
||||
class="toolbar"
|
||||
[class.app-is-mobile]="mobileQuery.matches"
|
||||
color="primary">
|
||||
<button
|
||||
mat-icon-button
|
||||
(click)="lnav.toggle()"
|
||||
*ngIf="mobileQuery.matches">
|
||||
<mat-icon>menu</mat-icon>
|
||||
</button>
|
||||
{{title}}
|
||||
<div class="fill-space"></div>
|
||||
<span whoami></span>
|
||||
</mat-toolbar>
|
||||
<mat-drawer-container class="sidenav-container">
|
||||
<mat-drawer
|
||||
mode="side"
|
||||
[opened]="!mobileQuery.matches">
|
||||
<div class="content">
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let route of nav">
|
||||
<a mat-button routerLink="{{route.path}}" routerLinkActive="active" (click)="toggleMobileNav(lnav)">{{route.title}}</a>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</div>
|
||||
</mat-drawer>
|
||||
<mat-drawer-content>
|
||||
<div class="content">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</mat-drawer-content>
|
||||
</mat-drawer-container>
|
||||
</mat-sidenav-content>
|
||||
</mat-sidenav-container>
|
||||
</div>
|
||||
@@ -0,0 +1,80 @@
|
||||
@import '~@angular/material/theming';
|
||||
|
||||
// Plus imports for other components in your app.
|
||||
|
||||
// Include the common styles for Angular Material. We include this here so that you only
|
||||
// have to load a single css file for Angular Material in your app.
|
||||
// Be sure that you only ever include this mixin once!
|
||||
@include mat-core();
|
||||
|
||||
// Define the palettes for your theme using the Material Design palettes available in palette.scss
|
||||
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
|
||||
// hue. Available color palettes: https://material.io/design/color/
|
||||
$app-primary: mat-palette($mat-indigo, 800);
|
||||
$app-accent: mat-palette($mat-pink, 800);
|
||||
$app-active: mat-palette($mat-pink, 800);
|
||||
|
||||
// The warn palette is optional (defaults to red).
|
||||
$app-warn: mat-palette($mat-red);
|
||||
|
||||
// Create the theme object (a Sass map containing all of the palettes).
|
||||
$app-theme: mat-light-theme($app-primary, $app-accent, $app-warn);
|
||||
|
||||
// Include theme styles for core and each component used in your app.
|
||||
// Alternatively, you can import and @include the theme mixins for each component
|
||||
// that you are using.
|
||||
@include angular-material-theme($app-theme);
|
||||
|
||||
.active {
|
||||
color: mat-color($app-primary);
|
||||
}
|
||||
.valid, .primary {
|
||||
color: mat-color($app-primary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form > * {
|
||||
margin-bottom: 1.5em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: mat-color($app-accent);
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.sidenav-content {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidenav-container {
|
||||
height: 90%;
|
||||
}
|
||||
|
||||
.app-content {
|
||||
flex: 1;
|
||||
margin: 0 auto;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: mat-color($app-active);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ChangeDetectorRef, EventEmitter, Output } from '@angular/core';
|
||||
import { MediaMatcher } from '@angular/cdk/layout';
|
||||
import { MatSidenav } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -6,5 +8,28 @@ import { Component } from '@angular/core';
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'HPIoTWebApp';
|
||||
title = 'Material PWA';
|
||||
mobileQuery: MediaQueryList;
|
||||
nav = [
|
||||
{
|
||||
'title': 'Home',
|
||||
'path': '/'
|
||||
},
|
||||
{
|
||||
'title': 'This is a second link',
|
||||
'path': '/auth'
|
||||
}
|
||||
];
|
||||
private mobileQueryListener: () => void;
|
||||
@Output() toggleSideNav = new EventEmitter();
|
||||
constructor( changeDetectorRef: ChangeDetectorRef, media: MediaMatcher ) {
|
||||
this.mobileQuery = media.matchMedia('(max-width: 600px)');
|
||||
this.mobileQueryListener = () => changeDetectorRef.detectChanges();
|
||||
this.mobileQuery.addListener(this.mobileQueryListener);
|
||||
}
|
||||
toggleMobileNav(nav: MatSidenav) {
|
||||
if (this.mobileQuery.matches) {
|
||||
nav.toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,23 @@ import { NgModule } from '@angular/core';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MaterialModule } from './material/material.module';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { ServiceWorkerModule } from '@angular/service-worker';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
AppComponent,
|
||||
HomeComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule
|
||||
AppRoutingModule,
|
||||
BrowserAnimationsModule,
|
||||
MaterialModule,
|
||||
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
|
||||
12
src/app/home/home.component.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="container">
|
||||
<div class ="viewer">
|
||||
<div class="message" *ngFor="let msg of serverMessages" >
|
||||
<p><span>Location: {{ msg.location.S }}</span></p>
|
||||
<p><span>Company: {{ msg.company.S }}</span></p>
|
||||
<p><span>Volume Flow: {{ msg.volume_flow.N }}</span></p>
|
||||
<p><span>Field: {{ msg.field.S }}</span></p>
|
||||
<p>---------------------------------</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
0
src/app/home/home.component.scss
Normal file
25
src/app/home/home.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ HomeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
29
src/app/home/home.component.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { WebSocketSubject } from 'rxjs/webSocket';
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.scss']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
public serverMessages = new Array<JSON>();
|
||||
|
||||
private socket$: WebSocketSubject<JSON>;
|
||||
|
||||
constructor() {
|
||||
|
||||
this.socket$ = new WebSocketSubject('wss://3fseaywb8b.execute-api.us-east-1.amazonaws.com/prototype');
|
||||
|
||||
this.socket$
|
||||
.subscribe(
|
||||
(message) => this.serverMessages.push(message),
|
||||
(err) => console.error(err),
|
||||
() => console.warn('Completed!')
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
82
src/app/material/material.module.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CdkTreeModule } from '@angular/cdk/tree';
|
||||
import {
|
||||
MatAutocompleteModule,
|
||||
MatBadgeModule,
|
||||
MatBottomSheetModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatChipsModule,
|
||||
MatDatepickerModule,
|
||||
MatDialogModule,
|
||||
MatDividerModule,
|
||||
MatExpansionModule,
|
||||
MatGridListModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatMenuModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressBarModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatRadioModule,
|
||||
MatRippleModule,
|
||||
MatSelectModule,
|
||||
MatSidenavModule,
|
||||
MatSliderModule,
|
||||
MatSlideToggleModule,
|
||||
MatSnackBarModule,
|
||||
MatSortModule,
|
||||
MatStepperModule,
|
||||
MatTableModule,
|
||||
MatTabsModule,
|
||||
MatToolbarModule,
|
||||
MatTooltipModule,
|
||||
MatTreeModule,
|
||||
} from '@angular/material';
|
||||
@NgModule({
|
||||
exports: [
|
||||
CdkTableModule,
|
||||
CdkTreeModule,
|
||||
MatAutocompleteModule,
|
||||
MatBadgeModule,
|
||||
MatBottomSheetModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatChipsModule,
|
||||
MatStepperModule,
|
||||
MatDatepickerModule,
|
||||
MatDialogModule,
|
||||
MatDividerModule,
|
||||
MatExpansionModule,
|
||||
MatGridListModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatMenuModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressBarModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatRadioModule,
|
||||
MatRippleModule,
|
||||
MatSelectModule,
|
||||
MatSidenavModule,
|
||||
MatSliderModule,
|
||||
MatSlideToggleModule,
|
||||
MatSnackBarModule,
|
||||
MatSortModule,
|
||||
MatTableModule,
|
||||
MatTabsModule,
|
||||
MatToolbarModule,
|
||||
MatTooltipModule,
|
||||
MatTreeModule,
|
||||
]
|
||||
})
|
||||
export class MaterialModule { }
|
||||
BIN
src/assets/icons/icon-128x128.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/assets/icons/icon-144x144.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/assets/icons/icon-152x152.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/assets/icons/icon-192x192.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/assets/icons/icon-384x384.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/assets/icons/icon-512x512.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
src/assets/icons/icon-72x72.png
Normal file
|
After Width: | Height: | Size: 792 B |
BIN
src/assets/icons/icon-96x96.png
Normal file
|
After Width: | Height: | Size: 958 B |
@@ -7,8 +7,13 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'hammerjs';
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
|
||||
51
src/manifest.webmanifest
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "HPIoTWebApp",
|
||||
"short_name": "HPIoTWebApp",
|
||||
"theme_color": "#1976d2",
|
||||
"background_color": "#fafafa",
|
||||
"display": "standalone",
|
||||
"scope": "/",
|
||||
"start_url": "/",
|
||||
"icons": [
|
||||
{
|
||||
"src": "assets/icons/icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +1,4 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
|
||||