Skip to content

Commit

Permalink
Godind/issue240 (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
godind authored Jan 18, 2024
1 parent 30654e5 commit ba3988f
Show file tree
Hide file tree
Showing 25 changed files with 613 additions and 58 deletions.
21 changes: 18 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,23 @@
<link rel="apple-touch-startup-image" href="assets/apple-splash-1334-750.jpg" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="assets/apple-splash-640-1136.jpg" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="assets/apple-splash-1136-640.jpg" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<style>html,body,app-root{height:100%}body{margin:0;touch-action:none}</style><link rel="stylesheet" href="styles.f98a2c1ba7cb7018.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.f98a2c1ba7cb7018.css"></noscript></head>
<style>html,body,app-root{height:100%}body{margin:0;touch-action:none}.loader-container{height:100%;width:100%;background-color:#424242}#loader{height:175px;inset:0;margin:auto;position:absolute;width:175px}#loader .dot{height:100%;inset:0;margin:auto;position:absolute;width:87.5px}#loader .dot:before{border-radius:100%;content:"";height:87.5px;left:0;position:absolute;right:0;top:0;transform:scale(0);width:87.5px}#loader .dot:nth-child(7n+1){transform:rotate(45deg)}#loader .dot:nth-child(7n+1):before{animation:.8s linear .1s normal none infinite running load;background:#e5ab13 none repeat scroll 0 0}#loader .dot:nth-child(7n+2){transform:rotate(90deg)}#loader .dot:nth-child(7n+2):before{animation:.8s linear .2s normal none infinite running load;background:#f0ca31 none repeat scroll 0 0}#loader .dot:nth-child(7n+3){transform:rotate(135deg)}#loader .dot:nth-child(7n+3):before{animation:.8s linear .3s normal none infinite running load;background:#92c7e9 none repeat scroll 0 0}#loader .dot:nth-child(7n+4){transform:rotate(180deg)}#loader .dot:nth-child(7n+4):before{animation:.8s linear .4s normal none infinite running load;background:#63afdf none repeat scroll 0 0}#loader .dot:nth-child(7n+5){transform:rotate(225deg)}#loader .dot:nth-child(7n+5):before{animation:.8s linear .5s normal none infinite running load;background:#3586ca none repeat scroll 0 0}#loader .dot:nth-child(7n+6){transform:rotate(270deg)}#loader .dot:nth-child(7n+6):before{animation:.8s linear .6s normal none infinite running load;background:#d52626 none repeat scroll 0 0}#loader .dot:nth-child(7n+7){transform:rotate(315deg)}#loader .dot:nth-child(7n+7):before{animation:.8s linear .7s normal none infinite running load;background:#e26767 none repeat scroll 0 0}#loader .dot:nth-child(7n+8){transform:rotate(360deg)}#loader .dot:nth-child(7n+8):before{animation:.8s linear .8s normal none infinite running load;background:#f8e598 none repeat scroll 0 0}#loader .loading{background-position:50% 50%;background-repeat:no-repeat;bottom:-40px;height:20px;left:0;position:absolute;right:0;width:180px}@keyframes load{to{opacity:0;transform:scale(1)}}</style><link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.css"></noscript></head>
<body>
<app-root></app-root>
<script src="runtime.e75056c32c37f59d.js" type="module"></script><script src="polyfills.64db6be9cdc8f808.js" type="module"></script><script src="main.9ac2d4dfd3811897.js" type="module"></script>
<app-root>
<div class="loader-container">
<div id="loader">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="loading"></div>
</div>
</div>
</app-root>
<script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="main.js" type="module"></script>

</body></html>
1 change: 0 additions & 1 deletion public/main.9ac2d4dfd3811897.js

This file was deleted.

1 change: 1 addition & 0 deletions public/main.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "/@mxtommy/kip/",
"theme_color": "#1E1E1E",
"background_color": "#1E1E1E",
"theme_color": "#424242",
"background_color": "#424242",
"display": "fullscreen",
"scope": "/@mxtommy/kip/",
"start_url": "/@mxtommy/kip/",
Expand Down Expand Up @@ -64,4 +64,4 @@
"form_factor": "wide"
}
]
}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions public/styles.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/styles.f98a2c1ba7cb7018.css

This file was deleted.

6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ import { BooleanMultiControlOptionsComponent } from './widget-config/boolean-mul
import { BooleanControlConfigComponent } from './widget-config/boolean-control-config/boolean-control-config.component';
import { PathsOptionsComponent } from './widget-config/paths-options/paths-options.component';
import { DisplayDatetimeComponent } from './widget-config/display-datetime/display-datetime.component';
import { SvgBooleanButtonComponent } from './widgets/svg-boolean-button/svg-boolean-button.component';
import { SvgBooleanLightComponent } from './widgets/svg-boolean-light/svg-boolean-light.component';


const appRoutes: Routes = [
Expand Down Expand Up @@ -204,7 +206,9 @@ const appNetworkInitializerFn = (appNetInitSvc: AppNetworkInitService) => {
BooleanMultiControlOptionsComponent,
BooleanControlConfigComponent,
PathsOptionsComponent,
DisplayDatetimeComponent
DisplayDatetimeComponent,
SvgBooleanButtonComponent,
SvgBooleanLightComponent
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
.float-right {
float: right;
.ctrl-grid {
display: grid;
width: auto;
height: auto;
margin: 0px;
grid-template-columns: [col-start] calc(100% - 90px) [col1-end] 80px [col2-end];
grid-template-areas: "controls actions";
row-gap: 0px;
column-gap: 10px;
justify-items: center;
align-items: center;
justify-content: center;
align-content: center;
margin-bottom: 10px;
}

.controls {
grid-area: controls;
width: 100%;
}

.actions {
grid-area: actions;
}

.btn-grid {
display: grid;
width: 80px;
height: 80px;
margin: 0px;
grid-template-columns: [col-start] 50% [col1-end] 50% [col2-end];
grid-template-rows: [row-start] 50% [row1-end] 50% [row2-end];
grid-template-areas:
"up delete"
"down delete";
row-gap: 0px;
column-gap: 0px;
justify-items: center;
align-items: center;
justify-content: center;
align-content: center;
}

.up {
grid-area: up;
}

.down {
grid-area: down;
}

.delete {
grid-area: delete;
}

.flex-label {
flex-grow: 2;
flex-shrink: 2;
}

.flex-settings {
flex-grow: 1;
flex-shrink: 1;
}

.settings {
min-width: 100px;
}

.flex-actions {
flex-grow: 0;
flex-shrink: 0;
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,58 @@
<div [formGroup]="ctrlFormGroup" class="flex-container rounded-card">
<div class="flex-field-50">
<mat-form-field class="fields" appearance="outline" floatLabel="always">
<mat-label>Label</mat-label>
<input matInput
type="string"
placeholder="Enter a display label..."
formControlName="ctrlLabel">
</mat-form-field>
<div [formGroup]="ctrlFormGroup" class="ctrl-grid rounded-card">
<div class="controls flex-container">
<div class="flex-label">
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
<mat-label>Label</mat-label>
<input matInput
type="string"
placeholder="Enter a display label..."
formControlName="ctrlLabel">
</mat-form-field>
</div>
<div class="flex-settings">
<mat-form-field class="settings" appearance="outline" floatLabel="always">
<mat-label>Type</mat-label>
<mat-select
placeholder="Select Type..."
formControlName="type"
name="type"
required>
<mat-option value=1>Toggle</mat-option>
<mat-option value=2>Push</mat-option>
<mat-option value=3>Indicator</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="flex-settings">
<mat-form-field class="settings" appearance="outline" floatLabel="always">
<mat-label>Color</mat-label>
<mat-select
placeholder="Select Color..."
formControlName="color"
name="color"
required>
<mat-option value='text'>Font</mat-option>
<mat-option value='primary'>Primary</mat-option>
<mat-option value='accent'>Accent</mat-option>
<mat-option value='warn'>Warn</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<div class="flex-field-50">
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
<mat-label>Color</mat-label>
<mat-select
placeholder="Select Color..."
formControlName="color"
name="color">
<mat-option value='text'>Font</mat-option>
<mat-option value='primary'>Primary</mat-option>
<mat-option value='accent'>Accent</mat-option>
<mat-option value='warn'>Warn</mat-option>
</mat-select>
</mat-form-field>
</div>

<div class="flex-field-100">
<button class="float-right" type="button" mat-raised-button color="primary" (click)="deleteControl()">Delete</button>
<div class="actions">
<div class="flex-actions">
<div class="btn-grid">
<button class="up" type="button" mat-icon-button color="primary" *ngIf="controlIndex !== 0" (click)="moveCtrlUp()" aria-label="Move control up in the list">
<i class="fa-solid fa-caret-up fa-2xl"></i>
</button>
<button class="down" type="button" mat-icon-button color="primary" *ngIf="controlIndex !== arrayLength - 1" (click)="moveCtrlDown()" aria-label="Move control down in the list">
<i class="fa-solid fa-caret-down fa-2xl"></i>
</button>
<button class="delete" type="button" mat-icon-button color="primary" (click)="deleteControl()" aria-label="Delete control">
<i class="fa-solid fa-trash-can fa-2xl"></i>
</button>
</div>
</div>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export interface IDeleteEventObj {
export class BooleanControlConfigComponent implements OnInit {
@Input() ctrlFormGroup!: UntypedFormGroup;
@Input() controlIndex: number;
@Input() arrayLength: number;
@Output() private deleteCtrl = new EventEmitter<IDeleteEventObj>();
@Output() private moveUp = new EventEmitter<number>();
@Output() private moveDown = new EventEmitter<number>();

constructor() { }

Expand All @@ -25,4 +28,12 @@ export class BooleanControlConfigComponent implements OnInit {
const delEvent: IDeleteEventObj = {ctrlIndex: this.controlIndex, pathID: this.ctrlFormGroup.get('pathID').value};
this.deleteCtrl.emit(delEvent);
}

public moveCtrlUp() {
this.moveUp.emit(this.controlIndex);
}

public moveCtrlDown() {
this.moveDown.emit(this.controlIndex);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.float-right {
float: right;
.add-btn {
margin-left: calc(50% - 20px);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<div [formGroup]="multiCtrlArray">
<button type="button" mat-raised-button color="primary" (click)="addCtrlGroup()">Add Control</button>
<boolean-control-config class="full-width"
*ngFor="let ctrl of multiCtrlArray.controls; index as i"
<boolean-control-config class="full-width" *ngFor="let ctrl of multiCtrlArray.controls; index as i"
[ctrlFormGroup]="ctrl"
[controlIndex]="i"
[arrayLength]="arrayLength"
(moveUp)="moveUp($event)"
(moveDown)="moveDown($event)"
(deleteCtrl)="deletePath($event)">
</boolean-control-config>
<button class="add-btn" type="button" mat-mini-fab color="primary" (click)="addCtrlGroup()" aria-label="Add control down in the list">
<i class="fa-solid fa-plus fa-2xl"></i>
</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ export class BooleanMultiControlOptionsComponent implements OnInit {
@Output() private updatePath = new EventEmitter<IDynamicControl>();
@Output() private delPath = new EventEmitter<string>();

public arrayLength: number = null;

constructor(
private fb: UntypedFormBuilder
) { }

ngOnInit(): void {
this.arrayLength = this.multiCtrlArray.length;
this.multiCtrlArray.valueChanges.pipe(debounceTime(350)).subscribe(values => {
this.updatePath.emit(values);
})
Expand All @@ -34,11 +37,14 @@ export class BooleanMultiControlOptionsComponent implements OnInit {
this.multiCtrlArray.push(
this.fb.group({
ctrlLabel: [null, Validators.required],
type: ['1', Validators.required],
pathID:[newUUID],
color:['text'],
value:[null]
}
));
// update array length for child components
this.arrayLength = this.multiCtrlArray.length;

// Create corresponding path group
const newPathObj: IWidgetPath = {
Expand All @@ -55,7 +61,20 @@ export class BooleanMultiControlOptionsComponent implements OnInit {
this.addPath.emit(newPathObj);
}

public moveUp(index: number) {
const ctrlGrp = this.multiCtrlArray.at(index);
this.multiCtrlArray.removeAt(index, {emitEvent: false});
this.multiCtrlArray.insert(index - 1, ctrlGrp, {emitEvent: false});
}

public moveDown(index: number) {
const ctrlGrp = this.multiCtrlArray.at(index);
this.multiCtrlArray.removeAt(index, {emitEvent: false});
this.multiCtrlArray.insert(index + 1, ctrlGrp, {emitEvent: false});
}

public deletePath(e): void {
this.delPath.emit(e)
this.delPath.emit(e);
this.arrayLength = this.multiCtrlArray.length;
}
}
10 changes: 5 additions & 5 deletions src/app/widget-list.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export class WidgetListService {
componentName: WidgetDateGenericComponent,
description: 'Date & Time',
},
{
name: 'WidgetBooleanSwitch',
componentName: WidgetBooleanSwitchComponent,
description: 'Boolean Control Panel',
},
{
name: 'WidgetStateComponent',
componentName: WidgetButtonComponent,
description: 'Boolean Button/Switch',
},
{
name: 'WidgetBooleanSwitch',
componentName: WidgetBooleanSwitchComponent,
description: 'Boolean Switches',
}
],
'Gauge': [
Expand Down
16 changes: 13 additions & 3 deletions src/app/widgets-interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Format, Policy } from './signalk-interfaces';

export enum ControlType {
toggle = 0,
push = 1,
indicator = 2,
}

/**
* KIP Dynamic Widgets interface.
*
Expand Down Expand Up @@ -192,14 +198,18 @@ export interface IWidgetSvcConfig {
* @interface IDynamicControl
*/
export interface IDynamicControl {
/** Label of the control */

/** Display label of the control */
ctrlLabel: string;
/** The path key name linked to the control */
/** The type of control: 1 = toggle, 2 = button, 3 = light */
type: ControlType;
/** A unique UUID to match against the path key name to link the control/path */
pathID: string;
/** The value of the control */
value: any;
value?: any;
/** The color of the control */
color: string;

}

/**
Expand Down
Loading

0 comments on commit ba3988f

Please sign in to comment.