forked from apache/ambari
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log Search UI: implement logs filtering by custom time range. (ababii…
…chuk)
- Loading branch information
1 parent
3502576
commit a9e558d
Showing
18 changed files
with
717 additions
and
97 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
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
25 changes: 25 additions & 0 deletions
25
...-logsearch/ambari-logsearch-web/src/app/components/date-picker/date-picker.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,25 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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. | ||
--> | ||
|
||
<div class="form-group"> | ||
<div #datepicker class="input-group date"> | ||
<input type="text" class="form-control"> | ||
<span class="input-group-addon"> | ||
<span class="fa fa-calendar"></span> | ||
</span> | ||
</div> | ||
</div> |
51 changes: 51 additions & 0 deletions
51
...gsearch/ambari-logsearch-web/src/app/components/date-picker/date-picker.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,51 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {StoreModule} from '@ngrx/store'; | ||
import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; | ||
|
||
import {DatePickerComponent} from './date-picker.component'; | ||
|
||
describe('DatePickerComponent', () => { | ||
let component: DatePickerComponent; | ||
let fixture: ComponentFixture<DatePickerComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DatePickerComponent], | ||
imports: [ | ||
StoreModule.provideStore({ | ||
appSettings | ||
}) | ||
], | ||
providers: [AppSettingsService] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DatePickerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create component', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
...ri-logsearch/ambari-logsearch-web/src/app/components/date-picker/date-picker.component.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,73 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 {Component, OnInit, OnDestroy, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; | ||
import * as $ from 'jquery'; | ||
import '@vendor/js/bootstrap-datetimepicker.min'; | ||
import {AppSettingsService} from '@app/services/storage/app-settings.service'; | ||
|
||
@Component({ | ||
selector: 'date-picker', | ||
templateUrl: './date-picker.component.html' | ||
}) | ||
export class DatePickerComponent implements OnInit, OnDestroy { | ||
|
||
constructor(private appSettings: AppSettingsService) { | ||
appSettings.getParameter('timeZone').subscribe(value => { | ||
this.destroyDatePicker(); | ||
this.timeZone = value; | ||
if (this.datePickerElement) { | ||
this.createDatePicker(); | ||
} | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
this.createDatePicker(); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.destroyDatePicker(); | ||
} | ||
|
||
@Output() | ||
timeChange: EventEmitter<number> = new EventEmitter(); | ||
|
||
@ViewChild('datepicker') | ||
datePicker: ElementRef; | ||
|
||
private datePickerElement: any; | ||
|
||
private timeZone: string; | ||
|
||
private createDatePicker(): void { | ||
this.datePickerElement = $(this.datePicker.nativeElement); | ||
this.datePickerElement.datetimepicker({ | ||
timeZone: this.timeZone | ||
}); | ||
this.datePickerElement.on('dp.change', event => this.timeChange.emit(event.date)); | ||
} | ||
|
||
private destroyDatePicker(): void { | ||
const datePicker = this.datePickerElement; | ||
if (datePicker) { | ||
datePicker.data('DateTimePicker').destroy(); | ||
} | ||
} | ||
|
||
} |
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
41 changes: 41 additions & 0 deletions
41
...mbari-logsearch-web/src/app/components/time-range-picker/time-range-picker.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,41 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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. | ||
--> | ||
|
||
<button class="btn btn-link dropdown-toggle" data-toggle="dropdown"> | ||
{{selectedLabel | translate}} <span class="caret"></span> | ||
</button> | ||
<div class="dropdown-menu row col-md-12"> | ||
<div class="col-md-4" (click)="$event.stopPropagation()"> | ||
<h4>{{'filters.timeRange' | translate}}</h4> | ||
<date-picker (timeChange)="setStartTime($event)"></date-picker> | ||
<date-picker (timeChange)="setEndTime($event)"></date-picker> | ||
<button class="btn btn-success pull-right" type="button" (click)="setCustomTimeRange()" | ||
[disabled]="!startTime || !endTime || startTime >= endTime"> | ||
{{'modal.apply' | translate}} | ||
</button> | ||
</div> | ||
<div class="col-md-8 row"> | ||
<h4>{{'filters.timeRange.quick' | translate}}</h4> | ||
<div *ngFor="let group of quickRanges" [ngClass]="'col-md-' + 12 / quickRanges.length"> | ||
<div *ngFor="let option of group"> | ||
<span class="time-range-name" (click)="setTimeRange(option.value, option.label)"> | ||
{{option.label | translate}} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
35 changes: 35 additions & 0 deletions
35
...mbari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.less
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,35 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 '../variables'; | ||
|
||
.btn.dropdown-toggle { | ||
text-transform: none; | ||
} | ||
|
||
.dropdown-menu { | ||
padding-bottom: @col-padding; | ||
|
||
date-picker /deep/ .form-group { | ||
margin-bottom: @col-padding; | ||
} | ||
|
||
.time-range-name { | ||
.clickable-item; | ||
} | ||
} |
Oops, something went wrong.