• sean

    About like script in the previous version this script can be work . but in 3.7.7 have this error,
    How can I fix

    TypeError: com.serotonin.m2m2.db.dao.MailingListDao.instance.getMailingList is not a function at line: 216
    
    function sendEmail(contents,recipients){
      var zHead = g_customerName +  "-[zDCIM System Report]";
    
      var dsvo = com.serotonin.m2m2.db.dao.MailingListDao.instance.getMailingList("XID_zlabsMailList");
      var zlabsMailingList = String(dsvo).slice(13, -2);
      //print(typeof(dsvo));
      //print(dsvo);
      //print(zlabsMailingList);
    
      var dsvo1 = com.serotonin.m2m2.db.dao.MailingListDao.instance.getMailingList("XID_customerMailList");
      // print(dsvo1);
      var userMailingList = String(dsvo1).slice(13, -2);
      //print(userMailingList);
    
      var defaultMailList = "";
      if (zlabsMailingList.length > 0){defaultMailList = zlabsMailingList;}
      if (userMailingList.length > 0) {defaultMailList = defaultMailList + "," + userMailingList ; }
    
      var the_recipientMail = (typeof recipients !== 'undefined') ?  recipients : defaultMailList;
      //print(the_recipientMail);
    
      var theRecipientArray = the_recipientMail.split(',');
      //print(theRecipientArray);
    
      if (the_recipientMail.length > 0){
        var emailContent = new com.serotonin.web.mail.EmailContent(null, contents, com.serotonin.m2m2.Common.UTF8);
        //print(emailContent);
        com.serotonin.m2m2.rt.maint.work.EmailWorkItem.queueEmail(theRecipientArray, zHead, emailContent, null);
      }
    }
    

    posted in User help read more
  • sean

    I have a metal datapoint script like this

    var triggerSMSAction = false;
    var thisText = "";
    var NL = "\r\n";
    var S = my.value;
    print('my.value= '+my.value);
    //print(my);
    
    var resendMsgTimeDelay = 300;
    
    var Ptr = -1;
    var txt = "";
    
    
    
    var theSecondsDelyforSignalVerification = 30;
    
    //--mango timestamp value in milliseconds since the epoch
    var now = new Date().getTime();
    //print("now=",now);
    
    
    
    
    
    
    var o1lastValue,o1_isLeak,o1;
    o1 = getDataPointByXID("XID_MainDC_Leak_A");
    // print(o1);
    o1lastValue = o1.lastValue();
    print ("o1lastValue =",o1lastValue);
    o1_isLeak = o1lastValue.value;
    print("o1_isLeak =",o1_isLeak);
    
    
    if (o1_isLeak === true) {
        print ("now =",now);
        print ("o1LastValueTime =",o1lastValue.time);
    	timeDiff = (now - o1lastValue.time)/1000;
    	
    	print("timeDiff =",timeDiff);
    	
    	if (timeDiff <= theSecondsDelyforSignalVerification) {o1_isLeak=false;}
    }
    
    //======================================================================
    Ptr = Ptr + 1;
    if (o1_isLeak === true){
             print("o1_isLeak=",o1_isLeak);
             print ("Debug it !!");
             if (!(S & Mask[Ptr])) { // 0101 & 0100 => 0100 => true
                // do stuff
                txt = 'Delay-Alarm';
                LOG.info(txt);
    
    			S = S | Mask[Ptr] ;
    			triggerSMSAction = true;
    			thisText = thisText + txt + NL;
            }
        
     }else{
        
            if (S & Mask[Ptr]) { // 0101 & 0100 => 0100 => true
                // from true to false
                txt = 'Delay-reCover';
                LOG.info(txt);
    
    			S = S ^ Mask[Ptr] ;
    			triggerSMSAction = true;
    			thisText = thisText + txt + NL;
            }
    }
    
    function getDataPointByXID(xid) {
      var dataPoints = DataPointQuery.query("eq(xid,"+xid+")");
      if( dataPoints.length !== 1 )
      throw LOG.info("Data point with xid '" + xid + "' not found.");
      return dataPoints[0].runtime;
    }
    

    I turn the datapoint "XID_MainDC_Leak_A" value to true but in the if (o1_isLeak === true) script will not work?
    How do I do fix it?

    posted in Mango feedback read more
  • sean

    @phildunlap Phildunlap
    In the recipients = ["you@doman.extension"];
    0_1599538791554_1599538752056.jpg
    how to use mailling list like XID_ourGroupMailList this mail group in here?

    posted in Scripting general Discussion read more
  • sean

    How can change datapoint value from user module Angularjs. code like is

    app.directive("alertEvent", function(){
        return {
            restrict: "E",
          scope: {
            point: "=",
            check: "="
        },
        link: function(scope, elemnt, attrs){
            
            var audio = new Audio('/rest/v2/file-stores/public/AlarmSound.mp3');
            audio.muted = false;
            
            scope.$watch("point.value", function(newValue, oldValue){
                var P = newValue;
                var Ch = scope.check;
                
                if (P == true){
                    if (Ch == true) {
                        for (let n =0; n<10; n++){
                    setTimeout(function(){
                        audio.play();
                    },6000*n)}
                    scope.point.value = false;
                    } else {
                        audio.pause();
                    }
                } else {
                    audio.pause();
                }
            })
        }
        }
    });
    

    want to when audio.play() finished change scope.point this datapoint value to false,How to I do?

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • sean

    0_1563418245881_mango_chart.PNG
    in 3.5.6 chart only show 3 decimal number,
    But in the 3.6.1
    0_1563418328990_mango_chart361.PNG
    Decimal number is too many like a bug ?

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • sean

    @phildunlap Thnaks phildunlap. in the event handler I try to use <ma-get-point-value point-xid="XID_eventhandler" point="A_eventhandler"></ma-get-point-value> to get data point Event detectors xid,
    but use {{A_eventhandler.value}} this not anything . When this event detector trigger <div ng-class="{red:A_eventhandler.value == true}"> still nothing happen.

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • sean

    how to detector a.value | moment.duration(2, 'minutes'); if I want to use ng-class="{red: a.value > 10}"
    but must a.value keep > 10 have 2 minutes than trigger class red ?
    like datapoint Event detectors limit and duration how to code in dashboard?

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • sean

    I have a question code like

    <ma-now update-interval="15 SECONDS" output="theTimeNow"></ma-now>
    
    <ma-point-values point="point2" values="point2Values"  from="theTimeNow | maMoment:'subtract':1:'Month'" to="theTimeNow" rollup="AVERAGE" rollup-interval="1 HOURS">
    </ma-point-values>
    
    {{}}
    

    how do I code to show a point2 last value from ma-now to before a month average kind of ma-point-values filter in {{}}?
    not {{point2Values}} this way. because like pic. I need just a number.
    0_1545305671607_values.PNG

    posted in Dashboard Designer & Custom AngularJS Pages read more