Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 076A417697 for ; Tue, 24 Feb 2015 16:31:58 +0000 (UTC) Received: (qmail 8890 invoked by uid 500); 24 Feb 2015 16:31:55 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 8869 invoked by uid 500); 24 Feb 2015 16:31:55 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 8844 invoked by uid 99); 24 Feb 2015 16:31:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Feb 2015 16:31:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B2B7FE0D74; Tue, 24 Feb 2015 16:31:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: alexantonenko@apache.org To: commits@ambari.apache.org Date: Tue, 24 Feb 2015 16:31:58 -0000 Message-Id: In-Reply-To: <130c63fe233d4230badf64865abe05ff@git.apache.org> References: <130c63fe233d4230badf64865abe05ff@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/12] ambari git commit: AMBARI-9676. Initial Hive View Submission to Contrib (alexantonenko) http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-delete.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-delete.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-delete.hbs new file mode 100644 index 0000000..a870a0e --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-delete.hbs @@ -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. +}} + +{{#modal-widget heading=heading close="close" ok="delete"}} + {{text}} +{{/modal-widget}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-save.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-save.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-save.hbs new file mode 100644 index 0000000..f327e3b --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/modal-save.hbs @@ -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. +}} + +{{#modal-widget heading=heading close="close" ok="save"}} + {{input type="text" class="form-control" value=text }} +{{/modal-widget}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/navbar.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/navbar.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/navbar.hbs new file mode 100644 index 0000000..f8f6bcb --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/navbar.hbs @@ -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. +}} + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/open-queries.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/open-queries.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/open-queries.hbs new file mode 100644 index 0000000..ad1d9bd --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/open-queries.hbs @@ -0,0 +1,23 @@ +{{! +* 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. +}} + +{{#tabs-widget tabs=queryTabs removeClicked="removeQueryTab" canRemove=true}} + {{render 'settings'}} + {{query-editor tables=selectedTables query=currentQuery.fileContent editor=view.editor highlightedText=highlightedText + columnsNeeded="getColumnsForAutocomplete"}} +{{/tabs-widget}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/queries.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/queries.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/queries.hbs new file mode 100644 index 0000000..6187dfe --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/queries.hbs @@ -0,0 +1,78 @@ +{{! +* 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. +}} + + + + + {{#each column in columns}} + + {{/each}} + + + + + {{#each query in this}} + + + + + + + + + + + + {{/each}} + +
+ {{#if column.caption}} + {{column-filter-widget class="pull-left" + column=column + filterValue=column.filterValue + sortAscending=controller.sortAscending + sortProperties=controller.sortProperties + columnSorted="sort" + columnFiltered="filter"}} + {{else}} + {{column.caption}} + {{/if}} + + +
+ {{#link-to "index.savedQuery" query}} + {{query.shortQuery}} + {{/link-to}} + + {{#link-to "index.savedQuery" query}} + {{query.title}} + {{/link-to}} + {{query.dataBase}}{{query.owner}} + {{#unless query.isNew}} +
+ + + + +
+ {{/unless}} +
\ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/redirect.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/redirect.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/redirect.hbs new file mode 100644 index 0000000..b776fd2 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/redirect.hbs @@ -0,0 +1,19 @@ +{{! +* 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. +}} + +{{outlet}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/settings.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/settings.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/settings.hbs new file mode 100644 index 0000000..15741802 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/settings.hbs @@ -0,0 +1,52 @@ +{{! +* 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. +}} + + + +{{#if showSettingsOverlay}} +
+

Settings + + +
+ +
+

+ + {{#each setting in querySettings.settings}} +
+
+
+
+
+ {{input class="input-sm form-control" placeholder="Key" value=setting.key}} +
+
+ {{input class="input-sm form-control" placeholder="Value" value=setting.value}} + +
+
+
+
+
+ {{/each}} + +
+{{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/udfs.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/udfs.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/udfs.hbs new file mode 100644 index 0000000..5bb8759 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/udfs.hbs @@ -0,0 +1,112 @@ +{{! +* 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. +}} + + + + + + {{#each column in columns}} + + {{/each}} + + + + + {{#each udf in this}} + + + {{#each column in controller.columns}} + + {{/each}} + + + {{/each}} + +
{{t "columns.fileResource"}} + {{#if column.caption}} + {{column-filter-widget class="pull-left" + column=column + filterValue=column.filterValue + sortAscending=controller.sortAscending + sortProperties=controller.sortProperties + columnSorted="sort" + columnFiltered="filter"}} + {{else}} + {{column.caption}} + {{/if}} + +
+ + +
+
+ {{#if udf.isEditing}} + {{#if udf.isEditingResource}} + {{extended-input type="text" + class="pull-left form-control halfed input-sm" + placeholderTranslation="placeholders.fileResource.name" + value=udf.fileResource.name}} + {{extended-input type="text" + class="pull-left form-control halfed input-sm" + placeholderTranslation="placeholders.fileResource.path" + value=udf.fileResource.path}} + {{else}} + {{select-widget items=controller.fileResources + selectedValue=udf.fileResource + labelPath="name" + defaultLabelTranslation="placeholders.select.file" + itemAdded="addFileResource" + itemEdited="editFileResource" + itemRemoved="removeFileResource" + canAdd=true + canEdit=true}} + {{/if}} + {{else}} + {{#if udf.fileResource}} + {{udf.fileResource.name}} ({{udf.fileResource.path}}) + {{/if}} + {{/if}} + + {{#if udf.isEditing}} + {{extended-input type="text" + class="pull-left form-control input-sm" + placeholderTranslation=column.caption + dynamicContextBinding="udf" + dynamicValueBinding="column.property"}} + {{else}} + {{path-binding udf column.property}} + {{/if}} + + {{#if udf.isEditing}} +
+ + +
+ {{else}} +
+ + + + +
+ {{/if}} +
\ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/transforms/date.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/transforms/date.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/transforms/date.js new file mode 100644 index 0000000..716ab84 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/transforms/date.js @@ -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 Ember from 'ember'; +import DS from 'ember-data'; + +export default DS.Transform.extend({ + + deserialize: function (serialized) { + var type = typeof serialized; + + if (type === "string") { + return new Date(Ember.Date.parse(serialized)); + } else if (type === "number") { + return new Date(serialized); + } else if (serialized === null || serialized === undefined) { + // if the value is not present in the data, + // return undefined, not null. + return serialized; + } else { + return null; + } + }, + + serialize: function (date) { + if (date instanceof Date) { + // Serialize it as a number to maintain millisecond precision + return Number(date); + } else { + return null; + } + } + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/constants.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/constants.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/constants.js new file mode 100644 index 0000000..c9b1fda --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/constants.js @@ -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 Ember from 'ember'; + +export default Ember.Object.create({ + appTitle: 'Hive', + + /** + * This should reflect the naming conventions accross the application. + * Changing one value also means changing the filenames for the chain of files + * represented by that value (routes, controllers, models etc). + * This dependency goes both ways. + */ + namingConventions: { + routes: { + index: 'index', + savedQuery: 'savedQuery', + historyQuery: 'historyQuery', + queries: 'queries', + history: 'history', + udfs: 'udfs', + logs: 'logs', + results: 'results', + explain: 'explain' + }, + + subroutes: { + savedQuery: 'index.savedQuery', + historyQuery: 'index.historyQuery', + jobLogs: 'index.historyQuery.logs', + jobResults: 'index.historyQuery.results', + jobExplain: 'index.historyQuery.explain' + }, + + index: 'index', + udf: 'udf', + udfs: 'udfs', + udfInsertPrefix: 'create temporary function ', + fileInsertPrefix: 'add jar ', + explainPrefix: 'EXPLAIN ', + insertUdfs: 'insert-udfs', + job: 'job', + jobs: 'jobs', + history: 'history', + savedQuery: 'saved-query', + database: 'database', + databases: 'databases', + openQueries: 'open-queries', + file: 'file', + fileResource: 'file-resource', + fileResources: 'file-resources', + loadedFiles: 'loaded-files', + alerts: 'alerts', + logs: 'logs', + results: 'results', + jobResults: 'index/history-query/results', + jobLogs: 'index/history-query/logs', + jobExplain: 'index/history-query/explain', + databaseTree: 'databases-tree', + databaseSearch: 'databases-search-results', + tables: 'tables', + columns: 'columns', + settings: 'settings' + }, + + statuses: { + unknown: "Unknown", + initialized: "Initialized", + running: "Running", + finished: "Finished", + canceled: "Canceled", + closed: "Closed", + error: "Error", + pending: "Pending" + }, + + alerts: { + warning: 'warning', + error: 'danger', + success: 'success' + }, + + results: { + save: { + csv: 'Save as csv', + hdfs: 'Save to HDFS' + }, + statuses: { + terminated: "TERMINATED", + runnable: "RUNNABLE" + } + }, + + //this can be replaced by a string.format implementation + adapter: { + version: '0.0.1', + instance: 'Hive', + apiPrefix: '/api/v1/views/HIVE/versions/', + instancePrefix: '/instances/', + resourcePrefix: 'resources/' + }, + + settings: { + executionEngine: 'hive.execution.engine' + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js new file mode 100644 index 0000000..ab4f8e5 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js @@ -0,0 +1,36 @@ +/** + * 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 Ember from 'ember'; + +/* globals moment */ + +export default Ember.Object.create({ + isInteger: function (x) { + return (x^0) === x; + }, + + isDate: function(date) { + return moment(date).isValid(); + }, + + regexes: { + allUppercase: /^[^a-z]*$/, + whitespaces: /^(\s*).*$/ + } +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/views/.gitkeep ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/.gitkeep b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/.gitkeep new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/views/history.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/history.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/history.js new file mode 100644 index 0000000..8a914f0 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/history.js @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ember from 'ember'; + +export default Ember.View.extend({ + colspan: function () { + return this.get('controller.columns.length') + 1; + }.property('controller.columns') +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/views/insert-udfs.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/insert-udfs.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/insert-udfs.js new file mode 100644 index 0000000..70ed640 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/insert-udfs.js @@ -0,0 +1,23 @@ +/** + * 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 Ember from 'ember'; + +export default Ember.View.extend({ + tagName: 'insert-udfs' +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/app/views/navbar.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/navbar.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/navbar.js new file mode 100644 index 0000000..0c535db --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/navbar.js @@ -0,0 +1,38 @@ +/** + * 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 Ember from 'ember'; +import constants from 'hive/utils/constants'; + +export default Ember.View.extend({ + title: constants.appTitle, + + items: Ember.A([ + Ember.Object.create({text: 'menus.query', + path: constants.namingConventions.routes.index}), + + Ember.Object.create({text: 'menus.savedQueries', + path: constants.namingConventions.routes.queries}), + + Ember.Object.create({text: 'menus.history', + path: constants.namingConventions.routes.history}), + + Ember.Object.create({text: 'menus.udfs', + path: constants.namingConventions.routes.udfs}) + ]) +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/big_tables.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/big_tables.js b/contrib/views/hive/src/main/resources/ui/hive-web/big_tables.js new file mode 100644 index 0000000..9f3a317 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/big_tables.js @@ -0,0 +1,54 @@ +/** + * 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. + */ + +var result = ''; +var tableCount = 15000; +var columnCount = 100; + +//tables and columns script +for (var i = 0; i < tableCount; i++) { + result += 'CREATE TABLE TABLE_' + i + ' ('; + (function () { + for (var j = 0; j < columnCount; j++) { + result += 'field_' + j + ' STRING'; + + if (j < columnCount - 1) { + result += ','; + } else { + result += ') ' + } + } + }()); + + result += "ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE; \nLOAD DATA LOCAL INPATH 'test.csv' OVERWRITE INTO TABLE " + + 'TABLE_' + i + ';\n\n'; +} + +console.log(result); + +//csv script +var fill = ''; +for (var i = 0; i < columnCount; i++) { + fill += 'field_' + i; + + if (i < columnCount - 1) { + fill += ', '; + } +} + +console.log(fill); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/bower.json ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/bower.json b/contrib/views/hive/src/main/resources/ui/hive-web/bower.json new file mode 100644 index 0000000..a4c2aca --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/bower.json @@ -0,0 +1,27 @@ +{ + "name": "hive", + "dependencies": { + "handlebars": "2.0.0", + "jquery": "^1.11.1", + "ember": "1.9.0", + "ember-data": "1.0.0-beta.11", + "ember-resolver": "~0.1.7", + "loader.js": "stefanpenner/loader.js#1.0.1", + "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3", + "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4", + "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2", + "ember-qunit": "0.1.8", + "ember-qunit-notifications": "0.0.4", + "qunit": "~1.15.0", + "bootstrap": "~3.2.0", + "ember-i18n": "~2.9.0", + "blanket": "~1.1.5", + "jquery-ui": "~1.11.2", + "selectize": "~0.11.2", + "pretender": "0.1.0" + }, + "resolutions": { + "handlebars": "2.0.0", + "ember": "1.9.0" + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/config/environment.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/config/environment.js b/contrib/views/hive/src/main/resources/ui/hive-web/config/environment.js new file mode 100644 index 0000000..86da93e --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/config/environment.js @@ -0,0 +1,65 @@ +/** + * 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. + */ + +/* jshint node: true */ + +module.exports = function(environment) { + var ENV = { + modulePrefix: 'hive', + environment: environment, + baseURL: '/', + locationType: 'hash', + EmberENV: { + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. 'with-controller': true + } + }, + + APP: { + // Here you can pass flags/options to your application instance + // when it is created + } + }; + + if (environment === 'development') { + // ENV.APP.LOG_RESOLVER = true; + ENV.APP.LOG_ACTIVE_GENERATION = true; + // ENV.APP.LOG_TRANSITIONS = true; + // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; + ENV.APP.LOG_VIEW_LOOKUPS = true; + } + + if (environment === 'test') { + // Testem prefers this... + ENV.baseURL = '/'; + ENV.locationType = 'auto'; + + // keep test console output quieter + ENV.APP.LOG_ACTIVE_GENERATION = false; + ENV.APP.LOG_VIEW_LOOKUPS = false; + + ENV.APP.rootElement = '#ember-testing'; + } + + if (environment === 'production') { + + } + + return ENV; +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/package.json ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/package.json b/contrib/views/hive/src/main/resources/ui/hive-web/package.json new file mode 100644 index 0000000..52e908a --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/package.json @@ -0,0 +1,45 @@ +{ + "name": "hive", + "version": "0.0.0", + "private": true, + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "start": "ember server", + "build": "ember build", + "test": "ember test", + "preinstall": "chmod +x node/npm/bin/node-gyp-bin/node-gyp", + "postinstall": "bash node/with_new_path.sh node node_modules/.bin/bower --allow-root install" + }, + "repository": "https://github.com/stefanpenner/ember-cli", + "engines": { + "node": ">= 0.10.0" + }, + "author": "", + "license": "MIT", + "devDependencies": { + "body-parser": "^1.2.0", + "bower": ">= 1.3.12", + "broccoli-asset-rev": "0.3.1", + "broccoli-sass": "^0.3.2", + "ember-cli": "0.1.2", + "ember-cli-blanket": "^0.2.2", + "ember-cli-content-security-policy": "0.3.0", + "ember-cli-font-awesome": "0.0.4", + "ember-cli-htmlbars": "^0.5.3", + "ember-cli-ic-ajax": "0.1.1", + "ember-cli-inject-live-reload": "^1.3.0", + "ember-cli-jquery-ui": "0.0.12", + "ember-cli-moment": "0.0.1", + "ember-cli-pretender": "^0.3.1", + "ember-cli-qunit": "0.1.0", + "ember-cli-selectize": "0.0.7", + "ember-data": "1.0.0-beta.10", + "ember-dynamic-component": "0.0.1", + "ember-export-application-global": "^1.0.0", + "express": "^4.8.5", + "glob": "^4.0.5" + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/testem.json ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/testem.json b/contrib/views/hive/src/main/resources/ui/hive-web/testem.json new file mode 100644 index 0000000..eff93f9 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/testem.json @@ -0,0 +1,11 @@ +{ + "framework": "qunit", + "test_page": "tests/index.html", + "launch_in_ci": [ + "PhantomJS" + ], + "launch_in_dev": [ + "PhantomJS", + "Chrome" + ] +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/.jshintrc ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/.jshintrc b/contrib/views/hive/src/main/resources/ui/hive-web/tests/.jshintrc new file mode 100644 index 0000000..6ebf71a --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/.jshintrc @@ -0,0 +1,74 @@ +{ + "predef": [ + "document", + "window", + "location", + "setTimeout", + "$", + "-Promise", + "QUnit", + "define", + "console", + "equal", + "notEqual", + "notStrictEqual", + "test", + "asyncTest", + "testBoth", + "testWithDefault", + "raises", + "throws", + "deepEqual", + "start", + "stop", + "ok", + "strictEqual", + "module", + "moduleFor", + "moduleForComponent", + "moduleForModel", + "process", + "expect", + "visit", + "exists", + "fillIn", + "click", + "keyEvent", + "triggerEvent", + "find", + "findWithAssert", + "wait", + "DS", + "isolatedContainer", + "startApp", + "andThen", + "currentURL", + "currentPath", + "currentRouteName" + ], + "node": false, + "browser": false, + "boss": true, + "curly": false, + "debug": false, + "devel": false, + "eqeqeq": true, + "evil": true, + "forin": false, + "immed": false, + "laxbreak": false, + "newcap": true, + "noarg": true, + "noempty": false, + "nonew": false, + "nomen": false, + "onevar": false, + "plusplus": false, + "regexp": false, + "undef": true, + "sub": true, + "strict": false, + "white": false, + "eqnull": true, + "esnext": true +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/blanket-options.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/blanket-options.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/blanket-options.js new file mode 100644 index 0000000..a5580a9 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/blanket-options.js @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* globals blanket */ + +blanket.options({ + filter: "//.*hive/.*/", + antifilter: ["//.*(tests).*/", "//.*(templates).*/"], + loaderExclusions: ['ember-cli-jquery-ui'] +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/api-mock.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/api-mock.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/api-mock.js new file mode 100644 index 0000000..46a73f9 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/api-mock.js @@ -0,0 +1,242 @@ +/** + * 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 applicationAdapter from 'hive/adapters/database'; + +export default function() { + var baseUrl = applicationAdapter.create().buildURL(); + var databases = ['db1', 'db2', 'db3']; + + this.get(baseUrl + '/resources/ddl/database', function(req) { + var db = { + databases: databases + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(db)]; + }); + + this.get(baseUrl + '/resources/ddl/database/db1/table.page', function (req) { + var tables = { + rows: [ + ['table1'], + ['table2'], + ['table3'] + ] + } + + return [200, {"Content-Type": "application/json"}, JSON.stringify(tables)]; + }); + + this.get(baseUrl + '/resources/ddl/database/db1/table/table1.page', function (req) { + var columns = { + rows: [ + ['column1', 'STRING'], + ['column2', 'STRING'], + ['column3', 'STRING'] + ] + } + + return [200, {"Content-Type": "application/json"}, JSON.stringify(columns)]; + }); + + this.get(baseUrl + '/udfs', function(req) { + var udf = { + "udfs": [{ + "name": "TestColumn", + "classname": "TestClassName", + "fileResource": 1, + "id": 1, + "owner": "owner1" + }, + { + "name": "Test2Columns", + "classname": "Test2ClassName", + "fileResource": 1, + "id": 2, + "owner": "owner2" + }] + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(udf)]; + }); + + this.post(baseUrl + '/jobs', function(req) { + var job = { + "job": { + "status":"Finished", + "dataBase":"db1", + "dateSubmitted":1421677418, + "logFile":"job1/logs", + "properties":{}, + "fileResources":[], + "statusDir":"job1", + "id":1, + "title":"New Query", + "duration":2, + "forcedContent":"", + "owner":"admin", + "confFile":"job1/conf", + "queryId":null, + "queryFile":"job1.hql" + } + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(job)]; + }); + + this.get(baseUrl + '/resources/file/job1.hql', function(req) { + var file = { + "file": { + "filePath": "job1.hql", + "fileContent": "select * from big", + "hasNext": false, + "page": 0, + "pageCount": 1 + } + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(file)]; + }); + + this.get(baseUrl + '/savedQueries', function(req) { + var savedQueries = { + "savedQueries": [{ + "queryFile": "saved1.hql", + "dataBase": "db1", + "title": "saved1", + "shortQuery": "", + "id": 1, + "owner": "owner1" + }, { + "queryFile": "saved2.hql", + "dataBase": "db2", + "title": "saved2", + "shortQuery": "select count(field_0) from big;", + "id": 2, + "owner": "owner2" + }] + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(savedQueries)]; + }); + + this.get(baseUrl + '/resources/file/saved1.hql', function(req) { + var file = { + "file": { + "filePath": "saved1.hql", + "fileContent": "select * from saved1", + "hasNext": false, + "page": 0, + "pageCount": 0 + } + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(file)]; + }); + + this.get(baseUrl + '/jobs', function(req) { + var jobs = { + "jobs": [ + { + "title": "Query1", + "queryFile": "saved1.hql", + "statusDir": "statusdir", + "dateSubmitted": 1421240048, + "duration": 97199, + "status": "Finished", + "forcedContent": "", + "id": 1, + "owner": "admin", + "logFile": "logs1", + "confFile": "conf1" + }, + { + "title": "Query2", + "queryFile": "saved1.hql", + "statusDir": "statusdir", + "dateSubmitted": 1421240048, + "duration": 97199, + "status": "Finished", + "forcedContent": "", + "id": 2, + "owner": "admin", + "logFile": "logs2", + "confFile": "conf2" + }, + { + "title": "Query3", + "queryFile": "saved1.hql", + "statusDir": "statusdir", + "dateSubmitted": 1421240048, + "duration": 97199, + "status": "Running", + "forcedContent": "", + "id": 3, + "owner": "admin", + "logFile": "logs3", + "confFile": "conf3" + }, + { + "title": "Query4", + "queryFile": "saved1.hql", + "statusDir": "statusdir", + "dateSubmitted": 1421240048, + "duration": 97199, + "status": "Error", + "forcedContent": "", + "id": 4, + "owner": "admin", + "logFile": "logs4", + "confFile": "con51" + } + ] + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(jobs)]; + }); + + this.get(baseUrl + '/fileResources', function(req) { + var files = { + "fileResources": [ + { + "name": "TestName", + "path": "TestPath", + "id": 1, + "owner": "owner1" + } + ] + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(files)]; + }); + + this.get(baseUrl + '/fileResources/1', function(req) { + var files = { + "fileResources": [ + { + "name": "TestName", + "path": "TestPath", + "id": 1, + "owner": "owner1" + } + ] + }; + + return [200, {"Content-Type": "application/json"}, JSON.stringify(files)]; + }); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/resolver.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/resolver.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/resolver.js new file mode 100644 index 0000000..f94998c --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/resolver.js @@ -0,0 +1,29 @@ +/** + * 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 Resolver from 'ember/resolver'; +import config from '../../config/environment'; + +var resolver = Resolver.create(); + +resolver.namespace = { + modulePrefix: config.modulePrefix, + podModulePrefix: config.podModulePrefix +}; + +export default resolver; http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/start-app.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/start-app.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/start-app.js new file mode 100644 index 0000000..e029055 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/helpers/start-app.js @@ -0,0 +1,43 @@ +/** + * 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 Ember from 'ember'; +import Application from '../../app'; +import Router from '../../router'; +import config from '../../config/environment'; + +export default function startApp(attrs) { + var App; + + var attributes = Ember.merge({}, config.APP); + attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; + + Router.reopen({ + location: 'none' + }); + + Ember.run(function() { + App = Application.create(attributes); + App.setupForTesting(); + App.injectTestHelpers(); + }); + + App.reset(); // this shouldn't be needed, i want to be able to "start an app at a specific URL" + + return App; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/img/spinner.gif ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/img/spinner.gif b/contrib/views/hive/src/main/resources/ui/hive-web/tests/img/spinner.gif new file mode 100644 index 0000000..39fcb67 Binary files /dev/null and b/contrib/views/hive/src/main/resources/ui/hive-web/tests/img/spinner.gif differ http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/index.html ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/index.html b/contrib/views/hive/src/main/resources/ui/hive-web/tests/index.html new file mode 100644 index 0000000..6adbc89 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/index.html @@ -0,0 +1,64 @@ + + + + + + + Hive Tests + + + + {{content-for 'head'}} + {{content-for 'test-head'}} + + + + + + + +
+
+ + {{content-for 'body'}} + {{content-for 'test-body'}} + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/database-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/database-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/database-test.js new file mode 100644 index 0000000..5be4fdc --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/database-test.js @@ -0,0 +1,105 @@ +/** + * 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 Ember from 'ember'; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +import api from '../helpers/api-mock'; + +var App; +var server; + +module('Integration: Databases', { + setup: function() { + App = startApp(); + /* global Pretender: true */ + server = new Pretender(api); + }, + teardown: function() { + Ember.run(App, App.destroy); + server.shutdown(); + } +}); + +test('Database Explorer is displayed and populated with databases from server.', function() { + expect(2); + + visit('/'); + + andThen(function() { + equal(find('.database-explorer').length, 1, 'Databases panel is visible.'); + equal(find('.database-explorer .databases').children().length, 3, 'Databases are listed.'); + }); +}); + +test('Expanding a database will retrieve the first page of tables for that database.', function () { + expect(1); + + visit('/'); + + andThen(function () { + var targetDB = find('.fa-database').first(); + + click(targetDB); + + andThen(function () { + equal(find('.fa-th').length, 3); + }); + }); +}); + +test('Expanding a table will retrieve the first page of columns for that table.', function () { + expect(2); + + visit('/'); + + andThen(function () { + var targetDB = find('.fa-database').first(); + + click(targetDB); + + andThen(function () { + var targetTable = find('.fa-th').first(); + + click(targetTable); + + andThen(function () { + console.log(find('.columns')); + + equal(find('.columns').length, 1, 'Columns container was loaded.'); + equal(find('.columns strong').length, 3, '3 columns were loaded for selected table.'); + }); + }); + }); +}); + +test('Searching for a table will display table results and column search field', function () { + expect(2); + + visit('/'); + + andThen(function () { + fillIn(find('input').first(), 'table'); + keyEvent(find('input').first(), 'keyup', 13); + + andThen(function () { + equal(find('input').length, 2, 'Columns search input has been rendered.'); + equal(find('.nav-tabs li').length, 2, 'Results tab has been redendered.'); + }); + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/history-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/history-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/history-test.js new file mode 100644 index 0000000..35a950d --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/history-test.js @@ -0,0 +1,95 @@ +/** + * 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 Ember from 'ember'; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +import api from '../helpers/api-mock'; + +var App; +var server; + +module('Integration: History', { + setup: function() { + App = startApp(); + /* global Pretender: true */ + server = new Pretender(api); + }, + + teardown: function() { + Ember.run(App, App.destroy); + server.shutdown(); + } +}); + +test('Save Queries should list saved queries', function() { + expect(1); + + visit("/history"); + + andThen(function() { + equal(find('#content .table tbody tr').length, 4); + }); +}); + +test('User should be able to filter the jobs', function() { + expect(4); + + visit("/history"); + + fillIn('column-filter input[placeholder=title]', "Query1"); + keyEvent('column-filter input[placeholder=title]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by title'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 4); + }); + + + fillIn('column-filter input[placeholder=status]', "Finished"); + keyEvent('column-filter input[placeholder=status]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2, 'User is able to filter by status'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 4); + }); +}); + +test('A query item should expand to show the HQL', function() { + expect(3); + visit("/history"); + + andThen(function() { + equal(find('.table-expandable tbody .secondary-row').length, 0, 'All queries are collapsed'); + }); + + click('.table-expandable tbody tr:first-child'); + + andThen(function() { + equal(find('.table-expandable tbody .secondary-row').length, 1, 'One query is expanded'); + ok(find('.table-expandable tbody tr:first-child').next().hasClass('secondary-row'), 'Clicked query is expanded'); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js new file mode 100644 index 0000000..235a225 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js @@ -0,0 +1,108 @@ +/** + * 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 Ember from 'ember'; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +import api from '../helpers/api-mock'; + +var App; +var server; + +module('Integration: Query Editor', { + setup: function() { + App = startApp(); + /* global Pretender: true */ + server = new Pretender(api); + }, + + teardown: function() { + Ember.run(App, App.destroy); + server.shutdown(); + } +}); + +test('Query Editor is visible', function() { + expect(1); + + visit("/"); + + andThen(function() { + equal(find('.query-editor-panel').length, 1, 'Query Editor is visible'); + }); +}); + +test('Can execute query', function() { + expect(1); + + visit("/"); + + Ember.run(function() { + find('.CodeMirror').get(0).CodeMirror.setValue('select count(*) from table1'); + }); + + click('.execute-query'); + + andThen(function() { + ok(find('.query-process-results-panel .nav-tabs li:nth-child(2)').hasClass('active'), 'Results tab is visible'); + }); +}); + + +test('Can save query', function() { + expect(2); + + visit("/"); + + andThen(function() { + equal(find('.modal-dialog').length, 0, 'Modal dialog is hidden'); + }); + + Ember.run(function() { + find('.CodeMirror').get(0).CodeMirror.setValue('select count(*) from table1'); + }); + click('.save-query-as'); + + andThen(function() { + equal(find('.modal-dialog').length, 1, 'Modal dialog is shown'); + }); + + click('.modal-dialog .modal-footer .btn-danger'); +}); + +test('Can execute selection', function() { + expect(2); + visit('/'); + + var query1 = "select color from z;", + query2 = "select fruit from z;", + query = query1 + "\n" + query2, + editor; + + Ember.run(function() { + editor = find('.CodeMirror').get(0).CodeMirror; + editor.setValue(query); + editor.setSelection({ line: 1, ch: 0 }, { line: 1, ch: 20 }); + }); + click('.execute-query'); + + andThen(function() { + equal(editor.getValue(), query, 'Editor value didn\'t change'); + equal(editor.getSelection(), query2, 'Query 2 is selected'); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js new file mode 100644 index 0000000..c444523 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js @@ -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 Ember from 'ember'; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +import api from '../helpers/api-mock'; + +var App; +var server; + +module('Integration: Saved Queries', { + setup: function() { + App = startApp(); + /* global Pretender: true */ + server = new Pretender(api); + }, + + teardown: function() { + Ember.run(App, App.destroy); + server.shutdown(); + } +}); + +test('Save Queries should list saved queries', function() { + expect(1); + + visit("/queries"); + + + andThen(function() { + equal(find('#content .table tbody tr').length, 2); + }); +}); + +test('User should be able to filter the queries', function() { + expect(8); + + visit("/queries"); + + fillIn('column-filter input[placeholder=preview]', "select count"); + keyEvent('column-filter input[placeholder=preview]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by short query form.'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); + + fillIn('column-filter input[placeholder=title]', "saved1"); + keyEvent('column-filter input[placeholder=title]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by title'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); + + fillIn('column-filter input[placeholder=database]', "db1"); + keyEvent('column-filter input[placeholder=database]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by database'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); + + fillIn('column-filter input[placeholder=owner]', "owner1"); + keyEvent('column-filter input[placeholder=owner]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by owner'); + }); + + click('.clear-filters'); + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); +}); + +test('User is able to load a query from saved queries', function() { + expect(1); + + visit("/queries"); + click('#content .table tbody tr:first-child td:first-child a'); + + andThen(function() { + equal(currentURL(), "/queries/1", 'User is redirected'); + }); +}); + +test('Saved Query options menu', function() { + expect(2); + + visit("/queries"); + click('.fa-gear'); + + andThen(function() { + equal(find('.dropdown-menu:visible').length, 1, 'Query menu is visible'); + equal(find('.dropdown-menu:visible li').length, 2, 'Query menu has 2 options'); + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/udfs-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/udfs-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/udfs-test.js new file mode 100644 index 0000000..95a0043 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/integration/udfs-test.js @@ -0,0 +1,91 @@ +/** + * 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 Ember from 'ember'; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +import api from '../helpers/api-mock'; + +var App; +var server; + +module('Integration: Udfs', { + setup: function() { + App = startApp(); + /* global Pretender: true */ + server = new Pretender(api); + }, + + teardown: function() { + Ember.run(App, App.destroy); + server.shutdown(); + } +}); + +test('Save Queries should list saved queries', function() { + expect(1); + + visit("/udfs"); + + andThen(function() { + equal(find('#content .table tbody tr').length, 2); + }); +}); + +test('User should be able to filter the udfs', function() { + expect(4); + + visit("/udfs"); + + fillIn('column-filter input[placeholder="udf name"]', "TestColumn"); + keyEvent('column-filter input[placeholder="udf name"]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by name'); + }); + + click('.clear-filters'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); + + fillIn('column-filter input[placeholder="udf class name"]', "TestClassName"); + keyEvent('column-filter input[placeholder="udf class name"]', 'keyup'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 1, 'User is able to filter by class name'); + }); + + click('.clear-filters'); + + andThen(function() { + equal(find('#content .table tbody tr:visible').length, 2); + }); +}); + +test('User is able to add udf', function() { + expect(1); + + visit("/udfs"); + click('.add-udf'); + + andThen(function() { + equal(find('#content .table tbody tr').length, 3); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/test-helper.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/test-helper.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/test-helper.js new file mode 100644 index 0000000..53d9f9b --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/test-helper.js @@ -0,0 +1,30 @@ +/** + * 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 resolver from './helpers/resolver'; +import { + setResolver +} from 'ember-qunit'; + +setResolver(resolver); + +document.write('
'); + +QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'}); +var containerVisibility = QUnit.urlParams.nocontainer ? 'hidden' : 'visible'; +document.getElementById('ember-testing-container').style.visibility = containerVisibility; http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/.gitkeep ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/.gitkeep b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/.gitkeep new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/application.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/application.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/application.js new file mode 100644 index 0000000..da39a39 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/application.js @@ -0,0 +1,48 @@ +/** + * 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 { + moduleFor, + test +} from 'ember-qunit'; + +import constants from 'hive/utils/constants'; + +moduleFor('adapter:application', 'ApplicationAdapter', { + // Specify the other units that are required for this test. + // needs: ['serializer:foo'] +}); + +// Replace this with your real tests. +test('X-Requested-By header is set.', function() { + expect(1); + + var adapter = this.subject(); + + ok(adapter.get('headers.X-Requested-By'), 'X-Requested-By is set to a truthy value.'); +}); + +test('buildUrl returns an url with default values for version and instance paramters if not running within an Ambari instance.', function () { + expect(1); + + var adapter = this.subject(); + + var url = adapter.buildURL(); + + equal(url, constants.adapter.apiPrefix + '0.0.1' + constants.adapter.instancePrefix + 'Hive'); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/file.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/file.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/file.js new file mode 100644 index 0000000..ea70232 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/adapters/file.js @@ -0,0 +1,39 @@ +/** + * 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 { + moduleFor, + test +} from 'ember-qunit'; + +import constants from 'hive/utils/constants'; + +moduleFor('adapter:file', 'FileAdapter', { + // Specify the other units that are required for this test. + // needs: ['serializer:foo'] +}); + +// Replace this with your real tests. +test('pathForType returns correct path.', function() { + expect(1); + + var adapter = this.subject(); + var type = 'dummy'; + + equal(adapter.pathForType(type), constants.adapter.resourcePrefix + type); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/alert-message-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/alert-message-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/alert-message-widget-test.js new file mode 100644 index 0000000..c7deabb --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/alert-message-widget-test.js @@ -0,0 +1,91 @@ +/** + * 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 Ember from 'ember'; +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('alert-message-widget', 'AlertMessageWidgetComponent', { + needs: [] +}); + +test('isExpanded is toggled on click', function() { + expect(2); + + var message = Ember.Object.create({ isExpanded: false}); + + var component = this.subject({ + message: message + }); + + Ember.run(function() { + component.click(); + }); + + equal(component.get('message.isExpanded'), true, 'isExpanded is set to true'); + + Ember.run(function() { + component.click(); + }); + + equal(component.get('message.isExpanded'), false, 'isExpanded is set to false'); +}); + +test('removeLater should be called on click', function() { + expect(1); + + var message = Ember.Object.create({ isExpanded: false}); + + var targetObject = { + removeLater: function() { + ok(true, 'External removeLater called'); + } + }; + + var component = this.subject({ + targetObject: targetObject, + removeLater: 'removeLater', + message: message + }); + + Ember.run(function() { + component.click(); + }); + + Ember.run(function() { + component.click(); + }); +}); + +test('remove action should call external removeMessage', function() { + expect(1); + + var targetObject = { + removeMessage: function() { + ok(true, 'External removeMessage called'); + } + }; + + var component = this.subject({ + targetObject: targetObject, + removeMessage: 'removeMessage' + }); + + Ember.run(function() { + component.send('remove', {}); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f5482d89/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/collapsible-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/collapsible-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/collapsible-widget-test.js new file mode 100644 index 0000000..3af6d7d --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/collapsible-widget-test.js @@ -0,0 +1,44 @@ +/** + * 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 Ember from 'ember'; +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('collapsible-widget', 'CollapsibleWidgetComponent'); + +test('Component expand/collapse toggle action', function () { + expect(1); + + var targetObject = { + expanded: function() { + ok(true, 'External expanded called'); + } + }; + + var component = this.subject({ + targetObject: targetObject, + isExpanded: 'isExpanded', + expanded: 'expanded' + }); + + var $component = this.append(); + + Ember.run(function() { + component.set('isExpanded', false); + component.send('toggle', {}); + }); +});