123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- /**
- * 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.WidgetEditController = App.WidgetWizardController.extend({
- name: 'widgetEditController',
- totalSteps: 2,
- content: Em.Object.create({
- controllerName: 'widgetEditController',
- widgetService: null,
- widgetType: '',
- /**
- * Example:
- * {
- * "display_unit": "%",
- * "warning_threshold": 70,
- * "error_threshold": 90
- * }
- */
- widgetProperties: {},
- /**
- * Example:
- * [{
- * widget_id: "metrics/rpc/closeRegion_num_ops",
- * name: "rpc.rpc.closeRegion_num_ops",
- * pointInTime: true,
- * temporal: true,
- * category: "default"
- * serviceName: "HBASE"
- * componentName: "HBASE_CLIENT"
- * type: "GANGLIA"//or JMX
- * level: "COMPONENT"//or HOSTCOMPONENT
- * }]
- * @type {Array}
- */
- allMetrics: [],
- /**
- * Example:
- * [{
- * "name": "regionserver.Server.percentFilesLocal",
- * "serviceName": "HBASE",
- * "componentName": "HBASE_REGIONSERVER"
- * }]
- */
- widgetMetrics: [],
- /**
- * Example:
- * [{
- * "name": "Files Local",
- * "value": "${regionserver.Server.percentFilesLocal}"
- * }]
- */
- widgetValues: [],
- expressions: [],
- dataSets: [],
- templateValue: null,
- widgetName: null,
- widgetDisplayName: null,
- widgetDescription: null,
- widgetScope: null,
- widgetId: null
- }),
- loadMap: {
- '1': [
- {
- type: 'sync',
- callback: function () {
- this.load('widgetType');
- this.load('widgetProperties');
- this.load('widgetValues');
- this.load('widgetMetrics');
- this.load('expressions');
- this.load('dataSets');
- this.load('templateValue');
- }
- },
- {
- type: 'async',
- callback: function () {
- return this.loadAllMetrics();
- }
- }
- ],
- '2': [
- {
- type: 'sync',
- callback: function () {
- this.load('widgetName');
- this.load('widgetDescription');
- this.load('widgetDisplayName');
- }
- }
- ]
- },
- /**
- * set current step
- * @param {string} currentStep
- * @param {boolean} completed
- * @param {boolean} skipStateSave
- */
- setCurrentStep: function (currentStep, completed, skipStateSave) {
- this._super(currentStep, completed);
- if (App.get('testMode') || skipStateSave) {
- return;
- }
- },
- /**
- * post widget definition to server
- * @returns {$.ajax}
- */
- putWidgetDefinition: function (data) {
- return App.ajax.send({
- name: 'widgets.wizard.edit',
- sender: this,
- data: {
- data: data,
- widgetId: this.get('content.widgetId')
- },
- success: 'putWidgetDefinitionSuccessCallback'
- });
- },
- putWidgetDefinitionSuccessCallback: function() {
- },
- /**
- * Clear all temporary data
- */
- finish: function () {
- this.setCurrentStep('1', false, true);
- this.save('widgetType', '');
- this.save('widgetService', '');
- this.save('widgetProperties', null);
- this.save('widgetMetrics', []);
- this.save('widgetValues', []);
- this.save('widgetName', '');
- this.save('widgetDescription', '');
- this.save('widgetDisplayName', '');
- this.save('widgetScope', '');
- this.save('allMetrics', []);
- this.save('expressions', []);
- this.save('dataSets', []);
- this.save('templateValue', '');
- this.resetDbNamespace();
- }
- });
|