|
@@ -8,8 +8,6 @@ import INTERFACE_CONFIG_WHITELIST from './interfaceConfigWhitelist';
|
8
|
8
|
import parseURLParams from './parseURLParams';
|
9
|
9
|
import logger from './logger';
|
10
|
10
|
|
11
|
|
-declare var $: Object;
|
12
|
|
-
|
13
|
11
|
// XXX The functions getRoomName and parseURLParams are split out of
|
14
|
12
|
// functions.js because they are bundled in both app.bundle and
|
15
|
13
|
// do_external_connect, webpack 1 does not support tree shaking, and we don't
|
|
@@ -40,69 +38,6 @@ export function createFakeConfig(baseURL: string) {
|
40
|
38
|
};
|
41
|
39
|
}
|
42
|
40
|
|
43
|
|
-/**
|
44
|
|
- * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
|
45
|
|
- * to React app it's better to use load config instead.
|
46
|
|
- *
|
47
|
|
- * @param {string} location - URL of the domain from which the config is to be
|
48
|
|
- * obtained.
|
49
|
|
- * @param {string} room - Room name.
|
50
|
|
- * @private
|
51
|
|
- * @returns {Promise<void>}
|
52
|
|
- */
|
53
|
|
-export function obtainConfig(location: string, room: string): Promise<void> {
|
54
|
|
- return new Promise((resolve, reject) =>
|
55
|
|
- _obtainConfig(location, room, (success, error) => {
|
56
|
|
- success ? resolve() : reject(error);
|
57
|
|
- })
|
58
|
|
- );
|
59
|
|
-}
|
60
|
|
-
|
61
|
|
-/**
|
62
|
|
- * Sends HTTP POST request to specified {@code endpoint}. In request the name
|
63
|
|
- * of the room is included in JSON format:
|
64
|
|
- * {
|
65
|
|
- * "rooomName": "someroom12345"
|
66
|
|
- * }.
|
67
|
|
- *
|
68
|
|
- * @param {string} endpoint - The name of HTTP endpoint to which to send
|
69
|
|
- * the HTTP POST request.
|
70
|
|
- * @param {string} roomName - The name of the conference room for which config
|
71
|
|
- * is requested.
|
72
|
|
- * @param {Function} complete - The callback to invoke upon success or failure.
|
73
|
|
- * @returns {void}
|
74
|
|
- */
|
75
|
|
-function _obtainConfig(endpoint: string, roomName: string, complete: Function) {
|
76
|
|
- logger.info(`Send config request to ${endpoint} for room: ${roomName}`);
|
77
|
|
- $.ajax(
|
78
|
|
- endpoint,
|
79
|
|
- {
|
80
|
|
- contentType: 'application/json',
|
81
|
|
- data: JSON.stringify({ roomName }),
|
82
|
|
- dataType: 'json',
|
83
|
|
- method: 'POST',
|
84
|
|
-
|
85
|
|
- error(jqXHR, textStatus, errorThrown) {
|
86
|
|
- logger.error('Get config error: ', jqXHR, errorThrown);
|
87
|
|
- complete(false, `Get config response status: ${textStatus}`);
|
88
|
|
- },
|
89
|
|
- success(data) {
|
90
|
|
- const { config, interfaceConfig, loggingConfig } = window;
|
91
|
|
-
|
92
|
|
- try {
|
93
|
|
- overrideConfigJSON(
|
94
|
|
- config, interfaceConfig, loggingConfig,
|
95
|
|
- data);
|
96
|
|
- complete(true);
|
97
|
|
- } catch (e) {
|
98
|
|
- logger.error('Parse config error: ', e);
|
99
|
|
- complete(false, e);
|
100
|
|
- }
|
101
|
|
- }
|
102
|
|
- }
|
103
|
|
- );
|
104
|
|
-}
|
105
|
|
-
|
106
|
41
|
/* eslint-disable max-params, no-shadow */
|
107
|
42
|
|
108
|
43
|
/**
|