http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-settings.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-settings.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-settings.model.ts deleted file mode 100644 index 11821a3..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-settings.model.ts +++ /dev/null @@ -1,27 +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 * as moment from 'moment-timezone'; - -export interface AppSettings { - timeZone: string; -} - -export const defaultSettings: AppSettings = { - timeZone: moment.tz.guess() -}
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-state.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-state.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-state.model.ts deleted file mode 100644 index 2995002..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/app-state.model.ts +++ /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. - */ - -export interface AppState { - isAuthorized: boolean; - isInitialLoading: boolean; - isLoginInProgress: boolean; - isAuditLogsSet: boolean; - isServiceLogsSet: boolean; -} - -export const initialState: AppState = { - isAuthorized: false, - isInitialLoading: false, - isLoginInProgress: false, - isAuditLogsSet: false, - isServiceLogsSet: false -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log-field.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log-field.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log-field.model.ts deleted file mode 100644 index 96372a1..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log-field.model.ts +++ /dev/null @@ -1,225 +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 {LogField} from '@app/models/log-field.model'; - -const columnsNamesMap = { - access: { - displayName: 'logs.accessType', - isDisplayed: true - }, - action: { - displayName: 'logs.action' - }, - agent: { - displayName: 'logs.agent' - }, - agentHost: { - displayName: 'logs.agentHost' - }, - authType: { - displayName: 'logs.authType' - }, - bundle_id: { - displayName: 'logs.bundleId' - }, - case_id: { - displayName: 'logs.caseId' - }, - cliIP: { - displayName: 'logs.clientIp', - isDisplayed: true - }, - cliType: { - displayName: 'logs.clientType' - }, - cluster: { - displayName: 'logs.cluster' - }, - dst: { - displayName: 'logs.dst' - }, - evtTime: { - displayName: 'logs.eventTime', - isDisplayed: true - }, - file: { - displayName: 'logs.file' - }, - host: { - displayName: 'logs.host' - }, - id: { - displayName: 'logs.id' - }, - ip: { - displayName: 'logs.ip' - }, - level: { - displayName: 'logs.level' - }, - log_message: { - displayName: 'logs.message' - }, - logType: { - displayName: 'logs.logType' - }, - logfile_line_number: { - displayName: 'logs.logfileLineNumber' - }, - logger_name: { - displayName: 'logs.loggerName' - }, - logtime: { - displayName: 'logs.logTime' - }, - path: { - displayName: 'logs.path' - }, - perm: { - displayName: 'logs.perm' - }, - policy: { - displayName: 'logs.policy' - }, - proxyUsers: { - displayName: 'logs.proxyUsers' - }, - reason: { - displayName: 'logs.reason' - }, - repo: { - displayName: 'logs.repo', - isDisplayed: true - }, - repoType: { - displayName: 'logs.repoType' - }, - req_caller_id: { - displayName: 'logs.reqCallerId' - }, - reqContext: { - displayName: 'logs.reqContext' - }, - reqData: { - displayName: 'logs.reqData' - }, - req_self_id: { - displayName: 'logs.reqSelfId' - }, - resType: { - displayName: 'logs.resType' - }, - resource: { - displayName: 'logs.resource', - isDisplayed: true - }, - result: { - displayName: 'logs.result', - isDisplayed: true - }, - sess: { - displayName: 'logs.session' - }, - text: { - displayName: 'logs.text' - }, - type: { - displayName: 'logs.type' - }, - ugi: { - displayName: 'logs.ugi' - }, - reqUser: { - displayName: 'logs.user', - isDisplayed: true - }, - ws_base_url: { - displayName: 'logs.baseUrl' - }, - ws_command: { - displayName: 'logs.command' - }, - ws_component: { - displayName: 'logs.component' - }, - ws_details: { - displayName: 'logs.details' - }, - ws_display_name: { - displayName: 'logs.displayName' - }, - ws_os: { - displayName: 'logs.os' - }, - ws_repo_id: { - displayName: 'logs.repoId' - }, - ws_repo_version: { - displayName: 'logs.repoVersion' - }, - ws_repositories: { - displayName: 'logs.repositories' - }, - ws_request_id: { - displayName: 'logs.requestId' - }, - ws_result_status: { - displayName: 'logs.resultStatus' - }, - ws_roles: { - displayName: 'logs.roles' - }, - ws_stack_version: { - displayName: 'logs.stackVersion' - }, - ws_stack: { - displayName: 'logs.stack' - }, - ws_status: { - displayName: 'logs.status' - }, - ws_task_id: { - displayName: 'logs.taskId' - }, - ws_version_note: { - displayName: 'logs.versionNote' - }, - ws_version_number: { - displayName: 'logs.versionNumber' - }, - tags: { - isAvailable: false - }, - tags_str: { - isAvailable: false - }, - seq_num: { - isAvailable: false - } -}; - -export class AuditLogField extends LogField { - constructor(name: string) { - super(name); - const preset = columnsNamesMap[this.name]; - if (preset) { - Object.assign(this, preset); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log.model.ts deleted file mode 100644 index 2b34cd6..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/audit-log.model.ts +++ /dev/null @@ -1,46 +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 {Log} from '@app/models/log.model'; - -export interface AuditLog extends Log { - policy?: string; - reason?: string; - result: number; - text?: string; - tags?: string[]; - resource?: string; - sess?: string; - access?: string; - logType: string; - tags_str?: string; - resType?: string; - reqUser: string; - reqData?: string; - repoType: number; - repo: string; - proxyUsers?: string[]; - evtTime: string; - enforcer: string; - reqContext?: string; - cliType?: string; - cliIP?: string; - agent?: string; - agentHost?: string; - action?: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/bar-graph.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/bar-graph.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/bar-graph.model.ts deleted file mode 100644 index a197bf5..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/bar-graph.model.ts +++ /dev/null @@ -1,24 +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 {CommonEntry} from '@app/models/common-entry.model'; - -export interface BarGraph { - dataCount: CommonEntry[], - name: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/common-entry.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/common-entry.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/common-entry.model.ts deleted file mode 100644 index dad82ab..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/common-entry.model.ts +++ /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. - */ - -export interface CommonEntry { - name: string; - value: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/count.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/count.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/count.model.ts deleted file mode 100644 index 02fc41c..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/count.model.ts +++ /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. - */ - -export interface Count { - name: string; - count: number; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/filter.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/filter.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/filter.model.ts deleted file mode 100644 index c7ff662..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/filter.model.ts +++ /dev/null @@ -1,25 +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. - */ - -export interface Filter { - label: string; - hosts: string[]; - defaultLevels: string[]; - overrideLevels: string[]; - expiryTime: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/graph.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/graph.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/graph.model.ts deleted file mode 100644 index 04966b2..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/graph.model.ts +++ /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. - */ - -export interface Graph { - name: string; - count: string; - dataList?: Graph[] -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log-field.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log-field.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log-field.model.ts deleted file mode 100644 index 0e738ab..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log-field.model.ts +++ /dev/null @@ -1,27 +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. - */ - -export class LogField { - constructor(name: string) { - this.name = name; - } - name: string; - displayName: string = this.name; - isDisplayed: boolean = false; - isAvailable: boolean = true; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log.model.ts deleted file mode 100644 index 188bbd2..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/log.model.ts +++ /dev/null @@ -1,37 +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. - */ - -export interface Log { - type: string; - _version_: number; - id: string; - file?: string; - seq_num: number; - bundle_id?: string; - case_id?: string; - log_message: string; - logfile_line_number: number; - message_md5: string; - cluster: string; - event_count: number; - event_md5: string; - event_dur_ms: number; - _ttl_: string; - _expire_at_: number; - _router_field_?: number; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/node.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/node.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/node.model.ts deleted file mode 100644 index 2891d142..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/node.model.ts +++ /dev/null @@ -1,29 +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 {CommonEntry} from '@app/models/common-entry.model'; - -export interface Node { - name: string; - type?: string; - value: string; - isParent: boolean; - isRoot: boolean; - childs?: Node[]; - logLevelCount: CommonEntry[]; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log-field.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log-field.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log-field.model.ts deleted file mode 100644 index 081eecf..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log-field.model.ts +++ /dev/null @@ -1,107 +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 {LogField} from '@app/models/log-field.model'; - -const columnsNamesMap = { - log_message: { - displayName: 'logs.message', - isDisplayed: true - }, - bundle_id: { - displayName: 'logs.bundleId' - }, - case_id: { - displayName: 'logs.caseId' - }, - cluster: { - displayName: 'logs.cluster' - }, - event_count: { - displayName: 'logs.eventCount' - }, - file: { - displayName: 'logs.file' - }, - host: { - displayName: 'logs.host' - }, - id: { - displayName: 'logs.id' - }, - ip: { - displayName: 'logs.ip' - }, - level: { - displayName: 'logs.level', - isDisplayed: true - }, - line_number: { - displayName: 'logs.lineNumber' - }, - logtype: { - displayName: 'logs.logType' - }, - logfile_line_number: { - displayName: 'logs.logfileLineNumber' - }, - logger_name: { - displayName: 'logs.loggerName' - }, - logtime: { - isDisplayed: true - }, - method: { - displayName: 'logs.method' - }, - path: { - displayName: 'logs.path' - }, - rowtype: { - displayName: 'logs.rowType' - }, - thread_name: { - displayName: 'logs.threadName' - }, - type: { - displayName: 'logs.type', - isDisplayed: true - }, - tags: { - isAvailable: false - }, - text: { - isAvailable: false - }, - message: { - isAvailable: false - }, - seq_num: { - isAvailable: false - } -}; - -export class ServiceLogField extends LogField { - constructor(name: string) { - super(name); - const preset = columnsNamesMap[this.name]; - if (preset) { - Object.assign(this, preset); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log.model.ts deleted file mode 100644 index ee27343..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/service-log.model.ts +++ /dev/null @@ -1,27 +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 {Log} from '@app/models/log.model'; - -export interface ServiceLog extends Log { - path: string; - host: string; - level: string; - logtime: number; - ip: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/solr-collection-state.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/solr-collection-state.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/solr-collection-state.model.ts deleted file mode 100644 index 0824dda..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/solr-collection-state.model.ts +++ /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. - */ - -export interface SolrCollectionState { - znodeReady: boolean; - configurationUploaded: boolean; - solrCollectionReady: boolean; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts deleted file mode 100644 index 31d52b3..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts +++ /dev/null @@ -1,169 +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 {Observable} from 'rxjs/Observable'; -import {Store, Action} from '@ngrx/store'; -import {AppSettings} from '@app/models/app-settings.model'; -import {AppState} from '@app/models/app-state.model'; -import {AuditLog} from '@app/models/audit-log.model'; -import {ServiceLog} from '@app/models/service-log.model'; -import {BarGraph} from '@app/models/bar-graph.model'; -import {Graph} from '@app/models/graph.model'; -import {Node} from '@app/models/node.model'; -import {UserConfig} from '@app/models/user-config.model'; -import {Filter} from '@app/models/filter.model'; -import {AuditLogField} from '@app/models/audit-log-field.model'; -import {ServiceLogField} from '@app/models/service-log-field.model'; - -export const storeActions = { - 'ARRAY.ADD': 'ADD', - 'ARRAY.DELETE.PRIMITIVE': 'DELETE_PRIMITIVE', - 'ARRAY.DELETE.OBJECT': 'DELETE_OBJECT', - 'ARRAY.CLEAR': 'CLEAR', - 'ARRAY.MAP': 'MAP', - - 'OBJECT.SET': 'SET' -}; - -export interface AppStore { - appSettings: AppSettings; - appState: AppState; - auditLogs: AuditLog[]; - serviceLogs: ServiceLog[]; - serviceLogsHistogramData: BarGraph[]; - graphs: Graph[]; - hosts: Node[]; - userConfigs: UserConfig[]; - filters: Filter[]; - clusters: string[]; - components: string[]; - serviceLogsFields: ServiceLogField[]; - auditLogsFields: AuditLogField[]; -} - -export class ModelService { - - constructor(modelName: string, store: Store<AppStore>) { - this.modelName = modelName; - this.store = store; - } - - protected modelName: string; - - protected store: Store<AppStore>; - - getAll(): Observable<any> { - return this.store.select(this.modelName); - } - -} - -export class CollectionModelService extends ModelService { - - addInstance(instance: any): void { - this.addInstances([instance]); - } - - addInstances(instances: any[]): void { - this.store.dispatch({ - type: `${storeActions['ARRAY.ADD']}_${this.modelName}`, - payload: instances - }); - } - - deleteObjectInstance(instance: any): void { - this.store.dispatch({ - type: `${storeActions['ARRAY.DELETE.OBJECT']}_${this.modelName}`, - payload: instance - }); - } - - deletePrimitiveInstance(instance: any): void { - this.store.dispatch({ - type: `${storeActions['ARRAY.DELETE.PRIMITIVE']}_${this.modelName}`, - payload: instance - }); - } - - clear(): void { - this.store.dispatch({ - type: `${storeActions['ARRAY.CLEAR']}_${this.modelName}` - }); - } - - mapCollection(modifier: (item: any) => {}): void { - this.store.dispatch({ - type: `${storeActions['ARRAY.MAP']}_${this.modelName}`, - payload: { - modifier: modifier - } - }); - } - -} - -export class ObjectModelService extends ModelService { - - getParameter(key: string): Observable<any> { - return this.store.select(this.modelName, key); - } - - setParameter(key: string, value: any): void { - let payload = {}; - payload[key] = value; - this.setParameters(payload); - } - - setParameters(params: any): void { - this.store.dispatch({ - type: `${storeActions['OBJECT.SET']}_${this.modelName}`, - payload: params - }); - } - -} - -export function getCollectionReducer(modelName: string, defaultState: any = []): any { - return (state: any = defaultState, action: Action) => { - switch (action.type) { - case `${storeActions['ARRAY.ADD']}_${modelName}`: - return [...state, ...action.payload]; - case `${storeActions['ARRAY.DELETE.OBJECT']}_${modelName}`: - return state.filter(instance => instance.id !== action.payload.id); - case `${storeActions['ARRAY.DELETE.PRIMITIVE']}_${modelName}`: - return state.filter(item => item !== action.payload); - case `${storeActions['ARRAY.CLEAR']}_${modelName}`: - return []; - case `${storeActions['ARRAY.MAP']}_${modelName}`: - return state.map(action.payload.modifier); - default: - return state; - } - }; -} - -export function getObjectReducer(modelName: string, defaultState: any = {}) { - return (state: any = defaultState, action: Action): any => { - switch (action.type) { - case `${storeActions['OBJECT.SET']}_${modelName}`: - return Object.assign({}, state, action.payload); - default: - return state; - } - }; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/models/user-config.model.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/user-config.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/user-config.model.ts deleted file mode 100644 index f52761c..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/user-config.model.ts +++ /dev/null @@ -1,26 +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. - */ - -export interface UserConfig { - id: string; - userName: string; - filtername: string; - values: string; - shareNameList: string[]; - rowType: string; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.spec.ts deleted file mode 100644 index 0d0c24c..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.spec.ts +++ /dev/null @@ -1,26 +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 {TimeZoneAbbrPipe} from './timezone-abbr.pipe'; - -describe('TimeZoneAbbrPipe', () => { - it('create an instance', () => { - const pipe = new TimeZoneAbbrPipe(); - expect(pipe).toBeTruthy(); - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.ts deleted file mode 100644 index f4aab0b..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/pipes/timezone-abbr.pipe.ts +++ /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 {Pipe, PipeTransform} from '@angular/core'; -import * as moment from 'moment-timezone'; - -@Pipe({ - name: 'timeZoneAbbr' -}) -export class TimeZoneAbbrPipe implements PipeTransform { - - transform(value: string): string { - return moment.tz.zone(value).abbr(moment().valueOf()); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.spec.ts deleted file mode 100644 index ff0ee37..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.spec.ts +++ /dev/null @@ -1,43 +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 {TestBed, inject} from '@angular/core/testing'; -import {StoreModule} from '@ngrx/store'; -import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; - -import {ComponentActionsService} from './component-actions.service'; - -describe('ComponentActionsService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - StoreModule.provideStore({ - appSettings - }) - ], - providers: [ - AppSettingsService, - ComponentActionsService - ] - }); - }); - - it('should create service', inject([ComponentActionsService], (service: ComponentActionsService) => { - expect(service).toBeTruthy(); - })); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.ts deleted file mode 100644 index a8235fa..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-actions.service.ts +++ /dev/null @@ -1,53 +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 {Injectable} from '@angular/core'; -import {AppSettingsService} from '@app/services/storage/app-settings.service'; -import {CollectionModelService} from '@app/models/store.model'; - -@Injectable() -export class ComponentActionsService { - - constructor(private appSettings: AppSettingsService) { - } - - //TODO implement actions - - undo() { - } - - redo() { - } - - refresh() { - } - - openHistory() { - } - - setTimeZone(timeZone: string): void { - this.appSettings.setParameter('timeZone', timeZone); - } - - updateSelectedColumns(columnNames: string[], model: CollectionModelService): void { - model.mapCollection(item => Object.assign({}, item, { - isDisplayed: columnNames.indexOf(item.name) > -1 - })); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.spec.ts deleted file mode 100644 index b6ec8d7..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.spec.ts +++ /dev/null @@ -1,84 +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 {TestBed, inject} from '@angular/core/testing'; -import {StoreModule} from '@ngrx/store'; -import {HostsService, hosts} from '@app/services/storage/hosts.service'; -import {AuditLogsService, auditLogs} from '@app/services/storage/audit-logs.service'; -import {ServiceLogsService, serviceLogs} from '@app/services/storage/service-logs.service'; -import {AuditLogsFieldsService, auditLogsFields} from '@app/services/storage/audit-logs-fields.service'; -import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage/service-logs-fields.service'; -import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; -import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; -import {ClustersService, clusters} from '@app/services/storage/clusters.service'; -import {ComponentsService, components} from '@app/services/storage/components.service'; -import {LogsContainerService} from '@app/services/logs-container.service'; -import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; - -import {ComponentGeneratorService} from './component-generator.service'; - -describe('ComponentGeneratorService', () => { - beforeEach(() => { - const httpClient = { - get: () => { - return { - subscribe: () => { - } - } - } - }; - TestBed.configureTestingModule({ - imports: [ - StoreModule.provideStore({ - hosts, - auditLogs, - serviceLogs, - auditLogsFields, - serviceLogsFields, - serviceLogsHistogramData, - appSettings, - clusters, - components - }) - ], - providers: [ - ComponentGeneratorService, - LogsContainerService, - { - provide: HttpClientService, - useValue: httpClient - }, - FilteringService, - HostsService, - AuditLogsService, - ServiceLogsService, - AuditLogsFieldsService, - ServiceLogsFieldsService, - ServiceLogsHistogramDataService, - AppSettingsService, - ClustersService, - ComponentsService - ] - }); - }); - - it('should create service', inject([ComponentGeneratorService], (service: ComponentGeneratorService) => { - expect(service).toBeTruthy(); - })); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.ts deleted file mode 100644 index c49f40f..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/component-generator.service.ts +++ /dev/null @@ -1,57 +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 {Injectable, ComponentFactoryResolver, ViewContainerRef} from '@angular/core'; -import {HostsService} from '@app/services/storage/hosts.service'; -import {LogsContainerService} from '@app/services/logs-container.service'; -import {NodeBarComponent} from '@app/components/node-bar/node-bar.component'; - -@Injectable() -export class ComponentGeneratorService { - - constructor(private resolver: ComponentFactoryResolver, private hostsStorage: HostsService, private logsContainer: LogsContainerService) { - } - - private createComponent(type: any, container: ViewContainerRef, properties?: any): void { - const factory = this.resolver.resolveComponentFactory(type); - container.clear(); - let component = container.createComponent(factory); - Object.assign(component.instance, properties); - } - - getDataForHostsNodeBar(hostName: string, container: ViewContainerRef): void { - let data; - this.hostsStorage.getAll().subscribe(hosts => { - if (container && hosts && hosts.length) { - const selectedHost = hosts.find(host => host.name === hostName); - data = selectedHost.logLevelCount.map(event => { - return { - color: this.logsContainer.colors[event.name], - value: event.value - }; - }); - if (data.length) { - this.createComponent(NodeBarComponent, container, { - data - }); - } - } - }); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts deleted file mode 100644 index e3f731e..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts +++ /dev/null @@ -1,67 +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 {TestBed, inject} from '@angular/core/testing'; -import {StoreModule} from '@ngrx/store'; -import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; -import {ClustersService, clusters} from '@app/services/storage/clusters.service'; -import {ComponentsService, components} from '@app/services/storage/components.service'; -import {HostsService, hosts} from '@app/services/storage/hosts.service'; -import {UtilsService} from '@app/services/utils.service'; -import {HttpClientService} from '@app/services/http-client.service'; - -import {FilteringService} from './filtering.service'; - -describe('FilteringService', () => { - beforeEach(() => { - const httpClient = { - get: () => { - return { - subscribe: () => { - } - } - } - }; - TestBed.configureTestingModule({ - imports: [ - StoreModule.provideStore({ - appSettings, - clusters, - components, - hosts - }) - ], - providers: [ - FilteringService, - AppSettingsService, - ClustersService, - ComponentsService, - HostsService, - UtilsService, - { - provide: HttpClientService, - useValue: httpClient - } - ] - }); - }); - - it('should create service', inject([FilteringService], (service: FilteringService) => { - expect(service).toBeTruthy(); - })); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts deleted file mode 100644 index 5b9e90d..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts +++ /dev/null @@ -1,352 +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 {Injectable} from '@angular/core'; -import {FormControl, FormGroup} from '@angular/forms'; -import * as moment from 'moment-timezone'; -import {AppSettingsService} from '@app/services/storage/app-settings.service'; -import {ClustersService} from '@app/services/storage/clusters.service'; -import {ComponentsService} from '@app/services/storage/components.service'; -import {HostsService} from '@app/services/storage/hosts.service'; -import {HttpClientService} from '@app/services/http-client.service'; - -@Injectable() -export class FilteringService { - - constructor(private httpClient: HttpClientService, private appSettings: AppSettingsService, private clustersStorage: ClustersService, private componentsStorage: ComponentsService, private hostsStorage: HostsService) { - appSettings.getParameter('timeZone').subscribe(value => this.timeZone = value || this.defaultTimeZone); - clustersStorage.getAll().subscribe(clusters => { - this.filters.clusters.options = [...this.filters.clusters.options, ...clusters.map(this.getListItem)]; - }); - componentsStorage.getAll().subscribe(components => { - this.filters.components.options = [...this.filters.components.options, ...components.map(this.getListItem)]; - }); - hostsStorage.getAll().subscribe(hosts => { - this.filters.hosts.options = [...this.filters.hosts.options, ...hosts.map(host => { - return { - label: `${host.name} (${host.value})`, - value: host.name - }; - })]; - }); - } - - private getListItem(name: string): any { - return { - label: name, - value: name - }; - } - - private readonly defaultTimeZone = moment.tz.guess(); - - private readonly paginationOptions = ['10', '25', '50', '100']; - - timeZone: string = this.defaultTimeZone; - - filters = { - clusters: { - label: 'filter.clusters', - options: [], - defaultValue: '' - }, - text: { - label: 'filter.message', - defaultValue: '' - }, - timeRange: { - options: [ - { - label: 'filter.timeRange.1hr', - value: { - type: 'LAST', - unit: 'h', - interval: 1 - } - }, - { - label: 'filter.timeRange.24hr', - value: { - type: 'LAST', - unit: 'h', - interval: 24 - } - }, - { - label: 'filter.timeRange.today', - value: { - type: 'CURRENT', - unit: 'd' - } - }, - { - label: 'filter.timeRange.yesterday', - value: { - type: 'PAST', - unit: 'd' - } - }, - { - label: 'filter.timeRange.7d', - value: { - type: 'LAST', - unit: 'd', - interval: 7 - } - }, - { - label: 'filter.timeRange.30d', - value: { - type: 'LAST', - unit: 'd', - interval: 30 - } - }, - { - label: 'filter.timeRange.thisMonth', - value: { - type: 'CURRENT', - unit: 'M' - } - }, - { - label: 'filter.timeRange.lastMonth', - value: { - type: 'PAST', - unit: 'M' - } - }, - { - label: 'filter.timeRange.custom', - value: { - type: 'CUSTOM' - } - } - ], - defaultValue: { - type: 'LAST', - unit: 'h', - interval: 1 - }, - defaultLabel: 'filter.timeRange.1hr' - }, - components: { - label: 'filter.components', - iconClass: 'fa fa-cubes', - options: [], - defaultValue: '' - }, - levels: { - label: 'filter.levels', - iconClass: 'fa fa-sort-amount-asc', - options: [ - { - label: 'levels.fatal', - value: 'FATAL' - }, - { - label: 'levels.error', - value: 'ERROR' - }, - { - label: 'levels.warn', - value: 'WARN' - }, - { - label: 'levels.info', - value: 'INFO' - }, - { - label: 'levels.debug', - value: 'DEBUG' - }, - { - label: 'levels.trace', - value: 'TRACE' - }, - { - label: 'levels.unknown', - value: 'UNKNOWN' - } - ], - defaultValue: '' - }, - hosts: { - label: 'filter.hosts', - iconClass: 'fa fa-server', - options: [], - defaultValue: '' - }, - sorting: { - label: 'sorting.title', - options: [ - { - label: 'sorting.level.asc', - value: { - key: 'level', - type: 'asc' - } - }, - { - label: 'sorting.level.desc', - value: { - key: 'level', - type: 'desc' - } - }, - { - label: 'sorting.component.asc', - value: { - key: 'type', - type: 'asc' - } - }, - { - label: 'sorting.component.desc', - value: { - key: 'type', - type: 'desc' - } - }, - { - label: 'sorting.time.asc', - value: { - key: 'logtime', - type: 'asc' - } - }, - { - label: 'sorting.time.desc', - value: { - key: 'logtime', - type: 'desc' - } - } - ], - defaultValue: '', - defaultLabel: '' - }, - pageSize: { - label: 'pagination.title', - options: this.paginationOptions.map(option => { - return { - label: option, - value: option - } - }), - defaultValue: '10', - defaultLabel: '10' - }, - page: { - defaultValue: 0 - } - }; - - private filtersFormItems = Object.keys(this.filters).reduce((currentObject, key) => { - let formControl = new FormControl(), - item = { - [key]: formControl - }; - formControl.setValue(this.filters[key].defaultValue); - return Object.assign(currentObject, item); - }, {}); - - filtersForm = new FormGroup(this.filtersFormItems); - - loadClusters(): void { - this.httpClient.get('clusters').subscribe(response => { - const clusterNames = response.json(); - if (clusterNames) { - this.clustersStorage.addInstances(clusterNames); - } - }); - } - - loadComponents(): void { - this.httpClient.get('components').subscribe(response => { - const jsonResponse = response.json(), - components = jsonResponse && jsonResponse.groupList; - if (components) { - const componentNames = components.map(component => component.type); - this.componentsStorage.addInstances(componentNames); - } - }); - } - - loadHosts(): void { - this.httpClient.get('hosts').subscribe(response => { - const jsonResponse = response.json(), - hosts = jsonResponse && jsonResponse.vNodeList; - if (hosts) { - this.hostsStorage.addInstances(hosts); - } - }); - } - - private getStartTime(value: any, current: string): string { - let time; - if (value) { - const endTime = moment(moment(current).valueOf()); - switch (value.type) { - case 'LAST': - time = endTime.subtract(value.interval, value.unit); - break; - case 'CURRENT': - time = moment().tz(this.timeZone).startOf(value.unit); - break; - case 'PAST': - time = endTime.startOf(value.unit); - break; - default: - break; - } - } - return time ? time.toISOString() : ''; - } - - private getEndTime(value: any): string { - let time; - if (value) { - switch (value.type) { - case 'LAST': - time = moment(); - break; - case 'CURRENT': - time = moment().tz(this.timeZone).endOf(value.unit); - break; - case 'PAST': - time = moment().tz(this.timeZone).startOf(value.unit).millisecond(-1); - break; - default: - break; - } - } - return time ? time.toISOString() : ''; - } - - readonly valueGetters = { - end_time: this.getEndTime.bind(this), - start_time: this.getStartTime.bind(this), - to: this.getEndTime.bind(this), - from: this.getStartTime.bind(this), - sortType: value => value && value.type, - sortBy: value => value && value.key, - page: value => value == null ? value : value.toString() - }; - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.spec.ts deleted file mode 100644 index 0dfb0f3..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.spec.ts +++ /dev/null @@ -1,67 +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 {TestBed, inject} from '@angular/core/testing'; -import {HttpModule, Request} from '@angular/http'; -import {StoreModule} from '@ngrx/store'; -import {AppStateService, appState} from '@app/services/storage/app-state.service'; -import {HttpClientService} from './http-client.service'; - -describe('HttpClientService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - HttpModule, - StoreModule.provideStore({ - appState - }) - ], - providers: [ - HttpClientService, - AppStateService - ] - }); - }); - - it('should create service', inject([HttpClientService], (service: HttpClientService) => { - expect(service).toBeTruthy(); - })); - - describe('#generateUrlString()', () => { - it('should generate URL from presets', inject([HttpClientService], (service: HttpClientService) => { - expect(service.generateUrlString('status')).toEqual('api/v1/status'); - })); - - it('should return explicit URL', inject([HttpClientService], (service: HttpClientService) => { - expect(service.generateUrlString('login')).toEqual('login'); - })); - }); - - describe('#generateUrl()', () => { - it('string parameter', inject([HttpClientService], (service: HttpClientService) => { - expect(service.generateUrl('status')).toEqual('api/v1/status'); - })); - - it('request object parameter', inject([HttpClientService], (service: HttpClientService) => { - let request = new Request({ - url: 'status' - }); - expect(service.generateUrl(request).url).toEqual('api/v1/status'); - })); - }); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts deleted file mode 100644 index 8fed570..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts +++ /dev/null @@ -1,138 +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 {Injectable} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/operator/first'; -import {Http, XHRBackend, Request, RequestOptions, RequestOptionsArgs, Response, Headers, URLSearchParams} from '@angular/http'; -import {AuditLogsQueryParams} from '@app/classes/queries/audit-logs-query-params.class'; -import {ServiceLogsQueryParams} from '@app/classes/queries/service-logs-query-params.class'; -import {ServiceLogsHistogramQueryParams} from '@app/classes/queries/service-logs-histogram-query-params.class'; -import {AppStateService} from '@app/services/storage/app-state.service'; - -@Injectable() -export class HttpClientService extends Http { - - constructor(backend: XHRBackend, defaultOptions: RequestOptions, private appState: AppStateService) { - super(backend, defaultOptions); - } - - private readonly apiPrefix = 'api/v1/'; - - private readonly endPoints = { - status: { - url: 'status' - }, - auditLogs: { - url: 'audit/logs', - params: opts => new AuditLogsQueryParams(opts) - }, - auditLogsFields: { - url: 'audit/logs/schema/fields' - }, - serviceLogs: { - url: 'service/logs', - params: opts => new ServiceLogsQueryParams(opts) - }, - serviceLogsHistogram: { - url: 'service/logs/histogram', - params: opts => new ServiceLogsHistogramQueryParams(opts) - }, - serviceLogsFields: { - url: 'service/logs/schema/fields' - }, - components: { - url: 'service/logs/components' - }, - clusters: { - url: 'service/logs/clusters' - }, - hosts: { - url: 'service/logs/tree' - } - }; - - private readonly unauthorizedStatuses = [401, 403, 419]; - - private generateUrlString(url: string): string { - const preset = this.endPoints[url]; - return preset ? `${this.apiPrefix}${preset.url}` : url; - } - - private generateUrl(request: string | Request): string | Request { - if (typeof request === 'string') { - return this.generateUrlString(request); - } - if (request instanceof Request) { - request.url = this.generateUrlString(request.url); - return request; - } - } - - private generateOptions(url: string, params: {[key: string]: string}): RequestOptionsArgs { - const preset = this.endPoints[url], - rawParams = preset && preset.params ? preset.params(params) : params; - if (rawParams) { - const paramsString = Object.keys(rawParams).map(key => `${key}=${rawParams[key]}`).join('&'), - urlParams = new URLSearchParams(paramsString, { - encodeKey: key => key, - encodeValue: value => encodeURIComponent(value) - }); - return { - params: urlParams - }; - } else { - return { - params: rawParams - }; - } - } - - private handleError(request: Observable<Response>): void { - request.subscribe(null, (error: any) => { - if (this.unauthorizedStatuses.indexOf(error.status) > -1) { - this.appState.setParameter('isAuthorized', false); - } - }); - } - - request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> { - let req = super.request(this.generateUrl(url), options).share().first(); - this.handleError(req); - return req; - } - - get(url, params?: {[key: string]: string}): Observable<Response> { - return super.get(this.generateUrlString(url), this.generateOptions(url, params)); - } - - postFormData(url: string, params: {[key: string]: string}, options?: RequestOptionsArgs): Observable<Response> { - const encodedParams = this.generateOptions(url, params).params; - let body; - if (encodedParams && encodedParams instanceof URLSearchParams) { - body = encodedParams.rawParams; - } - let requestOptions = Object.assign({}, options); - if (!requestOptions.headers) { - requestOptions.headers = new Headers(); - } - requestOptions.headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - return super.post(url, body, requestOptions); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.spec.ts deleted file mode 100644 index 8ebbd72..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.spec.ts +++ /dev/null @@ -1,82 +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 {TestBed, inject} 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 {AuditLogsFieldsService, auditLogsFields} from '@app/services/storage/audit-logs-fields.service'; -import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage/service-logs-fields.service'; -import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; -import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; -import {ClustersService, clusters} from '@app/services/storage/clusters.service'; -import {ComponentsService, components} from '@app/services/storage/components.service'; -import {HostsService, hosts} from '@app/services/storage/hosts.service'; -import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; - -import {LogsContainerService} from './logs-container.service'; - -describe('LogsContainerService', () => { - beforeEach(() => { - const httpClient = { - get: () => { - return { - subscribe: () => { - } - } - } - }; - TestBed.configureTestingModule({ - imports: [ - StoreModule.provideStore({ - auditLogs, - serviceLogs, - auditLogsFields, - serviceLogsFields, - serviceLogsHistogramData, - appSettings, - clusters, - components, - hosts - }) - ], - providers: [ - AuditLogsService, - ServiceLogsService, - AuditLogsFieldsService, - ServiceLogsFieldsService, - ServiceLogsHistogramDataService, - AppSettingsService, - ClustersService, - ComponentsService, - HostsService, - LogsContainerService, - { - provide: HttpClientService, - useValue: httpClient - }, - FilteringService - ] - }); - }); - - it('should create service', inject([LogsContainerService], (service: LogsContainerService) => { - expect(service).toBeTruthy(); - })); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.ts deleted file mode 100644 index 702deab..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/logs-container.service.ts +++ /dev/null @@ -1,148 +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 {Injectable} from '@angular/core'; -import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; -import {AuditLogsService} from '@app/services/storage/audit-logs.service'; -import {AuditLogsFieldsService} from '@app/services/storage/audit-logs-fields.service'; -import {ServiceLogsService} from '@app/services/storage/service-logs.service'; -import {ServiceLogsFieldsService} from '@app/services/storage/service-logs-fields.service'; -import {ServiceLogsHistogramDataService} from '@app/services/storage/service-logs-histogram-data.service'; - -@Injectable() -export class LogsContainerService { - - constructor(private httpClient: HttpClientService, private auditLogsStorage: AuditLogsService, private auditLogsFieldsStorage: AuditLogsFieldsService, private serviceLogsStorage: ServiceLogsService, private serviceLogsFieldsStorage: ServiceLogsFieldsService, private serviceLogsHistogramStorage: ServiceLogsHistogramDataService, private filtering: FilteringService) { - } - - readonly colors = { - WARN: '#FF8916', - ERROR: '#E81D1D', - FATAL: '#830A0A', - INFO: '#2577B5', - DEBUG: '#65E8FF', - TRACE: '#888', - UNKNOWN: '#BDBDBD' - }; - - private readonly listFilters = { - clusters: ['clusters'], - text: ['iMessage'], - timeRange: ['end_time', 'start_time'], - components: ['mustBe'], - levels: ['level'], - hosts: ['host_name'], - sorting: ['sortType', 'sortBy'], - pageSize: ['pageSize'], - page: ['page'] - }; - - private readonly histogramFilters = { - clusters: ['clusters'], - text: ['iMessage'], - timeRange: ['to', 'from'], - components: ['mustBe'], - levels: ['level'] - }; - - readonly logsTypeMap = { - auditLogs: { - logsModel: this.auditLogsStorage, - fieldsModel: this.auditLogsFieldsStorage, - isSetFlag: 'isAuditLogsSet' - }, - serviceLogs: { - logsModel: this.serviceLogsStorage, - fieldsModel: this.serviceLogsFieldsStorage, - isSetFlag: 'isServiceLogsSet' - } - }; - - totalCount: number = 0; - - loadLogs(logsType: string): void { - this.httpClient.get(logsType, this.getParams('listFilters')).subscribe(response => { - const jsonResponse = response.json(); - this.logsTypeMap[logsType].logsModel.clear(); - if (jsonResponse) { - const logs = jsonResponse.logList, - count = jsonResponse.totalCount || 0; - if (logs) { - this.serviceLogsStorage.addInstances(logs); - } - this.totalCount = count; - } - }); - this.httpClient.get('serviceLogsHistogram', this.getParams('histogramFilters')).subscribe(response => { - const jsonResponse = response.json(); - this.serviceLogsHistogramStorage.clear(); - if (jsonResponse) { - const histogramData = jsonResponse.graphData; - if (histogramData) { - this.serviceLogsHistogramStorage.addInstances(histogramData); - } - } - }); - } - - private getParams(filtersMapName: string): any { - let params = {}; - Object.keys(this[filtersMapName]).forEach(key => { - const inputValue = this.filtering.filtersForm.getRawValue()[key], - paramNames = this[filtersMapName][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 if (paramName === 'from') { - value = valueGetter(inputValue, params['to']); - } else { - value = valueGetter(inputValue); - } - } else { - value = inputValue; - } - if (value != null && value !== '') { - params[paramName] = value; - } - }); - }, this); - return params; - } - - getHistogramData(data: any[]): any { - let histogramData = {}; - data.forEach(type => { - const name = type.name; - type.dataCount.forEach(entry => { - const timeStamp = new Date(entry.name).valueOf(); - if (!histogramData[timeStamp]) { - let initialValue = {}; - Object.keys(this.colors).forEach(key => initialValue[key] = 0); - histogramData[timeStamp] = initialValue; - } - histogramData[timeStamp][name] = Number(entry.value); - }); - }); - return histogramData; - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web-new/src/app/services/mock-api-data.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/mock-api-data.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/mock-api-data.service.spec.ts deleted file mode 100644 index 410f70d..0000000 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/mock-api-data.service.spec.ts +++ /dev/null @@ -1,81 +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 {TestBed, inject} from '@angular/core/testing'; -import {mockApiDataService} from './mock-api-data.service'; - -describe('mockApiDataService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [mockApiDataService] - }); - }); - - it('should create service', inject([mockApiDataService], (service: mockApiDataService) => { - expect(service).toBeTruthy(); - })); - - describe('#parseUrl()', () => { - const cases = [ - { - url: 'root', - base: '/', - collectionName: 'root', - query: '', - title: 'one-level depth url, no query params' - }, - { - url: 'root?param0=1¶m1=2', - base: '/', - collectionName: 'root', - query: 'param0=1¶m1=2', - title: 'one-level depth url with query params' - }, - { - url: 'root/resources/collection', - base: 'root/resources/', - collectionName: 'collection', - query: '', - title: 'more than one-level depth url, no query params' - }, - { - url: 'root/resources/collection?param0=1¶m1=2', - base: 'root/resources/', - collectionName: 'collection', - query: 'param0=1¶m1=2', - title: 'more than one-level depth url with query params' - } - ]; - - cases.forEach(test => { - describe(test.title, () => { - it('base', inject([mockApiDataService], (service: mockApiDataService) => { - expect(service.parseUrl(test.url).base).toEqual(test.base); - })); - - it('collectionName', inject([mockApiDataService], (service: mockApiDataService) => { - expect(service.parseUrl(test.url).collectionName).toEqual(test.collectionName); - })); - - it('query', inject([mockApiDataService], (service: mockApiDataService) => { - expect(service.parseUrl(test.url).query.toString()).toEqual(test.query); - })); - }); - }); - }); -});