• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Import javascript library

    Scripting general Discussion
    scipting javascript
    3
    98
    86.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      arvand.owji @phildunlap
      last edited by

      @phildunlap my permission doesnt let me to delete them. I dont have the SU password. I tried to go another route and see if ican just invoke this from linux command prompt. "curl -ls http://xxxxxxxx". It didnt work and prompt me to try the url in another browser and there i realzied that im getting error "MANGO XHR access failed". It seems im not login and doesnt let me to make any changes (which is a good thing). How can i easily login without going through the REST API. is there anyway to login from MangoAPI jquery?

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by phildunlap

        I think you're looking for this page: https://help.infiniteautomation.com/mango-rest-api-authentication/

        If this is an ES you can sudo using the regular user's password to sudo su, you don't need to su root.

        A 2 Replies Last reply Reply Quote 0
        • A
          arvand.owji @phildunlap
          last edited by

          @phildunlap Thanks. Assuming we get the http get working, do we still need to implement the login or because mango is doignthe request, the authentication is not needed

          1 Reply Last reply Reply Quote 0
          • A
            arvand.owji
            last edited by

            btw, i delete the folder and i still get the same error. Thanks

            1 Reply Last reply Reply Quote 0
            • A
              arvand.owji @phildunlap
              last edited by

              @phildunlap

              @phildunlap said in Import javascript library:

              I think you're looking for this page: https://help.infiniteautomation.com/mango-rest-api-authentication/

              If this is an ES you can sudo using the regular user's password to sudo su, you don't need to su root.

              What will be the request url? I tried to replace the localhost:8080 with my mango box url and im getting page not found error inside mango website when i try it in the browser
              http://xxxxxx.com/rest/v2/login

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by

                It should be a POST to /rest/v2/login

                What version of Mango and the API do you have installed?

                A 1 Reply Last reply Reply Quote 0
                • A
                  arvand.owji @phildunlap
                  last edited by

                  @phildunlap said in Import javascript library:

                  It should be a POST to /rest/v2/login

                  What version of Mango and the API do you have installed?

                  mangoES3273

                  1 Reply Last reply Reply Quote 0
                  • A
                    arvand.owji
                    last edited by

                    [0_1500407785003_coolprop4.html](Uploading 100%)

                    Here is the file file im experimenting with. Its pretty simple. All im doing is setting the xid = 'DP_274226';

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      arvand.owji @arvand.owji
                      last edited by

                      <!DOCTYPE html>
                      <html>
                      <head>
                      <title>Set Point Value</title>
                      <!-- Add the Mango Favicon -->
                      <link rel="icon" href="/images/favicon.ico">

                          <!-- Page Style -->
                          <style></style>
                          <link href="/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
                          <link href="/modules/dashboards/web/private/css/dashboard.css" rel="stylesheet">
                      
                          <!-- Base Library -->
                          <script type="text/javascript" src="/resources/loaderConfig.js"></script>
                          <script type="text/javascript" src="/resources/require.js"></script>
                          <script type="text/javascript" src="/resources/main.js"></script>
                          <script type="text/javascript" src="coolprop.js"></script>
                          <script type="text/javascript">
                      
                          require(['jquery', 'mango/api'],
                                  function($, MangoAPI) {
                          
                            $('#document').ready(function(){
                      		
                      		
                      		
                            	//We need the data type for the point
                            	var xid = 'DP_274226';
                            	MangoAPI.defaultApi.getPoint(xid).then(function(point){
                            		
                            		//Check to see if settable
                            		if(point.pointLocator.settable === false){
                            			var statusRow = [];
                                    	statusRow.push(xid + ' not settable.');
                                    	statusRow.push(new Date());
                                    	//Append a status row
                                    	$('#status').append(createRow(statusRow));
                                    	return;
                      				}
                                	var pvt = getPointValueTime(point);
                                	MangoAPI.defaultApi.putValue(xid, pvt).then(function(response){
                                      	var statusRow = [];
                                      	statusRow.push('Set Value For ' + xid + ' to ' + pvt.value);
                                      	statusRow.push(new Date());
                                      	//Append a status row
                                      	$('#status').append(createRow(statusRow));
                                	}).fail(MangoAPI.logError);        		
                            	}).fail(MangoAPI.logError);
                            });
                            
                            function createRow(columns){
                            	var tr = $('<tr>');
                            	for(var i=0; i<columns.length; i++){
                            		 var td = $('<td>');
                         			  td.text(columns*);
                         			  tr.append(td);
                            	}
                            	return tr;
                            }
                      
                            
                            function getPointValueTime(dataPoint){
                      		
                            	var value = null;              
                      		value= Module.PropsSI('S', 'P', 55, 'T', 400, 'Nitrogen');
                            	return {
                                		value: value,
                                		timestamp: new Date().getTime(),
                                		annotation: 'Set by custom dashboard',
                                		dataType: dataPoint.pointLocator.dataType,
                                	};
                            }
                          });
                          </script>
                          
                      </head>
                      <body>
                        <div id="main">
                          
                          <div class="row">
                            <div class="col-md-12">
                              <table class="table">
                                <tr><th>Status</th><th>Time</th></tr>
                                <tbody id="status"></tbody>
                              </table>
                            </div>
                          </div>
                      
                        </div>
                      </body>
                      

                      </html>

                      1 Reply Last reply Reply Quote 0
                      • phildunlapP
                        phildunlap
                        last edited by phildunlap

                        @arvand.owji said in Import javascript library:

                        mangoES3273

                        Try going to the /modules.shtm page and checking for updates. That page is also the right place to get version information. I can assume that you haven't modified it since it was shipped, but then I have to make an assumption and look up your system. It's easier for me if you report the current reality. You haven't really done anything with your data source from the json, so it doesn't make any sense it wouldn't be working.

                        There was no stack trace for the timer already cancelled message, was there?

                        My impression is that something is misconfigured. Otherwise, something is overridden. Can you share the output of find /opt/mango/overrides?

                        If there are no upgrades, I would try starting Mango on a clean database (move your existing Mango/databases directory to Mango/databases-bck while Mango is off) and setting up a new HTTP Retriever data source in the clean environment. If that works, you could consider restoring your system from a json export or database restore if something has gone awry somehow in the database.

                        Edit: If you haven't restarted Mango since those memory errors, maybe that's related? Give it a restart from the /modules.shtm page

                        A 3 Replies Last reply Reply Quote 0
                        • A
                          arvand.owji @phildunlap
                          last edited by arvand.owji

                          @phildunlap said in Import javascript library:

                          /modules.shtm

                          So my version is core 2.8.8 build 635 - paid. Obviosuly this is an older version compare to 3.1.1 and when i go to upgrades, i see a LOT of upgrades. Here is the stack trace:

                          DWR invocation exception 
                          java.lang.IllegalStateException: Timer already cancelled.
                          	at com.serotonin.timer.RealTimeTimer.scheduleImpl(RealTimeTimer.java:129)
                          	at com.serotonin.timer.AbstractTimer.schedule(AbstractTimer.java:35)
                          	at com.serotonin.m2m2.util.timeout.TimeoutTask.<init>(TimeoutTask.java:63)
                          	at
                          com.serotonin.m2m2.rt.dataSource.PollingDataSource.beginPolling(PollingDataSource.java:220)
                          	at com.serotonin.m2m2.rt.RuntimeManager.startDataSourcePolling(RuntimeManager.java:363)
                          	at com.serotonin.m2m2.rt.RuntimeManager.saveDataSource(RuntimeManager.java:277)
                          	at com.serotonin.m2m2.rt.dataSource.DataSourceRTM.save(DataSourceRTM.java:54)
                          	at com.serotonin.m2m2.rt.dataSource.DataSourceRTM.save(DataSourceRTM.java:23)
                          	at com.serotonin.m2m2.web.dwr.AbstractRTDwr.toggle(AbstractRTDwr.java:53)
                          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                          	at java.lang.reflect.Method.invoke(Method.java:498)
                          	at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
                          	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                          	at com.serotonin.m2m2.web.dwr.util.TranslationsFilter.doFilter(TranslationsFilter.java:37)
                          	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                          	at com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter(ExceptionDetectionFilter.java:26)
                          	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                          	at com.serotonin.m2m2.web.dwr.util.DwrPermissionFilter.doFilter(DwrPermissionFilter.java:45)
                          	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                          	at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
                          	at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
                          	at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
                          	at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
                          	at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
                          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
                          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
                          	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
                          	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
                          	at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
                          	at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300)
                          	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
                          	at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:87)
                          	at com.serotonin.m2m2.web.filter.MangoShallowEtagHeaderFilter.doFilterInternal(MangoShallowEtagHeaderFilter.java:47)
                          	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
                          	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
                          	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
                          	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
                          	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
                          	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
                          	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
                          	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
                          	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
                          	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
                          	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
                          	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
                          	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
                          	at org.eclipse.jetty.server.Server.handle(Server.java:499)
                          	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
                          	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
                          	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
                          	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
                          	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
                          	at java.lang.Thread.run(Thread.java:745)
                          
                          1 Reply Last reply Reply Quote 0
                          • A
                            arvand.owji @phildunlap
                            last edited by

                            @phildunlap said in Import javascript library:

                            My impression is that something is misconfigured. Otherwise, something is overridden. Can you share the output of find /opt/mango/overrides?

                            /opt/mango/overrides
                            /opt/mango/overrides/properties
                            /opt/mango/overrides/properties/env.properties
                            /opt/mango/overrides/classes

                            1 Reply Last reply Reply Quote 0
                            • A
                              arvand.owji @phildunlap
                              last edited by

                              @phildunlap said in Import javascript library:

                              Edit: If you haven't restarted Mango since those memory errors, maybe that's related? Give it a restart from the /modules.shtm page

                              funny enough i tried to restart it from there and im getting the same timer already canceled error.

                              ERROR 2017-07-19 09:01:36,436 (com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter:38) - DWR invocation exception 
                              java.lang.IllegalStateException: Timer already cancelled.
                              	at com.serotonin.timer.RealTimeTimer.scheduleImpl(RealTimeTimer.java:129)
                              	at com.serotonin.timer.AbstractTimer.schedule(AbstractTimer.java:35)
                              	at com.serotonin.m2m2.util.timeout.TimeoutTask.<init>(TimeoutTask.java:43)
                              	at com.serotonin.m2m2.util.timeout.TimeoutTask.<init>(TimeoutTask.java:32)
                              	at com.serotonin.m2m2.Lifecycle.scheduleShutdown(Lifecycle.java:1321)
                              	at com.serotonin.m2m2.web.dwr.ModulesDwr.scheduleRestart(ModulesDwr.java:70)
                              	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                              	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                              	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                              	at java.lang.reflect.Method.invoke(Method.java:498)
                              	at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
                              	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                              	at com.serotonin.m2m2.web.dwr.util.TranslationsFilter.doFilter(TranslationsFilter.java:37)
                              	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                              	at com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter(ExceptionDetectionFilter.java:26)
                              	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                              	at com.serotonin.m2m2.web.dwr.util.DwrPermissionFilter.doFilter(DwrPermissionFilter.java:45)
                              	at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
                              	at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
                              	at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
                              	at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
                              	at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
                              	at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
                              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
                              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
                              	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
                              	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
                              	at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
                              	at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300)
                              	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
                              	at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:87)
                              	at com.serotonin.m2m2.web.filter.MangoShallowEtagHeaderFilter.doFilterInternal(MangoShallowEtagHeaderFilter.java:47)
                              	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
                              	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
                              	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
                              	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
                              	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
                              	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
                              	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
                              	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
                              	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
                              	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
                              	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
                              	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
                              	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
                              	at org.eclipse.jetty.server.Server.handle(Server.java:499)
                              	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
                              	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
                              	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
                              	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
                              	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
                              	at java.lang.Thread.run(Thread.java:745)
                              
                              1 Reply Last reply Reply Quote 0
                              • phildunlapP
                                phildunlap
                                last edited by

                                Yeah, almost certainly restarting is all that is required. Command line restarting options on a MangoES...

                                sudo service mango reload #tell the Mango service to restart
                                sudo /opt/mango/bin/ma.sh restart #more or less what restarting the service is going to do
                                sudo /opt/mango/bin/ma.sh restart; sleep 120; if [ ! -z $(pidof java) ] && [ -e /opt/mango/RESTART ]; then sudo kill -9 $(pidof java); fi #tell Mango to restart, kill it in two minutes if it hasn't restarted
                                sudo reboot #reboot the ES
                                
                                A 2 Replies Last reply Reply Quote 0
                                • A
                                  arvand.owji @phildunlap
                                  last edited by

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  • A
                                    arvand.owji @phildunlap
                                    last edited by

                                    @phildunlap said in Import javascript library:

                                    Yeah, almost certainly restarting is all that is required. Command line restarting options on a MangoES...

                                    sudo service mango reload #tell the Mango service to restart
                                    sudo /opt/mango/bin/ma.sh restart #more or less what restarting the service is going to do
                                    sudo /opt/mango/bin/ma.sh restart; sleep 120; if [ ! -z $(pidof java) ] && [ -e /opt/mango/RESTART ]; then sudo kill -9 $(pidof java); fi #tell Mango to restart, kill it in two minutes if it hasn't restarted
                                    sudo reboot #reboot the ES
                                    

                                    so after this, the site completely went down and i cant even login anymore. The Mango ES is up and in the process lists i see Mango but the web is not working. Cant even login

                                    1 Reply Last reply Reply Quote 0
                                    • phildunlapP
                                      phildunlap
                                      last edited by phildunlap

                                      Which did you do? You probably would have to have had done one of the last two, I doubt the first two work in this case.

                                      tail -n 30 /opt/mango/logs/ma.log

                                      This will always kill Mango (and any other Java processes running): kill -9 $(pidof java); (edit: okay, it won't kill a process in D sleep)

                                      This will start Mango with both stdout and stderr coming back to the command line, if you think Mango is having trouble starting: sudo /opt/mango/bin/ma.sh start

                                      A 1 Reply Last reply Reply Quote 0
                                      • A
                                        arvand.owji @phildunlap
                                        last edited by

                                        @phildunlap said in Import javascript library:

                                        kill -9 $(pidof java

                                        ok. that worked andi could login. I went to the htp get data source and disabled/enabled the data source and i got that timer already canceled error again :(

                                        1 Reply Last reply Reply Quote 0
                                        • phildunlapP
                                          phildunlap
                                          last edited by

                                          Upload your entire ma.log file. I also provided steps for trying again on a clean setup.

                                          A 1 Reply Last reply Reply Quote 0
                                          • A
                                            arvand.owji @phildunlap
                                            last edited by arvand.owji

                                            @phildunlap [0_1500562677214_ma.log](Uploading 100%)
                                            Thanks. Are you able to see this file that i just uploaded? Thanks.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post