source : HYSDeployment.js

  1. 'use strict';
  2. /**
  3. * This widget displays the HYS Battery Percentage available to deploy.
  4. * <p>
  5. * Example:
  6. * <p><b>
  7. * <sra-bar-gauge-h-y-s-deployment data-sra-args-show-digital-value="false"></sra-bar-gauge-h-y-s-deployment>
  8. * </b>
  9. * <img src="../widgets/BarGauge/HYSDeployment/icon.png" />
  10. * @ngdoc directive
  11. * @name sra-bar-gauge-h-y-s-deployment
  12. * @param {boolean} data-sra-args-show-digital-value Set to true or false for displaying the digital value. Defaults to true. Can be overridden from the URL with "SHOWDIGITALVALUE=false".
  13. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 50.
  14. * @author Jeffrey Gilliam
  15. * @since 1.8
  16. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  17. * @license Apache License 2.0
  18. */
  19. define(['SIMRacingApps','widgets/BarGauge/BarGauge','css!widgets/BarGauge/HYSDeployment/HYSDeployment'],
  20. function(SIMRacingApps,BarGauge) {
  21. var self = {
  22. name: "sraBarGaugeHYSDeployment",
  23. url: 'BarGauge/HYSDeployment',
  24. template: 'HYSDeployment.html',
  25. defaultWidth: 800,
  26. defaultHeight: 280,
  27. defaultInterval: 50 //initialize with the default interval
  28. };
  29. self.module = angular.module('SIMRacingApps'); //get the main module
  30. self.module.directive(self.name,
  31. ['sraDispatcher', '$filter',
  32. function(sraDispatcher, $filter) {
  33. return {
  34. restrict: 'EA',
  35. $scope: true,
  36. templateUrl: sraDispatcher.getWidgetUrl(self.url) + '/' + self.template,
  37. controller: [ '$scope', function($scope) {
  38. $scope.directiveName = self.name;
  39. $scope.defaultWidth = self.defaultWidth;
  40. $scope.defaultHeight = self.defaultHeight;
  41. $scope.defaultInterval = self.defaultInterval;
  42. }]
  43. , link: function($scope,$element,$attrs) {
  44. //copy arguments to our $scope
  45. $scope.value =
  46. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "DefaultValue");
  47. $scope.sraShowValue = sraDispatcher.getBoolean($scope.sraArgsSHOWDIGITALVALUE, $attrs.sraArgsShowDigitalValue, $attrs.sraArgsShowValue, true);
  48. //register with the dispatcher
  49. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  50. }
  51. };
  52. }]);
  53. return self;
  54. });