Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
externalDrivers.forEach( (d) => {
if (get(d, 'hasUi')) {
const jsUrl = proxifyUrl(d.uiUrl, this.get('app.proxyEndpoint'));
const cssUrl = proxifyUrl(d.uiUrl.replace(/\.js$/, '.css'), get(this, 'app.proxyEndpoint'));
// skip setProperties cause of weird names
set(promises, `${ d.name }Js`, loadScript(jsUrl, `driver-ui-js-${ d.name }`));
set(promises, `${ d.name }Css`, loadStylesheet(cssUrl, `driver-ui-css-${ d.name }`));
}
});
if (isEmpty(promises)) {
return model;
} else {
return hashSettled(promises).then( (settled) => {
let allkeys = Object.keys(settled);
allkeys.forEach( (key) => {
if (get(settled, `${ key }.state`) === 'rejected') {
let tmp = key.indexOf('Js') > -1 ? key.replace(/\Js$/, '') : key.replace(/\Css$/, '');
let match = kontainerDrivers.findBy('id', tmp);
console.log('Error Loading External Component for: ', match);
if (match && get(match, 'scriptError') !== true) {
set(match, 'scriptError', get(this, 'intl').t('clusterNew.externalError'));
}
}
});
}).finally(() => {
return model;
});
let { kontainerDrivers } = model;
let externalDrivers = kontainerDrivers.filter( (d) => d.uiUrl !== '' && d.state === 'active');
let promises = {};
externalDrivers.forEach( (d) => {
if (get(d, 'hasUi')) {
const jsUrl = proxifyUrl(d.uiUrl, this.get('app.proxyEndpoint'));
const cssUrl = proxifyUrl(d.uiUrl.replace(/\.js$/, '.css'), get(this, 'app.proxyEndpoint'));
// skip setProperties cause of weird names
set(promises, `${ d.name }Js`, loadScript(jsUrl, `driver-ui-js-${ d.name }`));
set(promises, `${ d.name }Css`, loadStylesheet(cssUrl, `driver-ui-css-${ d.name }`));
}
});
return hashSettled(promises).then( (settled) => {
let allkeys = Object.keys(settled);
allkeys.forEach( (key) => {
if (get(settled, `${ key }.state`) === 'rejected') {
let tmp = key.indexOf('Js') > -1 ? key.replace(/\Js$/, '') : key.replace(/\Css$/, '');
let match = kontainerDrivers.findBy('id', tmp);
console.log('Error Loading External Component for: ', match);
if (match && get(match, 'scriptError') !== true) {
set(match, 'scriptError', get(this, 'intl').t('clusterNew.externalError'));
}
}
});
}).finally(() => {
return model;
});
function generateContext() {
var services = dnsCache.srv;
var a_records = dnsCache.a;
var promises = {};
services.forEach((value, dnsName) => promises[dnsName] = resolveSRV(dnsName));
a_records.forEach((value, dnsName) => promises[dnsName] = resolveA(dnsName));
debug('Starting DNS lookups for keys=%j', Object.keys(promises));
return RSVP.hashSettled(promises).then(function (result) {
debug('DNS lookup completed');
var context = {};
Object.keys(result).map(key => {
var promiseResult = result[key];
if (promiseResult && promiseResult.state === 'fulfilled') {
// A record lookups do not have ports
if ( typeof(promiseResult.value[0]['port']) == "undefined" )
a_records.set(key, promiseResult.value);
else
services.set(key, promiseResult.value);
} else {
// Set key as undefined but do not delete it
services.set(key);
a_records.set(key);
}
});
_resolvePromises(promises) {
if (promises && typeof promises.then === 'function') {
return RSVP.Promise.resolve(promises);
}
if (Array.isArray(promises)) {
if (this.get('forceResolveAll')) {
return RSVP.allSettled(promises);
}
return RSVP.all(promises);
}
if (typeOf(promises) === 'object') {
if (this.get('forceResolveAll')) {
return RSVP.hashSettled(promises);
}
return RSVP.hash(promises);
}
return RSVP.Promise.resolve(promises);
},
return new EmberPromise((resolve, reject) => {
hashSettled(promiseHash).then((results) => {
let model = EmberObject.create();
if (results.visitTypes.state === 'fulfilled') {
model.set('visitTypesList', results.visitTypes.value);
}
if (results.visitFormsOption.state === 'fulfilled') {
model.set('visitForms', results.visitFormsOption.value);
} else {
model.set('visitForms', {});
}
resolve(model);
}, reject);
});
}