<commit_before>async function(args) {
/*
created_timestamp(-1)
base_component_id("homepage")
is_app(true)
display_name("Homepage app")
description('Homepage app')
uses_javascript_librararies(["aframe"])

load_once_from_file(true)
read_only(true)
logo_url("data:image/jpeg;base64,/9j/4AAQSkZJR<KEY>ABAAD/2wCEAAkGBxIQEg8SEBETEBAWFhYQFhITGBkQExUXFhIaFhUWFRUaHSkgGBomGxUVIj0kJSorLi4uFx8zODM4NygtLisBCgoKDg0OGxAQGzMlHyUtLS0tLS0rLS0tLS0tMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS01LS0tLS0tLS0tLf/AABEIAKQBMwMBEQACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUBAgMGB//EAEUQAAEDAgEHBwgGCQUBAAAAAAEAAgMEESEFEhUxQVORBhMUIlFU4VJhcYGSoaLSMjNicqOxFpSys7TBwtHTIzRzgvAH/8QAGwEBAAIDAQEAAAAAAAAAAAAAAAECAwQGBQf/xAA3EQEAAQMABwcDAgUEAwAAAAAAAQIDEQQSEzFRUpEFFBUhQVNhFjJxM4EiNLHB8AZCkqE10eH/2gAMAwEAAhEDEQA/ALBbLjBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEC<KEY>ICD//2Q==")
*/
    var introa = []//['homepage_1','homepage_2','homepage_3','homepage_4',
                   // 'vb','homepage_6',"todo","form_subscribe_to_appshare","test"]
                   //alert(3)
   console.log(`calling await loadV2("app_editor_3")`)
    await loadV2("app_editor_3")
    console.log(`calling await loadV2("app_editor_3") loaded`)
    var mm = null
//alert(2)
    Vue.component('homepage', {

      template: `<div>
                    <div    style="position: sticky; left:0px; top:0px; height:70px; width: 100vw ;z-index: -2000;background-color: white;padding:0;margin:0;">
                    <h3 style="border:solid 1px;border-color: lightgray; padding: 14px; margin: 0px;font-family: Helvetica;">Appshare</h3>
                    </div>

      <div  class="container-fluid" style='position: relative; padding:20;margin:0; width: 95%;'>



                    <div v-bind:refresh='refresh'
                         ref='maingrid'
                         class="grid"
                         style='background-color: white; color: black; padding-top: 20px;padding-bottom: 20px;'>





                                <div    v-for="(item, index) in intro_apps"
                                        class="grid-item col-lg-4">
                                        <div
                                        style="border-radius: 30px;background-color:white;border-width: 0px;margin:0px;padding:10px;"
                                       >

                                       <div v-if="item.type == 'add'" >
                                        <div    style='border-radius: 5px;padding:20px; margin:0;border: 2px solid pink;'
                                                >
                                           <h4>
                                            Create a new app
                                           </h4>
                                           <select v-model="app_type">
                                              <option selected value="vb">Drag and Drop Builder</option>
                                              <option          value="todo">Database app</option>
                                              <option          value="game">3d AFrame app</option>
                                              <option          value="new_app">Text only</option>
                                            </select>
                                           <button style='margin-bottom:10px;' class='btn btn-primary' v-on:click='copyAndEditApp($event,app_type)'>Go</button>
                                           </div>
                                           </div>

                                   <div v-if="item.type == 'app'" >
                                       <div v-if="(edit_app == item.data.id)"
                                               style="position: fixed; left:0px; top:0px; height:100%; width: 100vw ;z-index: 200000;background-color: white;overflow-y:scroll; padding: 20px;">
                                               <div v-on:click='editApp($event,null);addApp(item.data.id,index)' class="btn-lg btn-danger" style='margin-bottom: 20px;'>Close</div>
                                               <component v-if='' :is='"app_editor_3"' v-bind:app_id='item.data.id' v-bind:card_index='index'></component>
                                       </div>




                                   <div style='border-radius: 25px;padding:20px; margin:0;border: 2px solid lightgray;'>
                                    <div v-if='isInlineApp(item.data.id)' >
                                       <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}</kbd>
                                       <component v-if='edit_app != item.data.id' :is='item.data.id'></component>
                                    </div>

                                    <div v-if='!isInlineApp(item.data.id)' >
                                        <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}</kbd>
                                        <span v-if='isEditable(item.data.id)' class="badge badge-warning" >Editable</span>
                                        <span v-if='!isEditable(item.data.id)' class="badge badge-info" >Read only</span>

                                        <img    v-if='(app_records[item.data.id] && app_records[item.data.id].logo_url && (app_records[item.data.id].logo_url != ""))'
                                                v-bind:src='app_records[item.data.id].logo_url'
                                                style='width: 100%;'
                                                v-bind:alt='app_records[item.data.id].logo_url'
                                                v-on:click='editApp($event,item.data.id)'
                                                ></img>
                                    </div>


                                    <ul class="nav flex-column">
                                    <li class="nav-item" v-if='!isEditable(item.data.id)'>
                                      <a  v-on:click='editApp($event,item.data.id)'
                                          class="nav-link active" href="#">View source</a>
                                    </li>

                                      <li class="nav-item" v-if='isEditable(item.data.id)'>
                                        <a  v-on:click='editApp($event,item.data.id)'
                                            class="nav-link active" href="#">Edit</a>
                                      </li>
                                    </ul>

                            </div>





                                    </div>
                                    </div>








                            </div>

                        </div>
                    </div>








                </div>
       </div>`
      ,


    data: function() {
        return {
                    apps: [],
                    app_type: "vb",
                    intro_apps: [],
                    loaded_app: new Object(),
                    show_menu: null,
                    refresh: 0,
                    edit_app: null,
                    app_records: new Object(),
                    msnry: null
                }},

      mounted: async function() {
            mm = this
            //alert(1)

            this.msnry = new Masonry( mm.$refs.maingrid, {
              itemSelector: '.grid-item'
            });
            Vue.nextTick(() => {
                  this.msnry.reloadItems();
                  this.msnry.layout();
              });

           mm.addAdder()

           var sql =    "select  *  from  system_code  where " +
                        "        component_type = 'app' and base_component_id like 'homepage_%'" +
                        "        and code_tag = 'LATEST' order by base_component_id asc"

           var results = await callApp(
               {
                    driver_name:    "systemFunctions2",
                    method_name:    "sql"
               }
               ,
               {
                   sql: sql
               })
               for (var rt=0; rt < results.length; rt++) {
                   var appId = results[rt].base_component_id
                   mm.addAppFast(appId,-1, results[rt])
                   component_loaded[appId] = true
               }


               mm.search()




            this.$root.$on('message', (text) => {
                if (text.type == "insert_app_at") {
                    console.log(JSON.stringify(text,null,2));
                    mm.intro_apps.splice(text.card_index, 0, {});
                    mm.addApp(text.base_component_id, text.card_index)
                    mm.edit_app = text.base_component_id
                    mm.refresh++
                }
            })

             globalEventBus.$on('new-appshare-app-uploaded',
                async function(data) {
                    //zzz
                    //alert(JSON.stringify(data,null,2))
                    mm.intro_apps.splice(1, 0, {});
                    mm.addApp(data, 1)
                    setTimeout(function() {
                          mm.editApp(null, data)
                    },50)
             });
      },
      methods: {
          addAdder: async function() {
                  mm.intro_apps.push( {
                                        type: "add",
                                      } )
                mm.refresh++
              },
              addAppFast: async function(baseComponentId, cardIndex,vv) {
                  if (baseComponentId) {

                      if (vv.code) {
                          var x = eval("(" + vv.code + ")")
                          x.call()
                      }
                      setTimeout(function() {
                          var app = {
                                                type: "app",
                                                data:
                                                    {
                                                        id: baseComponentId
                                                    }
                                              }
                          if (cardIndex != -1) {
                            mm.intro_apps[cardIndex] =  app

                          } else {
                            mm.intro_apps.push( app  )
                          }
                          mm.loaded_app[baseComponentId] = true
                          if (vv) {
                              mm.app_records[vv.base_component_id] = vv
                              mm.refresh++
                          }
                          setTimeout(function() {
                              mm.msnry.reloadItems();
                              mm.msnry.layout();
                          },50)
                      },100)

                  }
              },
            addApp: async function(baseComponentId, cardIndex) {
              if (baseComponentId) {
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  component_loaded[baseComponentId] = false
                  dev_app_component_loaded[baseComponentId] = false
                  component_cache[baseComponentId] = null
                  var vv = await loadV2(baseComponentId)
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }
                  setTimeout(function() {
                      mm.msnry.reloadItems();
                      mm.msnry.layout();
                  },50)
              }
          },
          copyApp: async function(  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              mm.addApp(result.value.base_component_id, 1)

                          })
          },
          copyAndEditApp: async function(event,  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              mm.addApp(result.value.base_component_id, 1)
                              setTimeout(function() {
                                    mm.editApp(event, result.value.base_component_id)
                              },50)

                          })
          },
          isEditable: function(baseComponentId) {
                if (this.app_records[baseComponentId]) {
                    if ((this.app_records[baseComponentId].read_write_status == null ) ||
                         (this.app_records[baseComponentId].read_write_status.indexOf("READ") == -1 ))   {
                         return true
                }

                }

               return false
          },
          isInlineApp: function(baseComponentId) {
                if (baseComponentId && (baseComponentId.length > 0)) {
                    if ((!this.isEditable(baseComponentId)) && (baseComponentId.startsWith("homepage"))) {
                        return true
                    }
                }

               return false
          },
          editApp: async function(event,item) {
              if (event) {
                  event.stopPropagation()
              }
              this.show_menu = null;
              this.edit_app = item;
          },
          showMenu: async function(item) {
            this.show_menu= item;
          },








          search: async function() {
              var sql =    `SELECT  id, base_component_id, logo_url, read_write_status
                                FROM
                            system_code
                                where
                                    component_type = 'app'
                                        and
                                    code_tag = 'LATEST'
                                        and
                                    visibility = 'PUBLIC'
                            order by base_component_id asc; `

              var results = await callApp(
                  {
                       driver_name:    "systemFunctions2",
                       method_name:    "sql"
                  }
                  ,
                  {
                      sql: sql
                  })
              for (var rt=0; rt < results.length; rt++) {
                  var appId = results[rt].base_component_id
                  if (!mm.loaded_app[  appId  ]) {
                        mm.addAppFast(appId,-1, results[rt])
                  }
              }
              }





      }
    })

}
<commit_msg>load the public apps using await<commit_after>async function(args) {
/*
created_timestamp(-1)
base_component_id("homepage")
is_app(true)
display_name("Homepage app")
description('Homepage app')
uses_javascript_librararies(["aframe"])

load_once_from_file(true)
read_only(true)
logo_url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxIQEg8SEBETEBAWFhYQFhITGBkQExUXFhIaFhUWFRUaHSkgGBomGxUVIj0kJSorLi4uFx8zODM4NygtLisBCgoKDg0OGxAQGzMlHyUtLS0tLS0rLS0tLS0tMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS01LS0tLS0tLS0tLf/AABEIAKQBMwMBEQACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUBAgMGB//EAEUQAAEDAgEHBwgGCQUBAAAAAAEAAgMEESEFEhUxQVORBhMUIlFU4VJhcYGSoaLSMjNicqOxFpSys7TBwtHTIzRzgvAH/8QAGwEBAAIDAQEAAAAAAAAAAAAAAAECAwQGBQf/xAA3EQEAAQMABwcDAgUEAwAAAAAAAQIDEQQSEzFRUpEFFBUhQVNhFjJxM4EiNLHB8AZCkqE10eH/2gAMAwEAAhEDEQA/ALBbLjBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECyAgICAgICAgICAgICAgICAgICAgICAgIIuVXEQTkEgiOQgjAg5hxBVavtllsRm7T+YVfIWV8lFA57nPcS+7nEuJtI4aylO5n7QiI0iqI+P6I3Pv0tzee7M6PnZlzm37c3VdRT90stVMdyiceeUWaWXKNVPAyZ8FLB1XmI5r5HG4tfYLh3m6vnwiP4p+GSIo0WzTXNOaquPoxlvJUlAzpNH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j5U1Z5jMcDprdy3iPlTVnmMxwOmt3LeI+VNWeYzHA6a3ct4j5U1Z5jMcDprdy3iPlTVnmMxwb6UO7+LwVdlHFOs06cNy3iPlVtWeZGY4HThuW8R8qas8xmODZuUrYCIAeZ1v6VE28+qdb4bDKf2Pi8FGy+TWZ0n9j3+CjZfJrGk/se/wTZfJrGk/se/wTZfJrGk/se/wTZfJrGk/se/wTZfJrGk/se/wTZfJrGk/se/wTZfJrGk/se/wTZfJrNdKHd/F4Kdl8msgrIqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICD//2Q==")
*/
    var introa = []//['homepage_1','homepage_2','homepage_3','homepage_4',
                   // 'vb','homepage_6',"todo","form_subscribe_to_appshare","test"]
                   //alert(3)
   console.log(`calling await loadV2("app_editor_3")`)
    await loadV2("app_editor_3")
    console.log(`calling await loadV2("app_editor_3") loaded`)
    var mm = null
//alert(2)
    Vue.component('homepage', {

      template: `<div>
                    <div    style="position: sticky; left:0px; top:0px; height:70px; width: 100vw ;z-index: -2000;background-color: white;padding:0;margin:0;">
                    <h3 style="border:solid 1px;border-color: lightgray; padding: 14px; margin: 0px;font-family: Helvetica;">Appshare</h3>
                    </div>

      <div  class="container-fluid" style='position: relative; padding:20;margin:0; width: 95%;'>



                    <div v-bind:refresh='refresh'
                         ref='maingrid'
                         class="grid"
                         style='background-color: white; color: black; padding-top: 20px;padding-bottom: 20px;'>





                                <div    v-for="(item, index) in intro_apps"
                                        class="grid-item col-lg-4">
                                        <div
                                        style="border-radius: 30px;background-color:white;border-width: 0px;margin:0px;padding:10px;"
                                       >

                                       <div v-if="item.type == 'add'" >
                                        <div    style='border-radius: 5px;padding:20px; margin:0;border: 2px solid pink;'
                                                >
                                           <h4>
                                            Create a new app
                                           </h4>
                                           <select v-model="app_type">
                                              <option selected value="vb">Drag and Drop Builder</option>
                                              <option          value="todo">Database app</option>
                                              <option          value="game">3d AFrame app</option>
                                              <option          value="new_app">Text only</option>
                                            </select>
                                           <button style='margin-bottom:10px;' class='btn btn-primary' v-on:click='copyAndEditApp($event,app_type)'>Go</button>
                                           </div>
                                           </div>

                                   <div v-if="item.type == 'app'" >
                                       <div v-if="(edit_app == item.data.id)"
                                               style="position: fixed; left:0px; top:0px; height:100%; width: 100vw ;z-index: 200000;background-color: white;overflow-y:scroll; padding: 20px;">
                                               <div v-on:click='editApp($event,null);addApp(item.data.id,index)' class="btn-lg btn-danger" style='margin-bottom: 20px;'>Close</div>
                                               <component v-if='' :is='"app_editor_3"' v-bind:app_id='item.data.id' v-bind:card_index='index'></component>
                                       </div>




                                   <div style='border-radius: 25px;padding:20px; margin:0;border: 2px solid lightgray;'>
                                    <div v-if='isInlineApp(item.data.id)' >
                                       <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}</kbd>
                                       <component v-if='edit_app != item.data.id' :is='item.data.id'></component>
                                    </div>

                                    <div v-if='!isInlineApp(item.data.id)' >
                                        <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}</kbd>
                                        <span v-if='isEditable(item.data.id)' class="badge badge-warning" >Editable</span>
                                        <span v-if='!isEditable(item.data.id)' class="badge badge-info" >Read only</span>

                                        <img    v-if='(app_records[item.data.id] && app_records[item.data.id].logo_url && (app_records[item.data.id].logo_url != ""))'
                                                v-bind:src='app_records[item.data.id].logo_url'
                                                style='width: 100%;'
                                                v-bind:alt='app_records[item.data.id].logo_url'
                                                v-on:click='editApp($event,item.data.id)'
                                                ></img>
                                    </div>


                                    <ul class="nav flex-column">
                                    <li class="nav-item" v-if='!isEditable(item.data.id)'>
                                      <a  v-on:click='editApp($event,item.data.id)'
                                          class="nav-link active" href="#">View source</a>
                                    </li>

                                      <li class="nav-item" v-if='isEditable(item.data.id)'>
                                        <a  v-on:click='editApp($event,item.data.id)'
                                            class="nav-link active" href="#">Edit</a>
                                      </li>
                                    </ul>

                            </div>





                                    </div>
                                    </div>








                            </div>

                        </div>
                    </div>








                </div>
       </div>`
      ,


    data: function() {
        return {
                    apps: [],
                    app_type: "vb",
                    intro_apps: [],
                    loaded_app: new Object(),
                    show_menu: null,
                    refresh: 0,
                    edit_app: null,
                    app_records: new Object(),
                    msnry: null
                }},

      mounted: async function() {
            mm = this
            //alert(1)

            this.msnry = new Masonry( mm.$refs.maingrid, {
              itemSelector: '.grid-item'
            });
            Vue.nextTick(() => {
                  this.msnry.reloadItems();
                  this.msnry.layout();
              });

           mm.addAdder()

           var sql =    "select  *  from  system_code  where " +
                        "        component_type = 'app' and base_component_id like 'homepage_%'" +
                        "        and code_tag = 'LATEST' order by base_component_id asc"

           var results = await callApp(
               {
                    driver_name:    "systemFunctions2",
                    method_name:    "sql"
               }
               ,
               {
                   sql: sql
               })
               for (var rt=0; rt < results.length; rt++) {
                   var appId = results[rt].base_component_id
                   mm.addAppFast(appId,-1, results[rt])
                   component_loaded[appId] = true
               }


               await mm.search()




            this.$root.$on('message', (text) => {
                if (text.type == "insert_app_at") {
                    console.log(JSON.stringify(text,null,2));
                    mm.intro_apps.splice(text.card_index, 0, {});
                    mm.addApp(text.base_component_id, text.card_index)
                    mm.edit_app = text.base_component_id
                    mm.refresh++
                }
            })

             globalEventBus.$on('new-appshare-app-uploaded',
                async function(data) {
                    //zzz
                    //alert(JSON.stringify(data,null,2))
                    mm.intro_apps.splice(1, 0, {});
                    mm.addApp(data, 1)
                    setTimeout(function() {
                          mm.editApp(null, data)
                    },50)
             });
      },
      methods: {
          addAdder: async function() {
                  mm.intro_apps.push( {
                                        type: "add",
                                      } )
                mm.refresh++
              },
              addAppFast: async function(baseComponentId, cardIndex,vv) {
                  if (baseComponentId) {

                      if (vv.code) {
                          var x = eval("(" + vv.code + ")")
                          x.call()
                      }
                      setTimeout(function() {
                          var app = {
                                                type: "app",
                                                data:
                                                    {
                                                        id: baseComponentId
                                                    }
                                              }
                          if (cardIndex != -1) {
                            mm.intro_apps[cardIndex] =  app

                          } else {
                            mm.intro_apps.push( app  )
                          }
                          mm.loaded_app[baseComponentId] = true
                          if (vv) {
                              mm.app_records[vv.base_component_id] = vv
                              mm.refresh++
                          }
                          setTimeout(function() {
                              mm.msnry.reloadItems();
                              mm.msnry.layout();
                          },50)
                      },100)

                  }
              },
            addApp: async function(baseComponentId, cardIndex) {
              if (baseComponentId) {
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  component_loaded[baseComponentId] = false
                  dev_app_component_loaded[baseComponentId] = false
                  component_cache[baseComponentId] = null
                  var vv = await loadV2(baseComponentId)
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }
                  setTimeout(function() {
                      mm.msnry.reloadItems();
                      mm.msnry.layout();
                  },50)
              }
          },
          copyApp: async function(  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              mm.addApp(result.value.base_component_id, 1)

                          })
          },
          copyAndEditApp: async function(event,  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              mm.addApp(result.value.base_component_id, 1)
                              setTimeout(function() {
                                    mm.editApp(event, result.value.base_component_id)
                              },50)

                          })
          },
          isEditable: function(baseComponentId) {
                if (this.app_records[baseComponentId]) {
                    if ((this.app_records[baseComponentId].read_write_status == null ) ||
                         (this.app_records[baseComponentId].read_write_status.indexOf("READ") == -1 ))   {
                         return true
                }

                }

               return false
          },
          isInlineApp: function(baseComponentId) {
                if (baseComponentId && (baseComponentId.length > 0)) {
                    if ((!this.isEditable(baseComponentId)) && (baseComponentId.startsWith("homepage"))) {
                        return true
                    }
                }

               return false
          },
          editApp: async function(event,item) {
              if (event) {
                  event.stopPropagation()
              }
              this.show_menu = null;
              this.edit_app = item;
          },
          showMenu: async function(item) {
            this.show_menu= item;
          },








          search: async function() {
              var sql =    `SELECT  id, base_component_id, logo_url, read_write_status
                                FROM
                            system_code
                                where
                                    component_type = 'app'
                                        and
                                    code_tag = 'LATEST'
                                        and
                                    visibility = 'PUBLIC'
                            order by base_component_id asc; `

              var results = await callApp(
                  {
                       driver_name:    "systemFunctions2",
                       method_name:    "sql"
                  }
                  ,
                  {
                      sql: sql
                  })
              for (var rt=0; rt < results.length; rt++) {
                  var appId = results[rt].base_component_id
                  if (!mm.loaded_app[  appId  ]) {
                        mm.addAppFast(appId,-1, results[rt])
                  }
              }
              }





      }
    })

}

{'fraction_non_alphanumeric': 0.08717807118831267, 'fraction_numerical': 0.041066318590290675, 'mean_word_length': 1.424919349930002, 'pattern_counts': {'":': 4, '<': 147, '<?xml version=': 0, '>': 153, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 240, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6258170', 'n_tokens_mistral': 15042, 'n_tokens_neox': 13872, 'n_words': 1122}