Example #1
0
    function getComplianceStateChanges(result,deviceID){
        var currentState = device.getCurrentDeviceState(parseInt(deviceID));
        if(currentState == 'A'){
            currentState = "Active";
        }else if(currentState == 'PV'){
            currentState = "Policy Violated";
        }else{
            currentState = "Blocked";
        }
        var state = getComplianceStateFromReceivedData(parse(result[0].received_data));
        var array = new Array();
        var obj = {};
        obj.userID =  result[0].user_id;
        obj.timeStamp = common.getFormattedDate(result[0].received_date);
        obj.resons = getComplianceInfoFromReceivedData(parse(result[0].received_data));
        obj.status = state;
        obj.current_status = currentState;
        array.push(obj);

        for(var i = 1; i<result.length;i++){
            if(getComplianceStateFromReceivedData(parse(result[i].received_data)) !== state){
                state = getComplianceStateFromReceivedData(parse(result[i].received_data));
                var obj = {};
                obj.userID =  result[i].user_id;
                obj.timeStamp = common.getFormattedDate(result[i].received_date);
                obj.resons = getComplianceInfoFromReceivedData(parse(result[i].received_data));
                obj.status = state;
                obj.current_status = currentState;
                array.push(obj);
            }
        }
        return  array;
    }