Skip to content
Snippets Groups Projects
Commit a1177010 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add function

parent c9ffa99b
No related branches found
No related tags found
1 merge request!544App controls
<form
[formGroup]="formGroup"
class="height-full overflow-auto padding-top-1"
(submit)="service.callService()"
(submit)="onSubmit()"
>
<!-- Building code -->
<app-building-code-control [control]="formGroup.controls.buildingCode" />
......
......@@ -3,7 +3,10 @@ import {ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatError, MatHint, MatInputModule} from '@angular/material/input';
import {MatFormField, MatSelectModule} from '@angular/material/select';
import {NshmpLibNgControlPanelButtonsComponent} from '@ghsc/nshmp-lib-ng/nshmp';
import {
NshmpLibNgControlPanelButtonsComponent,
NshmpService,
} from '@ghsc/nshmp-lib-ng/nshmp';
import {Subscription} from 'rxjs';
import {AppService} from '../../services/app.service';
......@@ -32,7 +35,10 @@ export class ControlPanelInputComponent implements OnInit, OnDestroy {
subs: Subscription[] = [];
constructor(public service: AppService) {}
constructor(
public service: AppService,
private nshmpService: NshmpService,
) {}
ngOnInit(): void {
const controls = this.formGroup.controls;
......@@ -55,4 +61,12 @@ export class ControlPanelInputComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
this.subs.forEach(sub => sub.unsubscribe());
}
/**
* On form submit.
*/
onSubmit(): void {
this.service.callService();
this.nshmpService.selectPlotControl();
}
}
......@@ -9,6 +9,7 @@ import {
MatSnackBarLabel,
} from '@angular/material/snack-bar';
import {MatTooltip} from '@angular/material/tooltip';
import {NSHMP_TEMPLATE_PROVIDERS} from '@ghsc/nshmp-template';
/**
* Angular material snackbar to show link to download results.
......@@ -24,6 +25,7 @@ import {MatTooltip} from '@angular/material/tooltip';
MatSnackBarAction,
MatIcon,
],
providers: [NSHMP_TEMPLATE_PROVIDERS],
selector: 'app-snack-bar',
styleUrl: './snack-bar.component.scss',
templateUrl: './snack-bar.component.html',
......
......@@ -2,7 +2,7 @@
<form
class="height-full overflow-auto padding-top-1"
[formGroup]="formGroup"
(submit)="service.callService()"
(submit)="onSubmit()"
>
@let depths = parameters()?.depths;
@let location = parameters()?.location;
......
......@@ -13,6 +13,7 @@ import {
import {
FormGroupControls,
NshmpLibNgControlPanelButtonsComponent,
NshmpService,
} from '@ghsc/nshmp-lib-ng/nshmp';
import {NcmUsageParameter} from '@ghsc/nshmp-utils-ts/libs/ncm/geophysical';
import {Location} from '@ghsc/nshmp-utils-ts/libs/nshmp-lib/geo';
......@@ -61,7 +62,10 @@ export class ControlPanelComponent implements OnInit, OnDestroy {
private subs: Subscription[] = [];
constructor(public service: AppService) {}
constructor(
public service: AppService,
private nshmpService: NshmpService,
) {}
ngOnInit(): void {
const controls = this.formGroup.controls;
......@@ -86,6 +90,11 @@ export class ControlPanelComponent implements OnInit, OnDestroy {
this.subs.forEach(sub => sub.unsubscribe());
}
onSubmit(): void {
this.service.callService();
this.nshmpService.selectPlotControl();
}
removeLocation(index: number): void {
this.formGroup.controls.locations.removeAt(index);
}
......
......@@ -10,7 +10,10 @@ import {
NshmpLibNgMapSelectSiteComponent,
SelectSiteDialogData,
} from '@ghsc/nshmp-lib-ng/map';
import {NshmpLibNgControlPanelButtonsComponent} from '@ghsc/nshmp-lib-ng/nshmp';
import {
NshmpLibNgControlPanelButtonsComponent,
NshmpService,
} from '@ghsc/nshmp-lib-ng/nshmp';
import {Location} from '@ghsc/nshmp-utils-ts/libs/nshmp-lib/geo';
import {environment} from 'projects/nshmp-apps/src/environments/environment';
import {Subscription} from 'rxjs';
......@@ -55,7 +58,10 @@ export class ControlPanelComponent implements OnInit, OnDestroy {
private subs: Subscription[] = [];
constructor(public service: AppService) {}
constructor(
public service: AppService,
private nshmpService: NshmpService,
) {}
ngOnInit(): void {
const controls = this.formGroup.controls;
......@@ -83,6 +89,23 @@ export class ControlPanelComponent implements OnInit, OnDestroy {
this.subs.forEach(sub => sub.unsubscribe());
}
onSubmit(): void {
this.service.callService();
this.nshmpService.selectPlotControl();
}
/**
* Set the location form fields.
*
* @param location The location
*/
setLocation(location: Location): void {
this.formGroup.patchValue({
latitude: location.latitude,
longitude: location.longitude,
});
}
private onModelChange(): void {
const {latitude, longitude} = this.formGroup.getRawValue();
const latitudeBounds = this.service.usage().response.latitude;
......@@ -106,20 +129,4 @@ export class ControlPanelComponent implements OnInit, OnDestroy {
this.formGroup.controls.longitude.markAsPristine();
this.service.resetState();
}
onSubmit(): void {
this.service.callService();
}
/**
* Set the location form fields.
*
* @param location The location
*/
setLocation(location: Location): void {
this.formGroup.patchValue({
latitude: location.latitude,
longitude: location.longitude,
});
}
}
......@@ -6,32 +6,5 @@
@use '@ghsc/nshmp-template/styles/variables';
nshmp-template-control-panel form {
padding: 1em 0.5em 4em;
}
/* Form buttons */
.form-buttons {
bottom: 0;
padding: 1em 0 0 0;
position: absolute;
width: variables.$side-panel-width;
z-index: 10;
background-color: mat.m2-get-color-from-palette(variables.$nshmp-accent);
box-shadow: 0 0 1px rgba(0, 0, 0, 0.8);
}
.form-buttons.full-width {
width: 100%;
}
.form-buttons--left {
left: 0;
}
.form-buttons--right {
right: 0;
}
body.dark-mode .form-buttons {
background-color: mat.m2-get-color-from-palette(variables.$nshmp-accent, 800);
padding: 1em 0.5em 1em;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment