<commit_before>import { Http,Headers } from '@angular/http';
import { Injectable } from '@angular/core';
import * as _ from 'lodash';

@Injectable()
export class RuntimeService {

    constructor(public http: Http) {
        console.log('Task Service created.', http);
    }


    getRuntime(filter_s: string) {
        // return an observable
        return this.http.get('/runtime/info')
        .map( (responseData) => {
            return responseData.json();
        })
        .map((runtime_devs) => {
            let result = [];
            if (runtime_devs) {
                _.forEach(runtime_devs,function(value,key){
                  console.log("KEY: ",key);
                  console.log("FOREACH LOOP",value,key);
                    if(filter_s && filter_s.length > 0 ) {
                        console.log("maching: "+key+ "| filter: "+filter_s);
                        var re = new RegExp(filter_s, 'gi');
                        if (key.match(filter_s)){
                            result.push({'ID': key, 'value' :value});
                        }
                        console.log(key.match(re));
                    } else {
                            result.push({'ID': key, 'value' :value});
                    }
                });
            }
            console.log("result:",result);
            return result;
        });
    }

    getRuntimeById(id : string) {
        // return an observable
        return this.http.get('/runtime/info/'+id)
        .map( (responseData) =>
            responseData.json()
    )};

    changeDeviceActive(id : string, event : boolean) {
        // return an observable
        if (event) {
            return this.http.put('/runtime/activatedev/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        } else {
            return this.http.put('/runtime/deactivatedev/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        }
    };

    changeStateDebug(id : string, event : boolean) {
        // return an observable
        if (event) {
            return this.http.put('/runtime/actsnmpdbg/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        } else {
            return this.http.put('/runtime/deactsnmpdbg/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        }
    };

    downloadLogFile(id : string) {
        // return an observable
        return this.http.get('/runtime/getdevicelog/'+id)
        .map( (res) => {
            console.log("service_response",res)
            //return new Blob([res.arrayBuffer()],{type: "application/octet-stream" })
            return new Blob([res['_body']],{type: "application/octet-stream" })
        })
    };

    forceFltUpdate(id : string) {
        // return an observable
        return this.http.get('/runtime/forcefltupdate/'+id)
        .map( (responseData) =>
            responseData.json()
        )
    };
}<commit_msg>replace http for httpwrapper on runtime<commit_after>import { HttpAPI } from '../common/httpAPI'
import { Injectable } from '@angular/core';
import * as _ from 'lodash';

@Injectable()
export class RuntimeService {

    constructor(public httpAPI: HttpAPI) {
    }


    getRuntime(filter_s: string) {
        // return an observable
        return this.httpAPI.get('/runtime/info')
        .map( (responseData) => {
            return responseData.json();
        })
        .map((runtime_devs) => {
            let result = [];
            if (runtime_devs) {
                _.forEach(runtime_devs,function(value,key){
                  console.log("KEY: ",key);
                  console.log("FOREACH LOOP",value,key);
                    if(filter_s && filter_s.length > 0 ) {
                        console.log("maching: "+key+ "| filter: "+filter_s);
                        var re = new RegExp(filter_s, 'gi');
                        if (key.match(filter_s)){
                            result.push({'ID': key, 'value' :value});
                        }
                        console.log(key.match(re));
                    } else {
                            result.push({'ID': key, 'value' :value});
                    }
                });
            }
            console.log("result:",result);
            return result;
        });
    }

    getRuntimeById(id : string) {
        // return an observable
        return this.httpAPI.get('/runtime/info/'+id)
        .map( (responseData) =>
            responseData.json()
    )};

    changeDeviceActive(id : string, event : boolean) {
        // return an observable
        if (event) {
            return this.httpAPI.put('/runtime/activatedev/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        } else {
            return this.httpAPI.put('/runtime/deactivatedev/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        }
    };

    changeStateDebug(id : string, event : boolean) {
        // return an observable
        if (event) {
            return this.httpAPI.put('/runtime/actsnmpdbg/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        } else {
            return this.httpAPI.put('/runtime/deactsnmpdbg/'+id,id)
            .map( (responseData) =>
                responseData.json()
            )
        }
    };

    downloadLogFile(id : string) {
        // return an observable
        return this.httpAPI.get('/runtime/getdevicelog/'+id)
        .map( (res) => {
            console.log("service_response",res)
            //return new Blob([res.arrayBuffer()],{type: "application/octet-stream" })
            return new Blob([res['_body']],{type: "application/octet-stream" })
        })
    };

    forceFltUpdate(id : string) {
        // return an observable
        return this.httpAPI.get('/runtime/forcefltupdate/'+id)
        .map( (responseData) =>
            responseData.json()
        )
    };
}
{'fraction_non_alphanumeric': 0.1397179403082978, 'fraction_numerical': 0.00032797638570022957, 'mean_word_length': 1.474239350912779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4020165', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1659, 'n_words': 299}