http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js deleted file mode 100644 index bfb976d..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js +++ /dev/null @@ -1,388 +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. - */ - -/** - * Config for each ajax-request - * - * Fields example: - * mock - testMode url - * real - real url (without API prefix) - * type - request type (also may be defined in the format method) - * format - function for processing ajax params after default formatRequest. May be called with one or two parameters (data, opt). Return ajax-params object - * schema - basic validation schema (tv4) for response (optional) - * - * @type {Object} - */ -var urls = { - - 'slider.getViewParams': { - real: '?fields=ViewInstanceInfo', - mock: '/data/resource/slider-properties.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - }, - schema: { - required: ['ViewInstanceInfo'], - properties: { - ViewInstanceInfo: { - required: ['properties', 'description', 'label'] - } - } - } - }, - - 'slider.getViewParams.v2': { - real: 'resources/status', - mock: '/data/resource/slider-properties-2.json', - headers: { - "Accept": "application/json; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - }, - schema: { - required: ['version', 'validations', 'parameters'], - properties: { - validations: { - type: 'array' - }, - parameters: { - type : 'object' - } - } - } - }, - - 'mapper.applicationTypes': { - real: 'apptypes?fields=*', - mock: '/data/apptypes/all_fields.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - }, - schema: { - required: ['items'], - properties: { - items: { - type: 'array', - items: { - required: ['id', 'typeComponents', 'typeConfigs'], - properties: { - typeConfigs: { - type: 'object' - }, - typeComponents: { - type: 'array', - items: { - required: ['id', 'name', 'category', 'displayName'] - } - } - } - } - } - } - } - }, - - 'mapper.applicationApps': { - real: '?fields=apps/*', - mock: '/data/apps/apps.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - }, - 'format': function() { - return { - timeout: 20000 - }; - }, - schema: { - required: ['items'], - properties: { - items: { - type: 'array', - items: { - required: ['id', 'description', 'diagnostics', 'name', 'user', 'state', 'type', 'components', 'configs'], - alerts: { - type: 'object', - detail: { - type: 'array' - } - } - } - } - } - } - }, - - 'mapper.applicationStatus': { - real: 'resources/status', - mock: '/data/resource/status_true.json' - }, - - 'saveInitialValues': { - real: '', - mock: '/data/resource/empty_json.json', - headers: { - "Content-Type": "text/plain; charset=utf-8" - }, - format: function (data) { - return { - type: 'PUT', - data: JSON.stringify(data.data), - dataType: 'text' - } - } - }, - - 'validateAppName': { - real: 'apps?validateAppName={name}', - mock: '/data/resource/empty_json.json', - format: function () { - return { - dataType: 'text', - showErrorPopup: true - } - } - }, - - 'createNewApp': { - real: 'apps', - mock: '/data/resource/empty_json.json', - headers: { - "Content-Type": "text/plain; charset=utf-8" - }, - format: function (data) { - return { - type: 'POST', - data: JSON.stringify(data.data), - dataType: 'text', - showErrorPopup: true - } - } - }, - - 'destroyApp': { - real: 'apps/{id}', - mock: '', - format: function () { - return { - method: 'DELETE', - dataType: 'text', - showErrorPopup: true - } - } - }, - - 'changeAppState': { - real: 'apps/{id}', - mock: '', - headers: { - "Content-Type": "text/plain; charset=utf-8" - }, - format: function (data) { - return { - method: 'PUT', - data: JSON.stringify(data.data), - dataType: 'text', - showErrorPopup: true - } - } - }, - 'flexApp': { - real: 'apps/{id}', - mock: '', - headers: { - "Content-Type": "text/plain; charset=utf-8" - }, - format: function (data) { - return { - method: 'PUT', - data: JSON.stringify(data.data), - dataType: 'text', - showErrorPopup: true - } - } - }, - - 'metrics': { - real: 'apps/{id}?fields=metrics/{metric}', - mock: '/data/metrics/metric.json', - headers: { - "Accept": "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'metrics2': { - real: 'apps/{id}/metrics/{metric}', - mock: '/data/metrics/metric2.json' - }, - - 'metrics3': { - real: 'apps/{id}/metrics/{metric}', - mock: '/data/metrics/metric3.json' - }, - - 'metrics4': { - real: 'apps/{id}/metrics/{metric}', - mock: '/data/metrics/metric4.json' - } - -}; -/** - * Replace data-placeholders to its values - * - * @param {String} url - * @param {Object} data - * @return {String} - */ -var formatUrl = function (url, data) { - if (!url) return null; - var keys = url.match(/\{\w+\}/g); - keys = (keys === null) ? [] : keys; - if (keys) { - keys.forEach(function (key) { - var raw_key = key.substr(1, key.length - 2); - var replace; - if (!data || !data[raw_key]) { - replace = ''; - } - else { - replace = data[raw_key]; - } - url = url.replace(new RegExp(key, 'g'), replace); - }); - } - return url; -}; - -/** - * this = object from config - * @return {Object} - */ -var formatRequest = function (data) { - var opt = { - type: this.type || 'GET', - dataType: 'json', - async: true, - headers: this.headers || {Accept: "application/json; charset=utf-8"} - }; - if (App.get('testMode')) { - opt.url = formatUrl(this.mock ? this.mock : '', data); - opt.type = 'GET'; - } - else { - var prefix = App.get('urlPrefix'); - if (Em.get(data, 'urlPrefix')) { - prefix = Em.get(data, 'urlPrefix'); - } - var url = formatUrl(this.real, data); - opt.url = prefix + (url ? url : ''); - if (this.format) { - jQuery.extend(opt, this.format(data, opt)); - } - } - - return opt; -}; - -/** - * Wrapper for all ajax requests - * - * @type {Object} - */ -var ajax = Em.Object.extend({ - /** - * Send ajax request - * - * @param {Object} config - * @return {$.ajax} jquery ajax object - * - * config fields: - * name - url-key in the urls-object *required* - * sender - object that send request (need for proper callback initialization) *required* - * data - object with data for url-format - * beforeSend - method-name for ajax beforeSend response callback - * success - method-name for ajax success response callback - * error - method-name for ajax error response callback - * callback - callback from <code>App.updater.run</code> library - */ - send: function (config) { - - Ember.assert('Ajax sender should be defined!', config.sender); - Ember.assert('Invalid config.name provided - ' + config.name, urls[config.name]); - - var opt = {}; - - // default parameters - var params = { - clusterName: App.get('clusterName') - }; - - if (config.data) { - jQuery.extend(params, config.data); - } - - opt = formatRequest.call(urls[config.name], params); - opt.context = this; - - // object sender should be provided for processing beforeSend, success, error and complete responses - opt.beforeSend = function (xhr) { - if (config.beforeSend) { - config.sender[config.beforeSend](opt, xhr, params); - } - }; - - opt.success = function (data) { - console.log("TRACE: The url is: " + opt.url); - - // validate response if needed - if (urls[config.name].schema) { - var result = tv4.validateMultiple(data, urls[config.name].schema); - if (!result.valid) { - result.errors.forEach(function (error) { - console.warn('Request: ' + config.name, 'WARNING: ', error.message, error.dataPath); - }); - } - } - - if (config.success) { - config.sender[config.success](data, opt, params); - } - }; - - opt.error = function (request, ajaxOptions, error) { - if (config.error) { - config.sender[config.error](request, ajaxOptions, error, opt, params); - } else if (config.sender.defaultErrorHandler) { - config.sender.defaultErrorHandler.call(config.sender, request, opt.url, opt.type, opt.showErrorPopup); - } - }; - - opt.complete = function (xhr, status) { - if (config.complete) { - config.sender[config.complete](xhr, status); - } - }; - - return $.ajax(opt); - } - -}); - -App.ajax = ajax.create({});
http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js b/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js deleted file mode 100644 index 9986c55..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -String.prototype.format = function () { - var args = arguments; - return this.replace(/{(\d+)}/g, function (match, number) { - return typeof args[number] != 'undefined' ? args[number] : match; - }); -}; - -/** - * Return formatted string with inserted spaces before upper case and replaced '_' to spaces - * Also capitalize first letter - * - * Examples: - * 'apple' => 'Apple' - * 'apple_banana' => 'Apple banana' - * 'apple_bananaUranium' => 'Apple banana Uranium' - */ -String.prototype.humanize = function () { - var content = this; - return content && (content[0].toUpperCase() + content.slice(1)).replace(/([A-Z])/g, ' $1').replace(/_/g, ' '); -} - -/** - * Helper function for bound property helper registration - * @memberof App - * @method registerBoundHelper - * @param name {String} name of helper - * @param view {Em.View} view - */ -App.registerBoundHelper = function(name, view) { - Ember.Handlebars.registerHelper(name, function(property, options) { - options.hash.contentBinding = property; - return Ember.Handlebars.helpers.view.call(this, view, options); - }); -}; - -/** - * Return formatted string with inserted <code>wbr</code>-tag after each dot - * - * @param {String} content - * - * Examples: - * - * returns 'apple' - * {{formatWordBreak 'apple'}} - * - * returns 'apple.<wbr />banana' - * {{formatWordBreak 'apple.banana'}} - * - * returns 'apple.<wbr />banana.<wbr />uranium' - * {{formatWordBreak 'apple.banana.uranium'}} - */ -App.registerBoundHelper('formatWordBreak', Em.View.extend({ - tagName: 'span', - template: Ember.Handlebars.compile('{{{view.result}}}'), - devider:'/', - - /** - * @type {string} - */ - result: function() { - var d = this.get('devider'); - var r = new RegExp('\\'+d,"g"); - return this.get('content') && this.get('content').toString().replace(r, d+'<wbr />'); - }.property('content') -})); - -/** - * Return formatted string with inserted spaces before upper case and replaced '_' to spaces - * Also capitalize first letter - * - * @param {String} content - * - * Examples: - * - * returns 'apple' - * {{humanize 'Apple'}} - * - * returns 'apple_banana' - * {{humanize 'Apple banana'}} - * - * returns 'apple_bananaUranium' - * {{humanize 'Apple banana Uranium'}} - */ -App.registerBoundHelper('humanize', Em.View.extend({ - - tagName: 'span', - - template: Ember.Handlebars.compile('{{{view.result}}}'), - - /** - * @type {string} - */ - result: function() { - var content = this.get('content'); - return content && content.humanize(); - }.property('content') -})); - -/** - * Ambari overrides the default date transformer. - * This is done because of the non-standard data - * sent. For example Nagios sends date as "12345678". - * The problem is that it is a String and is represented - * only in seconds whereas Javascript's Date needs - * milliseconds representation. - */ -DS.attr.transforms = { - date: { - from: function (serialized) { - var type = typeof serialized; - if (type === 'string') { - serialized = parseInt(serialized); - type = typeof serialized; - } - if (type === 'number') { - if (!serialized) { //serialized timestamp = 0; - return 0; - } - // The number could be seconds or milliseconds. - // If seconds, then the length is 10 - // If milliseconds, the length is 13 - if (serialized.toString().length < 13) { - serialized = serialized * 1000; - } - 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; - } - }, - to: function (deserialized) { - if (deserialized instanceof Date) { - return deserialized.getTime(); - } else { - return null; - } - } - } -}; -/** - * Allow get translation value used in I18n for attributes that ends with Translation. - * For example: - * <code> - * {{input name="new" placeholderTranslation="any"}} - * </code> - **/ -Em.TextField.reopen(Em.I18n.TranslateableAttributes); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/helpers/string_utils.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/string_utils.js b/contrib/views/slider/src/main/resources/ui/app/helpers/string_utils.js deleted file mode 100644 index 9675f49..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/helpers/string_utils.js +++ /dev/null @@ -1,163 +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. - */ - -module.exports = { - - pad: function(str, len, pad, dir) { - - var STR_PAD_LEFT = 1; - var STR_PAD_RIGHT = 2; - var STR_PAD_BOTH = 3; - - if (typeof(len) == "undefined") { len = 0; } - if (typeof(pad) == "undefined") { pad = ' '; } - if (typeof(dir) == "undefined") { dir = STR_PAD_RIGHT; } - - if (len + 1 >= str.length) { - - switch (dir){ - - case STR_PAD_LEFT: - str = Array(len + 1 - str.length).join(pad) + str; - break; - - case STR_PAD_BOTH: - var padlen = len - str.length; - var right = Math.ceil((padlen) / 2); - var left = padlen - right; - str = Array(left+1).join(pad) + str + Array(right+1).join(pad); - break; - - default: - str = str + Array(len + 1 - str.length).join(pad); - break; - - } // switch - - } - return str; - - }, - underScoreToCamelCase: function(name){ - function replacer(str, p1, p2, offset, s) { - return str[1].toUpperCase(); - } - return name.replace(/_\w/g,replacer); - }, - - /** - * Forces given string into upper camel-case representation. The first - * character of each word will be capitalized with the rest in lower case. - */ - getCamelCase : function(name) { - if (name != null) { - return name.toLowerCase().replace(/(\b\w)/g, function(f) { - return f.toUpperCase(); - }) - } - return name; - }, - - /** - * Compare two versions by following rules: - * first higher than second then return 1 - * first lower than second then return -1 - * first equal to second then return 0 - * @param first {string} - * @param second {string} - * @return {number} - */ - compareVersions: function(first, second){ - if (!(typeof first === 'string' && typeof second === 'string')) { - return false; - } - if (first === '' || second === '') { - return false; - } - var firstNumbers = first.split('.'); - var secondNumbers = second.split('.'); - var length = 0; - var i = 0; - var result = false; - if(firstNumbers.length === secondNumbers.length) { - length = firstNumbers.length; - } else if(firstNumbers.length < secondNumbers.length){ - length = secondNumbers.length; - } else { - length = firstNumbers.length; - } - - while(i < length && !result){ - firstNumbers[i] = (firstNumbers[i] === undefined) ? 0 : window.parseInt(firstNumbers[i]); - secondNumbers[i] = (secondNumbers[i] === undefined) ? 0 : window.parseInt(secondNumbers[i]); - if(firstNumbers[i] > secondNumbers[i]){ - result = 1; - break; - } else if(firstNumbers[i] === secondNumbers[i]){ - result = 0; - } else if(firstNumbers[i] < secondNumbers[i]){ - result = -1; - break; - } - i++; - } - return result; - }, - - isSingleLine: function(string){ - return String(string).trim().indexOf("\n") == -1; - }, - /** - * transform array of objects into CSV format content - * @param array - * @return {Array} - */ - arrayToCSV: function(array){ - var content = ""; - array.forEach(function(item){ - var row = []; - for(var i in item){ - if(item.hasOwnProperty(i)){ - row.push(item[i]); - } - } - content += row.join(',') + '\n'; - }); - return content; - }, - - /** - * Extracts filename from linux/unix path - * @param path - * @return {string}: filename - */ - getFileFromPath: function(path) { - if (!path || typeof path !== 'string') { - return ''; - } - return path.replace(/^.*[\/]/, ''); - }, - - getPath: function(path) { - if (!path || typeof path !== 'string' || path[0] != '/') { - return ''; - } - var last_slash = path.lastIndexOf('/'); - return (last_slash!=0)?path.substr(0,last_slash):'/'; - } -}; http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/initialize.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/initialize.js b/contrib/views/slider/src/main/resources/ui/app/initialize.js deleted file mode 100755 index 03fd52a..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/initialize.js +++ /dev/null @@ -1,171 +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. - */ - -'use strict'; - -window.App = require('config/app'); - -require('config/router'); -require('config/store'); -require('translations'); -require('mappers/mapper'); - -App.initializer({ - name: "preload", - - initialize: function(container, application) { - var viewId = 'SLIDER'; - var viewVersion = '1.0.0'; - var instanceName = 'SLIDER_1'; - if (location.pathname != null) { - var splits = location.pathname.split('/'); - if (splits != null && splits.length > 4) { - viewId = splits[2]; - viewVersion = splits[3]; - instanceName = splits[4]; - } - } - - application.reopen({ - /** - * Test mode is automatically enabled if running on brunch server - * @type {bool} - */ - testMode: (location.port == '3333'), - - /** - * @type {string} - */ - name: viewId, - - /** - * Slider version - * @type {string} - */ - version: viewVersion, - - /** - * @type {string} - */ - instance: instanceName, - - /** - * @type {string} - */ - label: instanceName, - - /** - * @type {string|null} - */ - description: null, - - /** - * API url for Slider - * Format: - * <code>/api/v1/views/[VIEW_NAME]/versions/[VERSION]/instances/[INSTANCE_NAME]/</code> - * @type {string} - */ - urlPrefix: function() { - return '/api/v1/views/%@1/versions/%@2/instances/%@3/'.fmt(this.get('name'), this.get('version'), this.get('instance')); - }.property('name', 'version', 'instance'), - - /** - * Should Slider View be enabled - * @type {bool} - */ - viewEnabled: false, - - /** - * Should Slider View be disabled - * @type {bool} - */ - viewDisabled: Em.computed.not('viewEnabled'), - - /** - * List of errors - * @type {string[]} - */ - viewErrors: [], - - /** - * Host with Metrics Server (AMBARI_METRICS) - * @type {string|null} - */ - metricsHost: null, - - /** - * Port of Metrics Server (AMBARI_METRICS port) - * @type {array|null} - */ - metricsPort: null, - - /** - * Last time when mapper ran - * @type {null|number} - */ - mapperTime: null, - - /** - * Default java_home value for Slider View instance - * @type {string|null} - */ - javaHome: null - - }); - if(!window.QUnit) { - var sliderController = application.__container__.lookup('controller:Slider'); - sliderController.getViewDisplayParameters().done(function() { - sliderController.run('initResources'); - }).fail(function(){ - // If initial view-listing failed, it might be due to bad previous-configs. - // We will initialize '/resources/status' to load configs again, and then - // attempt one more time to load view parameters. - sliderController.touchViewStatus().done(function() { - sliderController.getViewDisplayParameters().done(function() { - sliderController.run('initResources'); - }); - }); - }); - application.ApplicationTypeMapper.load(); - application.SliderAppsMapper.run('load'); - } - } -}); - -// Load all modules in order automatically. Ember likes things to work this -// way so everything is in the App.* namespace. -var folderOrder = [ - 'initializers', 'mixins', 'routes', 'models', 'mappers', - 'views', 'controllers', 'helpers', - 'templates', 'components' - ]; - -folderOrder.forEach(function(folder) { - window.require.list().filter(function(module) { - return new RegExp('^' + folder + '/').test(module); - }).forEach(function(module) { - require(module); - }); -}); - -$.ajaxSetup({ - cache : false, - headers : { - "X-Requested-By" : "X-Requested-By" - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mappers/application_type.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/application_type.js b/contrib/views/slider/src/main/resources/ui/app/mappers/application_type.js deleted file mode 100644 index 9fff2e3..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mappers/application_type.js +++ /dev/null @@ -1,162 +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. - */ - -/** - * Mapper for <code>App.SliderAppType</code> and <code>App.SliderAppComponent</code> models - * For nested models: - * <ul> - * <li> - * Define property (P1) started with '$' in <code>map</code> (example - $components). - * </li> - * <li> - * Define property componentsMap (P1 without '$' and with suffix 'Map'). - * It is used as map for nested models - * </li> - * <li> - * Define property componentsParentField (P1 without '$' and with suffix 'ParentField'). - * It is used as property in nested model to link it with parent model - * </li> - * </ul> - * @type {App.Mapper} - */ -App.ApplicationTypeMapper = App.Mapper.create({ - - /** - * Map for parsing JSON received from server - * Format: - * <code> - * { - * key1: 'path1', - * key2: 'path2', - * key3: 'path3' - * } - * </code> - * Keys - names for properties in App - * Values - pathes in JSON - * @type {object} - */ - map: { - id: 'id', - configs: 'typeConfigs', - typeName: 'typeName', - typeVersion: 'typeVersion', - index: 'id', - description: 'typeDescription', - version: 'typeVersion', - /** - * Map array to nested models - * Use <code>('$components').replace('$', '') + 'Map'</code> property as map - * Use <code>('$components').replace('$', '') + 'Model'</code> property as model to save data - */ - $components: 'typeComponents' - }, - - /** - * Map for <code>App.SliderAppTypeComponent</code> - * @type {object} - */ - componentsMap: { - id: 'id', - name: 'name', - displayName: 'displayName', - defaultNumInstances: 'instanceCount', - defaultYARNMemory: 'yarnMemory', - defaultYARNCPU: 'yarnCpuCores', - priority: 'priority' - }, - - /** - * Nested model name - <code>App.SliderAppTypeComponent</code> - * @type {string} - */ - componentsModel: 'sliderAppTypeComponent', - - /** - * Field in <code>App.SliderAppTypeComponent</code> with parent model link - * @type {string} - */ - componentsParentField: 'appType', - - /** - * Load data from <code>App.urlPrefix + this.urlSuffix</code> one time - * @method load - * @return {$.ajax} - */ - load: function() { - console.log('App.ApplicationTypeMapper loading data'); - return App.ajax.send({ - name: 'mapper.applicationTypes', - sender: this, - success: 'parse' - }); - }, - - /** - * Parse loaded data according to <code>map</code> - * Load <code>App.SliderAppType</code> models - * @param {object} data received from server data - * @method parse - */ - parse: function(data) { - var map = this.get('map'), - app_types = [], - self = this; - data.items.forEach(function(app_type) { - var model = {}; - Ember.keys(map).forEach(function(key) { - // Property should be parsed as array of nested models - if ('$' == key[0]) { - var k = key.replace('$', ''); - var components = self.parseNested(Ember.get(app_type, map[key]), k, app_type.id); - // save nested models and then link them with parent model - App.SliderApp.store.pushMany(self.get(k + 'Model'), components); - Ember.set(model, k, components.mapProperty('id')); - } - else { - Ember.set(model, key, Ember.getWithDefault(app_type, map[key], '')); - } - }); - app_types.pushObject(model); - }); - App.SliderApp.store.pushMany('sliderAppType', app_types); - }, - - /** - * Parse array of objects as list of nested models - * @param {object[]} data data to parse - * @param {string} k property name - * @param {string} parentId parent model's id - * @return {object[]} mapped models - * @method parseNested - */ - parseNested: function(data, k, parentId) { - var models = [], - map = this.get(k + 'Map'), - parentField = this.get(k + 'ParentField'); - data.forEach(function(item) { - var model = {id: item.id}; - model[parentField] = parentId; // link to parent model - Ember.keys(map).forEach(function(key) { - Ember.set(model, key, Ember.getWithDefault(item, map[key], '')); - }); - models.pushObject(model); - }); - return models; - } - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mappers/mapper.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/mapper.js deleted file mode 100644 index 2f985eb..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mappers/mapper.js +++ /dev/null @@ -1,56 +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. - */ - -/** - * Common mapper-object - * Extending this object you should implement <code>load</code> and <code>parse</code> methods - * @type {Ember.Object} - */ -App.Mapper = Ember.Object.extend({ - - /** - * Map for parsing JSON received from server - * Format: - * <code> - * { - * key1: 'path1', - * key2: 'path2', - * key3: 'path3' - * } - * </code> - * Keys - names for properties in object - * Values - pathes in JSON - * @type {object} - */ - map: {}, - - /** - * Load data from <code>App.urlPrefix + this.urlSuffix</code> - * @method load - */ - load: Ember.required(Function), - - /** - * Parse loaded data according to <code>map</code> - * Set <code>App</code> properties - * @param {object} data received data - * @method parse - */ - parse: Ember.required(Function) - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js deleted file mode 100644 index 95750ce..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js +++ /dev/null @@ -1,292 +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. - */ - -/** - * Mapper for <code>App.SliderApp</code> and <code>App.QuickLink</code> models - * @type {App.Mapper} - */ -App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, { - - /** - * List of app state display names - */ - stateMap: { - 'FROZEN': 'STOPPED', - 'THAWED': 'RUNNING' - }, - - /** - * @type {bool} - */ - isWarningPopupShown: false, - - /** - * @type {bool} - */ - isChained: true, - /** - * Load data from <code>App.urlPrefix + this.urlSuffix</code> one time - * @method load - * @return {$.ajax} - */ - load: function () { - var self = this; - var dfd = $.Deferred(); - - App.ajax.send({ - name: 'mapper.applicationApps', - sender: this, - success: 'parse' - }).fail(function(jqXHR, textStatus){ - App.__container__.lookup('controller:application').set('hasConfigErrors', true); - if (!self.get('isWarningPopupShown')) { - var message = textStatus === "timeout" ? "timeout" : jqXHR.responseText; - self.set('isWarningPopupShown', true); - window.App.__container__.lookup('controller:SliderApps').showUnavailableAppsPopup(message); - } - }).complete(function(){ - dfd.resolve(); - }); - return dfd.promise(); - }, - - /** - * close warning popup if apps became available - * @return {*} - */ - closeWarningPopup: function() { - if (Bootstrap.ModalManager.get('apps-warning-modal')) { - Bootstrap.ModalManager.close('apps-warning-modal'); - } - }, - - /** - * Parse loaded data - * Load <code>App.Alert</code> model - * @param {object} data received from server data - * @method parse - */ - parseAlerts: function (data) { - var alerts = [], - appId = data.id; - - if (data.alerts && data.alerts.detail) { - data.alerts.detail.forEach(function (alert) { - alerts.push({ - id: appId + alert.description, - title: alert.description, - serviceName: alert.service_name, - status: alert.status, - message: alert.output, - hostName: alert.host_name, - lastTime: alert.status_time, - appId: appId, - lastCheck: alert.last_status_time - }); - }); - alerts = alerts.sortBy('title'); - App.SliderApp.store.pushMany('sliderAppAlert', alerts); - } - return alerts.mapProperty('id'); - }, - - /** - * Parse loaded data - * Load <code>App.SliderAppComponent</code> model - * @param {object} data received from server data - * @method parse - */ - parseComponents: function (data) { - var components = [], - appId = data.id; - - Object.keys(data.components).forEach(function (key) { - var component = data.components[key], - activeContainers = Object.keys(component.activeContainers); - for (var i = 0; i < component.instanceCount; i++) { - components.pushObject( - Ember.Object.create({ - id: appId + component.componentName + i, - status: activeContainers[i] ? "Running" : "Stopped", - host: activeContainers[i] ? component.activeContainers[activeContainers[i]].host : "", - containerId: activeContainers[i] ? component.activeContainers[activeContainers[i]].name : "", - componentName: component.componentName, - appId: appId - }) - ); - } - }); - App.SliderApp.store.pushMany('sliderAppComponent', components); - return components.mapProperty('id'); - }, - - /** - * Parse loaded data - * Load <code>App.SliderApp.configs</code> model - * @param {object} data received from server data - * @method parse - */ - parseConfigs: function (data) { - var configs = {}; - Object.keys(data.configs).forEach(function (key) { - configs[key] = data.configs[key]; - }); - return configs; - }, - - /** - * Parse loaded data - * Load <code>App.QuickLink</code> model - * @param {object} data received from server data - * @method parse - */ - parseQuickLinks : function(data) { - var quickLinks = [], - appId = data.id, - yarnAppId = appId, - index = appId.lastIndexOf('_'); - if (index > 0) { - yarnAppId = appId.substring(0, index + 1); - for (var k = (appId.length - index - 1); k < 4; k++) { - yarnAppId += '0'; - } - yarnAppId += appId.substring(index + 1); - } - var yarnUI = "http://"+window.location.hostname+":8088", - viewConfigs = App.SliderApp.store.all('sliderConfig'); - if (!Em.isNone(viewConfigs)) { - var viewConfig = viewConfigs.findBy('viewConfigName', 'yarn.rm.webapp.url'); - if (!Em.isNone(viewConfig)) { - yarnUI = 'http://' + viewConfig.get('value'); - } - } - quickLinks.push( - Ember.Object.create({ - id: 'YARN application ' + yarnAppId, - label: 'YARN application', - url: yarnUI + '/cluster/app/application_' + yarnAppId - }) - ); - - if(!data.urls){ - App.SliderApp.store.pushMany('QuickLink', quickLinks); - return quickLinks.mapProperty('id'); - } - - Object.keys(data.urls).forEach(function (key) { - quickLinks.push( - Ember.Object.create({ - id: appId+key, - label: key, - url: data.urls[key] - }) - ); - }); - App.SliderApp.store.pushMany('QuickLink', quickLinks); - return quickLinks.mapProperty('id'); - }, - - parseObject: function (o) { - if (Ember.typeOf(o) !== 'object') return []; - return Ember.keys(o).map(function (key) { - return {key: key, value: o[key]}; - }); - }, - - /** - * Concatenate <code>supportedMetrics</code> into one string - * @param {object} app - * @returns {string} - * @method parseMetricNames - */ - parseMetricNames : function(app) { - if (app.supportedMetrics) { - return app.supportedMetrics.join(","); - } - return ""; - }, - - /** - * Parse loaded data - * Load <code>App.SliderApp</code> model - * @param {object} data received from server data - * @method parse - */ - parse: function (data) { - var apps = [], - self = this, - appsToDelete = App.SliderApp.store.all('sliderApp').mapBy('id'); - - App.__container__.lookup('controller:application').set('hasConfigErrors', false); - - if (this.get('isWarningPopupShown')) { - this.closeWarningPopup(); - this.set('isWarningPopupShown', false); - } - - data.apps.forEach(function (app) { - var componentsId = app.components ? self.parseComponents(app) : [], - configs = app.configs ? self.parseConfigs(app) : {}, - quickLinks = self.parseQuickLinks(app), - alerts = self.parseAlerts(app), - jmx = self.parseObject(app.jmx), - metricNames = self.parseMetricNames(app), - masterActiveTime = jmx.findProperty('key', 'MasterActiveTime'), - masterStartTime = jmx.findProperty('key', 'MasterStartTime'); - if (masterActiveTime) { - masterActiveTime.value = new Date(Date.now() - masterActiveTime.value).getHours() + "h:" + new Date(Date.now() - masterActiveTime.value).getMinutes() + "m"; - } - if (masterStartTime) { - masterStartTime.value = (new Date(parseInt(masterStartTime.value)).toUTCString()); - } - apps.push( - Ember.Object.create({ - id: app.id, - yarnId: app.yarnId, - name: app.name, - status: app.state, - displayStatus: self.stateMap[app.state] || app.state, - user: app.user, - started: app.startTime || 0, - ended: app.endTime || 0, - appType: app.typeId, - diagnostics: app.diagnostics || "-", - description: app.description || "-", - components: componentsId, - quickLinks: quickLinks, - alerts: alerts, - configs: configs, - jmx: jmx, - runtimeProperties: app.configs, - supportedMetricNames: metricNames - }) - ); - - appsToDelete = appsToDelete.without(app.id); - }); - appsToDelete.forEach(function (app) { - var appRecord = App.SliderApp.store.getById('sliderApp', app); - if (appRecord) { - appRecord.deleteRecord(); - } - }); - apps.forEach(function(app) { - App.SliderApp.store.push('sliderApp', app, true); - }); - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mixins/ajax_error_handler.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mixins/ajax_error_handler.js b/contrib/views/slider/src/main/resources/ui/app/mixins/ajax_error_handler.js deleted file mode 100644 index 90614b5..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mixins/ajax_error_handler.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Attach default error handler on error of Ajax calls - * To correct work should be mixed with Controller or View instance - * Example: - * <code> - * var obj = Ember.Controller.extend(App.AjaxErrorHandler, { - * callToServer: function() { - * App.ajax.send(config); - * } - * }); - * if ajax config doesn't have error handler then the default hanlder will be established - * </code> - * @type {Ember.Mixin} - */ -App.AjaxErrorHandler = Ember.Mixin.create({ - /** - * flag to indicate whether popup with ajax already opened to avoid popup overlaying - */ - errorPopupShown: false, - /** - * defaultErrorHandler function is referred from App.ajax.send function - * @jqXHR {jqXHR Object} - * @url {string} - * @method {String} Http method - * @showErrorPopup {boolean} - */ - defaultErrorHandler: function (jqXHR, url, method, showErrorPopup) { - var self = this; - method = method || 'GET'; - var context = this.get('isController') ? this : (this.get('isView') && this.get('controller')); - try { - var json = $.parseJSON(jqXHR.responseText); - var message = json.message; - } catch (err) { - } - - if (!context) { - console.warn('WARN: App.AjaxErrorHandler should be used only for views and controllers'); - return; - } - if (showErrorPopup && !this.get('errorPopupShown')) { - Bootstrap.ModalManager.open( - "ajax-error-modal", - Em.I18n.t('common.error'), - Ember.View.extend({ - classNames: ['api-error'], - templateName: 'common/ajax_error', - api: Em.I18n.t('ajax.apiInfo').format(method, url), - statusCode: Em.I18n.t('ajax.statusCode').format(jqXHR.status), - message: message, - showMessage: !!message, - willDestroyElement: function () { - self.set('errorPopupShown', false); - } - }), - [ - Ember.Object.create({title: Em.I18n.t('ok'), dismiss: 'modal', type: 'success'}) - ], - context - ); - this.set('errorPopupShown', true); - } - } -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mixins/run_periodically.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mixins/run_periodically.js b/contrib/views/slider/src/main/resources/ui/app/mixins/run_periodically.js deleted file mode 100644 index 68bfc3f..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mixins/run_periodically.js +++ /dev/null @@ -1,109 +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. - */ - -/** - * Allow to run object method periodically and stop it - * Example: - * <code> - * var obj = Ember.Object.createWithMixins(App.RunPeriodically, { - * method: Ember.K - * }); - * obj.set('interval', 10000); // override default value - * obj.loop('method'); // run periodically - * obj.stop(); // stop running - * </code> - * @type {Ember.Mixin} - */ -App.RunPeriodically = Ember.Mixin.create({ - - /** - * Interval for loop - * @type {number} - */ - interval: 5000, - - /** - * setTimeout's return value - * @type {number} - */ - timer: null, - - /** - * flag to indicate whether each call should be chained to previous one - * @type {bool} - */ - isChained: false, - - /** - * Run <code>methodName</code> periodically with <code>interval</code> - * @param {string} methodName method name to run periodically - * @param {bool} initRun should methodName be run before setInterval call (default - true) - * @method run - */ - run: function(methodName, initRun) { - initRun = Em.isNone(initRun) ? true : initRun; - var self = this, - interval = this.get('interval'); - Ember.assert('Interval should be numeric and greated than 0', $.isNumeric(interval) && interval > 0); - if (initRun) { - this[methodName](); - } - - if (this.get('isChained')) { - this.loop(self, methodName, interval); - } else { - this.set('timer', - setInterval(function () { - self[methodName](); - }, interval) - ); - } - }, - - /** - * Start chain of calls of <code>methodName</code> with <code>interval</code> - * next call made only after previous is finished - * callback should return deffered object to run next loop - * @param {object} context - * @param {string} methodName method name to run periodically - * @param {number} interval - * @method loop - */ - loop: function (context, methodName, interval) { - var self = this; - this.set('timer', - setTimeout(function () { - context[methodName]().done(function () { - self.loop(context, methodName, interval); - }); - }, interval) - ); - }, - - /** - * Stop running <code>timer</code> - * @method stop - */ - stop: function() { - var timer = this.get('timer'); - if (!Em.isNone(timer)) { - clearTimeout(timer); - } - } - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/mixins/with_panels.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mixins/with_panels.js b/contrib/views/slider/src/main/resources/ui/app/mixins/with_panels.js deleted file mode 100644 index 972834f..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/mixins/with_panels.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. - */ - -/** - * Mixin for views that use Bootstrap.BsPanelComponent component - * Add caret for collapsed/expanded panels at the left of panel's title - * Usage: - * <code> - * App.SomeView = Em.View.extend(App.WithPanels, { - * didInsertElement: function() { - * this.addCarets(); - * } - * }); - * </code> - * @type {Em.Mixin} - */ -App.WithPanels = Ember.Mixin.create({ - - /** - * Add caret before panel's title and add handlers for expand/collapse events - * Set caret-down when panel is expanded - * Set caret-right when panel is collapsed - * @method addArrows - */ - addCarets: function() { - var panel = $('.panel'); - panel.find('.panel-heading').prepend('<span class="pull-left icon icon-caret-right"></span>'); - panel.find('.panel-collapse.collapse.in').each(function() { - $(this).parent().find('.icon.icon-caret-right:first-child').addClass('icon-caret-down').removeClass('icon-caret-right'); - }); - panel.on('hidden.bs.collapse', function (e) { - $(e.delegateTarget).find('span.icon').addClass('icon-caret-right').removeClass('icon-caret-down'); - }).on('shown.bs.collapse', function (e) { - $(e.delegateTarget).find('span.icon').addClass('icon-caret-down').removeClass('icon-caret-right'); - }); - } - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/.gitkeep ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/.gitkeep b/contrib/views/slider/src/main/resources/ui/app/models/.gitkeep deleted file mode 100755 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/config_property.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/config_property.js b/contrib/views/slider/src/main/resources/ui/app/models/config_property.js deleted file mode 100644 index 625dfec..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/config_property.js +++ /dev/null @@ -1,47 +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. - */ - - -/** - * Config property - * @type {object} - */ -App.ConfigProperty = Em.Object.extend({ - name: null, - value: null, - label: "", - viewType: null, - view: function () { - switch (this.get('viewType')) { - case 'checkbox': - return Em.Checkbox; - case 'select': - return Em.Select; - default: - return Em.TextField; - } - }.property('viewType'), - className: function () { - return "value-for-" + this.get('label').replace(/\./g, "-"); - }.property('viewType'), - readOnly: false, - //used for config with "select" view - options: [], - //indicate whether it single config or set of configs - isSet: false -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/host.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/host.js b/contrib/views/slider/src/main/resources/ui/app/models/host.js deleted file mode 100644 index 19269c2..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/host.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. - */ - -App.Host = DS.Model.extend({ - - /** - * @type {string} - */ - hostName: DS.attr('string'), - - /** - * @type {string} - */ - publicHostName: DS.attr('string') - -}); - -App.Host.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js deleted file mode 100644 index de31dfc..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js +++ /dev/null @@ -1,207 +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.SliderApp = DS.Model.extend({ - - /** - * @type {string} - */ - yarnId: DS.attr('string'), - - /** - * @type {string} - */ - name: DS.attr('string'), - - /** - * @type {status} - */ - status: DS.attr('string'), - - /** - * Status before performed action - * @type {string} - */ - statusBeforeAction: DS.attr('string'), - - /** - * @type {displayStatus} - */ - displayStatus: DS.attr('string'), - - /** - * @type {string} - */ - user: DS.attr('string'), - - /** - * @type {number} - */ - started: DS.attr('number'), - - /** - * @type {boolean} - */ - isActionPerformed: DS.attr('boolean'), - - /** - * @type {boolean} - */ - isActionFinished: function() { - return this.get('status') != this.get('statusBeforeAction'); - }.property('statusBeforeAction', 'status'), - - /** - * @type {String} - */ - - startedToLocalTime: function () { - var started = this.get('started'); - return started ? moment(started).format('ddd, DD MMM YYYY, HH:mm:ss Z [GMT]') : '-'; - }.property('started'), - - /** - * @type {number} - */ - ended: DS.attr('number'), - - /** - * @type {String} - */ - - endedToLocalTime: function () { - var ended = this.get('ended'); - return ended ? moment(ended).format('ddd, DD MMM YYYY, HH:mm:ss Z [GMT]') : '-'; - }.property('ended'), - - /** - * @type {App.SliderAppType} - */ - appType: DS.belongsTo('sliderAppType'), - - /** - * @type {string} - */ - - description: DS.attr('string'), - /** - * @type {string} - */ - diagnostics: DS.attr('string'), - - /** - * @type {App.SliderAppComponent[]} - */ - components: DS.hasMany('sliderAppComponent', {async: true}), - - /** - * @type {App.QuickLink[]} - */ - quickLinks: DS.hasMany('quickLink', {async: true}), - - /** - * @type {App.SliderAppAlert[]} - */ - alerts: DS.hasMany('sliderAppAlert', {async: true}), - - /** - * @type {App.TypedProperty[]} - */ - runtimeProperties: DS.hasMany('typedProperty', {async: true}), - - /** - * @type {object} - * Format: - * { - * site-name1: { - * config1: value1, - * config2: value2 - * ... - * }, - * site-name2: { - * config3: value5, - * config4: value6 - * ... - * }, - * ... - * } - */ - configs: DS.attr('object'), - - jmx: DS.attr('object'), - - supportedMetricNames: DS.attr('string'), - - /** - * Config categories, that should be hidden on app page - * @type {string[]} - */ - hiddenCategories: [], - - /** - * @type {boolean} - */ - doNotShowComponentsAndAlerts: function () { - return this.get('status') == "FROZEN" || this.get('status') == "FAILED"; - }.property('status', 'components', 'alerts'), - - /** - * Display metrics only for running apps - * Also don't display if metrics don't exist - * @type {boolean} - */ - showMetrics: function () { - if (!this.get('supportedMetricNames.length')) return false; - if (App.get('metricsHost') != null) { - return true; - } - return App.SliderApp.Status.running === this.get('status'); - }.property('status', 'configs', 'supportedMetricNames'), - - /** - * Map object to array - * @param {object} o - * @returns {{key: string, value: *}[]} - */ - mapObject: function (o) { - if (Ember.typeOf(o) !== 'object') return []; - return Ember.keys(o).map(function (key) { - return { - key: key, - value: o[key], - isMultiline: o[key].indexOf("\n") !== -1 || o[key].length > 100 - }; - }); - } - -}); - -App.SliderApp.FIXTURES = []; - -App.SliderApp.Status = { - accepted: "ACCEPTED", - failed: "FAILED", - finished: "FINISHED", - killed: "KILLED", - new: "NEW", - new_saving: "NEW_SAVING", - running: "RUNNING", - submitted: "SUBMITTED", - frozen: "FROZEN", - stopped: "STOPPED" -}; http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_app_alert.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_alert.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_alert.js deleted file mode 100644 index f62c3ab..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_alert.js +++ /dev/null @@ -1,149 +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.SliderAppAlert = DS.Model.extend({ - /** - * @type {string} - */ - title: DS.attr('string'), - - /** - * @type {string} - */ - serviceName: DS.attr('string'), - - /** - * @type {string} - */ - status: DS.attr('string'), - - /** - * @type {string} - */ - message: DS.attr('string'), - - /** - * @type {string} - */ - hostName: DS.attr('string'), - - /** - * @type {number} - */ - lastTime: DS.attr('number'), - - /** - * @type {number} - */ - lastCheck: DS.attr('number'), - - /** - * @type {App.SliderApp} - */ - appId: DS.belongsTo('sliderApp'), - - /** - * @type {string} - */ - iconClass: function () { - var statusMap = Em.Object.create({ - 'OK': 'icon-ok', - 'WARNING': 'icon-warning-sign', - 'CRITICAL': 'icon-remove', - 'PASSIVE': 'icon-medkit' - }); - return statusMap.getWithDefault(this.get('status'), 'icon-question-sign'); - }.property('status'), - - /** - * @type {object} - */ - date: function () { - return DS.attr.transforms.date.from(this.get('lastTime')); - }.property('lastTime'), - - /** - * Provides how long ago this alert happened. - * - * @type {String} - */ - timeSinceAlert: function () { - var d = this.get('date'); - var timeFormat; - var statusMap = Em.Object.create({ - 'OK': 'OK', - 'WARNING': 'WARN', - 'CRITICAL': 'CRIT', - 'PASSIVE': 'MAINT' - }); - var messageKey = statusMap.getWithDefault(this.get('status'), 'UNKNOWN'); - - if (d) { - timeFormat = Em.I18n.t('sliderApp.alerts.' + messageKey + '.timePrefix'); - var prevSuffix = $.timeago.settings.strings.suffixAgo; - $.timeago.settings.strings.suffixAgo = ''; - var since = timeFormat.format($.timeago(this.makeTimeAtleastMinuteAgo(d))); - $.timeago.settings.strings.suffixAgo = prevSuffix; - return since; - } else if (d == 0) { - timeFormat = Em.I18n.t('sliderApp.alerts.' + messageKey + '.timePrefixShort'); - return timeFormat; - } else { - return ""; - } - }.property('date', 'status'), - - /** - * - * @param d - * @return {object} - */ - makeTimeAtleastMinuteAgo: function (d) { - var diff = (new Date).getTime() - d.getTime(); - if (diff < 60000) { - diff = 60000 - diff; - return new Date(d.getTime() - diff); - } - return d; - }, - - /** - * Provides more details about when this alert happened. - * - * @type {String} - */ - timeSinceAlertDetails: function () { - var details = ""; - var date = this.get('date'); - if (date) { - var dateString = date.toDateString(); - dateString = dateString.substr(dateString.indexOf(" ") + 1); - dateString = Em.I18n.t('sliderApp.alerts.occurredOn').format(dateString, date.toLocaleTimeString()); - details += dateString; - } - var lastCheck = this.get('lastCheck'); - if (lastCheck) { - lastCheck = new Date(lastCheck * 1000); - details = details ? details + Em.I18n.t('sliderApp.alerts.brLastCheck').format($.timeago(lastCheck)) : Em.I18n.t('sliderApp.alerts.lastCheck').format($.timeago(lastCheck)); - } - return details; - }.property('lastCheck', 'date') - -}); - -App.SliderAppAlert.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js deleted file mode 100644 index 6a577c2..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js +++ /dev/null @@ -1,65 +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.SliderAppComponent = DS.Model.extend({ - - /** - * @type {string} - */ - status: DS.attr('string'), - - /** - * @type {string} - */ - host: DS.attr('string'), - - /** - * @type {string} - */ - componentName: DS.attr('string'), - - /** - * @type {string} - */ - containerId: DS.attr('string'), - - /** - * @type {App.SliderApp} - */ - appId: DS.belongsTo('sliderApp'), - - /** - * Is component running (used in the templates) - * @type {bool} - */ - isRunning: function() { - return this.get('status') === 'Running'; - }.property('status'), - - url: function() { - var host = this.get('host'); - var containerId = this.get('containerId'); - if (host != null && containerId != null) { - return "http://" + this.get('host') + ":8042/node/container/" + this.get('containerId'); - } - return null; - }.property('host', 'containerId') - -}); - -App.SliderAppComponent.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js deleted file mode 100644 index cb376bc..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js +++ /dev/null @@ -1,64 +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.SliderAppType = DS.Model.extend({ - - /** - * @type {string} - */ - index: DS.attr('string'), - - /** - * @type {string} - */ - typeName: DS.attr('string'), - - /** - * @type {string} - */ - typeVersion: DS.attr('string'), - - /** - * @type {App.SliderAppTypeComponent[]} - */ - components: DS.hasMany('sliderAppTypeComponent'), - - /** - * @type {string} - */ - description: DS.attr('string'), - - /** - * @type {string} - */ - version: DS.attr('string'), - - /** - * @type {object} - */ - configs: DS.attr('object'), - - displayName : function() { - var typeName = this.get('typeName'); - var typeVersion = this.get('typeVersion'); - return (typeName == null ? '' : typeName) + " (" - + (typeVersion == null ? '' : typeVersion) + ")" - }.property('typeName', 'typeVersion') -}); - -App.SliderAppType.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js deleted file mode 100644 index 1576b04..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -App.SliderAppTypeComponent = DS.Model.extend({ - - /** - * @type {string} - */ - index: DS.attr('string'), // (app-type + name) - - /** - * @type {string} - */ - name: DS.attr('string'), - - /** - * @type {string} - */ - displayName: DS.attr('string'), - - /** - * @type {number} - */ - defaultNumInstances: DS.attr('number'), - - /** - * @type {number} - */ - defaultYARNMemory: DS.attr('number'), - - /** - * @type {number} - */ - defaultYARNCPU: DS.attr('number'), - - /** - * @type {App.SliderAppType} - */ - appType: DS.belongsTo('sliderAppType'), - - /** - * @type {number} - */ - priority: DS.attr('string') - -}); - -App.SliderAppTypeComponent.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js deleted file mode 100644 index b1b2129..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Slider config-property (see Ambari-Admin view-settings) - * Also see <code>view.xml</code> - * @type {DS.Model} - */ -App.SliderConfig = DS.Model.extend({ - - /** - * Name in the Ambari-Admin - * @type {string} - */ - viewConfigName: DS.attr('string'), - - /** - * Shown name - * @type {string} - */ - displayName: DS.attr('string'), - - /** - * @type {null|string} - */ - value: null - -}); - -App.SliderConfig.FIXTURES = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js deleted file mode 100644 index d526ee7..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.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. - */ - -App.QuickLink = DS.Model.extend({ - - /** - * @type {string} - */ - label: DS.attr('string'), - - /** - * @type {string} - */ - url: DS.attr('string') - -}); - -App.QuickLink.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js b/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js deleted file mode 100644 index 3c7e919..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -App.TypedProperty = DS.Model.extend({ - - /** - * @type {string} - */ - key: DS.attr('string'), - - /** - * @type {string} - */ - value: DS.attr('string'), - - /** - * @type {string} - */ - type: DS.attr('string') // (one of 'date', 'host') - -}); - -App.TypedProperty.FIXTURES = []; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/routes/create_app_wizard.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/routes/create_app_wizard.js b/contrib/views/slider/src/main/resources/ui/app/routes/create_app_wizard.js deleted file mode 100644 index de1f52d..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/routes/create_app_wizard.js +++ /dev/null @@ -1,54 +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.CreateAppWizardRoute = Ember.Route.extend({ - - controller: null, - - setupController: function (controller) { - this.set('controller', controller); - }, - - actions: { - nextStep: function () { - this.get('controller').nextStep(); - }, - - prevStep: function () { - this.get('controller').prevStep(); - } - } -}); - -App.CreateAppWizardStep1Route = Em.Route.extend({ - - setupController: function(controller, model) { - controller.set('model', model); - controller.initializeNewApp(); - controller.loadAvailableTypes(); - } - -}); - -App.CreateAppWizardStep2Route = Em.Route.extend({ - - setupController: function(controller, model) { - controller.set('model', model); - controller.initializeNewApp(); - } - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/app/routes/main.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/routes/main.js b/contrib/views/slider/src/main/resources/ui/app/routes/main.js deleted file mode 100644 index fc83860..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/routes/main.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. - */ - -App.ApplicationRoute = Ember.Route.extend({ - renderTemplate: function() { - this.render(); - var controller = this.controllerFor('tooltip-box'); - this.render("bs-tooltip-box", { - outlet: "bs-tooltip-box", - controller: controller, - into: "application" - }); - } -}); - -App.IndexRoute = Ember.Route.extend({ - - model: function () { - return this.modelFor('sliderApps'); - }, - - redirect: function () { - this.transitionTo('slider_apps'); - } - -}); - -App.SliderAppsRoute = Ember.Route.extend({ - - model: function () { - return this.store.all('sliderApp'); - }, - - - setupController: function(controller, model) { - controller.set('model', model); - - // Load sliderConfigs to storage - App.SliderApp.store.pushMany('sliderConfig', Em.A([ - Em.Object.create({id: 1, required: false, viewConfigName: 'site.global.metric_collector_host', displayName: 'metricsServer'}), - Em.Object.create({id: 2, required: false, viewConfigName: 'site.global.metric_collector_port', displayName: 'metricsPort'}), - Em.Object.create({id: 3, required: false, viewConfigName: 'site.global.metric_collector_lib', displayName: 'metricsLib'}), - Em.Object.create({id: 4, required: false, viewConfigName: 'yarn.rm.webapp.url', displayName: 'yarnRmWebappUrl'}) - ])); - }, - - actions: { - createApp: function () { - this.transitionTo('createAppWizard'); - } - } -}); - -App.SliderAppRoute = Ember.Route.extend({ - - model: function(params) { - return this.store.all('sliderApp', params.slider_app_id); - } - -}); \ No newline at end of file