Skip to content

Commit

Permalink
Log Search UI: implement logs filtering by custom time range. (ababii…
Browse files Browse the repository at this point in the history
…chuk)
  • Loading branch information
aBabiichuk committed Sep 18, 2017
1 parent 3502576 commit a9e558d
Show file tree
Hide file tree
Showing 18 changed files with 717 additions and 97 deletions.
30 changes: 15 additions & 15 deletions ambari-logsearch/ambari-logsearch-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@
"@types/moment-timezone": "^0.2.34",
"@types/node": "~6.0.60",
"angular-in-memory-web-api": "^0.3.1",
"autoprefixer": "^6.5.3",
"circular-dependency-plugin": "^3.0.0",
"codelyzer": "~2.0.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.1",
"cssnano": "^3.10.0",
"exports-loader": "^0.6.3",
"file-loader": "^0.10.0",
"html-webpack-plugin": "^2.29.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
Expand All @@ -58,30 +67,21 @@
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0",
"webpack-dev-server": "~2.7.1",
"webpack": "~3.5.5",
"autoprefixer": "^6.5.3",
"css-loader": "^0.28.1",
"cssnano": "^3.10.0",
"exports-loader": "^0.6.3",
"file-loader": "^0.10.0",
"html-webpack-plugin": "^2.29.0",
"less-loader": "^4.0.5",
"postcss-loader": "^1.3.3",
"postcss-url": "^5.1.2",
"protractor": "~5.1.0",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"source-map-loader": "^0.2.0",
"istanbul-instrumenter-loader": "^2.0.0",
"style-loader": "^0.13.1",
"stylus-loader": "^3.0.1",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0",
"url-loader": "^0.5.7",
"circular-dependency-plugin": "^3.0.0",
"webpack": "~3.5.5",
"webpack-concat-plugin": "1.4.0",
"copy-webpack-plugin": "^4.0.1"
"webpack-dev-server": "~2.7.1"
}
}
4 changes: 4 additions & 0 deletions ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ import {ModalComponent} from '@app/components/modal/modal.component';
import {TimeZonePickerComponent} from '@app/components/timezone-picker/timezone-picker.component';
import {NodeBarComponent} from '@app/components/node-bar/node-bar.component';
import {SearchBoxComponent} from '@app/components/search-box/search-box.component';
import {TimeRangePickerComponent} from '@app/components/time-range-picker/time-range-picker.component';
import {DatePickerComponent} from '@app/components/date-picker/date-picker.component';

import {TimeZoneAbbrPipe} from '@app/pipes/timezone-abbr.pipe';

Expand Down Expand Up @@ -119,6 +121,8 @@ export function getXHRBackend(injector: Injector, browser: BrowserXhr, xsrf: XSR
TimeZonePickerComponent,
NodeBarComponent,
SearchBoxComponent,
TimeRangePickerComponent,
DatePickerComponent,
TimeZoneAbbrPipe
],
imports: [
Expand Down
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>
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();
});
});
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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
[defaultLabel]="filters.clusters.defaultLabel" [isMultipleChoice]="true"
class="filter-input"></filter-dropdown>
<search-box formControlName="query" [items]="searchBoxItems" class="filter-input"></search-box>
<filter-dropdown formControlName="timeRange" [options]="filters.timeRange.options"
[defaultLabel]="filters.timeRange.defaultLabel" class="filter-input"></filter-dropdown>
<time-range-picker formControlName="timeRange" [defaultLabel]="filters.timeRange.defaultLabel"
class="filter-input"></time-range-picker>
<timezone-picker class="filter-input"></timezone-picker>
<!--button class="btn btn-success" type="button">
<span class="fa fa-search"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@
border-right-width: @input-border-width;
margin-right: -1 * (@input-border-width);
}

time-range-picker {
/deep/ .dropdown-menu {
left: @col-padding;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as $ from 'jquery';
export class ModalComponent implements OnInit, AfterViewInit {

constructor(private element: ElementRef) {
this.rootElement = $(this.element.nativeElement);
this.rootElement = $(element.nativeElement);
}

ngOnInit() {
Expand Down
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>
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;
}
}
Loading

0 comments on commit a9e558d

Please sign in to comment.