_onProjectItemClicked(projectName) {
    this.selectedProject = this.getProjectByName(projectName);
    let event = new CustomEvent("project-selected", {
      detail: {
        message: "Selected project in project list.",
        project: JSON.parse(JSON.stringify(this.selectedProject))
      },
      bubbles: true
    });
    this.dispatchEvent(event);

    // join Yjs room for the project metadata
    if(this.y) {
      this.y.connector.disconnect();
    }
    Y({
      db: {
        name: "memory" // store the shared data in memory
      },
      connector: {
        name: "websockets-client", // use the websockets connector
        room: "projects_" + this.system + "_" + projectName,
        authInfo: {
          accessToken: Auth.getAccessToken(),
          basicAuth: Auth.getBasicAuthPart()
        },
        //options: { resource: this.yjsResourcePath},
        url: this.yjsAddress
      },
      share: { // specify the shared content
        data: 'Map'
      }
    }).then(function(y) {
      this.y = y;
      const currentMetadataYjs = y.share.data.get("projectMetadata");

      y.share.data.observe(event => {
        if(event.name == "projectMetadata") {
          this.selectedProject.metadata = y.share.data.get("projectMetadata");
          window.dispatchEvent(new CustomEvent("metadata-changed", {
            detail: JSON.parse(JSON.stringify(this.selectedProject.metadata)),
            bubbles: true
          }));
        }
      });

      if(!currentMetadataYjs) {
        y.share.data.set("projectMetadata", JSON.parse(JSON.stringify(this.selectedProject.metadata)));
      }
    }.bind(this));
  }
/**
   * Gets called when the user clicks on a project in the project list. Fires an event that notifies the parent
   * elements that a project got selected.
   * @param projectName Name of the project that got selected in the project list.
   * @private
   */
Gets called when the user clicks on a project in the project list. Fires an event that notifies the parent
elements that a project got selected.
@param projectName Name of the project that got selected in the project list.
@private
Gets called when the user clicks on a project in the project list . Fires an event that notifies the parent elements that a project got selected . @param projectName Name of the project that got selected in the project list . @private
_onProjectItemClicked(projectName) {
    this.selectedProject = this.getProjectByName(projectName);
    let event = new CustomEvent("project-selected", {
      detail: {
        message: "Selected project in project list.",
        project: JSON.parse(JSON.stringify(this.selectedProject))
      },
      bubbles: true
    });
    this.dispatchEvent(event);
    if(this.y) {
      this.y.connector.disconnect();
    }
    Y({
      db: {
        name: "memory" 
      },
      connector: {
        name: "websockets-client", 
        room: "projects_" + this.system + "_" + projectName,
        authInfo: {
          accessToken: Auth.getAccessToken(),
          basicAuth: Auth.getBasicAuthPart()
        },
        url: this.yjsAddress
      },
      share: { 
        data: 'Map'
      }
    }).then(function(y) {
      this.y = y;
      const currentMetadataYjs = y.share.data.get("projectMetadata");
      y.share.data.observe(event => {
        if(event.name == "projectMetadata") {
          this.selectedProject.metadata = y.share.data.get("projectMetadata");
          window.dispatchEvent(new CustomEvent("metadata-changed", {
            detail: JSON.parse(JSON.stringify(this.selectedProject.metadata)),
            bubbles: true
          }));
        }
      });
      if(!currentMetadataYjs) {
        y.share.data.set("projectMetadata", JSON.parse(JSON.stringify(this.selectedProject.metadata)));
      }
    }.bind(this));
  }
_onProjectItemClicked ( projectName ) { this . selectedProject = this . getProjectByName ( projectName ) ; let event = new CustomEvent ( "project-selected" , { detail : { message : "Selected project in project list." , project : JSON . parse ( JSON . stringify ( this . selectedProject ) ) } , bubbles : true } ) ; this . dispatchEvent ( event ) ; if ( this . y ) { this . y . connector . disconnect ( ) ; } Y ( { db : { name : "memory" } , connector : { name : "websockets-client" , room : "projects_" + this . system + "_" + projectName , authInfo : { accessToken : Auth . getAccessToken ( ) , basicAuth : Auth . getBasicAuthPart ( ) } , url : this . yjsAddress } , share : { data : 'Map' } } ) . then ( function ( y ) { this . y = y ; const currentMetadataYjs = y . share . data . get ( "projectMetadata" ) ; y . share . data . observe ( event => { if ( event . name == "projectMetadata" ) { this . selectedProject . metadata = y . share . data . get ( "projectMetadata" ) ; window . dispatchEvent ( new CustomEvent ( "metadata-changed" , { detail : JSON . parse ( JSON . stringify ( this . selectedProject . metadata ) ) , bubbles : true } ) ) ; } } ) ; if ( ! currentMetadataYjs ) { y . share . data . set ( "projectMetadata" , JSON . parse ( JSON . stringify ( this . selectedProject . metadata ) ) ) ; } } . bind ( this ) ) ; }
Gets called when the user clicks on a project in the project list.
Gets called when the user clicks on a project in the project list .
// join Yjs room for the project metadata // store the shared data in memory // use the websockets connector //options: { resource: this.yjsResourcePath}, // specify the shared content