Kaynağa Gözat

more fixes and cleanup

Nikolay Suslov 4 yıl önce
ebeveyn
işleme
9eb32b3add
7 değiştirilmiş dosya ile 715 ekleme ve 706 silme
  1. 388 403
      public/app.js
  2. 0 60
      public/helpers.js
  3. 15 0
      public/lib/utils/log.js
  4. 87 0
      public/lib/utils/query.js
  5. 19 26
      public/vwf.js
  6. 202 214
      public/web/index-app.js
  7. 4 3
      public/web/world-app.js

Dosya farkı çok büyük olduğundan ihmal edildi
+ 388 - 403
public/app.js


+ 0 - 60
public/helpers.js

@@ -35,35 +35,6 @@ class Helpers {
         return obj
     }
 
-
-    async Process(updatedURL) {
-        var result =
-            { 'public_path': "/", 'application': undefined, 'instance': undefined, 'private_path': undefined };
-        var segments = this.GenerateSegments(updatedURL);
-        var extension = undefined;
-
-        while ((segments.length > 0) && (await this.IsExist(this.JoinPath(result['public_path'], segments[0])))) {
-            result['public_path'] = this.JoinPath(result['public_path'], segments.shift());
-        }
-
-        if ((segments.length > 0) && (extension = await this.GetExtension(this.JoinPath(result['public_path'], segments[0])))) {
-            result['application'] = segments.shift();
-        } else if (extension = await this.GetExtension(this.JoinPath(result['public_path'], "index.vwf"))) {
-            result['application'] = "index.vwf";
-        }
-
-        if (extension) {
-            if ((segments.length > 0) && (this.IsInstanceID(segments[0]))) {
-                result['instance'] = segments.shift();
-            }
-            if (segments.length > 0) {
-                result['private_path'] = segments.join("/");
-            }
-        }
-
-        return result;
-    }
-
     // IsInstanceID tests if the passed in potential Instance ID 
     // is a valid instance id.
     IsInstanceID(potentialInstanceID) {
@@ -118,37 +89,6 @@ class Helpers {
     }
 
 
-    async IsFileExist(path) {
-
-        let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
-
-        var seperatorFixedPath = path.slice(1);//path.replace(/\//g, '/');
-        let worldName = seperatorFixedPath.split('/')[0];
-        let fileName = seperatorFixedPath.replace(worldName + '/', "");
-        let world = await userDB.get('worlds').get(worldName).promOnce();
-        if (world) {
-            let doc = Object.keys(world.data).includes(fileName);//(await userDB.get('worlds').get(worldName).get(fileName).promOnce()).data;
-            if (doc) {
-                return true
-            }
-        }
-        return false
-    }
-
-    async IsExist(path) {
-
-        let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
-        var seperatorFixedPath = (path.slice(1)).split('/');//path.replace(/\//g, '/');
-        if(seperatorFixedPath.length == 1){
-        let doc = (await  userDB.get('worlds').get(seperatorFixedPath[0]).promOnce()).data; //(await  userDB.get('worlds').promOnce()).data;
-       // let doc = Object.keys(worlds).includes('index_vwf_yaml');//(await  userDB.get('worlds').get(seperatorFixedPath).promOnce()).data;
-        if (doc) {
-            return true
-        }
-    }
-        return false
-    }
-
 
     // GenerateSegments takes a string, breaks it into
     // '/' separated segments, and removes potential

+ 15 - 0
public/lib/utils/log.js

@@ -0,0 +1,15 @@
+function log(o) {
+    if(typeof o === "object" && "_" in o) {
+      const obj = {...o};
+      delete obj._;
+      return console.log(obj);
+    }
+    return console.log(o);
+  }
+  
+  log.info = function(v) {
+    console.log(v + "\n" + "-".repeat(10));
+  }
+  
+export {log}
+  

+ 87 - 0
public/lib/utils/query.js

@@ -0,0 +1,87 @@
+const filterMetadata = (o) => {
+    const copy = {...o};
+    delete copy._;
+    return copy;
+  };
+  
+  const flatten = (arr) => {
+   return arr.reduce((c,v) => {
+     if(Array.isArray(v)){
+       return c.concat(flatten(v));
+     }
+     return c.concat(v);
+   }, []);
+  };
+  
+  function Query(db) {
+    if(!(this instanceof Query)) {
+      return new Query(db);
+    }
+    this.db = db;
+    this.nodes = [];
+    this.cursor = 0;
+    this.ctx = void 0;
+  }
+  
+  Query.prototype.add = function add(node) {
+    this.cursor += 1;
+    this.nodes.push(node);
+    this.ctx = this.nodes[this.nodes.length - 1];
+  };
+  
+  Query.prototype.getSet = function getSet() {
+    const n = this.ctx.then(v => {
+      if(Array.isArray(v)) {
+        return v.map(filterMetadata);
+      }
+      return filterMetadata(v);
+    })
+    .then(r => {
+      const getValues = (node) => {
+        return Promise.all(Object.keys(node).map(k => this.db.get(k).then()));
+      };
+      if(Array.isArray(r)) {
+        return Promise.all(r.map(getValues)).then(flatten);
+      }
+      return getValues(r);
+    })
+    this.add(n);
+    return this;
+  }
+  
+  Query.prototype.get = function get(path) {
+    if(this.cursor === 0) {
+      const node = this.db.get(path).then();
+      this.add(node);
+      return this;
+    }
+    const prev = this.nodes[this.cursor - 1];
+    const pNode = prev.then(r => {
+      if(Array.isArray(r)) {
+        const nodes = r.map(v => {
+          if(v[path] && v[path]["#"]) {
+            return this.db.get(v[path]["#"]).then();
+          }
+          return v[path] ? Promise.resolve(v[path]) : "";
+        });
+        return Promise.all(nodes.filter(v => v));
+      }
+      if(r[path] && r[path]["#"]) {
+        return this.db.get(r[path]["#"]).then();
+      }
+      return r[path] ? Promise.resolve(r[path]) : "";
+    });
+    this.add(pNode);
+    return this;
+  };
+  
+  Query.prototype.data = function data(cb) {
+    return this.ctx.then(v => {
+      if(Array.isArray(v)) {
+        return Promise.all(v);
+      }
+      return v;
+    });
+  };
+
+export {Query}

+ 19 - 26
public/vwf.js

@@ -283,6 +283,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
             }
 
             var userLibraries = args.shift() || {};
+            var conf = args.shift() || {};
             var applicationConfig = {};
 
             var callback = args.shift();
@@ -378,27 +379,6 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                 return activeLibraryList;
             }
 
-            let path =  JSON.parse(localStorage.getItem('lcs_app')).path.public_path;
-            let appName = JSON.parse(localStorage.getItem('lcs_app')).path.application.split(".").join("_");
-            let dbPath = appName + '_config_yaml';
-           
-            let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
-
-            userDB.get('worlds').get(path.slice(1)).get(dbPath).get('file').load(function(res) {
-                
-                var conf = "";
-
-                if (res) {
-                    let config = YAML.parse(res);
-                    conf = config
-                } 
-
-                let manualSettings = localStorage.getItem('lcs_app_manual_settings');
-                if(manualSettings){
-                    let manualConf = JSON.parse(manualSettings);
-                    conf.model = manualConf.model;
-                    conf.view = manualConf.view;
-                }
 
                 let confPromise = new Promise((resolve, reject) => {
                       resolve(conf); 
@@ -502,7 +482,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
 
                   
 
-            })
+            
 
             // jQuery.getJSON("admin/config", function(configLibraries) {
             // }).always(function(jqXHR, textStatus) { 
@@ -4597,7 +4577,11 @@ if ( ! childComponent.source ) {
                 if(dbName.includes("vwf_example_com")){
                     //userDB = await window._LCS_SYS_USER.get('proxy').then();
                    fileName = dbName;
-                   window._LCS_SYS_USER.get('proxy').get(fileName).get('file').load(comp=>{
+                   let dbNode = window._LCS_SYS_USER.get('proxy').get(fileName).get('file');
+
+                   let nodeProm = new Promise(res => dbNode.once(res))
+
+                   nodeProm.then(comp=>{
                     parseComp (comp);
                    })
                    
@@ -4611,7 +4595,10 @@ if ( ! childComponent.source ) {
                     let worldName = dbName.split('/')[0];
                     //userDB = await window._LCS_WORLD_USER.get('worlds').path(worldName).then();
                    fileName = dbName.replace(worldName + '/', "");
-                   userDB.get('worlds').path(worldName).get(fileName).get('file').load(comp=>{
+                   let dbNode = userDB.get('worlds').path(worldName).get(fileName).get('file');
+
+                   let nodeProm = new Promise(res => dbNode.once(res))
+                   nodeProm.then(comp=>{
                     parseComp (comp);
                    })
                    
@@ -4682,7 +4669,10 @@ if ( ! childComponent.source ) {
                 if(dbName.includes("vwf_example_com")){
                     //userDB = window._LCS_SYS_USER.get('proxy');
                     fileName = dbName;
-                    window._LCS_SYS_USER.get('proxy').get(fileName).get('file').load(comp=>{
+                    let dbNode = window._LCS_SYS_USER.get('proxy').get(fileName).get('file');
+                    let nodeProm = new Promise(res => dbNode.once(res))
+
+                    nodeProm.then(comp=>{
                         parseComp (comp);
                        })
                     // window._LCS_SYS_USER.get('proxy').get(fileName).get('file').once(function(r){
@@ -4692,7 +4682,10 @@ if ( ! childComponent.source ) {
  
                 } else {
                     fileName = dbName.replace(worldName + '/', "");
-                    userDB.get('worlds').path(worldName).get(fileName).get('file').load(comp=>{
+
+                    let dbNode = userDB.get('worlds').path(worldName).get(fileName).get('file');
+                    let nodeProm = new Promise(res => dbNode.once(res))
+                    nodeProm.then(comp=>{
                         parseComp (comp);
                        })
                     // userDB.get('worlds').path(worldName).get(fileName).get('file').once(function(r){

+ 202 - 214
public/web/index-app.js

@@ -16,15 +16,15 @@ class IndexApp {
         this.instances = {};
         //this.language = _LangManager.language;
 
-        if(!_app.isLuminary){
+        if (!_app.isLuminary) {
             this.initReflectorConnection();
         }
 
 
     }
 
-    
-    initReflectorConnection(){
+
+    initReflectorConnection() {
 
         this.options = {
 
@@ -95,35 +95,40 @@ class IndexApp {
             entry.appendChild(appEl);
         })
 
-        //init CELL
-        document.querySelector("#userLobby").$cell({
-            id: "userLobby",
+        document.querySelector("#worldsGUI").$cell({
+            id: "worldsGUI",
             $cell: true,
             $type: "div",
+            _comps: [],
+            _wcards: {},
             $components: [],
+            $refresh: function (comps) {
+                //do update;
+                //this._userAlias = user;
+                this._comps = comps;
+            },
+            $init: function () {
+                console.log('init comp...');
+            },
+
             $update: function () {
-                this.$components = self.initUserGUI()
+                //do update;
+                console.log('update me');
+                this.$components = this._comps;
             }
         });
 
-        document.querySelector("#worldsGUI").$cell({
-            id: 'worldsGUI',
+        //init CELL
+        document.querySelector("#userLobby").$cell({
+            id: "userLobby",
             $cell: true,
             $type: "div",
             $components: [],
-            _comps: [],
-            _refresh: async function (data, fn) {
-                _app.showProgressBar();
-                this._comps = await fn.call(self, data);
-                this.$update();
-                _app.hideProgressBar();
-            },
-            $update: async function () {
-                this.$components = this._comps
+            $update: function () {
+                this.$components = self.initUserGUI()
             }
         });
 
-
     }
 
     async generateFrontPage() {
@@ -164,43 +169,14 @@ class IndexApp {
     }
 
     async initWorldsProtosListForUser(userAlias) {
-        document.querySelector("#worldsGUI").$components = [];
-        await document.querySelector("#worldsGUI")._refresh(userAlias, this.getWorldsProtosListForUser);
-    }
-
-    async initWorldsStatesListForUser(userAlias) {
-        document.querySelector("#worldsGUI").$components = [];
-        await document.querySelector("#worldsGUI")._refresh(userAlias, this.getWorldsStatesListForUser);
-    }
-
-
-    async getWorldsStatesListForUser(userAlias) {
-
-        let worldsGUI = [];
-
-
-        let worlds = this.createWorldsGUI(userAlias, 'allStates' );
-
-        await _app.getAllStateWorldsInfoForUser(userAlias, function (data) {
-            let doc = document.querySelector("#allStates_" + userAlias);
-            if (doc) {
-                Object.assign(doc._states, data);
-                doc.$update();
-            }
-        }
-            );
-            worldsGUI.push(worlds);
-        // Object.entries(data).forEach(el => {
-
-        //     let worlds = this.createWorldsGUI(userAlias, el[0]);
-        //     worlds._states = el[1];
-        //     worlds.$update();
-        //     worldsGUI.push(worlds);
-
-        // })
+        let doc = document.querySelector("#worldsGUI");
+        //doc.$components = [];
+        let allInfo = await _app.getAllProtoWorldsInfoForUser(userAlias);//await this.getWorldsProtosListForUser(userAlias);
 
+        let worlds = this.createWorldsGUI(userAlias);
+        worlds._refresh(allInfo);
 
-        return [
+        let components = [
             {
                 $type: "div",
                 class: "mdc-layout-grid",
@@ -216,45 +192,41 @@ class IndexApp {
                                     {
                                         $type: "h1",
                                         class: "mdc-typography--headline4",
-                                        $text: 'States for ' + userAlias
+                                        $text: 'Worlds for ' + userAlias
                                     }
                                 ]
                             },
                             {
                                 $type: "div",
                                 class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                $components: [].concat(worldsGUI)
+                                $components: [worlds]
                             }
                         ]
                     }
                 ]
             }
-        ]
-    }
-
-    async getWorldsProtosListForUser(userAlias) {
+        ];
 
 
-        let worldsGUI = [];
+        doc.$refresh(components);
 
-        //let data = await _app.getAllProtoWorldsInfoForUser(userAlias);
+        //initiate update world cards
+        doc._wcards = worlds;
+        doc._wcards.$update();
 
-        let worlds = this.createWorldsGUI(userAlias);
+        console.log(allInfo);
 
-        await _app.getAllProtoWorldsInfoForUser(userAlias, function (data) {
+    }
 
-            let doc = document.querySelector("#allWorlds_" + userAlias);
-            if (doc) {
-                Object.assign(doc._states, data);
-                doc.$update();
-            }
-        })
+    async initWorldsStatesListForUser(userAlias) {
 
-        //worlds._states = data;
-        //worlds.$update();
-        worldsGUI.push(worlds);
+        let doc = document.querySelector("#worldsGUI");
+        //doc.$components = [];
+        let allInfo = await _app.getAllStateWorldsInfoForUser(userAlias);//await this.getWorldsProtosListForUser(userAlias);
 
-        return [
+        let worlds = this.createWorldsGUI(userAlias, 'allStates');
+        worlds._refresh(allInfo);
+        let components = [
             {
                 $type: "div",
                 class: "mdc-layout-grid",
@@ -270,25 +242,35 @@ class IndexApp {
                                     {
                                         $type: "h1",
                                         class: "mdc-typography--headline4",
-                                        $text: 'Worlds for ' + userAlias
+                                        $text: 'States for ' + userAlias
                                     }
                                 ]
                             },
                             {
                                 $type: "div",
                                 class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                $components: [].concat(worldsGUI)
-                            },
+                                $components: [].concat(worlds)
+                            }
                         ]
                     }
                 ]
             }
         ]
+
+        doc.$refresh(components);
+
+        //initiate update world cards
+        doc._wcards = worlds;
+        doc._wcards.$update();
+
+        console.log(allInfo);
+
     }
 
+
     initUser() {
 
-        _LCSDB.on('auth', function(ack) {
+        _LCSDB.on('auth', function (ack) {
 
             if (ack.sea.pub) {
 
@@ -300,13 +282,13 @@ class IndexApp {
                 // document.querySelector('#worldGUI').$update();
                 // document.querySelector('#main').$update();
 
-                _LCSDB.get('users').get(alias).not(function(res) {
+                _LCSDB.get('users').get(alias).not(function (res) {
                     let userObj = {
                         alias: alias,
                         pub: ack.sea.pub
                     }
                     _LCSDB.get('users').get(alias).put(userObj);
-                  })
+                })
 
                 _LCSDB.user().get('profile').once(function (data) { console.log(data) })
 
@@ -368,7 +350,7 @@ class IndexApp {
                             "onclick": function (e) {
                                 e.preventDefault();
                                 //page("/app/worlds/states")
-                                 window.location.pathname = "/app/worlds/states"
+                                window.location.pathname = "/app/worlds/states"
                                 //_app.indexApp.getAppDetailsFromDefaultDB('states');
 
                             }
@@ -394,54 +376,54 @@ class IndexApp {
             $cell: true,
             _luminarySwitch: null,
             $components: [
-              {
-                $type: "p",
-                class: "mdc-typography--headline5",
-                $text: "Use Krestianstvo Luminary (experimental)"
-              },
-              {
-                $type: 'p'
-              },
-              _app.widgets.switch({
-                'id': 'forceLuminary',
-                'init': function () {
-                  this._switch = new mdc.switchControl.MDCSwitch(this);
-                  let config = localStorage.getItem('lcs_config');
-                  this._switch.checked = JSON.parse(config).luminary;
-                  
-                 // this._replaceSwitch = this._switch;
-                  
+                {
+                    $type: "p",
+                    class: "mdc-typography--headline5",
+                    $text: "Use Krestianstvo Luminary (experimental)"
                 },
-                'onchange': function (e) {
-
-                    if (this._switch) {
-                        let chkAttr = this._switch.checked;//this.getAttribute('checked');
-                        if (chkAttr) {
-                            let config = JSON.parse(localStorage.getItem('lcs_config'));
-                            config.luminary = true;
-                            localStorage.setItem('lcs_config', JSON.stringify(config));
-                            window.location.reload(true);
-                            //this._switch.checked = false;
-                        } else {
-                            let config = JSON.parse(localStorage.getItem('lcs_config'));
-                            config.luminary = false;
-                            localStorage.setItem('lcs_config', JSON.stringify(config));
-                            window.location.reload(true);
+                {
+                    $type: 'p'
+                },
+                _app.widgets.switch({
+                    'id': 'forceLuminary',
+                    'init': function () {
+                        this._switch = new mdc.switchControl.MDCSwitch(this);
+                        let config = localStorage.getItem('lcs_config');
+                        this._switch.checked = JSON.parse(config).luminary;
+
+                        // this._replaceSwitch = this._switch;
+
+                    },
+                    'onchange': function (e) {
+
+                        if (this._switch) {
+                            let chkAttr = this._switch.checked;//this.getAttribute('checked');
+                            if (chkAttr) {
+                                let config = JSON.parse(localStorage.getItem('lcs_config'));
+                                config.luminary = true;
+                                localStorage.setItem('lcs_config', JSON.stringify(config));
+                                window.location.reload(true);
+                                //this._switch.checked = false;
+                            } else {
+                                let config = JSON.parse(localStorage.getItem('lcs_config'));
+                                config.luminary = false;
+                                localStorage.setItem('lcs_config', JSON.stringify(config));
+                                window.location.reload(true);
+                            }
                         }
                     }
                 }
-              }
-              ),
-              {
-                $type: 'label',
-                for: 'input-forceLuminary',
-                $text: 'On / Off'
-              }
+                ),
+                {
+                    $type: 'label',
+                    for: 'input-forceLuminary',
+                    $text: 'On / Off'
+                }
 
             ]
-          }
+        }
+
 
-          
 
         let userGUI =
         {
@@ -463,13 +445,12 @@ class IndexApp {
                                 "label": 'Sign OUT',
                                 "onclick": function (e) {
                                     _LCSDB.user().leave();
-                                    setTimeout(() =>  
-                                   {
-                                    //window.sessionStorage.removeItem('alias');
-                                    //window.sessionStorage.removeItem('tmp');
-                                    window.location.reload(true);
-                                }, 1);
-                                   
+                                    setTimeout(() => {
+                                        //window.sessionStorage.removeItem('alias');
+                                        //window.sessionStorage.removeItem('tmp');
+                                        window.location.reload(true);
+                                    }, 1);
+
                                 }
                             }),
                         {
@@ -504,7 +485,7 @@ class IndexApp {
                                 "onclick": function (e) {
                                     e.preventDefault();
                                     let alias = _LCSDB.user().is.alias;
-                                     window.location.pathname = '/' + alias + '/worlds/states'
+                                    window.location.pathname = '/' + alias + '/worlds/states'
                                     //page('/' + alias + '/worlds/states');
                                     // page.redirect('/' + alias + '/worlds/states');
                                     //_app.indexApp.getWorldsFromUserDB(alias);       
@@ -522,7 +503,7 @@ class IndexApp {
                                 window.location.pathname = '/settings';
                             }
                         }), _app.widgets.emptyDiv,
-                        _app.widgets.divider,
+                    _app.widgets.divider,
                     {
                         $type: "h1",
                         class: "mdc-typography--headline3",
@@ -626,7 +607,7 @@ class IndexApp {
                                                 } else {
                                                     //
                                                     _LCSDB.user().create(alias, pass,
-                                                        function(ack) {
+                                                        function (ack) {
                                                             if (!ack.wait) { }
                                                             if (ack.err) {
                                                                 console.log(ack.err)
@@ -638,11 +619,11 @@ class IndexApp {
                                                                     'pub': ack.pub
                                                                 };
                                                                 _LCSDB.get('users').get(alias).put(userObj);
-                                                                
+
                                                             }
                                                             _LCSDB.user().auth(alias, pass);
                                                         });
-                                                        
+
                                                 }
                                             }
                                         }),
@@ -746,7 +727,7 @@ class IndexApp {
                                             $type: "a",
                                             $text: m[0],
                                             //target: "_blank",
-                                           // href: window.location.protocol + "//" + window.location.host + "/" + m[1].user + m[0],
+                                            // href: window.location.protocol + "//" + window.location.host + "/" + m[1].user + m[0],
                                             onclick: function (e) {
                                                 self.checkForManualSettings();
                                                 window.location.pathname = "/" + m[1].user + m[0];
@@ -783,48 +764,48 @@ class IndexApp {
             },
             $init: function () {
 
-                if(_app.isLuminary){
+                if (_app.isLuminary) {
                     let luminaryPath = _app.luminaryPath;
                     let ref = _LCSDB.get(luminaryPath);
                     setInterval(function () {
-    
-                    ref.get('allclients').once().map().once(res => {
-    
-                        if (res) {
-                            if (res.id) {
-                                let clientTime = Gun.state.is(res, 'live');
-                                let now = Gun.time.is();
-    
-                                if (now - clientTime < 10000) {
-                                    let instance = res.user + res.instance;
-                                    //let data = JSON.stringify({[res.instance]: {instance: instance, clients: {}, user: res.user, loadInfo: {}}});
-                                    //console.log(data);
-                                    if(!self.instances[res.instance]) {
-                                    self.instances[res.instance] = {id: res.instance, instance: instance, clients: {[res.id]: res}, user: res.user, loadInfo: {} }
+
+                        ref.get('allclients').once().map().once(res => {
+
+                            if (res) {
+                                if (res.id) {
+                                    let clientTime = Gun.state.is(res, 'live');
+                                    let now = Gun.time.is();
+
+                                    if (now - clientTime < 10000) {
+                                        let instance = res.user + res.instance;
+                                        //let data = JSON.stringify({[res.instance]: {instance: instance, clients: {}, user: res.user, loadInfo: {}}});
+                                        //console.log(data);
+                                        if (!self.instances[res.instance]) {
+                                            self.instances[res.instance] = { id: res.instance, instance: instance, clients: { [res.id]: res }, user: res.user, loadInfo: {} }
+                                        } else {
+                                            self.instances[res.instance].clients[res.id] = res
+                                        }
+                                        let data = JSON.stringify(self.instances);
+                                        self.parseOnlineData(data);
+
                                     } else {
-                                        self.instances[res.instance].clients[res.id] = res
-                                    }
-                                    let data = JSON.stringify(self.instances);
-                                    self.parseOnlineData(data);
-                                    
-                                } else {
-                                    if(self.instances[res.instance]){
-                                    delete self.instances[res.instance].clients[res.id];
-                                    if(Object.keys(self.instances[res.instance].clients).length == 0){
-                                        delete self.instances[res.instance];
-                                        self.parseOnlineData(JSON.stringify({}));
-                                    }
+                                        if (self.instances[res.instance]) {
+                                            delete self.instances[res.instance].clients[res.id];
+                                            if (Object.keys(self.instances[res.instance].clients).length == 0) {
+                                                delete self.instances[res.instance];
+                                                self.parseOnlineData(JSON.stringify({}));
+                                            }
+                                        }
+
+                                        //ref.get('instances').get(res.instance).get(res.id).put(null);
                                     }
-                                        
-                                    //ref.get('instances').get(res.instance).get(res.id).put(null);
+
                                 }
-    
                             }
                         }
-                    }
-                    )
-                }, 5000);
-    
+                        )
+                    }, 5000);
+
 
                 }
 
@@ -917,9 +898,9 @@ class IndexApp {
                     //target: "_blank",
                     //href: "/" + desc.userAlias + '/' + desc.worldName,
                     onclick: function (e) {
-                            self.checkForManualSettings();
-                            window.location.pathname = "/" + desc.userAlias + '/' + desc.worldName
-                           
+                        self.checkForManualSettings();
+                        window.location.pathname = "/" + desc.userAlias + '/' + desc.worldName
+
                         //self.refresh();
                     }
                 });
@@ -956,6 +937,13 @@ class IndexApp {
 
 
                 online.push(onlineGUI);
+                if(!desc.info){
+                    desc.info = {
+                        imgUrl: "/defaults/worlds/webrtc/webimg.jpg",
+                        text: "..no text",
+                        title: "..no title"
+                    }
+                }
 
                 return {
                     $cell: true,
@@ -1067,7 +1055,7 @@ class IndexApp {
                     $type: "div",
                     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
                     $components: [
-                       
+
                         card
 
                         //self.createWorldCard(data[1].userAlias, data[1].worldName, data[0])
@@ -1078,11 +1066,11 @@ class IndexApp {
             },
             $update: function () {
                 let cards = Object.entries(this._states)
-                .filter(el => Object.keys(el[1]).length !== 0)
-                .sort(function (el1, el2) {
-                    return parseInt(el2[1].created) - parseInt(el1[1].created)
-                })
-                .map(this._makeWorldCard);
+                    .filter(el => Object.keys(el[1]).length !== 0)
+                    .sort(function (el1, el2) {
+                        return parseInt(el2[1].created) - parseInt(el1[1].created)
+                    })
+                    .map(this._makeWorldCard);
 
                 this.$components = [
                     {
@@ -1125,45 +1113,45 @@ class IndexApp {
 
     checkForManualSettings() {
         console.log("check for manual settings");
-                            let manualSettings = localStorage.getItem('lcs_app_manual_settings');
-                            if(manualSettings){
-                                localStorage.removeItem('lcs_app_manual_settings');
-                            }
-                          
-                            let el = document.querySelector('#runWorldGUI');
-                            if (el) {
-                                if (el._arSwitch.checked){
-
-                                let arSettings = {
-                                    model:{
-                                        'vwf/model/aframe': null
-                                }, 
-                                    view:{
-                                        'vwf/view/aframe' : null,
-                                        'vwf/view/editor-new': null
-                                }
-                            }
+        let manualSettings = localStorage.getItem('lcs_app_manual_settings');
+        if (manualSettings) {
+            localStorage.removeItem('lcs_app_manual_settings');
+        }
+
+        let el = document.querySelector('#runWorldGUI');
+        if (el) {
+            if (el._arSwitch.checked) {
+
+                let arSettings = {
+                    model: {
+                        'vwf/model/aframe': null
+                    },
+                    view: {
+                        'vwf/view/aframe': null,
+                        'vwf/view/editor-new': null
+                    }
+                }
 
-                                    localStorage.setItem('lcs_app_manual_settings', JSON.stringify(arSettings));
-                                } 
+                localStorage.setItem('lcs_app_manual_settings', JSON.stringify(arSettings));
+            }
 
-                                if (el._turnArOnSwitch.checked){
+            if (el._turnArOnSwitch.checked) {
 
-                                    let arSettings = {
-                                        model:{
-                                            'vwf/model/aframe': null
-                                    }, 
-                                        view:{
-                                            'vwf/view/aframe' : null,
-                                            'vwf/view/aframe-ar-driver': null
-                                    }
-                                }
-    
-                                        localStorage.setItem('lcs_app_manual_settings', JSON.stringify(arSettings));
-                                    } 
-    
-                                
-                            }
+                let arSettings = {
+                    model: {
+                        'vwf/model/aframe': null
+                    },
+                    view: {
+                        'vwf/view/aframe': null,
+                        'vwf/view/aframe-ar-driver': null
+                    }
+                }
+
+                localStorage.setItem('lcs_app_manual_settings', JSON.stringify(arSettings));
+            }
+
+
+        }
     }
 
 

+ 4 - 3
public/web/world-app.js

@@ -424,9 +424,10 @@ class WorldApp {
 
 
         if (!saveName) {
-            info = await _app.getWorldInfo(user, space);
+            info = await _app.getAllProtoWorldsInfoForUser(user.user, space) //await _app.getWorldInfo(user, space);
         } else {
-            info = await _app.getStateInfo(user, space, saveName);
+            let loadName = space + "/load/" + saveName;
+            info = await _app.getAllStateWorldsInfoForUser(user.user, space, loadName) //await _app.getStateInfo(user, space, saveName);
         }
         worldCardGUI._worldInfo = info;
         worldCardGUI.$update();
@@ -434,7 +435,7 @@ class WorldApp {
 
 
         if (!saveName) {
-            let statesData = await _app.getSaveStates(user, space);
+            let statesData = await _app.getAllStateWorldsInfoForUser(user.user, space) //await _app.getSaveStates(user, space);
             //let worldStates = this.createWorldStatesGUI();
             let worldStates = document.querySelector("#worldStatesGUI");
             worldStates._states = statesData;

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor