Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test control #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions openhtf/output/web_gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@
<div class="station">

<div class="nav-bar">
<button
*ngIf="dashboardEnabled"
(click)="goBack()"
type="button"
class="htf-link-button">
<button *ngIf="dashboardEnabled" (click)="goBack()" type="button" class="htf-link-button">
‹ Return to station selection
</button>
<div class="u-flex-grow"></div>
<button
(click)="manualReload()"
type="button"
class="htf-link-button">
<button (click)="manualReload()" type="button" class="htf-link-button">
Refresh station
</button>
</div>
Expand All @@ -52,19 +45,18 @@
<htf-user-input-plug [test]="activeTest"></htf-user-input-plug>
</div>



<div class="htf-layout-widgets-container">
<div class="htf-layout-widgets-left">
<div
*ngIf="selectedTest !== null"
class="past-test-warning htf-layout-widget">
<htf-test-control [test]="activeTest" [station]="selectedStation"
(onSelectTest)="onSelectTest($event.test)"></htf-test-control>
<div *ngIf="selectedTest !== null" class="past-test-warning htf-layout-widget">
<div class="htf-layout-widget-header">
<div>Displaying test record for a previous test run</div>
<span>&nbsp;({{ selectedTest.startTimeMillis | timeAgo }})</span>
<div class="u-flex-grow"></div>
<button
type="button"
class="htf-rounded-button-grey"
(click)="onSelectTest(null)">
<button type="button" class="htf-rounded-button-grey" (click)="onSelectTest(null)">
Return to current test
</button>
</div>
Expand All @@ -77,9 +69,7 @@
</div>

<div class="htf-layout-widgets-right">
<htf-history
[selectedTest]="selectedTest"
[station]="selectedStation"
<htf-history [selectedTest]="selectedTest" [station]="selectedStation"
(onSelectTest)="onSelectTest($event.test)">
</htf-history>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {TimeAgoPipe} from '../../shared/time-ago.pipe';

import {StationComponent} from './station.component';
import {StationService} from './station.service';
import {TestControlComponent} from './test-control.component';

// Selectors for components used in the station component template which take
// a single test state as input.
Expand Down Expand Up @@ -123,6 +124,7 @@ describe('station component', () => {
TestBed.configureTestingModule({
declarations: (testWidgetStubs as Array<{}>).concat([
HistoryComponentStub,
TestControlComponent,
StationComponent,
HostComponent,
TimeAgoPipe,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div class="htf-layout-widget">
<div [@animateIn]="'in'" *ngIf="!testRunning() && hasTests()">

<div class="htf-layout-widget-header">
<div>Start new test</div>
</div>

<div class="htf-layout-widget-body">
<div class="dropdown" (mouseleave)="isDropdownOpen = false">
<input #response_field type="text" [style.display]="inline" class="u-push-top" [(ngModel)]="searchText"
(input)="filterItems()" placeholder="Select test..." (click)="isDropdownOpen = true">
<ul *ngIf="isDropdownOpen" class="" dropdown-list>
<li *ngFor="let item of filteredTests" (click)="selectItem(item)" [class.selected]="item === selectedValue"
(mouseenter)="onMouseEnter(item)" (mouseleave)="onMouseLeave()">
{{item}}
</li>
</ul>
</div>

<div class="test-control-error-text u-push-top-third" *ngIf="error">
{{ error }}
</div>

<div class="u-text-align-right">
<button type="button" class="htf-rounded-button-grey u-push-top" (click)="sendTestStart(response_field)">
START
</button>
</div>

</div>
</div>

<div [@animateIn]="'in'" *ngIf="testRunning()">

<div class="htf-layout-widget-body">
<div [innerHTML]="control"></div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using [innerHTML] can be a security risk if the content is not sanitized. Ensure 'control' is properly sanitized before binding.


<div class="u-font-size-large">
<button type="button" class="htf-rounded-button-red u-font-size-large" (click)="abort()">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: There's an extra space in the class attribute between 'htf-rounded-button-red' and 'u-font-size-large'.

Suggested change
<button type="button" class="htf-rounded-button-red u-font-size-large" (click)="abort()">
<button type="button" class="htf-rounded-button-red u-font-size-large" (click)="abort()">

ABORT TEST
</button>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@import 'vars';

// Styling for lists injected into the prompt.
:host ::ng-deep ol,
:host ::ng-deep ul {
padding-left: 25px;
margin: 0;
}
Comment on lines +20 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using more specific selectors to avoid potential conflicts with other components

Suggested change
:host ::ng-deep ol,
:host ::ng-deep ul {
padding-left: 25px;
margin: 0;
}
:host ::ng-deep .custom-ol,
:host ::ng-deep .custom-ul {
padding-left: 25px;
margin: 0;
}


.test-control-has-error {
border-color: $theme-red;

&:focus {
border-color: darken($theme-red, 20%);
}
}

.test-control-error-text {
color: $theme-red;
font-size: $font-size-small;
}

.dropdown {
position: relative;
}

ul {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
max-height: 300px;
overflow-y: auto;
border: 1px solid #ccc;
border-top: none;
border-radius: 0 0 4px 4px;
position: absolute;
background-color: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
Comment on lines +43 to +56
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using classes instead of element selectors for better specificity and reusability

Suggested change
ul {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
max-height: 300px;
overflow-y: auto;
border: 1px solid #ccc;
border-top: none;
border-radius: 0 0 4px 4px;
position: absolute;
background-color: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.custom-ul {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
max-height: 300px;
overflow-y: auto;
border: 1px solid #ccc;
border-top: none;
border-radius: 0 0 4px 4px;
position: absolute;
background-color: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}


li {
padding: 10px;
cursor: pointer;
transition: background-color 0.3s;
}
Comment on lines +58 to +62
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a class selector for list items instead of the element selector

Suggested change
li {
padding: 10px;
cursor: pointer;
transition: background-color 0.3s;
}
.custom-li {
padding: 10px;
cursor: pointer;
transition: background-color 0.3s;
}


li.selected {
background-color: #3498db;
color: #fff;
}

li:hover {
background-color: #f2f2f2;
cursor: pointer;
}
Comment on lines +69 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Redundant cursor property, already set on line 60

Suggested change
li:hover {
background-color: #f2f2f2;
cursor: pointer;
}
li:hover {
background-color: #f2f2f2;
}


li:hover.selected {
background-color: #3498db;
color: #fff;
}
Comment on lines +74 to +77
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider combining this with the .selected class to reduce specificity

Suggested change
li:hover.selected {
background-color: #3498db;
color: #fff;
}
li.selected:hover {
background-color: #3498db;
color: #fff;
}

Loading