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/application/dialog/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/application/dialog/src/controller.js
/**
 * Bitrix Im
 * Dialog application
 *
 * @package bitrix
 * @subpackage im
 * @copyright 2001-2020 Bitrix
 */

// vue
import {VueVendorV2} from "ui.vue";

// im
import {Core} from "im.application.core";
import {Utils} from "im.lib.utils";
import {Logger} from "im.lib.logger";
import {DialogRestHandler} from "im.provider.rest";

// core
import "promise";

// pull
import {PULL as Pull} from "pull.client";

// component
import "./view";

export class DialogApplication
{
	/* region 01. Initialize */

	constructor(params = {})
	{
		this.inited = false;
		this.initPromise = new BX.Promise;

		this.params = params;

		this.template = null;
		this.rootNode = this.params.node || document.createElement('div');

		this.event = new VueVendorV2;

		this.initCore()
			.then(() => this.initComponent())
			.then(() => this.initComplete())
		;
	}

	initCore()
	{
		return new Promise((resolve, reject) => {
			Core.ready().then(controller => {
				this.controller = controller;
				resolve();
			})
		});
	}

	initComponent()
	{
		console.log('2. initComponent');

		this.controller.getStore().commit('application/set', {
			dialog: {
				dialogId: this.getDialogId()
			},
			options: {
				quoteEnable: true,
				autoplayVideo: true,
				darkBackground: false
			}
		});

		this.controller.addRestAnswerHandler(
			DialogRestHandler.create({
				store: this.controller.getStore(),
				controller: this.controller,
				context: this,
			})
		);

		let dialog = this.controller.getStore().getters['dialogues/get'](this.controller.application.getDialogId());
		if (dialog)
		{
			this.controller.getStore().commit('application/set', {dialog: {
				chatId: dialog.chatId,
				diskFolderId: dialog.diskFolderId || 0
			}});
		}

		return this.controller.createVue(this, {
			el: this.rootNode,
			data: () =>
			{
				return {
					userId: this.getUserId(),
					dialogId: this.getDialogId()
				};
			},
			// language=Vue
			template: `<bx-im-application-dialog :userId="userId" :initialDialogId="dialogId"/>`,
		})
		.then(vue => {
			this.template = vue;
			return new Promise((resolve, reject) => resolve());
		});
	}

	initComplete()
	{
		this.inited = true;
		this.initPromise.resolve(this);
	}

	ready()
	{
		if (this.inited)
		{
			let promise = new BX.Promise;
			promise.resolve(this);

			return promise;
		}

		return this.initPromise;
	}

/* endregion 01. Initialize */

/* region 02. Methods */

	getUserId()
	{
		let userId = this.params.userId || this.getLocalize('USER_ID');
		return userId? parseInt(userId): 0;
	}

	getDialogId()
	{
		return this.params.dialogId? this.params.dialogId.toString(): "0";
	}

	getHost()
	{
		return location.origin || '';
	}

	getSiteId()
	{
		return 's1';
	}

/* endregion 02. Methods */

/* region 03. Utils */

	addLocalize(phrases)
	{
		return this.controller.addLocalize(phrases);
	}

	getLocalize(name)
	{
		return this.controller.getLocalize(name);
	}

/* endregion 03. Utils */
}

Youez - 2016 - github.com/yon3zu
LinuXploit