You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/12/09 15:51:28 UTC
svn commit: r1418988 - in /incubator/ambari/branches/AMBARI-666: ./
ambari-web/ ambari-web/app/ ambari-web/app/assets/licenses/
ambari-web/app/controllers/main/charts/
ambari-web/app/controllers/main/charts/heatmap_metrics/
ambari-web/app/styles/ ambar...
Author: yusaku
Date: Sun Dec 9 14:51:22 2012
New Revision: 1418988
URL: http://svn.apache.org/viewvc?rev=1418988&view=rev
Log:
AMBARI-1041. Additional metrics need to be added to Heatmap UI. (Srimanth Gunturi via yusaku)
Added:
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning.js
incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.js
Removed:
incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.min.js
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-web/app/assets/licenses/NOTICE.txt
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/styles/application.less
incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/main/charts/heatmap.hbs
incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js
incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Sun Dec 9 14:51:22 2012
@@ -424,6 +424,9 @@ AMBARI-666 branch (unreleased changes)
IMPROVEMENTS
+ AMBARI-1041. Additional metrics need to be added to Heatmap UI. (Srimanth
+ Gunturi via yusaku)
+
AMBARI-1040. Cluster heatmap: green should always mean "good". (Srimanth
Gunturi via yusaku)
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/assets/licenses/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/assets/licenses/NOTICE.txt?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/assets/licenses/NOTICE.txt (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/assets/licenses/NOTICE.txt Sun Dec 9 14:51:22 2012
@@ -36,4 +36,7 @@ This product incudes Rickshaw 1.1.2 (htt
Copyright (C) 2011 by Shutterstock Images, LLC
This product includes Timeago (http://timeago.yarp.com/ - MIT License)
-Copyright (c) 2008-2012, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
\ No newline at end of file
+Copyright (c) 2008-2012, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
+
+This product includes Spin.js (http://fgnass.github.com/spin.js/ - MIT license)
+Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de]
\ No newline at end of file
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers.js Sun Dec 9 14:51:22 2012
@@ -48,6 +48,16 @@ require('controllers/main/charts/heatmap
require('controllers/main/charts/heatmap_metrics/heatmap_metric_processrun');
require('controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused');
require('controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed');
require('controllers/main/charts/heatmap');
require('controllers/main/charts/horizon_chart');
require('controllers/main/rack');
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap.js Sun Dec 9 14:51:22 2012
@@ -20,11 +20,31 @@ var App = require('app');
App.MainChartsHeatmapController = Em.Controller.extend({
name: 'mainChartsHeatmapController',
cluster: App.Cluster.find(1),
- allMetrics: [ Em.Object.create({
- label: Em.I18n.t('charts.heatmap.category.host'),
- category: 'host',
- items: [ App.MainChartHeatmapDiskSpaceUsedMetric.create(), App.MainChartHeatmapMemoryUsedMetric.create() /*, App.MainChartHeatmapProcessRunMetric.create()*/ ]
- }) ],
+ allMetrics: [
+ Em.Object.create({
+ label: Em.I18n.t('charts.heatmap.category.host'),
+ category: 'host',
+ items: [ App.MainChartHeatmapDiskSpaceUsedMetric.create(),
+ App.MainChartHeatmapMemoryUsedMetric.create()
+ /*, App.MainChartHeatmapProcessRunMetric.create()*/ ]
+ }),
+ Em.Object.create({
+ label: Em.I18n.t('charts.heatmap.category.hdfs'),
+ category: 'hdfs',
+ items: [ App.MainChartHeatmapDFSBytesReadMetric.create(),
+ App.MainChartHeatmapDFSBytesWrittenMetric.create(),
+ App.MainChartHeatmapDFSGCTimeMillisMetric.create(),
+ App.MainChartHeatmapDFSMemHeapUsedMetric.create() ]
+ }),
+ Em.Object.create({
+ label: Em.I18n.t('charts.heatmap.category.mapreduce'),
+ category: 'mapreduce',
+ items: [ App.MainChartHeatmapMapreduceMapsRunningMetric.create(),
+ App.MainChartHeatmapMapreduceReducesRunningMetric.create(),
+ App.MainChartHeatmapMapreduceGCTimeMillisMetric.create(),
+ App.MainChartHeatmapMapreduceMemHeapUsedMetric.create() ]
+ })
+ ],
selectedMetric: null,
/**
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js Sun Dec 9 14:51:22 2012
@@ -58,6 +58,12 @@ App.MainChartHeatmapMetric = Em.Object.e
* {String}
*/
units: '',
+
+ /**
+ * Indicates whether this metric is currently loading data from the server.
+ * {Boolean}
+ */
+ loading: false,
/**
* Provides following information about slots in an array of objects.
@@ -114,6 +120,12 @@ App.MainChartHeatmapMetric = Em.Object.e
* definition label being '0% - 10%'.
*/
slotDefinitionLabelSuffix: '',
+
+ /**
+ * URL template from which metrics will be gotten for all hosts.
+ * The {metricName} param will be replaced by the 'defaultMetric' value.
+ */
+ metricUrlTemplate: "/clusters/{clusterName}/hosts?fields={metricName}",
/**
* URL from which data for this metric can be gotten from. This should be
@@ -123,7 +135,7 @@ App.MainChartHeatmapMetric = Em.Object.e
var clusterName = App.router.get('clusterController.clusterName');
var fixedMetricName = this.get('defaultMetric');
fixedMetricName = fixedMetricName.replace(/\./g, "/");
- return App.formatUrl(App.apiPrefix + "/clusters/{clusterName}/hosts?fields={metricName}", {
+ return App.formatUrl(App.apiPrefix + this.get('metricUrlTemplate'), {
clusterName: App.router.get('clusterController.clusterName'),
metricName: fixedMetricName
}, "/data/cluster_metrics/cpu_1hr.json");
@@ -186,12 +198,17 @@ App.MainChartHeatmapMetric = Em.Object.e
* 'hostnameToSlotObject' has key as hostname, and the slot index as value.
*/
refreshHostSlots: function () {
+ this.set('loading', true);
jQuery.ajax({
url: this.get('metricUrl'),
dataType: 'json',
+ error: jQuery.proxy(function (xhr, textStatus, error) {
+ this.set('loading', false);
+ }, this),
success: jQuery.proxy(function (data) {
var hostToValueMap = this.metricMapper(data);
this.set('hostToValueMap', hostToValueMap);
+ this.set('loading', false);
}, this)
});
}.observes('slotDefinitions'),
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,59 @@
+/**
+ * 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');
+
+/**
+ * Base class for any HDFS metric.
+ */
+App.MainChartHeatmapDFSMetrics = App.MainChartHeatmapMetric.extend({
+ metricUrlTemplate: "/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=host_components/{metricName}",
+
+ /**
+ * Custom mapper for DFS metrics
+ */
+ metricMapper: function (json) {
+ var hostToValueMap = {};
+ var metricName = this.get('defaultMetric');
+ if (json.host_components) {
+ var props = metricName.split('.');
+ transformValueFunction = this.get('transformValue');
+ json.host_components.forEach(function (hc) {
+ var value = hc;
+ props.forEach(function (prop) {
+ value = value[prop];
+ });
+
+ if (transformValueFunction) {
+ value = transformValueFunction(value);
+ }
+
+ var hostName = hc.HostRoles.host_name;
+ hostToValueMap[hostName] = value;
+ });
+ }
+ return hostToValueMap;
+ },
+
+ /**
+ * Utility function which allows extending classes to transform the value
+ * assigned to a host.
+ *
+ * @type Function
+ */
+ tranformValue: null
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.MainChartHeatmapDFSBytesReadMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Bytes Read',
+ maximumValue: 1024, // 1GB
+ defaultMetric: 'metrics.dfs.datanode.bytes_read',
+ units: 'MB',
+ slotDefinitionLabelSuffix: 'MB',
+ transformValue: function (value) {
+ return value / (1 << 6); // bytes divided by 1MB.
+ }
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.MainChartHeatmapDFSBytesWrittenMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Bytes Written',
+ maximumValue: 1024, // 1GB
+ defaultMetric: 'metrics.dfs.datanode.bytes_written',
+ units: 'MB',
+ slotDefinitionLabelSuffix: 'MB',
+ transformValue: function (value) {
+ return value / (1 << 6); // bytes divided by 1MB.
+ }
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapDFSGCTimeMillisMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Garbage Collection Time',
+ maximumValue: 10000,
+ defaultMetric: 'metrics.jvm.gcTimeMillis',
+ units: ' ms',
+ slotDefinitionLabelSuffix: ' ms'
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapDFSMemHeapUsedMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'JVM Heap Memory Used',
+ maximumValue: 512,
+ defaultMetric: 'metrics.jvm.memHeapUsedM',
+ units: 'MB',
+ slotDefinitionLabelSuffix: 'MB'
+});
\ No newline at end of file
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js Sun Dec 9 14:51:22 2012
@@ -18,15 +18,6 @@
var App = require('app');
/**
- * Base class for any heatmap metric.
- *
- * This class basically provides the following for each heatmap metric.
- * <ul>
- * <li> Provides number of slots in which temperature can fall.
- * <li> Maintains the maximum value so as to scale slot ranges.
- * <li> Gets JSON data from server and maps response for all hosts into above
- * slots.
- * </ul>
*
*/
App.MainChartHeatmapDiskSpaceUsedMetric = App.MainChartHeatmapMetric.extend({
@@ -45,11 +36,11 @@ App.MainChartHeatmapDiskSpaceUsedMetric
props.forEach(function (prop) {
value = value[prop];
});
-
+
var total = value.disk_total;
var free = value.disk_free;
- value = (((total-free)*100)/total).toFixed(1);
-
+ value = (((total - free) * 100) / total).toFixed(1);
+
var hostName = item.Hosts.host_name;
hostToValueMap[hostName] = value;
});
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,59 @@
+/**
+ * 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');
+
+/**
+ * Base class for any MapReduce metric.
+ */
+App.MainChartHeatmapMapreduceMetrics = App.MainChartHeatmapMetric.extend({
+ metricUrlTemplate: "/clusters/{clusterName}/services/MAPREDUCE/components/TASKTRACKER?fields=host_components/{metricName}",
+
+ /**
+ * Custom mapper for DFS metrics
+ */
+ metricMapper: function (json) {
+ var hostToValueMap = {};
+ var metricName = this.get('defaultMetric');
+ if (json.host_components) {
+ var props = metricName.split('.');
+ transformValueFunction = this.get('transformValue');
+ json.host_components.forEach(function (hc) {
+ var value = hc;
+ props.forEach(function (prop) {
+ value = value[prop];
+ });
+
+ if (transformValueFunction) {
+ value = transformValueFunction(value);
+ }
+
+ var hostName = hc.HostRoles.host_name;
+ hostToValueMap[hostName] = value;
+ });
+ }
+ return hostToValueMap;
+ },
+
+ /**
+ * Utility function which allows extending classes to transform the value
+ * assigned to a host.
+ *
+ * @type Function
+ */
+ tranformValue: null
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_gctime.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapMapreduceGCTimeMillisMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Garbage Collection Time',
+ maximumValue: 10000,
+ defaultMetric: 'metrics.jvm.gcTimeMillis',
+ units: ' ms',
+ slotDefinitionLabelSuffix: ' ms'
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_mapsRunning.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapMapreduceMapsRunningMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Maps Running',
+ maximumValue: 100,
+ defaultMetric: 'metrics.mapred.tasktracker.maps_running',
+ units: ' maps',
+ slotDefinitionLabelSuffix: ' Maps'
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHeapUsed.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapMapreduceMemHeapUsedMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'JVM Heap Memory Used',
+ maximumValue: 512,
+ defaultMetric: 'metrics.jvm.memHeapUsedM',
+ units: 'MB',
+ slotDefinitionLabelSuffix: 'MB'
+});
\ No newline at end of file
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_reducesRunning.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+/**
+ *
+ */
+App.MainChartHeatmapMapreduceReducesRunningMetric = App.MainChartHeatmapDFSMetrics.extend({
+ name: 'Reduces Running',
+ maximumValue: 100,
+ defaultMetric: 'metrics.mapred.tasktracker.reduces_running',
+ units: ' reduces',
+ slotDefinitionLabelSuffix: ' Reduces'
+});
\ No newline at end of file
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js Sun Dec 9 14:51:22 2012
@@ -266,9 +266,11 @@ Em.I18n.translations = {
'charts.horizon.chart.attributes.io':'I/O',
'charts.heatmap.category.host':'Host',
- 'charts.heatmap.item.host.memory':'Memory Free',
+ 'charts.heatmap.item.host.memory':'Memory Used',
'charts.heatmap.item.host.disk':'Disk Space Used',
'charts.heatmap.item.host.process':'Total Running Processes',
+ 'charts.heatmap.category.hdfs':'HDFS',
+ 'charts.heatmap.category.mapreduce': 'MapReduce',
'metric.default':'combined',
'metric.cpu':'cpu',
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/styles/application.less?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/styles/application.less Sun Dec 9 14:51:22 2012
@@ -1493,6 +1493,9 @@ ul.filter {
/*Start Heatmap*/
.heatmap {
+ #heatmap-metric-title{
+ margin-left: 23px;
+ }
.rack.rack-5-2 {
.hosts {
height: 86px;
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/main/charts/heatmap.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/main/charts/heatmap.hbs?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/main/charts/heatmap.hbs (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/main/charts/heatmap.hbs Sun Dec 9 14:51:22 2012
@@ -60,7 +60,9 @@
{{/if}}
</div>
<div class="span10">
- <h4>{{controller.selectedMetric.name}}</h4>
+ <h4 id="heatmap-metric-loading">
+ <span id="heatmap-metric-title">{{controller.selectedMetric.name}}</span>
+ </h4>
<div class="row-fluid">
{{#each rack in controller.cluster.racks}}
<div {{bindAttr class="controller.rackClass"}}>
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js Sun Dec 9 14:51:22 2012
@@ -1,29 +1,51 @@
/**
- * 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
- *
+ * 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.
+ * 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.MainChartsHeatmapView = Em.View.extend({
- templateName: require('templates/main/charts/heatmap'),
- didInsertElement: function(){
- this._super();
- // set default metric
- this.set('controller.selectedMetric', this.get('controller.allMetrics')[0].get('items')[0]);
- $("#heatmapDetailsBlock").hide();
+ templateName: require('templates/main/charts/heatmap'),
+ spinner: null,
+ didInsertElement: function () {
+ this._super();
+ // set default metric
+ this.set('controller.selectedMetric', this.get('controller.allMetrics')[0].get('items')[0]);
+ $("#heatmapDetailsBlock").hide();
+ },
+ showLoading: function () {
+ if (this.get('controller.selectedMetric.loading')) {
+ var e = document.getElementById("heatmap-metric-loading");
+ if (e) {
+ var spinOpts = {
+ lines: 9,
+ length: 4,
+ width: 2,
+ radius: 3,
+ top: '0',
+ left: '0'
+ };
+ this.set('spinner', new Spinner(spinOpts).spin(e));
+ }
+ } else {
+ var spinner = this.get('spinner');
+ if (spinner) {
+ spinner.stop();
+ }
+ this.set('spinner', null);
}
+ }.observes('controller.selectedMetric.loading')
});
\ No newline at end of file
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee?rev=1418988&r1=1418987&r2=1418988&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee Sun Dec 9 14:51:22 2012
@@ -54,7 +54,8 @@ exports.config =
'vendor/scripts/jquery.dataTables.js',
'vendor/scripts/jquery.timeago.js',
'vendor/scripts/workflow_visualization.js',
- 'vendor/scripts/rickshaw.js'
+ 'vendor/scripts/rickshaw.js',
+ 'vendor/scripts/spin.js'
]
stylesheets:
Added: incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.js?rev=1418988&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/vendor/scripts/spin.js Sun Dec 9 14:51:22 2012
@@ -0,0 +1,320 @@
+//fgnass.github.com/spin.js#v1.2.7
+!function(window, document, undefined) {
+
+ /**
+ * Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de]
+ * Licensed under the MIT license
+ */
+
+ var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
+ , animations = {} /* Animation rules keyed by their name */
+ , useCssAnimations
+
+ /**
+ * Utility function to create elements. If no tag name is given,
+ * a DIV is created. Optionally properties can be passed.
+ */
+ function createEl(tag, prop) {
+ var el = document.createElement(tag || 'div')
+ , n
+
+ for(n in prop) el[n] = prop[n]
+ return el
+ }
+
+ /**
+ * Appends children and returns the parent.
+ */
+ function ins(parent /* child1, child2, ...*/) {
+ for (var i=1, n=arguments.length; i<n; i++)
+ parent.appendChild(arguments[i])
+
+ return parent
+ }
+
+ /**
+ * Insert a new stylesheet to hold the @keyframe or VML rules.
+ */
+ var sheet = function() {
+ var el = createEl('style', {type : 'text/css'})
+ ins(document.getElementsByTagName('head')[0], el)
+ return el.sheet || el.styleSheet
+ }()
+
+ /**
+ * Creates an opacity keyframe animation rule and returns its name.
+ * Since most mobile Webkits have timing issues with animation-delay,
+ * we create separate rules for each line/segment.
+ */
+ function addAnimation(alpha, trail, i, lines) {
+ var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
+ , start = 0.01 + i/lines*100
+ , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
+ , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
+ , pre = prefix && '-'+prefix+'-' || ''
+
+ if (!animations[name]) {
+ sheet.insertRule(
+ '@' + pre + 'keyframes ' + name + '{' +
+ '0%{opacity:' + z + '}' +
+ start + '%{opacity:' + alpha + '}' +
+ (start+0.01) + '%{opacity:1}' +
+ (start+trail) % 100 + '%{opacity:' + alpha + '}' +
+ '100%{opacity:' + z + '}' +
+ '}', sheet.cssRules.length)
+
+ animations[name] = 1
+ }
+ return name
+ }
+
+ /**
+ * Tries various vendor prefixes and returns the first supported property.
+ **/
+ function vendor(el, prop) {
+ var s = el.style
+ , pp
+ , i
+
+ if(s[prop] !== undefined) return prop
+ prop = prop.charAt(0).toUpperCase() + prop.slice(1)
+ for(i=0; i<prefixes.length; i++) {
+ pp = prefixes[i]+prop
+ if(s[pp] !== undefined) return pp
+ }
+ }
+
+ /**
+ * Sets multiple style properties at once.
+ */
+ function css(el, prop) {
+ for (var n in prop)
+ el.style[vendor(el, n)||n] = prop[n]
+
+ return el
+ }
+
+ /**
+ * Fills in default values.
+ */
+ function merge(obj) {
+ for (var i=1; i < arguments.length; i++) {
+ var def = arguments[i]
+ for (var n in def)
+ if (obj[n] === undefined) obj[n] = def[n]
+ }
+ return obj
+ }
+
+ /**
+ * Returns the absolute page-offset of the given element.
+ */
+ function pos(el) {
+ var o = { x:el.offsetLeft, y:el.offsetTop }
+ while((el = el.offsetParent))
+ o.x+=el.offsetLeft, o.y+=el.offsetTop
+
+ return o
+ }
+
+ var defaults = {
+ lines: 12, // The number of lines to draw
+ length: 7, // The length of each line
+ width: 5, // The line thickness
+ radius: 10, // The radius of the inner circle
+ rotate: 0, // Rotation offset
+ corners: 1, // Roundness (0..1)
+ color: '#000', // #rgb or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 100, // Afterglow percentage
+ opacity: 1/4, // Opacity of the lines
+ fps: 20, // Frames per second when using setTimeout()
+ zIndex: 2e9, // Use a high z-index by default
+ className: 'spinner', // CSS class to assign to the element
+ top: 'auto', // center vertically
+ left: 'auto', // center horizontally
+ position: 'relative' // element position
+ }
+
+ /** The constructor */
+ var Spinner = function Spinner(o) {
+ if (!this.spin) return new Spinner(o)
+ this.opts = merge(o || {}, Spinner.defaults, defaults)
+ }
+
+ Spinner.defaults = {}
+
+ merge(Spinner.prototype, {
+ spin: function(target) {
+ this.stop()
+ var self = this
+ , o = self.opts
+ , el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
+ , mid = o.radius+o.length+o.width
+ , ep // element position
+ , tp // target position
+
+ if (target) {
+ target.insertBefore(el, target.firstChild||null)
+ tp = pos(target)
+ ep = pos(el)
+ css(el, {
+ left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
+ top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
+ })
+ }
+
+ el.setAttribute('aria-role', 'progressbar')
+ self.lines(el, self.opts)
+
+ if (!useCssAnimations) {
+ // No CSS animation support, use setTimeout() instead
+ var i = 0
+ , fps = o.fps
+ , f = fps/o.speed
+ , ostep = (1-o.opacity) / (f*o.trail / 100)
+ , astep = f/o.lines
+
+ ;(function anim() {
+ i++;
+ for (var s=o.lines; s; s--) {
+ var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity)
+ self.opacity(el, o.lines-s, alpha, o)
+ }
+ self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
+ })()
+ }
+ return self
+ },
+
+ stop: function() {
+ var el = this.el
+ if (el) {
+ clearTimeout(this.timeout)
+ if (el.parentNode) el.parentNode.removeChild(el)
+ this.el = undefined
+ }
+ return this
+ },
+
+ lines: function(el, o) {
+ var i = 0
+ , seg
+
+ function fill(color, shadow) {
+ return css(createEl(), {
+ position: 'absolute',
+ width: (o.length+o.width) + 'px',
+ height: o.width + 'px',
+ background: color,
+ boxShadow: shadow,
+ transformOrigin: 'left',
+ transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
+ borderRadius: (o.corners * o.width>>1) + 'px'
+ })
+ }
+
+ for (; i < o.lines; i++) {
+ seg = css(createEl(), {
+ position: 'absolute',
+ top: 1+~(o.width/2) + 'px',
+ transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
+ opacity: o.opacity,
+ animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
+ })
+
+ if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
+
+ ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')))
+ }
+ return el
+ },
+
+ opacity: function(el, i, val) {
+ if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
+ }
+
+ })
+
+ /////////////////////////////////////////////////////////////////////////
+ // VML rendering for IE
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Check and init VML support
+ */
+ ;(function() {
+
+ function vml(tag, attr) {
+ return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
+ }
+
+ var s = css(createEl('group'), {behavior: 'url(#default#VML)'})
+
+ if (!vendor(s, 'transform') && s.adj) {
+
+ // VML support detected. Insert CSS rule ...
+ sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
+
+ Spinner.prototype.lines = function(el, o) {
+ var r = o.length+o.width
+ , s = 2*r
+
+ function grp() {
+ return css(
+ vml('group', {
+ coordsize: s + ' ' + s,
+ coordorigin: -r + ' ' + -r
+ }),
+ { width: s, height: s }
+ )
+ }
+
+ var margin = -(o.width+o.length)*2 + 'px'
+ , g = css(grp(), {position: 'absolute', top: margin, left: margin})
+ , i
+
+ function seg(i, dx, filter) {
+ ins(g,
+ ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
+ ins(css(vml('roundrect', {arcsize: o.corners}), {
+ width: r,
+ height: o.width,
+ left: o.radius,
+ top: -o.width>>1,
+ filter: filter
+ }),
+ vml('fill', {color: o.color, opacity: o.opacity}),
+ vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
+ )
+ )
+ )
+ }
+
+ if (o.shadow)
+ for (i = 1; i <= o.lines; i++)
+ seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
+
+ for (i = 1; i <= o.lines; i++) seg(i)
+ return ins(el, g)
+ }
+
+ Spinner.prototype.opacity = function(el, i, val, o) {
+ var c = el.firstChild
+ o = o.shadow && o.lines || 0
+ if (c && i+o < c.childNodes.length) {
+ c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
+ if (c) c.opacity = val
+ }
+ }
+ }
+ else
+ useCssAnimations = vendor(s, 'animation')
+ })()
+
+ if (typeof define == 'function' && define.amd)
+ define(function() { return Spinner })
+ else
+ window.Spinner = Spinner
+
+}(window, document);