<commit_before>function(args) {
/*
is_app(true)
control_type("VB")
display_name("postgres client control")
description("This will return the postgres control")
base_component_id("postgres_client_component")
load_once_from_file(true)
visibility("PRIVATE")
read_only(true)
properties(
    [
        {
            id:     "sql",
            name:   "SQL",
            type:   "String",
            default: "SELECT * FROM pg_catalog.pg_tables;"
        }
        ,
        {
            id:      "user",
            name:    "USER",
            type:    "String",
            default: "postgres"
        }
        ,
        {
            id:     "password",
            name:   "Password",
            type:   "String",
            default: "<PASSWORD>"  // this password is only used for testing so no security problem here
        }
        ,
        {
            id:     "database",
            name:   "Database",
            type:   "String",
            default: "postgres"
        }
        ,
        {
            id:     "port",
            name:   "Port",
            type:   "Number",
            default: 5432
        }
        ,
        {
            id:     "host",
            name:   "Host",
            type:   "String",
            default: "localhost"
        }
        ,
        {
            id:     "design_time_text",
            name:   "Design Time Text",
            type:   "String",
            help:       `<div>Help text for
                            <b>text</b> property
                         </div>`
        }

        ,
        {
            id:     "result",
            name:   "result",
            type:   "Array",
            default:    []
        }
        ,
        {
            id:     "background_color",
            name:   "Background color",
            type:   "String"
        }
        ,
        {
            id:         "executeSql",
            pre_snippet: `await `,
            snippet:    `executeSql()`,
            name:       "executeSql",
            type:       "Action",
            help:       `<div>Help text for
                            <b>executeSql</b> function
                            <div>The SQL is store in the "sql" property</div>
                         </div>`
        }
    ]
)//properties
logo_url("/driver_icons/postgres.jpg")
*/

    Vue.component("postgres_client_component",{
        props: ["meta","args", "name","refresh", "design_mode"]
        ,
        template: `<div v-bind:style='"white-space:normal;height:100%;width:100%; border: 0px;" +
                                    "background-color: "+    args["background_color"]  +  ";"'>
                                    Postgres:
                                                {{design_time_text}}
                 </div>`
        ,
        data: function() {
            return {
                design_time_text: ""
            }
        }
        ,
        watch: {
          // This would be called anytime the value of the input changes
          refresh(newValue, oldValue) {
            if (!this.design_mode) {
              //console.log("refresh: " + this.args.text)
              if (isValidObject(this.args)) {
                  //this.text = this.args.text
              }
          }
          }
        },
        mounted: async function() {
            registerComponent(this)

            if (this.design_mode == true) {
                this.design_time_text = args.design_time_text
            } else {

            }
        }
        ,
        methods: {
            executeSql: async function() {
                if (!this.design_mode) {
                    var result = await callFunction(
                                        {
                                            driver_name: "postgres_server",
                                            method_name: "postgres_sql"  }
                                            ,{
                                                sql:             this.args.sql,
                                                user:            this.args.user,
                                                password:        <PASSWORD>,
                                                database:        this.args.database,
                                                host:            this.args.host,
                                                port:            this.args.port
                                             })

                   debugger
                   //alert("executeSql: " + JSON.stringify(result,null,2))
                   console.log(JSON.stringify(result,null,2))
                   if (result.value) {
                        return result.value
                   }


               }
                this.changedFn()
                return {}
            }
            ,
            changedFn: function() {
                if (isValidObject(this.args)) {
                    //this.args.text = this.text<commit_msg>Postgres stores the SQL result in the "result" property<commit_after>function(args) {
/*
is_app(true)
control_type("VB")
display_name("postgres client control")
description("This will return the postgres control")
base_component_id("postgres_client_component")
load_once_from_file(true)
visibility("PRIVATE")
read_only(true)
properties(
    [
        {
            id:     "sql",
            name:   "SQL",
            type:   "String",
            default: "SELECT * FROM pg_catalog.pg_tables;"
        }
        ,
        {
            id:      "user",
            name:    "USER",
            type:    "String",
            default: "postgres"
        }
        ,
        {
            id:     "password",
            name:   "Password",
            type:   "String",
            default: "<PASSWORD>"  // this password is only used for testing so no security problem here
        }
        ,
        {
            id:     "database",
            name:   "Database",
            type:   "String",
            default: "postgres"
        }
        ,
        {
            id:     "port",
            name:   "Port",
            type:   "Number",
            default: 5432
        }
        ,
        {
            id:     "host",
            name:   "Host",
            type:   "String",
            default: "localhost"
        }
        ,
        {
            id:     "design_time_text",
            name:   "Design Time Text",
            type:   "String",
            help:       `<div>Help text for
                            <b>text</b> property
                         </div>`
        }

        ,
        {
            id:     "result",
            name:   "result",
            type:   "Array",
            default:    []
        }
        ,
        {
            id:     "background_color",
            name:   "Background color",
            type:   "String"
        }
        ,
        {
            id:         "executeSql",
            pre_snippet: `await `,
            snippet:    `executeSql()`,
            name:       "executeSql",
            type:       "Action",
            help:       `<div>Help text for
                            <b>executeSql</b> function
                            <div>The SQL is store in the "sql" property</div>
                         </div>`
        }
    ]
)//properties
logo_url("/driver_icons/postgres.jpg")
*/

    Vue.component("postgres_client_component",{
        props: ["meta","args", "name","refresh", "design_mode"]
        ,
        template: `<div v-bind:style='"white-space:normal;height:100%;width:100%; border: 0px;" +
                                    "background-color: "+    args["background_color"]  +  ";"'>
                                    Postgres:
                                                {{design_time_text}}
                 </div>`
        ,
        data: function() {
            return {
                design_time_text: ""
            }
        }
        ,
        watch: {
          // This would be called anytime the value of the input changes
          refresh(newValue, oldValue) {
            if (!this.design_mode) {
              //console.log("refresh: " + this.args.text)
              if (isValidObject(this.args)) {
                  //this.text = this.args.text
              }
          }
          }
        },
        mounted: async function() {
            registerComponent(this)

            if (this.design_mode == true) {
                this.design_time_text = args.design_time_text
            } else {

            }
        }
        ,
        methods: {
            executeSql: async function() {
                if (!this.design_mode) {
                    var result = await callFunction(
                                        {
                                            driver_name: "postgres_server",
                                            method_name: "postgres_sql"  }
                                            ,{
                                                sql:             this.args.sql,
                                                user:            this.args.user,
                                                password:        <PASSWORD>,
                                                database:        this.args.database,
                                                host:            this.args.host,
                                                port:            this.args.port
                                             })

                   debugger
                   //alert("executeSql: " + JSON.stringify(result,null,2))
                   console.log(JSON.stringify(result,null,2))
                   if (result.value) {
                        this.args.result = result.value.result

                        return result.value
                   }


               }
                this.args.result = []
                this.changedFn()
                return {}
            }
            ,
            changedFn: function() {
                if (isValidObject(this.args)) {
                    //this.args.text = this.text
{'fraction_non_alphanumeric': 0.10222752585521082, 'fraction_numerical': 0.0025855210819411296, 'mean_word_length': 0.8528002947678703, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 50, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6603975', 'n_tokens_mistral': 2423, 'n_tokens_neox': 2349, 'n_words': 466}