This is an automated email from the ASF dual-hosted git repository. ababiichuk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new 78c9b13 AMBARI-25143 Remove unused models from ambari-web. (ababiichuk) 78c9b13 is described below commit 78c9b13cfc4e1f0bc481b61892aa0d871b6399e7 Author: ababiichuk <ababiic...@hortonworks.com> AuthorDate: Tue Feb 5 14:48:32 2019 +0200 AMBARI-25143 Remove unused models from ambari-web. (ababiichuk) --- ambari-web/app/assets/data/racks/racks.json | 12 -- ambari-web/app/assets/test/tests.js | 4 - .../app/controllers/global/cluster_controller.js | 7 - ambari-web/app/controllers/main.js | 1 - ambari-web/app/mappers.js | 3 - ambari-web/app/mappers/racks_mapper.js | 25 --- ambari-web/app/mappers/root_service_mapper.js | 57 ------- ambari-web/app/mappers/target_cluster_mapper.js | 53 ------ ambari-web/app/models.js | 7 - ambari-web/app/models/authentication.js | 104 ------------ ambari-web/app/models/background_operation.js | 75 --------- ambari-web/app/models/form.js | 178 --------------------- ambari-web/app/models/rack.js | 42 ----- ambari-web/app/models/root_service.js | 44 ----- ambari-web/app/models/service_audit.js | 71 -------- ambari-web/app/models/target_cluster.js | 33 ---- ambari-web/app/models/user.js | 70 -------- ambari-web/app/utils/ajax/ajax.js | 5 - .../controllers/global/cluster_controller_test.js | 9 -- .../test/controllers/main/charts/heatmap_test.js | 1 - ambari-web/test/models/authentication_test.js | 95 ----------- ambari-web/test/models/form_test.js | 173 -------------------- ambari-web/test/models/rack_test.js | 53 ------ ambari-web/test/models/root_service_test.js | 78 --------- ambari-web/test/models/user_test.js | 52 ------ ambari-web/test/utils/form_field_test.js | 42 ----- 26 files changed, 1294 deletions(-) diff --git a/ambari-web/app/assets/data/racks/racks.json b/ambari-web/app/assets/data/racks/racks.json deleted file mode 100644 index 0eda3ff..0000000 --- a/ambari-web/app/assets/data/racks/racks.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "href": "http://localhost:8080/api/racks?fields=*", - "items": [ - { - "href": "http://localhost:8080/api/racks/1", - "Racks": { - "id": 1, - "name": "Default Rack" - } - } - ] -} diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index 760a27d..ed39021 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -239,7 +239,6 @@ var files = [ 'test/utils/ember_reopen_test', 'test/utils/errors/assertions_test', 'test/utils/errors/definitions_test', - 'test/utils/form_field_test', 'test/utils/file_utils_test', 'test/utils/handlebars_helpers_test', 'test/utils/host_progress_popup_test', @@ -489,18 +488,15 @@ var files = [ 'test/models/alerts/alert_group_test', 'test/models/alerts/alert_instance_test', 'test/models/alerts/alert_notification_test', - 'test/models/authentication_test', 'test/models/client_component_test', 'test/models/cluster_states_test', 'test/models/cluster_test', - 'test/models/form_test', 'test/models/host_test', 'test/models/host_component_test', 'test/models/hosts_test', 'test/models/master_component_test', 'test/models/operating_system_test', 'test/models/repository_test', - 'test/models/root_service_test', 'test/models/stack_service_component_test', 'test/models/service_test', 'test/models/slave_component_test', diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js index 9e5b4f7..13a8e1f 100644 --- a/ambari-web/app/controllers/global/cluster_controller.js +++ b/ambari-web/app/controllers/global/cluster_controller.js @@ -378,13 +378,6 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, { return "ABORTED" === status; }, - loadRootService: function () { - return App.ajax.send({ - name: 'service.ambari', - sender: this - }); - }, - requestHosts: function (realUrl, callback) { var testHostUrl = '/data/hosts/HDP2/hosts.json'; var url = this.getUrl(testHostUrl, realUrl); diff --git a/ambari-web/app/controllers/main.js b/ambari-web/app/controllers/main.js index 105fee0..c0ec21d 100644 --- a/ambari-web/app/controllers/main.js +++ b/ambari-web/app/controllers/main.js @@ -17,7 +17,6 @@ */ var App = require('app'); -require('models/background_operation'); App.MainController = Em.Controller.extend({ name: 'mainController', diff --git a/ambari-web/app/mappers.js b/ambari-web/app/mappers.js index e6f1bb0..28110a1 100644 --- a/ambari-web/app/mappers.js +++ b/ambari-web/app/mappers.js @@ -29,18 +29,15 @@ require('mappers/repository_version_mapper'); require('mappers/quicklinks_mapper'); require('mappers/hosts_mapper'); require('mappers/cluster_mapper'); -require('mappers/racks_mapper'); require('mappers/users_mapper'); require('mappers/service_mapper'); require('mappers/service_metrics_mapper'); -require('mappers/target_cluster_mapper'); require('mappers/components_state_mapper'); require('mappers/alert_definitions_mapper'); require('mappers/alert_definition_summary_mapper'); require('mappers/alert_instances_mapper'); require('mappers/alert_groups_mapper'); require('mappers/alert_notification_mapper'); -require('mappers/root_service_mapper'); require('mappers/widget_mapper'); require('mappers/widget_layout_mapper'); require('mappers/stack_upgrade_history_mapper'); diff --git a/ambari-web/app/mappers/racks_mapper.js b/ambari-web/app/mappers/racks_mapper.js deleted file mode 100644 index 52c68e1..0000000 --- a/ambari-web/app/mappers/racks_mapper.js +++ /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. - */ - - -App.racksMapper = App.QuickDataMapper.create({ - model: App.Rack, - config: { - id: "Racks.id", - name: "Racks.name" - } -}); diff --git a/ambari-web/app/mappers/root_service_mapper.js b/ambari-web/app/mappers/root_service_mapper.js deleted file mode 100644 index 66a4849..0000000 --- a/ambari-web/app/mappers/root_service_mapper.js +++ /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. - */ - -var App = require('app'); - -App.rootServiceMapper = App.QuickDataMapper.create({ - root_service_model: App.RootService, - root_service_component_model: App.RootServiceComponents, - - configRootService: { - id: 'service_name', - service_name: 'service_name', - components_key: 'components', - components_type: 'array', - components: { - item: 'id' - } - }, - - configRootServiceComponents: { - id: 'component_name', - component_name: 'component_name', - component_version: 'component_version', - server_clock: 'server_clock', - service_name: 'service_name', - properties: 'properties' - }, - - map: function (data) { - var rootServiceModel = this.get('root_service_model'); - var rootServiceComponentModel = this.get('root_service_component_model'); - var rootService = {}, rootServiceComponents = []; - rootService.id = rootService.service_name = data.RootService.service_name; - data.components.forEach(function (item) { - item.RootServiceComponents.id = item.RootServiceComponents.component_name; - rootServiceComponents.push(this.parseIt(item.RootServiceComponents, this.configRootServiceComponents)); - }, this); - rootService.components = rootServiceComponents; - App.store.safeLoadMany(rootServiceComponentModel, rootServiceComponents); - App.store.safeLoad(rootServiceModel, this.parseIt(rootService, this.configRootService)); - } -}); diff --git a/ambari-web/app/mappers/target_cluster_mapper.js b/ambari-web/app/mappers/target_cluster_mapper.js deleted file mode 100644 index 29cb508..0000000 --- a/ambari-web/app/mappers/target_cluster_mapper.js +++ /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. - */ - - -App.targetClusterMapper = App.QuickDataMapper.create({ - model: App.TargetCluster, - config: { - id: 'name', - name: 'name', - execute: 'execute', - workflow: 'workflow', - write: 'write', - readonly: 'readonly', - staging: 'staging', - working: 'working', - temp: 'temp' - }, - - map: function (json) { - var model = this.get('model'); - if (!model) { - return; - } - - if (json.items) { - var result = []; - var clustersToDelete = model.find().mapProperty('name'); - json.items.forEach(function (item) { - result.push(this.parseIt(item, this.config)); - clustersToDelete = clustersToDelete.without(item.name); - }, this); - clustersToDelete.forEach(function (name) { - this.deleteRecord(model.find().findProperty('name', name)); - }, this); - App.store.safeLoadMany(model, result); - } - } -}); diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js index 422e041..f5d4d80 100644 --- a/ambari-web/app/models.js +++ b/ambari-web/app/models.js @@ -19,8 +19,6 @@ // load all models here -require('models/form'); // should be the 1st -require('models/authentication'); require('models/cluster'); require('models/cluster_states'); require('models/hosts'); @@ -37,7 +35,6 @@ require('models/stack_service_component'); require('models/quick_links'); require('models/quicklinks/quick_links_config'); require('models/service'); -require('models/service_audit'); require('models/service/hdfs'); require('models/service/onefs'); require('models/service/yarn'); @@ -54,16 +51,12 @@ require('models/alerts/alert_config'); require('models/alerts/alert_group'); require('models/user'); require('models/host'); -require('models/rack'); -require('models/background_operation'); require('models/client_component'); require('models/host_component'); require('models/host_component_log'); -require('models/target_cluster'); require('models/slave_component'); require('models/master_component'); require('models/host_stack_version'); -require('models/root_service'); require('models/upgrade_entity'); require('models/finished_upgrade_entity'); require('models/configs/theme/theme_condition'); diff --git a/ambari-web/app/models/authentication.js b/ambari-web/app/models/authentication.js deleted file mode 100644 index bac88be..0000000 --- a/ambari-web/app/models/authentication.js +++ /dev/null @@ -1,104 +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. - */ - -App.Authentication = DS.Model.extend({ - method:DS.attr('boolean'), // use LDAP - primaryServer:DS.attr('string'), - secondaryServer:DS.attr('string'), - useSsl:DS.attr('boolean'), - bindMethod:DS.attr('boolean'), // use credentials - bindUser:DS.attr('string'), - password:DS.attr('string'), - passwordRetype:DS.attr('string'), - searchBaseDn:DS.attr('string'), - usernameAttribute:DS.attr('string') -}); - -App.Authentication.FIXTURES = [ - { - id:1, - method:0, - primary_server:"", - secondary_server:"", - use_ssl:false, - bind_method:0, - bind_user:"", - password:"", - password_retype:"", - search_base_dn:"", - username_attribute:"" - } -]; - -App.AuthenticationForm = App.Form.extend({ - testResult:false, - fieldsOptions:[ - { name:"method", displayName:"", isRequired:false, displayType:"select", - values:[ - {value:0, label:Em.I18n.t("admin.authentication.form.method.database")}, - {value:1, label:Em.I18n.t("admin.authentication.form.method.ldap")} - ] - }, - { name:"primaryServer", displayName:Em.I18n.t("admin.authentication.form.primaryServer"), /*validator:'ipaddress',*/ - isRequired:function () { - return this.get('form.field.method.value'); - }.property('form.field.method.value') - }, - { name:"secondaryServer", displayName:Em.I18n.t("admin.authentication.form.secondaryServer"), /*validator:'ipaddress',*/ isRequired:false}, - { name:"useSsl", displayName:Em.I18n.t("admin.authentication.form.useSsl"), displayType:"checkbox", isRequired:false }, - { name:"bindMethod", displayName:'', displayType:"select", isRequired:false, - values:[ - {value:0, label:Em.I18n.t("admin.authentication.form.bind.anonymously")}, - {value:1, label:Em.I18n.t("admin.authentication.form.bind.useCrenedtials")} - ]}, - { name:"bindUser", displayName:Em.I18n.t('admin.authentication.form.bindUserDN'), isRequired:function () { - return this.get('form.field.bindMethod.value'); - }.property('form.field.bindMethod.value')}, - { name:"password", displayName:Em.I18n.t('common.password'), displayType:"password", - isRequired:function () { - return this.get('form.field.bindMethod.value'); - }.property('form.field.bindMethod.value') }, - { name:"passwordRetype", displayName:Em.I18n.t('form.passwordRetype'), displayType:"password", - validator: "passwordRetype", - isRequired:function () { - return this.get('form.field.bindMethod.value'); - }.property('form.field.bindMethod.value')}, - { name:"searchBaseDn", displayName:Em.I18n.t('admin.authentication.form.searchBaseDN'), - isRequired:function () { - return this.get('form.field.method.value'); - }.property('form.field.method.value') - }, - { name:"usernameAttribute", displayName:Em.I18n.t('admin.authentication.form.usernameAttribute'), - isRequired:function () { - return this.get('form.field.method.value'); - }.property('form.field.method.value') - }, - - { name:"userDN", displayName:Em.I18n.t('admin.authentication.form.userDN') }, - { name:"userPassword", displayName:Em.I18n.t('common.password'), displayType:'password'} - ], - fields:[], - testConfiguration:function () { - this.set('testResult', parseInt(Math.random() * 2)); - return true; - }, - testConfigurationMessage: Em.computed.ifThenElse('testResult', Em.I18n.t('admin.authentication.form.test.success'), Em.I18n.t('admin.authentication.form.test.fail')), - - testConfigurationClass: Em.computed.ifThenElse('testResult', 'text-success', 'text-danger') - -}); \ No newline at end of file diff --git a/ambari-web/app/models/background_operation.js b/ambari-web/app/models/background_operation.js deleted file mode 100644 index 67b52cf..0000000 --- a/ambari-web/app/models/background_operation.js +++ /dev/null @@ -1,75 +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. - */ - - -var App = require('app'); - -App.BackgroundOperation = DS.Model.extend({ - operationName:DS.attr('string'), - events: DS.hasMany('App.BackgroundOperationEvent'), - cluster:DS.belongsTo('App.Cluster'), - host:DS.belongsTo('App.Host'), - operationLog: DS.attr('string') -}); - -App.BackgroundOperation.FIXTURES = [ - { - id:1, - operation_name:'Decommissioning host1', - operation_log:'Decommissioning log', - events:[1,2], - cluster_id:1, - host_id:1 - }, - { - id:2, - operation_name:'Starting DataNode on host4', - operation_log:'Starting DataNode log', - events:[3], - cluster_id:1, - host_id:1 - } -]; - -App.BackgroundOperationEvent = DS.Model.extend({ - eventName:DS.attr('string'), - operation:DS.belongsTo('App.BackgroundOperation'), - eventDate: DS.attr('string') -}); - -App.BackgroundOperationEvent.FIXTURES = [ - { - id:1, - event_name:'Some intermediate operation', - operation_id:1, - event_date:'4 min ago' - }, - { - id:2, - event_name:'Operation started', - operation_id:1, - event_date:'5 min ago' - }, - { - id:3, - event_name:'Operation started', - operation_id:2, - event_date:'5 min ago' - } -]; - diff --git a/ambari-web/app/models/form.js b/ambari-web/app/models/form.js deleted file mode 100644 index 22a48a9..0000000 --- a/ambari-web/app/models/form.js +++ /dev/null @@ -1,178 +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. - */ -var App = require('app'); - -// move this to models cause some errors -App.Form = Em.View.extend({ - /** - * generating fields from fieldsOptions - */ - classNames:["form-horizontal"], - attributeBindings: ['autocomplete'], - autocomplete: 'off', - i18nprefix:'form.', - fields:[], - field:{}, - messages:[], - object:false, - result:0, // save result var (-1 - error; 0 - init; 1 - success) - templateName:require('templates/common/form'), - tagName:'form', - - init:function () { - var thisForm = this; - if (!this.fields.length) { - this.fieldsOptions.forEach( - function (options) { - var field = App.FormField.create(options); - field.set('form', thisForm); - thisForm.fields.push(field); - thisForm.set("field." + field.get('name'), field); - } - ); - } - this._super(); - }, - - /** - * get field of form by name - * @param name - * @return {Object} - */ - getField: function (name) { - return this.get('fields').findProperty('name', name); - }, - - isValid:function () { - var isValid = true; - $.each(this.fields, function () { - this.validate(); - if (!this.get('isValid')) { - isValid = false; - } - }); - - return isValid; - }, - - updateValues:function () { - var object = this.get('object'); - if (object instanceof Em.Object) { - $.each(this.fields, function () { - this.set('value', (this.get('displayType') == 'password') ? '' : object.get(this.get('name'))); - }); - } else { - this.clearValues(); - } - - }.observes("object"), - - /** - * reset values to default of every field in the form - */ - clearValues: function () { - this.get('fields').forEach(function (field) { - var value = (field.get('defaultValue') === undefined) ? '' : field.get('defaultValue'); - field.set('value', value); - }, this); - }, - - visibleFields:Em.computed.filterBy('fields', 'isHiddenField', false), - - resultText:function () { - var text = ""; - switch (this.get('result')) { - case -1: - text = this.t("form.saveError"); - break; - case 1: - text = this.t("form.saveSuccess"); - break; - } - - return text; - }.property('result') -}); - -App.FormField = Em.Object.extend({ // try to realize this as view - name:'', - displayName:'', -// defaultValue:'', NOT REALIZED YET - description:'', - disabled:false, - displayType:'string', // string, digits, number, directories, textarea, checkbox - disableRequiredOnPresent:false, - errorMessage:'', - warnMessage:'', - form:false, - isRequired:true, // by default a config property is required - unit:'', - value:'', - - isValid:Em.computed.equal('errorMessage', ''), - - viewClass:function () { - var options = {}; - var element = Em.TextField; - switch (this.get('displayType')) { - case 'checkbox': - element = App.CheckboxView; - options.checkedBinding = "value"; - break; - case 'select': - element = Em.Select; - options.content = this.get('values'); - options.valueBinding = "value"; - options.optionValuePath = "content.value"; - options.optionLabelPath = "content.label"; - break; - case 'password': - options['type'] = 'password'; - break; - case 'textarea': - element = Em.TextArea; - break; - case 'hidden': - options.type = "hidden"; - break; - } - - return element.extend(options); - }.property('displayType'), - - validate:function () { - var value = this.get('value'); - var isError = false; - this.set('errorMessage', ''); - - if (this.get('isRequired') && (typeof value === 'string' && value.trim().length === 0)) { - this.set('errorMessage', 'This is required'); - isError = true; - } - - if (typeof value === 'string' && value.trim().length === 0) { // this is not to validate empty field. - isError = true; - } - - if (!isError) { - this.set('errorMessage', ''); - } - }, - - isHiddenField: Em.computed.equal('displayType', 'hidden') -}); diff --git a/ambari-web/app/models/rack.js b/ambari-web/app/models/rack.js deleted file mode 100644 index b9608d5..0000000 --- a/ambari-web/app/models/rack.js +++ /dev/null @@ -1,42 +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. - */ - - -var App = require('app'); - -App.Rack = DS.Model.extend({ - name: DS.attr('string'), - status: DS.attr('string'), - criticalHostsCount: DS.attr('number'), - deadHostsCount: DS.attr('number'), - liveHostsCount: DS.attr('number'), - hosts: [] -}); - -App.Rack.FIXTURES = [ - //here example of data - /*{ - id: 1, - name: 'Rack-0', - hosts: ['host01', 'host06', 'host05'], - status: 'LIVE', - live_hosts_count: 5, - critical_hosts_count: 0, - dead_hosts_count: 2 - }*/ -]; \ No newline at end of file diff --git a/ambari-web/app/models/root_service.js b/ambari-web/app/models/root_service.js deleted file mode 100644 index 06ca8d0..0000000 --- a/ambari-web/app/models/root_service.js +++ /dev/null @@ -1,44 +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. - */ - -var App = require('app'); - -/** - * This model loads the rootService (Ambari) - * The model maps to the http://localhost:8080/api/v1/services/AMBARI?fields=components/RootServiceComponents - * @type {*} - */ -App.RootService = DS.Model.extend({ - serviceName: DS.attr('string'), - displayName: Em.computed.formatRole('serviceName', true), - components: DS.hasMany('App.RootServiceComponents') -}); - -App.RootService.FIXTURES = []; - -App.RootServiceComponents = DS.Model.extend({ - componentName: DS.attr('string'), - displayName: Em.computed.formatRole('componentName', false), - componentVersion: DS.attr('string'), - serverClock: DS.attr('number'), - serviceName: DS.attr('string'), - properties: DS.attr('object') -}); - -App.RootServiceComponents.FIXTURES = []; - diff --git a/ambari-web/app/models/service_audit.js b/ambari-web/app/models/service_audit.js deleted file mode 100644 index 49270b6..0000000 --- a/ambari-web/app/models/service_audit.js +++ /dev/null @@ -1,71 +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. - */ - -var App = require('app'); - -App.ServiceAudit = DS.Model.extend({ - date: DS.attr('date'), - service: DS.belongsTo('App.Service'), - operationName: DS.attr('string'), - user: DS.belongsTo('App.User') -}); - -App.ServiceAudit.FIXTURES = [ - { - id: 1, - date: 'September 12, 2012 17:00', - operation_name: 'Reconfigure', - user_id: 2, - service_id: 1 - }, - { - id: 2, - date: 'September 13, 2012 17:00', - operation_name: 'Start', - user_id: 1, - service_id: 1 - }, - { - id: 3, - date: 'September 14, 2012 17:00', - operation_name: 'Install', - user_id: 1, - service_id: 1 - }, - { - id: 4, - date: 'September 12, 2012 17:00', - operation_name: 'Reconfigure', - user_id: 2, - service_id: 2 - }, - { - id: 5, - date: 'September 13, 2012 17:00', - operation_name: 'Start', - user_id: 1, - service_id: 2 - }, - { - id: 6, - date: 'September 14, 2012 17:00', - operation_name: 'Install', - user_id: 1, - service_id: 2 - } -]; \ No newline at end of file diff --git a/ambari-web/app/models/target_cluster.js b/ambari-web/app/models/target_cluster.js deleted file mode 100644 index 5533065..0000000 --- a/ambari-web/app/models/target_cluster.js +++ /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. - */ - - -var App = require('app'); - -App.TargetCluster = DS.Model.extend({ - name: DS.attr('string'), - execute: DS.attr('string'), - workflow: DS.attr('string'), - write: DS.attr('string'), - readonly: DS.attr('string'), - staging: DS.attr('string'), - working: DS.attr('string'), - temp: DS.attr('string') -}); - -App.TargetCluster.FIXTURES = []; \ No newline at end of file diff --git a/ambari-web/app/models/user.js b/ambari-web/app/models/user.js index 5c14724..a053c09 100644 --- a/ambari-web/app/models/user.js +++ b/ambari-web/app/models/user.js @@ -23,7 +23,6 @@ App.User = DS.Model.extend({ userName:DS.attr('string'), id: Em.computed.alias('userName'), userType: DS.attr('string'), - auditItems:DS.hasMany('App.ServiceAudit'), admin: DS.attr('boolean'), operator: DS.attr('boolean'), clusterUser: DS.attr('boolean'), @@ -45,74 +44,5 @@ App.User = DS.Model.extend({ isLdap: Em.computed.equal('userType', 'LDAP') }); -App.CreateUserForm = App.Form.extend({ - className:App.User, - object: Em.computed.alias('App.router.mainAdminUserCreateController.content'), - - fieldsOptions:[ - { name:"userName", displayName:"Username", toLowerCase: function(){var v = this.get('value'); this.set('value', v.toLowerCase())}.observes('value') }, - { name:"password", displayName:"Password", displayType:"password", isRequired: true }, - { name:"passwordRetype", displayName:"Retype Password", displayType:"password", validator:"passwordRetype", isRequired: true }, - { name:"admin", displayName:"Admin", displayType:"checkbox", isRequired:false, defaultValue: true} - ], - fields:[], - - isValid:function () { - var isValid = this._super(); - - var passField = this.get('field.password'); - var passRetype = this.get('field.passwordRetype'); - - if (!validator.empty(passField.get('value'))) { - if (passField.get('value') != passRetype.get('value')) { - passRetype.set('errorMessage', this.t('admin.users.createError.passwordValidation')); - isValid = false; - } - } - - if (isValid) { - var users = App.User.find(); - var userNameField = this.getField('userName'); - var userName = userNameField.get('value'); - - if (users.mapProperty('userName').contains(userName)) { - userNameField.set('errorMessage', this.t('admin.users.createError.userNameExists')); - return isValid = false; - } - } - - return isValid; - }, - - isWarn: function() { - var isWarn = false; - var userNameField = this.getField('userName'); - userNameField.set('warnMessage', ''); - var userName = userNameField.get('value'); - - if (this.isValid() && !validator.isValidUserName(userName)) { - userNameField.set('warnMessage', this.t('users.userName.validationFail')); - isWarn = true; - } - return isWarn; - }, - - save: function () { - - var object = this.get('object'); - var formValues = {}; - $.each(this.get('fields'), function () { - formValues[Ember.String.decamelize(this.get('name'))] = this.get('value'); - }); - - if (this.get('className')) { - App.store.safeLoad(this.get('className'), App.dateTime(), formValues); - } - - this.set('result', 1); - - return true; - } -}); App.User.FIXTURES = []; diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index e164ce7..4b2cf98 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -235,11 +235,6 @@ var urls = { 'mock': '/data/background_operations/host_upgrade_tasks.json' }, - 'service.ambari': { - 'real': '/services/AMBARI?fields=components/RootServiceComponents', - 'mock': '/data/services/ambari.json' - }, - 'ambari.service.load_server_version': { 'real': '/services/AMBARI?fields=components/RootServiceComponents/component_version&components/RootServiceComponents/component_name=AMBARI_SERVER&minimal_response=true', 'mock': '/data/services/ambari.json' diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js index 0d89a12..940de34 100644 --- a/ambari-web/test/controllers/global/cluster_controller_test.js +++ b/ambari-web/test/controllers/global/cluster_controller_test.js @@ -635,15 +635,6 @@ describe('App.clusterController', function () { }); }); - describe('#loadRootService()', function() { - - it('App.ajax.send should be called', function() { - controller.loadRootService(); - var args = testHelpers.findAjaxRequest('name', 'service.ambari'); - expect(args).to.exist; - }); - }); - describe('#requestHosts()', function() { beforeEach(function() { diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js b/ambari-web/test/controllers/main/charts/heatmap_test.js index df3dd74..83d2faf 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_test.js @@ -19,7 +19,6 @@ var App = require('app'); var controller; -require('models/rack'); require('controllers/main/charts/heatmap'); var testHelpers = require('test/helpers'); diff --git a/ambari-web/test/models/authentication_test.js b/ambari-web/test/models/authentication_test.js deleted file mode 100644 index db1d308..0000000 --- a/ambari-web/test/models/authentication_test.js +++ /dev/null @@ -1,95 +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. - */ - -var App = require('app'); - -require('models/authentication'); - -var form, - methods = [ - { - name: 'method', - fields: ['primaryServer', 'searchBaseDn', 'usernameAttribute'] - }, - { - name: 'bindMethod', - fields: ['bindUser', 'password', 'passwordRetype'] - } - ], - classCases = [ - { - result: 0, - message: 'fail', - className: 'danger' - }, - { - result: 1, - message: 'success', - className: 'success' - } - ]; - -describe('App.AuthenticationForm', function () { - - beforeEach(function() { - form = App.AuthenticationForm.create(); - }); - - methods.forEach(function (method) { - method.fields.forEach(function (field) { - describe('#' + field + '.isRequired', function () { - [2, 1, 0].forEach(function (i) { - it('should be ' + i + ' dependent on ' + method.name + ' value', function () { - form.getField(method.name).set('value', i); - expect(form.getField(field).get('isRequired')).to.equal(i); - }); - }); - }); - }); - }); - - App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationMessage', 'testResult', Em.I18n.t('admin.authentication.form.test.success'), Em.I18n.t('admin.authentication.form.test.fail')); - - App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationClass', 'testResult', 'text-success', 'text-danger'); - - describe('#testResult', function () { - it('should be 0 or 1', function () { - form.testConfiguration(); - expect([0, 1]).to.include(Number(form.get('testResult'))); - }); - }); - - describe('#testConfigurationMessage', function () { - classCases.forEach(function (item) { - it('should indicate ' + item.message, function () { - form.set('testResult', item.result); - expect(form.get('testConfigurationMessage')).to.equal(Em.I18n.t('admin.authentication.form.test.' + item.message)); - }); - }); - }); - - describe('#testConfigurationClass', function () { - classCases.forEach(function (item) { - it('should indicate ' + item.className, function () { - form.set('testResult', item.result); - expect(form.get('testConfigurationClass')).to.equal('text-' + item.className); - }); - }); - }); - -}); diff --git a/ambari-web/test/models/form_test.js b/ambari-web/test/models/form_test.js deleted file mode 100644 index fab811d..0000000 --- a/ambari-web/test/models/form_test.js +++ /dev/null @@ -1,173 +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. - */ - -var App = require('app'); - -require('models/form'); - -var form, - field, - formField, - resultCases = [ - { - text: Em.I18n.t('form.saveError'), - result: -1 - }, - { - text: Em.I18n.t('form.saveSuccess'), - result: 1 - }, - { - text: '', - result: 0 - } - ], - hiddenCases = [ - { - displayType: 'password', - type: 'hidden', - value: false - }, - { - displayType: 'hidden', - type: 'hidden', - value: true - } - ]; - - -describe('App.Form', function () { - - beforeEach(function () { - form = App.Form.create({ - fieldsOptions: [ - { - name: 'field0', - value: 'value0', - isRequired: false - } - ] - }); - field = form.get('fields').objectAt(0); - }); - - describe('#fields', function () { - it('should get data from formFields', function () { - var fields = form.get('fields'); - expect(fields).to.have.length(1); - expect(field.get('name')).to.equal('field0'); - }); - }); - - describe('#field', function () { - it('should get data from formFields', function () { - var field0 = form.get('field.field0'); - expect(form.get('field')).to.not.be.empty; - expect(field0.get('name')).to.equal('field0'); - expect(field0.get('form')).to.eql(form); - }); - }); - - describe('#getField', function () { - it('should get field0', function () { - expect(form.getField('field0')).to.eql(form.get('field.field0')); - }); - it('should be empty', function () { - form.set('fields', []); - expect(form.getField()).to.be.empty; - }); - }); - - describe('#isValid', function () { - it('should be true', function () { - field.set('isRequired', false); - expect(form.isValid()).to.be.true; - }); - it('should be false', function () { - field.setProperties({ - isRequired: true, - value: '' - }); - expect(form.isValid()).to.be.false; - }); - }); - - describe('#updateValues', function () { - it('should update field0 value', function () { - form.set('object', Em.Object.create({field0: 'value0upd'})); - expect(field.get('value')).to.equal('value0upd'); - }); - it('should empty password value', function () { - field.set('displayType', 'password'); - form.set('object', Em.Object.create()); - expect(field.get('value')).to.be.empty; - }); - it('should clear values', function () { - form.set('object', []); - expect(field.get('value')).to.be.empty; - }); - }); - - describe('#clearValues', function () { - it('should clear values', function () { - var field0 = form.get('fields').objectAt(0); - field0.set('value', 'value0'); - form.clearValues(); - expect(field0.get('value')).to.be.empty; - }); - }); - - describe('#resultText', function () { - resultCases.forEach(function (item) { - it('should be ' + item.text, function () { - form.set('result', item.result); - expect(form.get('resultText')).to.equal(item.text); - }); - }); - }); - -}); - -describe('App.FormField', function () { - - beforeEach(function () { - formField = App.FormField.create(); - }); - - describe('#isValid', function () { - it('should be true', function () { - expect(formField.get('isValid')).to.be.true; - }); - it('should be false', function () { - formField.set('errorMessage', 'error'); - expect(formField.get('isValid')).to.be.false; - }); - }); - - /*eslint-enable mocha-cleanup/asserts-limit */ - - describe('#isHiddenField', function () { - hiddenCases.forEach(function (item) { - it('should be ' + item.value, function () { - formField.setProperties(item); - expect(formField.get('isHiddenField')).to.equal(item.value); - }); - }); - }); - -}); diff --git a/ambari-web/test/models/rack_test.js b/ambari-web/test/models/rack_test.js deleted file mode 100644 index 8c664c8..0000000 --- a/ambari-web/test/models/rack_test.js +++ /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. - */ - -var App = require('app'); - -require('models/host'); -require('models/rack'); - -describe('App.Rack', function () { - - var data = { - id: 'rack1', - name: 'rack1' - }; - - App.store.safeLoad(App.Rack, data); - - describe('#liveHostsCount', function () { - - it('rack1 has two live hosts', function () { - var rack = App.Rack.find().findProperty('name', 'rack1'); - expect(rack.get('liveHostsCount')).to.equal(2); - }); - - it('rack1 has three live hosts', function () { - App.store.safeLoad(App.Host, { - id: 'host3', - host_name: 'host3', - health_status: 'HEALTHY' - }); - var rack = App.Rack.find().findProperty('name', 'rack1'); - rack.set('name', 'rack1'); - expect(rack.get('liveHostsCount')).to.equal(3); - }); - }); - - -}); diff --git a/ambari-web/test/models/root_service_test.js b/ambari-web/test/models/root_service_test.js deleted file mode 100644 index fa4a646..0000000 --- a/ambari-web/test/models/root_service_test.js +++ /dev/null @@ -1,78 +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. - */ - -var App = require('app'); -require('models/root_service'); - -var roleMock = function (str, flag) { - return flag ? str.toLowerCase() : str.toCapital(); -}; - -describe('App.RootService', function () { - - var rootService; - - beforeEach(function () { - rootService = App.RootService.createRecord(); - }); - - describe('#displayName', function () { - - beforeEach(function () { - sinon.stub(App.format, 'role', roleMock); - }); - - afterEach(function () { - App.format.role.restore(); - }); - - it('should format service name', function () { - rootService.set('serviceName', 'HDFS'); - expect(rootService.get('displayName')).to.equal('hdfs'); - }); - - }); - -}); - -describe('App.RootServiceComponents', function () { - - var rootServiceComponents; - - beforeEach(function () { - rootServiceComponents = App.RootServiceComponents.createRecord(); - }); - - describe('#displayName', function () { - - beforeEach(function () { - sinon.stub(App.format, 'role', roleMock); - }); - - afterEach(function () { - App.format.role.restore(); - }); - - it('should format component name', function () { - rootServiceComponents.set('componentName', 'DATANODE'); - expect(rootServiceComponents.get('displayName')).to.equal('Datanode'); - }); - - }); - -}); \ No newline at end of file diff --git a/ambari-web/test/models/user_test.js b/ambari-web/test/models/user_test.js index 4a3a48d..d9872dd 100644 --- a/ambari-web/test/models/user_test.js +++ b/ambari-web/test/models/user_test.js @@ -22,8 +22,6 @@ var modelSetup = require('test/init_model_test'); require('models/user'); var user, - form, - userNameField, userData = { id: 'user' }; @@ -62,53 +60,3 @@ describe('App.User', function () { }); }); }); - -function getForm() { - return App.CreateUserForm.create(); -} - -describe('App.CreateUserForm', function () { - - beforeEach(function () { - form = getForm(); - }); - - App.TestAliases.testAsComputedAlias(getForm(), 'object', 'App.router.mainAdminUserCreateController.content', 'object'); - - describe('#field.userName.toLowerCase', function () { - it('should convert userName into lower case', function () { - userNameField = form.getField('userName'); - userNameField.set('value', 'NAME'); - expect(userNameField.get('value')).to.equal('name'); - }); - }); - - describe('#isValid', function () { - it('should be false as default', function () { - expect(form.isValid()).to.be.false; - }); - it('should be true', function () { - form.get('fields').forEach(function (item) { - if (item.get('isRequired')) { - item.set('value', 'value'); - } - }); - expect(form.isValid()).to.be.true; - }); - }); - - describe('#isWarn', function () { - it('should be false as default', function () { - expect(form.isWarn()).to.be.false; - }); - it('should be true', function () { - form.getField('userName').set('value', '1'); - expect(form.isWarn()).to.be.true; - }); - it('should be false', function () { - form.getField('userName').set('value', 'name'); - expect(form.isWarn()).to.be.false; - }); - }); - -}); diff --git a/ambari-web/test/utils/form_field_test.js b/ambari-web/test/utils/form_field_test.js deleted file mode 100644 index f0bf190..0000000 --- a/ambari-web/test/utils/form_field_test.js +++ /dev/null @@ -1,42 +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. - */ - -var App = require('app'); -require('models/form'); - - -/* - * formField.isValid property doesn't update correctly, so I have to work with errorMessage property - */ -describe('App.FormField', function () { - - describe('#validate()', function () { - /*NUMBER TYPE END*/ - /*REQUIRE*/ - it('Required field shouldn\'t be empty', function () { - var formField = App.FormField.create(); - formField.set('displayType', 'string'); - formField.set('value', ''); - formField.set('isRequired', true); - formField.validate(); - expect(formField.get('errorMessage')).to.be.not.equal(''); - }); - /*REQUIRE END*/ - - }); -}); \ No newline at end of file