summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js112
1 files changed, 0 insertions, 112 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js
deleted file mode 100644
index c378d3b6..00000000
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/view-models/reportdashboard-page/src/components/models/WidgetModel.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2014 DataTorrent, Inc. ALL Rights Reserved.
- *
- * Licensed 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';
-
-angular.module('ui.dashboard')
- .factory('WidgetModel', function ($log) {
-
- function defaults() {
- return {
- title: 'Widget',
- style: {},
- size: {},
- enableVerticalResize: true,
- containerStyle: { width: '33%' }, // default width
- contentStyle: {}
- };
- };
-
- // constructor for widget model instances
- function WidgetModel(widgetDefinition, overrides) {
-
- // Extend this with the widget definition object with overrides merged in (deep extended).
- angular.extend(this, defaults(), _.merge(angular.copy(widgetDefinition), overrides));
-
- this.updateContainerStyle(this.style);
-
- if (!this.templateUrl && !this.template && !this.directive) {
- this.directive = widgetDefinition.name;
- }
-
- if (this.size && _.has(this.size, 'height')) {
- this.setHeight(this.size.height);
- }
-
- if (this.style && _.has(this.style, 'width')) { //TODO deprecate style attribute
- this.setWidth(this.style.width);
- }
-
- if (this.size && _.has(this.size, 'width')) {
- this.setWidth(this.size.width);
- }
- }
-
- WidgetModel.prototype = {
- // sets the width (and widthUnits)
- setWidth: function (width, units) {
- width = width.toString();
- units = units || width.replace(/^[-\.\d]+/, '') || '%';
-
- this.widthUnits = units;
- width = parseFloat(width);
-
- // check with min width if set, unit refer to width's unit
- if (this.size && _.has(this.size, 'minWidth')) {
- width = _.max([parseFloat(this.size.minWidth), width]);
- }
-
- if (width < 0 || isNaN(width)) {
- $log.warn('malhar-angular-dashboard: setWidth was called when width was ' + width);
- return false;
- }
-
- if (units === '%') {
- width = Math.min(100, width);
- width = Math.max(0, width);
- }
-
- this.containerStyle.width = width + '' + units;
-
- this.updateSize(this.containerStyle);
-
- return true;
- },
-
- setHeight: function (height) {
- this.contentStyle.height = height;
- this.updateSize(this.contentStyle);
- },
-
- setStyle: function (style) {
- this.style = style;
- this.updateContainerStyle(style);
- },
-
- updateSize: function (size) {
- angular.extend(this.size, size);
- },
-
- updateContainerStyle: function (style) {
- angular.extend(this.containerStyle, style);
- },
- serialize: function() {
- return _.pick(this, ['title', 'name', 'report_id', 'hideGrid', 'showChart' ,'rcloud_url','reportData','style', 'size', 'dataModelOptions', 'attrs', 'storageHash']);
- }
- };
-
- return WidgetModel;
- }); \ No newline at end of file