//
// $Id: InfohubContext.js 8501 2025-08-31 14:05:09Z jochen.hanff $
// // @ts-check
import { cnContext } from "../infohub/cnContext.js"
/**
*
* @category PortalServices
*
* @classdesc COLNEO infohub Web Portal Services <br>
* Class PortalServices provides methods to facilitate portal specific functions and services
* such as creating links to objects in table view or detail view.
*
*/
export class PortalServices {
#_hosturl = "";
#_path = "";
#_ctx = null;
/**
*
* Create a new object for web portal services.
*
* @param {cnContext} ctx Infohub context
* @param {string} hosturl URL of server, example "https://colneo.services"
* @param {string} path Path to web portal, e.g. "/cn_portal"
*
* @since 1.0, 09.2025, jh
*
*/
constructor( ctx , hosturl , path ) {
this.#_hosturl = hosturl;
this.#_path = path;
this.#_ctx = ctx;
}
/**
*
* Generate link to table view of object/node in portal
*
* @param {string} node_shortid
* @returns {string} Link
*/
getUrlForTableView( node_shortid) {
// let urlportal = this.#_url_portal || 'cn_portal'
// return `${window.location.protocol}//${window.location.hostname}/${this.#_path}?scope=${ctx.getScope()}#/documents/${node_shortid}`;
return `${this.#_hosturl}/${this.#_path}?scope=${this.#_ctx.getScope()}#/documents/${node_shortid}`;
}
/**
*
* Generate link to detail view of object/node in portal
*
* @param {string} node_shortid
* @returns {string} Link
*/
getUrlForDetailView ( node_shortid ) {
// let link = window.location.protocol + "//" + window.location.hostname + "/" + this.#_path +"?scope=" + ctx.getScope() + "#/view/" + node_shortid
return `${this.#_hosturl}/${this.#_path}?scope=${this.#_ctx.getScope()}#/view/${node_shortid}`;
}
}
Source