http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.html new file mode 100644 index 0000000..827f63c --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.html @@ -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. +--> + +<accordion-panel *ngFor="let log of logs | async; let i = index" [toggleId]="'details-' + i" class="col-md-12"> + <ng-template> + <div [ngClass]="'hexagon ' + log.className"></div> + <div [ngClass]="'col-md-1 log-status ' + log.className">{{log.level}}</div> + <div class="col-md-3"> + <div class="log-type">{{log.type}}</div> + <time class="log-time">{{log.time}}</time> + </div> + <div class="col-md-6 log-content-wrapper"> + <div class="collapse log-actions" [attr.id]="'details-' + i"> + <span class="action-icon fa fa-search"></span> + <span class="action-icon fa fa-external-link"></span> + <span class="action-icon fa fa-bullseye"></span> + </div> + <div class="log-content">{{log.message}}</div> + </div> + </ng-template> +</accordion-panel>
http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.less new file mode 100644 index 0000000..6ed0463 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.less @@ -0,0 +1,128 @@ +/** + * 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'; + +:host { + display: block; + overflow: hidden; + padding-top: @block-margin-top; + background-color: @main-background-color; // TODO implement actual color + + .hexagon { + // TODO get rid of magic numbers, base on actual design + left: -7.5px; + + &.fatal { + .common-hexagon(15px, @fatal-color); + } + + &.error { + .common-hexagon(15px, @error-color); + } + + &.warn { + .common-hexagon(15px, @warning-color); + } + + &.info { + .common-hexagon(15px, @info-color); + } + + &.debug { + .common-hexagon(15px, @debug-color); + } + + &.trace { + .common-hexagon(15px, @trace-color); + } + + &.unknown { + .common-hexagon(15px, @unknown-color); + } + } + + .log-status { + text-transform: uppercase; + + &.fatal { + color: @fatal-color; + } + + &.error { + color: @error-color; + } + + &.warn { + color: @warning-color; + } + + &.info { + color: @info-color; + } + + &.debug { + color: @debug-color; + } + + &.trace { + color: @trace-color; + } + + &.unknown { + color: @unknown-color; + } + } + + .log-type { + color: @link-color; + } + + .log-time { + color: @grey-color; + } + + .log-content-wrapper { + position: relative; + + // TODO get rid of magic numbers, base on actual design + .log-content { + overflow: hidden; + max-height: @default-line-height * 2em; + padding-right: 65px; + white-space: pre-wrap; + } + + .log-actions { + position: absolute; + right: 40px; + top: 0; + border: @input-border; + + &.collapsing + .log-content, &.collapse.in + .log-content { + min-height: 6em; + max-height: none; + } + + .action-icon { + .clickable-item; + display: block; + padding: 5px; + } + } + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts new file mode 100644 index 0000000..072bfcd --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts @@ -0,0 +1,72 @@ +/** + * 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 {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {StoreModule} from '@ngrx/store'; +import {AuditLogsService, auditLogs} from '@app/services/storage/audit-logs.service'; +import {ServiceLogsService, serviceLogs} from '@app/services/storage/service-logs.service'; +import {HttpClientService} from '@app/services/http-client.service'; +import {FilteringService} from '@app/services/filtering.service'; + +import {LogsListComponent} from './logs-list.component'; + +describe('LogsListComponent', () => { + let component: LogsListComponent; + let fixture: ComponentFixture<LogsListComponent>; + const httpClient = { + get: () => { + return { + subscribe: () => { + } + }; + } + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [LogsListComponent], + imports: [ + StoreModule.provideStore({ + auditLogs, + serviceLogs + }) + ], + providers: [ + { + provide: HttpClientService, + useValue: httpClient + }, + AuditLogsService, + ServiceLogsService, + FilteringService + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LogsListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create component', () => { + expect(component).toBeTruthy(); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts new file mode 100644 index 0000000..cc77784 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts @@ -0,0 +1,96 @@ +/** + * 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, Input} from '@angular/core'; +import 'rxjs/add/operator/map'; +import {HttpClientService} from '@app/services/http-client.service'; +import {ServiceLogsService} from '@app/services/storage/service-logs.service'; +import {FilteringService} from '@app/services/filtering.service'; + +@Component({ + selector: 'logs-list', + templateUrl: './logs-list.component.html', + styleUrls: ['./logs-list.component.less'] +}) +export class LogsListComponent implements OnInit { + + constructor(private httpClient: HttpClientService, private serviceLogsStorage: ServiceLogsService, private filtering: FilteringService) { + this.filtering.filteringSubject.subscribe(this.loadLogs.bind(this)); + } + + ngOnInit() { + this.loadLogs(); + } + + @Input() + private logsArrayId: string; + + private readonly usedFilters = { + clusters: ['clusters'], + text: ['iMessage'], + timeRange: ['end_time', 'start_time'], + components: ['component_name'], + levels: ['level'] + }; + + logs = this.serviceLogsStorage.getInstances().map(logs => { + return logs.map(log => { + return { + type: log.type, + level: log.level, + className: log.level.toLowerCase(), + message: log.log_message, + time: new Date(log.logtime).toLocaleDateString() + ' ' + new Date(log.logtime).toLocaleTimeString() // TODO use moment with custom time zone + } + }); + }); + + private loadLogs(): void { + this.httpClient.get(this.logsArrayId, this.getParams()).subscribe(response => { + this.serviceLogsStorage.clear(); + const logs = response.json().logList; + this.serviceLogsStorage.addInstances(logs); + }); + } + + private getParams(): any { + let params = {}; + Object.keys(this.usedFilters).forEach(key => { + const inputFilter = this.filtering.filters[key], + inputValue = inputFilter.selectedValue, + paramNames = this.usedFilters[key]; + paramNames.forEach(paramName => { + let value; + const valueGetter = this.filtering.valueGetters[paramName]; + if (valueGetter) { + if (paramName === 'start_time') { + value = valueGetter(inputValue, params['end_time']); + } else { + value = valueGetter(inputValue); + } + } else { + value = inputValue; + } + if (value) { + params[paramName] = value; + } + }); + }, this); + return params; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.html new file mode 100644 index 0000000..61d1b93 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.html @@ -0,0 +1,20 @@ +<!-- + 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. +--> + +<login-form *ngIf="!isAuthorized"></login-form> +<filters-panel *ngIf="isAuthorized" class="row"></filters-panel> +<logs-list *ngIf="isAuthorized" [logsArrayId]="'serviceLogs'"></logs-list> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.spec.ts new file mode 100644 index 0000000..536f1ef --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.spec.ts @@ -0,0 +1,49 @@ +/** + * 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 {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {HttpModule} from '@angular/http'; +import {HttpClientService} from '@app/services/http-client.service'; + +import {MainContainerComponent} from './main-container.component'; + +describe('MainContainerComponent', () => { + let component: MainContainerComponent; + let fixture: ComponentFixture<MainContainerComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MainContainerComponent], + imports: [HttpModule], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + providers: [HttpClientService] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MainContainerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create component', () => { + expect(component).toBeTruthy(); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.ts new file mode 100644 index 0000000..bac39ec --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/main-container/main-container.component.ts @@ -0,0 +1,37 @@ +/** + * 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} from '@angular/core'; +import {HttpClientService} from '@app/services/http-client.service'; + +@Component({ + selector: 'main-container', + templateUrl: './main-container.component.html' +}) +export class MainContainerComponent implements OnInit { + + constructor(private httpClient: HttpClientService) {} + + ngOnInit() { + } + + get isAuthorized() { + return this.httpClient.isAuthorized; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.html new file mode 100644 index 0000000..132d717 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.html @@ -0,0 +1,27 @@ +<!-- + 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 #dropdown [ngClass]="{'dropdown': hasSubItems, 'text-center': true}"> + <a [ngClass]="iconClass + ' icon'" (mousedown)="onMouseDown($event)" (mouseup)="onMouseUp($event)" + (click)="$event.stopPropagation()"></a> + <a #dropdownToggle class="dropdown-toggle caret" data-toggle="dropdown" *ngIf="hasCaret"></a> + <br> + <a *ngIf="label" (mousedown)="onMouseDown($event)" [ngClass]="labelClass" (mouseup)="onMouseUp($event)" + (click)="$event.stopPropagation()">{{label | translate}}</a> + <ul class="dropdown-menu" [isFilter]="isFilter" *ngIf="hasSubItems" [items]="subItems" + (selectedItemChange)="setSelectedValue($event)"></ul> +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.less new file mode 100644 index 0000000..6a3a43d --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.less @@ -0,0 +1,33 @@ +/** + * 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. + */ + +:host { + display: inline-block; + cursor: pointer; + + a:hover, a:focus { + text-decoration: none; + } + + .icon { + padding: 5px; + } + + .unstyled-link { + color: inherit; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.spec.ts new file mode 100644 index 0000000..424d322 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.spec.ts @@ -0,0 +1,126 @@ +/** + * 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 {NO_ERRORS_SCHEMA} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {Http} from '@angular/http'; +import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; +import {ComponentActionsService} from '@app/services/component-actions.service'; +import {FilteringService} from '@app/services/filtering.service'; + +import {MenuButtonComponent} from './menu-button.component'; + +export function HttpLoaderFactory(http: Http) { + return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); +} + +describe('MenuButtonComponent', () => { + let component: MenuButtonComponent; + let fixture: ComponentFixture<MenuButtonComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MenuButtonComponent], + imports: [ + TranslateModule.forRoot({ + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [Http] + })], + providers: [ + ComponentActionsService, + FilteringService + ], + schemas: [NO_ERRORS_SCHEMA] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MenuButtonComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create component', () => { + expect(component).toBeTruthy(); + }); + + describe('#hasSubItems', () => { + const cases = [ + { + subItems: null, + hasSubItems: false, + title: 'no sub-items' + }, + { + subItems: [], + hasSubItems: false, + title: 'empty sub-items array' + }, + { + subItems: [{}], + hasSubItems: true, + title: 'sub-items present' + } + ]; + + cases.forEach((test) => { + it(test.title, () => { + component.subItems = test.subItems; + expect(component.hasSubItems).toEqual(test.hasSubItems); + }); + }); + }); + + describe('#hasCaret', () => { + const cases = [ + { + subItems: null, + hasCaret: false, + title: 'no sub-items' + }, + { + subItems: [], + hasCaret: false, + title: 'empty sub-items array' + }, + { + subItems: [{}], + hideCaret: false, + hasCaret: true, + title: 'sub-items present, caret not hidden' + }, + { + subItems: [{}], + hideCaret: true, + hasCaret: true, + title: 'sub-items present, caret hidden' + } + ]; + + cases.forEach((test) => { + it(test.title, () => { + component.subItems = test.subItems; + component.hideCaret = Boolean(test.hideCaret); + expect(component.hasSubItems).toEqual(test.hasCaret); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.ts new file mode 100644 index 0000000..ded01b7 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/menu-button/menu-button.component.ts @@ -0,0 +1,102 @@ +/** + * 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, AfterViewInit, Input, ViewChild, ElementRef} from '@angular/core'; +import {ComponentActionsService} from '@app/services/component-actions.service'; +import {FilteringService} from '@app/services/filtering.service'; +import * as $ from 'jquery'; + +@Component({ + selector: 'menu-button', + templateUrl: './menu-button.component.html', + styleUrls: ['./menu-button.component.less'] +}) +export class MenuButtonComponent implements AfterViewInit { + + constructor(private actions: ComponentActionsService, private filtering: FilteringService) { + } + + ngAfterViewInit() { + } + + @ViewChild('dropdown') + dropdown: ElementRef; + + @Input() + label?: string; + + @Input() + action: string; + + @Input() + isFilter: boolean; + + @Input() + filterInstance?: any; + + @Input() + iconClass: string; + + @Input() + labelClass?: string; + + @Input() + subItems?: any[]; + + @Input() + hideCaret?: boolean; + + get hasSubItems(): boolean { + return Boolean(this.subItems && this.subItems.length); + } + + get hasCaret(): boolean { + return this.hasSubItems && !this.hideCaret; + } + + private clickStartTime: number; + + private readonly longClickInterval = 1000; + + onMouseDown(event: MouseEvent): void { + if (this.action && event.button === 0) { + this.clickStartTime = (new Date()).getTime(); + } + } + + onMouseUp(event: MouseEvent): void { + if (event.button === 0) { + const clickEndTime = (new Date()).getTime(); + if (this.hasSubItems && (!this.action || clickEndTime - this.clickStartTime >= this.longClickInterval)) { + $(this.dropdown.nativeElement).toggleClass('open'); + } else if (this.action) { + this.actions[this.action](); + } + event.stopPropagation(); + } + } + + setSelectedValue(options: any): void { + if (this.filterInstance.selectedValue !== options.value) { + this.filterInstance.selectedValue = options.value; + this.filterInstance.selectedLabel = options.label; + this.filtering.filteringSubject.next(null); + } + }; + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.html new file mode 100644 index 0000000..6898354 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.html @@ -0,0 +1,21 @@ +<!-- + 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. +--> + +<menu-button *ngFor="let item of items" [label]="item.label" [action]="item.action" + [iconClass]="item.iconClass" [labelClass]="item.labelClass" + [subItems]="item.subItems" [hideCaret]="item.hideCaret"> +</menu-button> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.less new file mode 100644 index 0000000..e5e85f4 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.less @@ -0,0 +1,22 @@ +/** + * 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'; + +:host { + .default-flex; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.spec.ts new file mode 100644 index 0000000..1649a50 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.spec.ts @@ -0,0 +1,45 @@ +/** + * 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 {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; + +import {TopMenuComponent} from './top-menu.component'; + +describe('TopMenuComponent', () => { + let component: TopMenuComponent; + let fixture: ComponentFixture<TopMenuComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [TopMenuComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TopMenuComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create component', () => { + expect(component).toBeTruthy(); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.ts new file mode 100644 index 0000000..73b6131 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/top-menu/top-menu.component.ts @@ -0,0 +1,122 @@ +/** + * 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} from '@angular/core'; + +@Component({ + selector: 'top-menu', + templateUrl: './top-menu.component.html', + styleUrls: ['./top-menu.component.less'] +}) +export class TopMenuComponent implements OnInit { + + constructor() { + } + + ngOnInit() { + } + + //TODO implement loading of real data into subItems + readonly items = [ + { + iconClass: 'fa fa-arrow-left', + label: 'topMenu.undo', + labelClass: 'unstyled-link', + action: 'undo', + subItems: [ + { + label: 'Apply \'Last week\' filter' + }, + { + label: 'Clear all filters' + }, + { + label: 'Apply \'HDFS\' filter' + }, + { + label: 'Apply \'Errors\' filter' + } + ] + }, + { + iconClass: 'fa fa-arrow-right', + label: 'topMenu.redo', + labelClass: 'unstyled-link', + action: 'redo', + subItems: [ + { + label: 'Apply \'Warnings\' filter' + }, + { + label: 'Switch to graph mode' + }, + { + label: 'Apply \'Custom Date\' filter' + } + ] + }, + { + iconClass: 'fa fa-refresh', + label: 'topMenu.refresh', + labelClass: 'unstyled-link', + action: 'refresh' + }, + { + iconClass: 'fa fa-history', + label: 'topMenu.history', + labelClass: 'unstyled-link', + action: 'openHistory', + subItems: [ + { + label: 'Apply \'Custom Date\' filter' + }, + { + label: 'Switch to graph mode' + }, + { + label: 'Apply \'Warnings\' filter' + }, + { + label: 'Apply \'Last week\' filter' + }, + { + label: 'Clear all filters' + }, + { + label: 'Apply \'HDFS\' filter' + }, + { + label: 'Apply \'Errors\' filter' + } + ] + }, + { + iconClass: 'fa fa-user unstyled-link', + hideCaret: true, + subItems: [ + { + label: 'Options' + }, + { + label: 'Logout' + } + ] + } + ]; + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/components/variables.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/variables.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/variables.less new file mode 100644 index 0000000..9a8ea09 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/variables.less @@ -0,0 +1,87 @@ +/** + * 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. + */ + +// Variables +@navbar-background-color: #323544; +@h1-vertical-margin: 20px; +@button-border-radius: 4px; +@input-border: 1px solid #CFD3D7; +@button-border-radius: 4px; +@input-group-addon-padding: 6px 12px; +@block-margin-top: 20px; +@link-color: #1491C1; +@link-hover-color: #23527C; +@grey-color: #666; +@default-line-height: 1.42857143; +@main-background-color: #ECECEC; + +@fatal-color: #830A0A; +@error-color: #E81D1D; +@warning-color: #FF8916; +@info-color: #2577B5; +@debug-color: #65E8FF; +@trace-color: #888; +@unknown-color: #BDBDBD; + +// Mixins +.flex-vertical-align { + display: flex; + align-items: center; +} + +.default-flex { + .flex-vertical-align; + justify-content: space-between; +} + +.common-hexagon(@side, @color) { + display: block; + position: absolute; + margin: (@side / 3.464101615) 0; + width: @side; + height: @side / 1.732050808; + background-color: @color; + + &:before, &:after { + display: block; + position: absolute; + width: 0; + border-left: (@side / 2) solid transparent; + border-right: (@side / 2) solid transparent; + content: ''; + } + + &:before { + bottom: 100%; + border-bottom: (@side / 3.464101615) solid @color; + } + + &:after { + top: 100%; + border-top: (@side / 3.464101615) solid @color; + } +} + +.clickable-item { + cursor: pointer; + color: @link-color; + + &:hover { + color: @link-hover-color; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.html deleted file mode 100644 index db4ee79..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.html +++ /dev/null @@ -1,20 +0,0 @@ -<!-- - 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. ---> - -<li *ngFor="let item of items"> - <a href="#" (click)="changeSelectedItem({value: item.value, label: item.label})">{{item.label | translate}}</a> -</li> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.less deleted file mode 100644 index d0f079a..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.less +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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. - */ - -:host { - max-height: 500px; // TODO get rid of magic number, base on actual design - overflow-y: auto; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.spec.ts deleted file mode 100644 index 445ee97..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.spec.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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 {Http} from '@angular/http'; -import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; -import {TranslateHttpLoader} from '@ngx-translate/http-loader'; - -import {DropdownListComponent} from './dropdown-list.component'; - -export function HttpLoaderFactory(http: Http) { - return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); -} - -describe('DropdownListComponent', () => { - let component: DropdownListComponent; - let fixture: ComponentFixture<DropdownListComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [DropdownListComponent], - imports: [TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [Http] - })] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DropdownListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create component', () => { - expect(component).toBeTruthy(); - }); - - describe('#changeSelectedItem()', () => { - - beforeEach(() => { - spyOn(component.selectedItemChange, 'emit').and.callFake(() => {}); - }); - - describe('not a filter list', () => { - it('event should not be emitted', () => { - component.isFilter = false; - component.changeSelectedItem({}); - expect(component.selectedItemChange.emit).not.toHaveBeenCalled(); - }); - }); - - describe('filter list', () => { - const options = { - label: 'l', - value: 'v' - }; - - beforeEach(() => { - component.isFilter = true; - component.changeSelectedItem(options); - }); - - it('event should be emitted', () => { - expect(component.selectedItemChange.emit).toHaveBeenCalled(); - }); - - it('event emitter should be called with correct arguments', () => { - expect(component.selectedItemChange.emit).toHaveBeenCalledWith(options); - }); - - }); - - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.ts deleted file mode 100644 index 808fcf8..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/dropdown-list/dropdown-list.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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, Input, Output, EventEmitter} from '@angular/core'; - -@Component({ - selector: 'ul.dropdown-menu', - templateUrl: './dropdown-list.component.html', - styleUrls: ['./dropdown-list.component.less'] -}) -export class DropdownListComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - - @Input() - items: any[]; - - @Input() - defaultAction: Function; - - @Input() - isFilter: boolean; - - @Output() - selectedItemChange: EventEmitter<any> = new EventEmitter(); - - changeSelectedItem(options: any): void { - if (this.isFilter) { - this.selectedItemChange.emit(options); - } - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.html deleted file mode 100644 index 1ac663e..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.html +++ /dev/null @@ -1,23 +0,0 @@ -<!-- - 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="filter-label" *ngIf="filterInstance.label">{{filterInstance.label | translate}}</div> -<button class="btn btn-link dropdown-toggle" data-toggle="dropdown"> - {{filterInstance.selectedLabel | translate}} <span class="caret"></span> -</button> -<ul class="dropdown-menu" [items]="filterInstance.options" [isFilter]="true" - (selectedItemChange)="setSelectedValue($event)"></ul> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.less deleted file mode 100644 index ec8e84b..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.less +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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'; - -:host { - position: relative; - .default-flex; - - .filter-label { - padding: @input-group-addon-padding; - } - - .btn { - text-transform: none; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.spec.ts deleted file mode 100644 index e0414f3..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * 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 {NO_ERRORS_SCHEMA} from '@angular/core'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {Http} from '@angular/http'; -import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; -import {TranslateHttpLoader} from '@ngx-translate/http-loader'; -import {FilteringService} from '@app/services/filtering.service'; - -import {FilterDropdownComponent} from './filter-dropdown.component'; - -export function HttpLoaderFactory(http: Http) { - return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); -} - -describe('FilterDropdownComponent', () => { - let component: FilterDropdownComponent; - let fixture: ComponentFixture<FilterDropdownComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [FilterDropdownComponent], - imports: [TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [Http] - })], - providers: [FilteringService], - schemas: [NO_ERRORS_SCHEMA] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FilterDropdownComponent); - component = fixture.componentInstance; - component.filterInstance = { - options: [ - { - value: 'v0', - label: 'l0' - }, - { - value: 'v1', - label: 'l1' - } - ] - }; - fixture.detectChanges(); - }); - - it('should create component', () => { - expect(component).toBeTruthy(); - }); - - describe('should take initial filter values from 1st item', () => { - it('selectedValue', () => { - expect(component.filterInstance.selectedValue).toEqual('v0'); - }); - - it('selectedLabel', () => { - expect(component.filterInstance.selectedLabel).toEqual('l0'); - }); - }); - - describe('#setSelectedValue()', () => { - beforeEach(() => { - component.setSelectedValue({ - value: 'v2', - label: 'l2' - }); - }); - - it('selectedValue', () => { - expect(component.filterInstance.selectedValue).toEqual('v2'); - }); - - it('selectedLabel', () => { - expect(component.filterInstance.selectedLabel).toEqual('l2'); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.ts deleted file mode 100644 index faaafcb..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-dropdown/filter-dropdown.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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, Input} from '@angular/core'; -import {FilteringService} from '@app/services/filtering.service'; - -@Component({ - selector: 'filter-dropdown', - templateUrl: './filter-dropdown.component.html', - styleUrls: ['./filter-dropdown.component.less'] -}) -export class FilterDropdownComponent implements OnInit { - - constructor(private filtering: FilteringService) { - } - - ngOnInit() { - this.filterInstance.selectedValue = this.filterInstance.options[0].value; - this.filterInstance.selectedLabel = this.filterInstance.options[0].label; - } - - @Input() - filterInstance: any; - - @Input() - options: any[]; - - setSelectedValue(options: any): void { - if (this.filterInstance.selectedValue !== options.value) { - this.filterInstance.selectedValue = options.value; - this.filterInstance.selectedLabel = options.label; - this.filtering.filteringSubject.next(null); - } - }; - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.html deleted file mode 100644 index ed3c4ba..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.html +++ /dev/null @@ -1,21 +0,0 @@ -<!-- - 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="input-group"> - <span class="input-group-addon">{{filterInstance.label | translate}}</span> - <input type="text" class="form-control" [(ngModel)]="filterInstance.selectedValue" (change)="onValueChange()"> <!-- TODO use ngModelChange with debounce --> -</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.less deleted file mode 100644 index 1395959..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.less +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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'; - -.input-group { - border: @input-border; - border-right-width: 0; -} - -.input-group-addon { - border: none; - background-color: transparent; - text-transform: uppercase; - - & + input { - border: none; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.spec.ts deleted file mode 100644 index e4f026c..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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 {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {Http} from '@angular/http'; -import {FormsModule} from '@angular/forms'; -import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; -import {TranslateHttpLoader} from '@ngx-translate/http-loader'; -import {FilteringService} from '@app/services/filtering.service'; - -import {FilterTextFieldComponent} from './filter-text-field.component'; - -export function HttpLoaderFactory(http: Http) { - return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); -} - -describe('FilterTextFieldComponent', () => { - let component: FilterTextFieldComponent; - let fixture: ComponentFixture<FilterTextFieldComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [FilterTextFieldComponent], - imports: [ - FormsModule, - TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [Http] - }) - ], - providers: [FilteringService], - schemas: [CUSTOM_ELEMENTS_SCHEMA] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FilterTextFieldComponent); - component = fixture.componentInstance; - component.filterInstance = {}; - fixture.detectChanges(); - }); - - it('should create component', () => { - expect(component).toBeTruthy(); - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.ts deleted file mode 100644 index 3f23ffd..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filter-text-field/filter-text-field.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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, Input} from '@angular/core'; -import {FilteringService} from '@app/services/filtering.service'; - -@Component({ - selector: 'filter-text-field', - templateUrl: './filter-text-field.component.html', - styleUrls: ['./filter-text-field.component.less'] -}) -export class FilterTextFieldComponent implements OnInit { - - constructor(private filtering: FilteringService) { - } - - ngOnInit() { - } - - @Input() - filterInstance: any; - - onValueChange() { - this.filtering.filteringSubject.next(null); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.html deleted file mode 100644 index 6387c22..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- - 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-inline filter-input-container col-md-8"> - <filter-dropdown [filterInstance]="filtering.filters.clusters"></filter-dropdown> - <filter-text-field [filterInstance]="filtering.filters.text"></filter-text-field> - <filter-dropdown [filterInstance]="filtering.filters.timeRange"></filter-dropdown> - <filter-dropdown [filterInstance]="filtering.filters.timeZone"></filter-dropdown> - <!--button class="btn btn-success" type="button"> - <span class="fa fa-search"></span> - </button--> -</div> -<div class="default-flex col-md-4"> - <a href="#"> - <span class="fa fa-search-minus"></span> {{'filter.excluded' | translate}} - </a> - <menu-button [label]="filtering.filters.components.label" [iconClass]="filtering.filters.components.iconClass" - [subItems]="filtering.filters.components.options" [isFilter]="true" - [filterInstance]="filtering.filters.components"></menu-button> - <menu-button [label]="filtering.filters.levels.label" [iconClass]="filtering.filters.levels.iconClass" - [subItems]="filtering.filters.levels.options" [isFilter]="true" - [filterInstance]="filtering.filters.levels"></menu-button> - <menu-button label="filter.capture" iconClass="fa fa-caret-right"></menu-button> -</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.less deleted file mode 100644 index 46a157c..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.less +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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'; - -.filter-input-container { - .flex-vertical-align; - justify-content: flex-start; - - .btn-success { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - - filter-dropdown { - border: @input-border; - - &:not(:last-child) { - border-right-width: 0; - } - - &:first-child { - border-radius: @button-border-radius 0 0 @button-border-radius; - } - - &:last-child { - border-radius: 0 @button-border-radius @button-border-radius 0; - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.spec.ts deleted file mode 100644 index 934f37a..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.spec.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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 {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {Http} from '@angular/http'; -import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; -import {TranslateHttpLoader} from '@ngx-translate/http-loader'; -import {FilteringService} from '@app/services/filtering.service'; - -import {FiltersPanelComponent} from './filters-panel.component'; - -export function HttpLoaderFactory(http: Http) { - return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); -} - -describe('FiltersPanelComponent', () => { - let component: FiltersPanelComponent; - let fixture: ComponentFixture<FiltersPanelComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [FiltersPanelComponent], - imports: [TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [Http] - })], - providers: [FilteringService], - schemas: [CUSTOM_ELEMENTS_SCHEMA] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FiltersPanelComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create component', () => { - expect(component).toBeTruthy(); - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.ts deleted file mode 100644 index 8c986f4..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/filters-panel/filters-panel.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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} from '@angular/core'; -import {FilteringService} from '@app/services/filtering.service'; - -@Component({ - selector: 'filters-panel', - templateUrl: './filters-panel.component.html', - styleUrls: ['./filters-panel.component.less'] -}) -export class FiltersPanelComponent implements OnInit { - - constructor(private filtering: FilteringService) { - } - - ngOnInit() { - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html deleted file mode 100644 index 37a96e9..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html +++ /dev/null @@ -1,33 +0,0 @@ -<!-- - 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="login-form well col-md-4 col-md-offset-4 col-sm-offset-4"> - <div class="alert alert-danger" *ngIf="isLoginAlertDisplayed" [innerHTML]="'authorization.error' | translate"></div> - <form #loginForm="ngForm" (ngSubmit)="login()"> - <div class="form-group"> - <label for="username">{{'authorization.name' | translate}}</label> - <input class="form-control" type="text" id="username" name="username" required [(ngModel)]="username"> - </div> - <div class="form-group"> - <label for="password">{{'authorization.password' | translate}}</label> - <input class="form-control" type="password" id="password" name="password" required [(ngModel)]="password"> - </div> - <button class="btn btn-success" [disabled]="!loginForm.form.valid || isRequestInProgress"> - {{'authorization.signIn' | translate}} - </button> - </form> -</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.less ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.less b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.less deleted file mode 100644 index f760ee8..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.less +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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'; - -.login-form { - margin-top: @block-margin-top; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts deleted file mode 100644 index 0498ee4..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * 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 {FormsModule} from '@angular/forms'; -import {HttpModule, Http} from '@angular/http'; -import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; -import {TranslateHttpLoader} from '@ngx-translate/http-loader'; -import {HttpClientService} from '@app/services/http-client.service'; - -import {LoginFormComponent} from './login-form.component'; - -export function HttpLoaderFactory(http: Http) { - return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); -} - -describe('LoginFormComponent', () => { - let component: LoginFormComponent; - let fixture: ComponentFixture<LoginFormComponent>; - - let authMock = { - isError: false - }; - const httpClient = { - isAuthorized: true, - post: () => { - return { - finally: (callback: () => void) => { - callback(); - return { - subscribe: (success: () => void, error: () => void) => { - authMock.isError ? error() : success(); - } - } - } - } - } - }; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [LoginFormComponent], - imports: [ - HttpModule, - FormsModule, - TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [Http] - }) - ], - providers: [ - { - provide: HttpClientService, - useValue: httpClient - } - ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(LoginFormComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create component', () => { - expect(component).toBeTruthy(); - }); - - describe('#login()', () => { - const cases = [ - { - isError: true, - isLoginAlertDisplayed: true, - isAuthorized: false, - title: 'login failure' - }, - { - isError: false, - isLoginAlertDisplayed: false, - isAuthorized: true, - title: 'login success' - } - ]; - - cases.forEach(test => { - describe(test.title, () => { - beforeEach(() => { - authMock.isError = test.isError; - component.login(); - }); - - it('isLoginAlertDisplayed', () => { - expect(component.isLoginAlertDisplayed).toEqual(test.isLoginAlertDisplayed); - }); - - it('isRequestInProgress', () => { - expect(component.isRequestInProgress).toEqual(false); - }) - }); - }); - - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ed660940/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.ts deleted file mode 100644 index 2a93775..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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} from '@angular/core'; -import 'rxjs/add/operator/finally'; -import {HttpClientService} from '@app/services/http-client.service'; - -@Component({ - selector: 'login-form', - templateUrl: './login-form.component.html', - styleUrls: ['./login-form.component.less'] -}) -export class LoginFormComponent implements OnInit { - - constructor(private httpClient: HttpClientService) { - } - - ngOnInit() { - } - - username: string; - - password: string; - - isLoginAlertDisplayed: boolean; - - isRequestInProgress: boolean; - - login() { - this.isRequestInProgress = true; - this.httpClient.post('login', { - username: this.username, - password: this.password - }).finally(() => { - this.isRequestInProgress = false; - }).subscribe(() => { - this.isLoginAlertDisplayed = false; - this.httpClient.isAuthorized = true; - }, () => { - this.isLoginAlertDisplayed = true; - this.httpClient.isAuthorized = false; - }); - } - -}
