我试图解析tomcat日志并将输出传递给弹性搜索.或多或少它运作良好.当我看到弹性搜索索引数据时,它包含大量具有标签字段的匹配数据_grokparsefailure.这导致了大量重复的匹配数据.为了避免这种情况,我试图在标签包含时删除事件_grokparsefailure.此配置写在grok filter下面的logstash.conf文件中.仍然输出到弹性搜索包含索引的doc包含标签_grokparsefailure.如果grok失败,我不希望该匹配转到弹性搜索,因为它在弹性搜索中导致重复数据.
logstash.conf 文件是:
input {
file {
path => "/opt/elasticSearch/logstash-1.4.2/input.log"
codec => multiline {
pattern => "^\["
negate => true
what => previous
}
start_position => "end"
}
}
filter {
grok {
match => [
"message", "^\[%{GREEDYDATA}\] %{GREEDYDATA} Searching hotels for country %{GREEDYDATA:country}, city %{GREEDYDATA:city}, checkin %{GREEDYDATA:checkin}, checkout %{GREEDYDATA:checkout}, roomstay %{GREEDYDATA:roomstay}, No. of hotels returned is %{NUMBER:hotelcount} ."
]
}
if "_grokparsefailure" in [tags]{
drop { }
}
}
output {
file …Run Code Online (Sandbox Code Playgroud) 我试图在另一个文件中定义枚举,以便在其他地方使用它.例如在html视图上.这可能吗?
enums.model.ts
export enum MyEnum{
First = 1,
Second= 2
}
Run Code Online (Sandbox Code Playgroud)
我-summary.component.ts
import {MyEnum} from "./app/models";
@Component({
selector: "my-summary",
templateUrl: "./my-summary.component.html"]
})
export class MySummaryComponent{ }
Run Code Online (Sandbox Code Playgroud)
我-summary.component.html
<div>
{{MyEnum.First}}
</div>
Run Code Online (Sandbox Code Playgroud)
它不起作用.模块'"path/app/models/index"' has no exported member 'MyEnum'.
我正在尝试通过典型的Angular方式通过ngModel绑定到输入字段类型文件:
<input type="file" id="fileUpload" [(ngModel)]="file">
Run Code Online (Sandbox Code Playgroud)
和
files:any
Run Code Online (Sandbox Code Playgroud)
我的问题是选择文件后,变量的值files仍然是undefined
此处的stackblitz示例:https ://stackblitz.com/edit/angular-6mbdww
嗨,我正在为我的 angular 代码编写单元测试用例。我正在尝试更新 gridview 中的文本框。下面是我的 gridview 代码。
<input *ngIf="editing[rowIndex + '-scopevalue']" class="inline-editor" autofocus (blur)="updateValue($event, 'scopevalue', value, rowIndex)" type="text" [value]="value" />
Run Code Online (Sandbox Code Playgroud)
下面的函数执行更新。
updateValue(event, cell, cellValue, rowIndex) {
this.editing[rowIndex + '-' + cell] = false;
this.rows[rowIndex][cell] = event.target.value;
this.rowsCache[rowIndex][cell] = event.target.value;
this.scopeEdit = this.rows[rowIndex];
this.updateScope();
}
Run Code Online (Sandbox Code Playgroud)
在单元测试用例下面,我正在编写检查上面的代码。
it('update scope name value', () => {
var row = component.rows[0];
let cell = 'scopevalue';
let cellValue = row.scopevalue;
let rowIndex = 0;
component.updateValue('/bmw', cell, cellValue, rowIndex);
});
Run Code Online (Sandbox Code Playgroud)
在上面的方法中,第一个参数应该是事件。有人可以帮助我如何创建活动吗?任何帮助,将不胜感激。谢谢
我的表使用芯片输入“类型”下的值。但是当其中没有值时。里面还有一块空芯片。有谁知道我该如何解决这个问题?
[![html
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef mat-sort-header="type">Type</th>
<td mat-cell *matCellDef="let truck" class="pr-24">
<mat-chip-list>
<span *ngFor="let truck of truck.type.split(',')">
<mat-chip>{{truck}}</mat-chip>
</span>
</mat-chip-list>
</td>
</ng-container>][1]][1]
Run Code Online (Sandbox Code Playgroud)
component.ts
import { Component, OnInit, ViewChild, ElementRef, Input, OnChanges } from '@angular/core';
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatChipsModule, MatChipInputEvent } from '@angular/material';
import { SelectionModel } from '@angular/cdk/collections';
import { Truck } from '../truck';
import { MapsAPILoader } from '@agm/core';
import { TruckDetailComponent } from '../truck-detail/truck-detail.component';
import { PlannerProject } from 'app/services/planner-projects/planner-project';
import { TrucksService …Run Code Online (Sandbox Code Playgroud) 如何在 Angular 服务中模拟 HTTP 错误响应?我经常需要处理不同的 HTTP 错误代码,有时我需要实现解决方案,但后端还没有准备好。如何从后端模拟错误?示例代码
public getData(): Observable<Response> {
return this.httpClient.get<Response>(`${this.endpoint}`);
}
Run Code Online (Sandbox Code Playgroud) 我想使用带有业力的 ChromeHeadless。我的配置是:
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function( config ) {
config.set({
basePath : '',
frameworks : ['jasmine', '@angular/cli'],
plugins : [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('@angular/cli/plugins/karma')
],
angularCli : {
environment: 'dev'
},
reporters : ['progress'],
autoWatch : false,
browsers: [
'ChromeHeadless',
],
singleRun : true
});
};
Run Code Online (Sandbox Code Playgroud)
当我运行 ng test 时,我仍然需要打开浏览器。这是我从业力控制台得到的信息:
Karma v2.0.0 服务器启动于http://0.0.0.0:9876/
我有有效的 Angular 测试设置。当我测试内部有嵌套组件的组件时,这会给我带来错误,这就是为什么我需要模拟这些组件。
Angular Test 文档向我们展示了模拟组件的其他方法 - 使用 NO_ERRORS_SCHEMA。当我尝试使用它时(无论是在无头模式还是使用 Chrome 的正常模式下),我的测试都会停止工作。信息看起来像这样
24 03 2019 18:48:45.750:INFO [launcher]: Starting browser Chrome
24 03 2019 18:48:49.599:WARN [karma]: No captured browser, open
http://localhost:9876/
24 03 2019 18:48:49.644:INFO [HeadlessChrome 73.0.3683 (Ubuntu
0.0.0)]: Connected on socket cQvumAWhGFfzQWh0AAAA with id 98993378
Run Code Online (Sandbox Code Playgroud)
在浏览器模式下,我只能看到信息:
Karma v4.0.1 - connected
Chromium 73.0.3683 (Ubuntu 0.0.0) is idle
Run Code Online (Sandbox Code Playgroud)
当我在没有 [NO_ERRORS_SCHEMA] 的情况下运行测试时,我可以看到我的测试结果,这就是为什么错误与此架构设置相关。
我的组件规格设置:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ContactComponent } from './contact.component';
import { NO_ERRORS_SCHEMA } from '@angular/compiler/src/core';
describe('ContactComponent', …Run Code Online (Sandbox Code Playgroud) 我尝试导入FormsModule和NgForm模块,以及将FormsModule添加到imports数组。
下面是我的代码:
//our root app component
import { Component, NgModule, VERSION } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule, NgForm} from '@angular/forms';
@Component({
selector: 'my-app',
template: `
<form #searchForm="ngForm">
<input type="text" required [(ngModel)]="model.search" ngControl="search" #inputSearch="ngForm">
<p class="error" [hidden]="inputSearch.valid"> This input is required</p>
</form>
`,
styles: [`
.error {
color: red;
font-size: 11px;
}
`]
})
export class App {
public model = {
search: ""
}
constructor() {
}
}
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [App],
bootstrap: …Run Code Online (Sandbox Code Playgroud) 我有一个子组件,在其父组件中使用了两次,它使用 ngOnChaages 来更新值;
这一切都工作得很好,但现在我正在尝试根据通过@Input变量传递给它的信息来操作子模板。
我发现的是;当父组件首次加载时,模板变量在函数调用中未定义
这是有道理的,因为该函数是在onChanges方法内调用的,并且没有给模板足够的时间来加载。
我需要重构我的代码,但是如何重构呢?
目前,如果我使用它就可以了setTimeout
所以简单来说:
@ViewChild('myContainer', {read: ElementRef}) myContainer: ElementRef;
@Input() myUpdatingVar
ngOnChanges(): void {
if (this.myUpdatingVar === someValue) {
this.myFunc(this.someValue1);
} else {
this.myFunc(this.someValue2);
}
}
myFunc(param){
do stuff....
this.updateDom(anotherParam);
}
updateDom(param) {
// If I use setTimeout this works
this.myContainer.nativeElement.querySelector(`#someId`); // Undefined
}
Run Code Online (Sandbox Code Playgroud) angular ×9
javascript ×4
typescript ×4
angular-test ×2
karma-runner ×2
http-error ×1
logstash ×1
mocking ×1