-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kamu 165 set watermark add event from UI (#105)
* Added modal window. * Add @danielmoncada/angular-datetime-picker package. * Added datetime-picker component. * Add description in the template. * Add unit tests. * Fix min value for dateTime picker. * Add timezone dropdown. * Add timezone difference.
- Loading branch information
1 parent
896bf6f
commit bdc45ff
Showing
16 changed files
with
381 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ts/overview-component/components/edit-watermark-modal/edit-watermark-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<div class="d-flex p-4"> | ||
<div class="flex-grow-1 ms-2 text-center"> | ||
<span class="fs-5 fw-bold"> Set Watermark</span> | ||
</div> | ||
<div> | ||
<button | ||
type="button" | ||
class="btn-close" | ||
aria-label="Close" | ||
(click)="activeModal.close()" | ||
></button> | ||
</div> | ||
</div> | ||
<div class="px-4"> | ||
<mat-divider></mat-divider> | ||
</div> | ||
<div class="p-4"> | ||
<div class="d-flex align-middle"> | ||
<span> | ||
<mat-icon class="fs-4">help_outline</mat-icon> | ||
</span> | ||
<p class="ps-2"> | ||
A watermark defines a point in event time for which with a high | ||
probability all preceding events have been already observed. Telling | ||
the system | ||
<em | ||
>"You most likely will not get any events with time less than T | ||
any more"</em | ||
> | ||
allows it to advance the downstream computations, like windowed | ||
aggregations and streaming joins, and ensure consistent results. | ||
Watermarks are typically advanced automatically based on observed | ||
data or information from the data source, but you can also set them | ||
manually here. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="body text-center"> | ||
<div class="d-flex align-items-center pb-4 ms-4 ps-4"> | ||
<span class="me-4">Time zone:</span> | ||
<select class="form-select w-75" [(ngModel)]="timeZone"> | ||
<option [ngValue]="timeZone"> | ||
(UTC{{ createOffset(this.date) }}) {{ timeZone }} | ||
</option> | ||
</select> | ||
</div> | ||
<div class="d-flex align-items-center ms-4 ps-4"> | ||
<span>Watermark:</span> | ||
<input | ||
[(ngModel)]="date" | ||
[owlDateTime]="fromdatepicker" | ||
placeholder="Date Time" | ||
class="form-control w-65 ms-4" | ||
name="fromDate" | ||
[min]="minLocalWatermark" | ||
/> | ||
<owl-date-time #fromdatepicker></owl-date-time> | ||
<span [owlDateTimeTrigger]="fromdatepicker" class="trigger ms-2" | ||
><mat-icon>calendar_month</mat-icon> | ||
</span> | ||
</div> | ||
</div> | ||
<div class="p-4 d-flex justify-content-end"> | ||
<button | ||
type="button" | ||
class="btn btn-success" | ||
(click)="commitSetWatermarkEvent(); activeModal.close()" | ||
data-test-id="commit-setWatermark-event" | ||
[disabled]="isDateValid" | ||
> | ||
Save | ||
</button> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
...ts/overview-component/components/edit-watermark-modal/edit-watermark-modal.component.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.custom-picker | ||
z-index: 9999!important | ||
|
||
.w-65 | ||
width: 67% !important |
83 changes: 83 additions & 0 deletions
83
...overview-component/components/edit-watermark-modal/edit-watermark-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
|
||
import { EditWatermarkModalComponent } from "./edit-watermark-modal.component"; | ||
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap"; | ||
import { Apollo } from "apollo-angular"; | ||
import { MatDividerModule } from "@angular/material/divider"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
import { | ||
OwlDateTimeModule, | ||
OwlNativeDateTimeModule, | ||
} from "@danielmoncada/angular-datetime-picker"; | ||
import { OwlMomentDateTimeModule } from "@danielmoncada/angular-datetime-picker-moment-adapter"; | ||
import { FormsModule } from "@angular/forms"; | ||
import timekeeper from "timekeeper"; | ||
import { mockDatasetBasicsFragment } from "src/app/search/mock.data"; | ||
import { emitClickOnElementByDataTestId } from "src/app/common/base-test.helpers.spec"; | ||
import { AppDatasetCreateService } from "src/app/dataset-create/dataset-create.service"; | ||
import { of } from "rxjs"; | ||
|
||
describe("EditWatermarkModalComponent", () => { | ||
let component: EditWatermarkModalComponent; | ||
let fixture: ComponentFixture<EditWatermarkModalComponent>; | ||
let appDatasetCreateService: AppDatasetCreateService; | ||
const FROZEN_TIME = new Date("2022-10-01 12:00:00"); | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [EditWatermarkModalComponent], | ||
providers: [Apollo, NgbActiveModal], | ||
imports: [ | ||
MatDividerModule, | ||
MatIconModule, | ||
OwlDateTimeModule, | ||
OwlNativeDateTimeModule, | ||
OwlMomentDateTimeModule, | ||
FormsModule, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(EditWatermarkModalComponent); | ||
component = fixture.componentInstance; | ||
appDatasetCreateService = TestBed.inject(AppDatasetCreateService); | ||
component.datasetBasics = mockDatasetBasicsFragment; | ||
}); | ||
|
||
it("should create", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
beforeAll(() => { | ||
timekeeper.freeze(FROZEN_TIME); | ||
}); | ||
|
||
it("should check init date when currentWatermark is null", () => { | ||
const result = new Date(); | ||
fixture.detectChanges(); | ||
expect(component.date).toEqual(result); | ||
}); | ||
|
||
it("should check init minLocalWatermark when currentWatermark is not null", () => { | ||
(component.currentWatermark = "2023-03-12T00:00:00+00:00"), | ||
fixture.detectChanges(); | ||
const result = "2023-03-12T00:00:00.000Z"; | ||
expect(component.minLocalWatermark).toEqual(result); | ||
}); | ||
|
||
it("should check commit SetWatermark event", () => { | ||
fixture.detectChanges(); | ||
const commitSetWatermarkEventSpy = spyOn( | ||
component, | ||
"commitSetWatermarkEvent", | ||
).and.callThrough(); | ||
spyOn(appDatasetCreateService, "commitEventToDataset").and.returnValue( | ||
of(), | ||
); | ||
emitClickOnElementByDataTestId(fixture, "commit-setWatermark-event"); | ||
expect(commitSetWatermarkEventSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
afterAll(() => { | ||
timekeeper.reset(); | ||
}); | ||
}); |
Oops, something went wrong.