Last active
May 18, 2018 23:18
-
-
Save theredpea/95c696a6ca8003f1d657af1f80e0413d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Note the use of "s.create(...) below | |
//a=["qvangular", "core.utils/authentication", "core.utils/deferred", "core.utils/websocket", "general.controllers/error-handler-controller", "general.controllers/warning-handler-controller", "enigma", "enigma-sense-utilities", "autogenerated/qix/engine-api", "autogenerated/qix/engine-enums", "util", "translator", "core.models/mixins/all"]; | |
//(function(e, t, n, i, r, o, s, a, l, c, u, h, d) { console.log(s);})(...a) | |
//logs "s"; | |
//whose value is: 'enigma' | |
//l must be module "autogenerated/qix/engine-api" | |
define("core.models/communication", ["qvangular", "core.utils/authentication", "core.utils/deferred", "core.utils/websocket", "general.controllers/error-handler-controller", "general.controllers/warning-handler-controller", "enigma", "enigma-sense-utilities", "autogenerated/qix/engine-api", "autogenerated/qix/engine-enums", "util", "translator", "core.models/mixins/all"], function(e, t, n, i, r, o, s, a, l, c, u, h, d) { | |
"use strict"; | |
function p(t, n, i) { | |
t.code !== c.LocalizedErrorCode.LOCERR_GENERIC_ABORTED && e.getService("$timeout")(function() { | |
t.isHandled || (i ? i() : n ? n(t) : r.showDialog(t)) | |
}, 1e3) | |
} | |
function f(e, t) { | |
var n = []; | |
if (e.warnings && (1 !== e.warnings.length || e.warnings[0] !== c.LocalizedWarningCode.LOCWARN_EXPORT_DATA_TRUNCATED)) { | |
for (var i = 0; i < e.warnings.length; i++) | |
n.push({ | |
code: e.warnings[i] | |
}); | |
t ? t(e) : o.showDialog(n) | |
} | |
} | |
function m(e, t, i) { | |
var r = t.handle ? e.apis.getApi(t.handle) : void 0; | |
return r && !r.isCancelled && i.code === c.LocalizedErrorCode.LOCERR_GENERIC_ABORTED && q.indexOf(t.method) > -1 ? (i.isHandled = !0, | |
t.retry()) : n.reject(i) | |
} | |
function g(e, t, i) { | |
return i.code === l.enums.LocalizedErrorCode.LOCERR_HC_MODAL_OBJECT_ERROR ? (i.isHandled = !0, | |
e.app.abortModalSelection().then(function() { | |
return t.retry() | |
})) : n.reject(i) | |
} | |
function v(e) { | |
if (void 0 === e && (e = {}), | |
void 0 === e.urlParams && (e.urlParams = {}), | |
e.ttl = parseFloat(u.getParameterByName("ttl")), | |
isNaN(e.ttl) || (e.suspendOnClose = !0), | |
"string" != typeof e.host && (e.host = u.hostname), | |
"string" != typeof e.port && (e.port = u.port || void 0), | |
"string" != typeof e.prefix && (e.prefix = "/" === u.basePath ? "" : u.basePath), | |
"boolean" != typeof e.isSecure ? e.secure = u.isSecure : e.secure = e.isSecure, | |
"string" != typeof e.reloadURI ? e.urlParams.reloadUri = u.reloadURI : e.urlParams.reloadUri = e.reloadURI, | |
void 0 === e.identity) { | |
var t = u.getParameterByName("identity"); | |
t && (e.identity = t) | |
} | |
return "/" === e.prefix && (e.prefix = ""), | |
e | |
} | |
function y(o, a) { | |
//s.create ; s represents enigma | |
//schema: l ; which is module "autogenerated/qix/engine-api" | |
//mixins: d ; which is module "core.models/mixins/all" | |
// o is the URL | |
// | |
var u = w[o]; | |
return u || ((u = s.create({ | |
Promise: e.getService("$q"), | |
schema: l, | |
mixins: d, | |
url: o, | |
suspendOnClose: a.suspendOnClose, | |
createSocket: function(e) { | |
return new i(e) | |
}, | |
responseInterceptors: [{ | |
onRejected: m | |
}, { | |
onRejected: g | |
}, { | |
onRejected: function(e, t, i) { | |
return p(i, a.onError), | |
n.reject(i) | |
} | |
}] | |
})).sessionConfig = a, | |
u.on("notification:*", function(e, n) { | |
if ("OnAuthenticationInformation" === e && t.parse(n), | |
a.onError) { | |
if ("fatal" === n.severity) { | |
var i = -1 !== _.indexOf(e); | |
a.onError({ | |
message: i ? h.get("ProxyError." + e) : n.message ? n.message : n, | |
method: e | |
}) | |
} | |
} else | |
-1 !== _.indexOf(e) && r.showDialog({ | |
message: "ProxyError." + e, | |
refreshButton: !0 | |
}) | |
}), | |
u.on("traffic:received", function(e) { | |
f(e, a.onWarning) | |
}), | |
u.on("closed", function() { | |
p({ | |
code: c.LocalizedErrorCode.LOCERR_GENERIC_CONNECTION_LOST, | |
message: h.get("ErrorCode." + c.LocalizedErrorCode.LOCERR_GENERIC_CONNECTION_LOST) | |
}, a.onError, a.onClose), | |
delete w[o] | |
}), | |
w[o] = u), | |
u | |
} | |
function b(e, t, n) { | |
e = e || "", | |
t.appId = e; | |
var r = y(a.buildUrl(t), t); | |
return r.open().then(function(t) { | |
return e ? (r.openDocPromise || (r.openDocPromise = t.openDoc(e, "", "", "", !!n).then(function(e) { | |
return e.global = t, | |
e | |
})), | |
r.openDocPromise) : { | |
global: t | |
} | |
}).catch(function(e) { | |
throw e.srcElement instanceof i && p(e = { | |
message: "ErrorDialog.NoConnectionCreated" | |
}, t.onError), | |
e | |
}) | |
} | |
///------------- | |
//seems "sessionConfig" is only relevant for the qglobal API: | |
define("apis/qglobal", ["qvangular", "core.models/app", "autogenerated/qix/engine-enums", "core.models/rpc-session", "apis/qutil"], function(e, t, n, i, r) { | |
"use strict"; | |
function o(e, t, n, i) { | |
return e.session.rpc({ | |
method: t, | |
handle: -1, | |
params: n || [] | |
}).then(function(e) { | |
return i && i(e.result), | |
e.result | |
}) | |
} | |
function s(n, i, r) { | |
e.$apply(e.$rootScope, function() { | |
t.getList(n).then(function(e) { | |
r && n.close(), | |
i(e) | |
}, function() { | |
l && l({ | |
code: u.LOCERR_GENERIC_CONNECTION_LOST, | |
message: "ErrorCode." + u.LOCERR_GENERIC_CONNECTION_LOST | |
}) | |
}) | |
}) | |
} | |
function a(e) { | |
if (r.initClient(), | |
e instanceof i) | |
this.session = e; | |
else if (e.app && e.rpc) { | |
var t = i.getIfCached(e.app.id, e.sessionConfig); | |
this.session = t || i.get(e.app.id, e.sessionConfig), | |
this.session.open() | |
} else | |
this.session = i.get("?transient=", e), | |
this.session.open() | |
} | |
var l, c, u = n.NxLocalizedErrorCode; | |
return a.setErrorCallback = function(e, t) { | |
l = e, | |
c = t | |
} | |
, | |
a.get = function(e) { | |
var t = r.makeConfig(e); | |
return t.onError = l ? function(e) { | |
(e = e || {}).code !== u.LOCERR_GENERIC_CONNECTION_LOST && l(e || { | |
code: u.LOCERR_GENERIC_CONNECTION_LOST, | |
message: "Connection lost" | |
}) | |
} | |
: l, | |
r.capabilityFlags.init(e), | |
new a(t) | |
} | |
, | |
a.getAppList = function(e, t) { | |
//rpc session is important; its i | |
"core.models/rpc-session", "apis/qutil"], function(e, t, n, i, r) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment