• cbyrne

    @phildunlap Thanks Phil! The naming was just for show, it's named differently in our system for the exact reason you gave. Thanks for the note about permissions, fixed now.

    posted in User help read more
  • cbyrne

    Finally got a working solution. Posted the basic custom module below for anyone else who comes across this thread.

    define(['angular', 'require'], function(angular, require) {
    'use strict';
    
    var userModule = angular.module('userModule', ['maUiApp']);
    
    userModule.component('userComponent', {
        bindings: {},
        controller: ['$scope', '$http', 
            function($scope, $http){
                $scope.msg = null;
                $scope.sendPost = function(point_xid, date_from, date_to, email_recipients){
                    var from = JSON.stringify(date_from);
                    var to = JSON.stringify(date_to);
                    var emails = JSON.stringify(email_recipients);
                    var script = "send_HTTP_debug(point_xid, " + from + ", " + to + ", " + emails + ")"
    
                    var address= "/rest/v2/script/run";
                    var content = {'Content-Type': 'application/json;charset=UTF-8'};
                    var data = {
                          "context": [
                            {
                              "contextUpdate": true,
                              "variableName": "point_xid",
                              "xid": point_xid
                            },
                          ],
                          "logLevel": "DEBUG",
                          "permissions": [
                            "admin"
                          ],
                          "script": script,
                          "wrapInFunction": true
                    };
                    function success(response){$scope.msg=response;};
                    function error(response){$scope.msg=response;};
    
                    $http.post(address, JSON.stringify(data),content).then(success, error);
                };
            }],
        template: '\
        <div flex layout="column">\
            <md-input-container md-no-float="">\
                <label>Point</label>\
                <ma-point-list ng-model="point" query="query_tmpVal" start="start_tmpVal" limit="limit_tmpVal" sort="sort_tmpVal"></ma-point-list>\
            </md-input-container>\
            <div flex layout="row">\
                <md-input-container style="flex-grow:1">\
                <label>From</label>\
                    <ma-date-picker ng-model="date_from" mode="date" format="DD/MM/YYYY"></ma-date-picker>\
                </md-input-container>\
                <div style="width="10vw">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>\
                <md-input-container style="flex-grow:1">\
                    <label>To</label>\
                    <ma-date-picker ng-model="date_to" mode="date" format="DD/MM/YYYY"></ma-date-picker>\
                </md-input-container>\
            </div>\
            <md-input-container>\
                <ma-email-recipients ng-model="email_recipients"></ma-email-recipients>\
            </md-input-container>\
            <md-button class="md-primary md-raised" ng-click="sendPost(point.xid, date_from, date_to, email_recipients)">Request Report</md-button>\
            <p>{{msg}}</p>\
        </div>\
        '
    });
    
    return userModule;
    
    }); // define
    

    posted in User help read more
  • cbyrne

    @phildunlap After some work I got a little further but I've hit a stumbling block with the POST data spec

    {
      "context": [
        {
          "contextUpdate": true,
          "variableName": "string",
          "xid": "string"
        }
      ],
      "logLevel": "TRACE",
      "permissions": [
        "string"
      ],
      "resultDataType": "string",
      "script": "string",
      "wrapInFunction": true
    }
    

    The global function I want to call is something like send_http(point, start_time, end_time, email_addresses) and I have the four parameters. The point I presume I can send as the context, but I don't know how to send the other parameters.

    posted in User help read more
  • cbyrne

    @phildunlap thanks Phil, could you give me an example of how exactly to call the $http.post request? Sorry, I'm not fluent with angular at all. What I can find online does the whole var app = angular.module... boilerplate but I know I'm already in that context in the dashboard designer so I'm note sure how to define the function as I usually would in a scripting context.

    posted in User help read more
  • cbyrne

    Could anyone tell me how to call a global script from a dashboard?

    The layout would be pretty simple:

    • point selector
    • date range picker
    • email recipients
    • button

    The script takes values from the point selector, date range picker and email recipients. This I know how to do but I just don't know how to call the global script as the on-click action of the button.

    Thanks!

    posted in User help read more
  • cbyrne

    @phildunlap Hey Philip, it's actually the data point copy that throws the error, data source copies just fine. I have observed the same error over two separate installations running 3.6.4

    It also doesn't seem to depend on the data source type.

    posted in User help read more
  • cbyrne

    I'm using Data File sources which are still handled through the legacy UI. From a quick test, I don't think the new UI has this issue.

    Relevant console log:

    ERROR 2019-08-29T17:18:12,275 (com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter:38) - DWR invocation exception com.serotonin.m2m2.vo.permission.PermissionException: Subclass DWRs must implement method to use 
    at com.serotonin.m2m2.web.dwr.AbstractDwr.getCopy(AbstractDwr.java:182) ~[mango-3.6.4.jar:?] 
    at com.serotonin.m2m2.web.dwr.DataPointDwr.getCopy(DataPointDwr.java:268) ~[mango-3.6.4.jar:?] 
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] 
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] 
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] 
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] 
    at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] 
    at com.serotonin.m2m2.web.dwr.util.TranslationsFilter.doFilter(TranslationsFilter.java:37) ~[mango-3.6.4.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] 
    at com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter(ExceptionDetectionFilter.java:26) ~[mango-3.6.4.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] 
    at com.serotonin.m2m2.web.dwr.util.DwrPermissionFilter.doFilter(DwrPermissionFilter.java:46) ~[mango-3.6.4.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101) ~[dwr-2.0.11.jar:?] 
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146) ~[dwr-2.0.11.jar:?] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) ~[javax.servlet-api-3.1.0.jar:3.1.0] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0] 
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:108) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at com.serotonin.m2m2.web.filter.MangoShallowEtagHeaderFilter.doFilterInternal(MangoShallowEtagHeaderFilter.java:95) ~[mango-3.6.4.jar:?] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.authentication.switchuser.SwitchUserFilter.doFilter(SwitchUserFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at com.serotonin.m2m2.web.mvc.spring.security.RateLimitingFilter.doFilterInternal(RateLimitingFilter.java:56) ~[mango-3.6.4.jar:?] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at com.serotonin.m2m2.web.mvc.spring.security.PermissionExceptionFilter.doFilter(PermissionExceptionFilter.java:34) ~[mango-3.6.4.jar:?] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:155) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) ~[jetty-security-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:740) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.Server.handle(Server.java:503) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] 
    at java.lang.Thread.run(Thread.java:834) [?:?] 
    

    posted in User help read more
  • cbyrne

    @phildunlap Cool cool cool, sounds like a nice solution. Thanks for keeping us in the loop!

    posted in User help read more
  • cbyrne

    @phildunlap Thanks Phil, much appreciated!

    Similarly, would you consider adding a last_value-first value to the mango statistics object?

    There already are the values Start, First, and Last in terms of values. They are formally defined here: https://help.infiniteautomation.com/mango-rollups-and-statistics

    I should have been more specific on what I meant, I mean could the statistics object include a value which is equal to the last value minus the start value for the time period, essentially, the consumption or delta in my terms. For example, on the point details page in the point statistics card, it would be great to have one more value, the delta/consumption. But this is minor to the original issue.

    posted in User help read more
  • cbyrne

    @cwangv
    We import our data from CSV files that are timestamp,value_1...value_n in fomat.
    Maybe I'm misunderstanding but I don't see polling times affecting it.

    posted in User help read more