Last active
April 25, 2018 16:33
-
-
Save theredpea/f1e5ae0cb7c28d2052b839515af909b4 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
| define("js/single/single-object-service", ["qvangular", "core.utils/deferred", "apis/single-url", "jquery", "general.controllers/error-handler-controller"], function(e, t, n, i, r) { | |
| "use strict"; | |
| function o(t, n) { | |
| n.hasOption("debug"), | |
| t.setOnError(function(t) { | |
| n.callback && window[n.callback].onError ? window[n.callback].onError(t.code, t.message) : (window.console.log("Error", t), | |
| e.getService("$delayedModal").isOpened || r.showDialog(t)) | |
| }, function(e) { | |
| "OnAuthenticationInformation" !== e.method && window.console.log("Warning", e) | |
| }) | |
| } | |
| function s(t, n) { | |
| n.hasOption("noanimate") && e.getService("$animate").enabled(!1), | |
| n.lang && t.setLanguage(n.lang), | |
| n.theme && t.theme.apply(n.theme) | |
| } | |
| ///============================ | |
| ///NOTE | |
| //Note how we *dont* need to wait on clearAll()! | |
| //Note how there are also no locking | |
| //And how selectValues is the *only* method used | |
| //And that bookmark could apply (applies *first*); without waiting selections are applied | |
| ///============================ | |
| function a(e, t) { | |
| t.hasOption("clearselections") && e.clearAll(), | |
| t.bookmark && e.bookmark.apply(t.bookmark), | |
| t.select.forEach(function(t) { | |
| var n = t.split(","); | |
| if (n.length > 1) { | |
| var i = n.slice(1); | |
| i.forEach(function(e, t) { | |
| isNaN(e) || ((+e).toString().length < e.length ? i[t] = e : i[t] = +e) | |
| }), | |
| e.field(n[0]).selectValues(i, !1, !0) | |
| } | |
| }) | |
| } | |
| function l(t, n) { | |
| e.getService("$timeout")(function() { | |
| document.getElementById("content").offsetHeight, | |
| window[n.callback].onRendered(t.id) | |
| }, 1e3) | |
| } | |
| function c(e, t) { | |
| window.visualization = t, | |
| t.isValid && t.layout.title && (document.title = t.layout.title), | |
| t.Validated.bind(function() { | |
| t.layout.title && (document.title = t.layout.title) | |
| }), | |
| e.callback && window[e.callback].onValid && (t.isValid && window[e.callback].onValid(t.id), | |
| t.Validated.bind(function() { | |
| window[e.callback].onValid(t.id) | |
| })), | |
| e.callback && window[e.callback].onRendered && (t.isValid && l(t, e), | |
| t.Validated.bind(function() { | |
| l(t, e) | |
| })) | |
| } | |
| function u(e, t, n) { | |
| e.getObject(document.getElementById("content"), t, n.getApiOptions()).then(function(e) { | |
| c(n, e) | |
| }) | |
| } | |
| function h(e, t, n) { | |
| e.getSnapshot(document.getElementById("content"), t).then(function(e) { | |
| c(n, e) | |
| }) | |
| } | |
| function d(e, t, n) { | |
| e.getObject(t).then(function(t) { | |
| t.getLayout().then(function(t) { | |
| var r = t.labelExpression || t.qMeta.title; | |
| r && (document.title = r); | |
| var o = '<div style="position:relative;width:100%;height:100%" class="qvt-sheet">' | |
| , s = 0 | |
| , a = 0; | |
| t.cells.forEach(function(e) { | |
| s = Math.max(s, e.col + e.colspan), | |
| a = Math.max(a, e.row + e.rowspan) | |
| }), | |
| t.cells.forEach(function(e) { | |
| var t = "position:absolute;"; | |
| t += "left:" + 100 * e.col / s + "%;", | |
| t += "top:" + 100 * e.row / a + "%;", | |
| t += "width:" + 100 * e.colspan / s + "%;", | |
| t += "height:" + 100 * e.rowspan / a + "%;", | |
| o += '<div style="' + t + '" data-qid="' + e.name + '"></div>' | |
| }), | |
| o += "</div>", | |
| i("#content").html(o).find("div").each(function() { | |
| this.dataset.qid && e.getObject(this, this.dataset.qid, n.getApiOptions()) | |
| }) | |
| }) | |
| }) | |
| } | |
| return { | |
| init: function(e, r) { | |
| var l = new t | |
| , c = n.parse(window.location); | |
| if (o(e, c), | |
| s(e, c), | |
| c.isValid()) { | |
| var p = { | |
| identity: c.identity, | |
| host: r.host, | |
| port: r.port, | |
| prefix: r.prefix | |
| }; | |
| c.feature && (p.featureFlags = c.feature.toUpperCase().split(",")); | |
| var f = e.openApp(c.app, p); | |
| f.model.waitForOpen.promise.then(function() { | |
| if (window._app = f.model.enigmaModel, | |
| //NOTE HOW a() is called FIRST! | |
| //a is the function above which does selections | |
| //So first, selections | |
| a(f, c), | |
| f) { | |
| if (c.hasOption("currsel")) { | |
| i("#CURRSELPANEL").show(); | |
| var e = {}; | |
| c.hasOption("nointeraction") && (e.noInteraction = !0), | |
| c.hasOption("noselections") && (e.noSelections = !0), | |
| f.getObject("CURRSELPANEL", "CurrentSelections", e) | |
| } else | |
| i("#CURRSELPANEL").hide(); | |
| //THEN AFTER a() is called, the appropriate function is called depending on type of sheet | |
| //Here are the frames after visiting: | |
| //https://usrem-nnd.qliktech.com/single/?appid=a35ea1fe-7caf-4162-872f-a44831e73a06&sheet=0488a0e2-7f81-4eb0-873e-f02630763e44&select=ID,1 | |
| //https://usrem-nnd.qliktech.com/single/?appid=a35ea1fe-7caf-4162-872f-a44831e73a06&sheet=0488a0e2-7f81-4eb0-873e-f02630763e44&opt=nointeraction&select=clearall&select=X,0.00001182500272989273 | |
| //Using https://gist.github.com/theredpea/4cdb271e8d377b31ead185b2eb6f41b5 | |
| //While requests: GetField (for selection) executes *before* GetObject (for sheet)... | |
| //And responses come back in respective order (GetField response *before* GetObject response) | |
| //The next requests have the GetLayout (for sheet) executing *before* SelectValues (for selection/field) | |
| // | |
| // [ | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"method\":\"OnAuthenticationInformation\",\"params\":{\"userId\":\"nnd\",\"userDirectory\":\"QTSEL\",\"logoutUri\":\"https://usrem-nnd.qliktech.com:443/qps/user\",\"mustAuthenticate\":false}}", | |
| // "length": "189", | |
| // "time": "09:42:14.295" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"method\":\"OnConnected\",\"params\":{\"qSessionState\":\"SESSION_CREATED\"}}", | |
| // "length": "85", | |
| // "time": "09:42:14.296" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"OpenDoc\",\"handle\":-1,\"params\":[\"a35ea1fe-7caf-4162-872f-a44831e73a06\",\"\",\"\",\"\",false],\"jsonrpc\":\"2.0\",\"id\":1}", | |
| // "length": "134", | |
| // "time": "09:42:14.301" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"qReturn\":{\"qType\":\"Doc\",\"qHandle\":1,\"qGenericId\":\"a35ea1fe-7caf-4162-872f-a44831e73a06\"}},\"change\":[1]}", | |
| // "length": "138", | |
| // "time": "09:42:14.378" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":true,\"method\":\"GetAppLayout\",\"handle\":1,\"params\":[],\"jsonrpc\":\"2.0\",\"id\":2}", | |
| // "length": "84", | |
| // "time": "09:42:14.400" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"GetField\",\"handle\":1,\"params\":[\"ID\",\"$\"],\"jsonrpc\":\"2.0\",\"id\":3}", | |
| // "length": "89", | |
| // "time": "09:42:14.402" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"GetObject\",\"handle\":1,\"params\":[\"0488a0e2-7f81-4eb0-873e-f02630763e44\"],\"jsonrpc\":\"2.0\",\"id\":4}", | |
| // "length": "120", | |
| // "time": "09:42:14.402" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":2,\"delta\":true,\"result\":{\"qLayout\":[{\"op\":\"add\",\"path\":\"/\",\"value\":{\"qTitle\":\"x_y_scatter\",\"qFileName\":\"a35ea1fe-7caf-4162-872f-a44831e73a06\",\"qLastReloadTime\":\"2017-08-31T05:48:18.950Z\",\"qHasScript\":true,\"qStateNames\":[],\"qMeta\":{},\"qLocaleInfo\":{\"qDecimalSep\":\".\",\"qThousandSep\":\",\",\"qListSep\":\";\",\"qMoneyDecimalSep\":\".\",\"qMoneyThousandSep\":\",\",\"qCurrentYear\":2017,\"qMoneyFmt\":\"$#,##0.00;-$#,##0.00\",\"qTimeFmt\":\"h:mm:ss TT\",\"qDateFmt\":\"M/D/YYYY\",\"qTimestampFmt\":\"M/D/YYYY h:mm:ss[.fff] TT\",\"qCalendarStrings\":{\"qDayNames\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\"],\"qMonthNames\":[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],\"qLongDayNames\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"],\"qLongMonthNames\":[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]},\"qFirstWeekDay\":6,\"qBrokenWeeks\":true,\"qReferenceDay\":0,\"qFirstMonthOfYear\":1,\"qCollation\":\"en-US\"},\"qHasData\":true,\"qThumbnail\":{},\"modifiedDate\":\"2017-11-22T21:14:23.154Z\",\"published\":false,\"publishTime\":\"1753-01-01T00:00:00.000Z\",\"privileges\":[\"read\",\"update\",\"delete\",\"publish\",\"exportdata\",\"offlineaccess\",\"duplicate\"],\"description\":\"\",\"qFileSize\":1952339,\"dynamicColor\":\"\",\"create\":[{\"resource\":\"sheet\",\"canCreate\":true},{\"resource\":\"bookmark\",\"canCreate\":true},{\"resource\":\"story\",\"canCreate\":true},{\"resource\":\"dimension\",\"canCreate\":true},{\"resource\":\"measure\",\"canCreate\":true},{\"resource\":\"masterobject\",\"canCreate\":true},{\"resource\":\"folderconnection\",\"canCreate\":true},{\"resource\":\"oledbconnection\",\"canCreate\":true},{\"resource\":\"odbcconnection\",\"canCreate\":true},{\"resource\":\"internetconnection\",\"canCreate\":true},{\"resource\":\"customconnection\",\"canCreate\":true}],\"stream\":null,\"canCreateDataConnections\":true}}]}}", | |
| // "length": "1826", | |
| // "time": "09:42:14.402" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":3,\"result\":{\"qReturn\":{\"qType\":\"Field\",\"qHandle\":2}}}", | |
| // "length": "75", | |
| // "time": "09:42:14.403" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":4,\"result\":{\"qReturn\":{\"qType\":\"GenericObject\",\"qHandle\":3,\"qGenericType\":\"sheet\",\"qGenericId\":\"0488a0e2-7f81-4eb0-873e-f02630763e44\"}}}", | |
| // "length": "158", | |
| // "time": "09:42:14.403" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":true,\"method\":\"GetLayout\",\"handle\":3,\"params\":[],\"jsonrpc\":\"2.0\",\"id\":5}", | |
| // "length": "81", | |
| // "time": "09:42:14.407" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"SelectValues\",\"handle\":2,\"params\":[[{\"qIsNumeric\":true,\"qNumber\":1}],false,true],\"jsonrpc\":\"2.0\",\"id\":6}", | |
| // "length": "129", | |
| // "time": "09:42:14.408" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":5,\"delta\":true,\"result\":{\"qLayout\":[{\"op\":\"add\",\"path\":\"/\",\"value\":{\"qInfo\":{\"qId\":\"0488a0e2-7f81-4eb0-873e-f02630763e44\",\"qType\":\"sheet\"},\"qMeta\":{\"title\":\"binned\",\"description\":\"\",\"privileges\":[\"read\",\"update\",\"delete\",\"publish\"],\"modifiedDate\":\"2017-08-31T06:02:05.176Z\",\"published\":false,\"publishTime\":\"1753-01-01T00:00:00.000Z\",\"approved\":false,\"owner\":{\"id\":\"cac9ac70-6ed0-4f8b-8731-dbf3323c3faa\",\"userId\":\"nnd\",\"userDirectory\":\"QTSEL\",\"name\":\"nnd\",\"privileges\":null},\"qSize\":-1,\"sourceObject\":\"\",\"draftObject\":\"\"},\"qSelectionInfo\":{},\"rank\":0,\"thumbnail\":{\"qStaticContentUrl\":{}},\"columns\":24,\"rows\":12,\"cells\":[{\"name\":\"mRJqsUG\",\"type\":\"scatterplot\",\"col\":4,\"row\":0,\"colspan\":20,\"rowspan\":12},{\"name\":\"ZAvSSHX\",\"type\":\"filterpane\",\"col\":0,\"row\":0,\"colspan\":4,\"rowspan\":12}],\"qChildList\":{\"qItems\":[{\"qInfo\":{\"qId\":\"mRJqsUG\",\"qType\":\"scatterplot\"},\"qData\":{\"title\":\"\"}},{\"qInfo\":{\"qId\":\"ZAvSSHX\",\"qType\":\"filterpane\"},\"qData\":{\"title\":\"\"}}]}}}]}}", | |
| // "length": "975", | |
| // "time": "09:42:14.409" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":6,\"result\":{\"qReturn\":true},\"change\":[1,2]}", | |
| // "length": "65", | |
| // "time": "09:42:14.409" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":true,\"method\":\"GetAppLayout\",\"handle\":1,\"params\":[],\"jsonrpc\":\"2.0\",\"id\":7}", | |
| // "length": "84", | |
| // "time": "09:42:14.411" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"GetObject\",\"handle\":1,\"params\":[\"mRJqsUG\"],\"jsonrpc\":\"2.0\",\"id\":8}", | |
| // "length": "91", | |
| // "time": "09:42:14.414" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":false,\"method\":\"GetObject\",\"handle\":1,\"params\":[\"ZAvSSHX\"],\"jsonrpc\":\"2.0\",\"id\":9}", | |
| // "length": "91", | |
| // "time": "09:42:14.417" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":7,\"delta\":true,\"result\":{\"qLayout\":[]}}", | |
| // "length": "61", | |
| // "time": "09:42:14.419" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":8,\"result\":{\"qReturn\":{\"qType\":\"GenericObject\",\"qHandle\":4,\"qGenericType\":\"scatterplot\",\"qGenericId\":\"mRJqsUG\"}}}", | |
| // "length": "135", | |
| // "time": "09:42:14.419" | |
| // }, | |
| // { | |
| // "data": "{\"jsonrpc\":\"2.0\",\"id\":9,\"result\":{\"qReturn\":{\"qType\":\"GenericObject\",\"qHandle\":5,\"qGenericType\":\"filterpane\",\"qGenericId\":\"ZAvSSHX\"}}}", | |
| // "length": "134", | |
| // "time": "09:42:14.420" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":true,\"method\":\"GetLayout\",\"handle\":4,\"params\":[],\"jsonrpc\":\"2.0\",\"id\":10}", | |
| // "length": "82", | |
| // "time": "09:42:14.423" | |
| // }, | |
| // { | |
| // "data": "{\"delta\":true,\"method\":\"GetLayout\",\"handle\":5,\"params\":[],\"jsonrpc\":\"2.0\",\"id\":11}", | |
| // "length": "82", | |
| // "time": "09:42:14.423" | |
| // }, | |
| // { | |
| // "data": "a35ea1fe-7caf-4162-872f-a44831e73a06?reloadUri=htt…0e2-7f81-4eb0-873e-f02630763e44%26select%3DID%2C1/app", | |
| // "length": "" | |
| // } | |
| // ] | |
| c.object ? u(f, c.object, c) : c.sheet ? d(f, c.sheet, c) : c.snapshot && h(f, c.snapshot, c) | |
| } | |
| l.resolve({ | |
| options: { | |
| currsel: c.hasOption("currsel"), | |
| noInteraction: c.hasOption("nointeraction"), | |
| noAnimate: c.hasOption("noanimate"), | |
| language: c.lang | |
| } | |
| }) | |
| }) | |
| } else { | |
| var m = r.prefix + "dev-hub/single-configurator"; | |
| c.app && (m += "/#app{" + c.app + "}"), | |
| location.href = m | |
| } | |
| return l.promise | |
| } | |
| } | |
| }), | |
| //https://usrem-nnd.qliktech.com/single/?appid=27a08e58-903e-46e9-8593-de3ff9f99c8b&sheet=bda40c18-62df-4029-89f4-789efa45cfd7&select=clearall&select=D1,1&select=DateD1,31918 | |
| define("apis/single-url", [], function() { | |
| "use strict"; | |
| function e() { | |
| Object.defineProperty(this, "select", { | |
| value: [] | |
| }) | |
| } | |
| function t(e, t, n) { | |
| n = decodeURIComponent(n), | |
| "select" === t ? "clearall" === n ? Object.defineProperty(e, "clearselections", { | |
| value: !0 | |
| }) : e.select.push(n) : ("options" === t && (n = n.toLowerCase()), | |
| Object.defineProperty(e, t, { | |
| value: n | |
| })) | |
| } | |
| var n = ["app", "object", "sheet", "snapshot", "theme", "options", "identity", "callback", "lang", "bookmark", "select", "feature"] | |
| , i = { | |
| appid: "app", | |
| obj: "object", | |
| opt: "options" | |
| }; | |
| return e.prototype.hasOption = function(e) { | |
| return !("clearselections" !== e || !this.clearselections) || this.options && this.options.indexOf(e) > -1 | |
| } | |
| , | |
| e.prototype.getApiOptions = function() { | |
| var e = {}; | |
| return this.hasOption("nointeraction") && (e.noInteraction = !0), | |
| this.hasOption("noselections") && (e.noSelections = !0), | |
| e | |
| } | |
| , | |
| e.prototype.isValid = function() { | |
| return !(!this.app || !(this.object || this.sheet || this.snapshot)) | |
| } | |
| , | |
| e.parse = function(r) { | |
| var o, s = new e; | |
| return r.hash ? r.hash.substr(1).split("/").forEach(function(e) { | |
| o ? (t(s, o, e), | |
| o = void 0) : n.indexOf(e) > -1 && (o = e) | |
| }) : r.search.substr(1).split("&").forEach(function(e) { | |
| var n = e.split("="); | |
| n.length > 0 && (o = n[0], | |
| i[o] && (o = i[o]), | |
| t(s, o, n[1])) | |
| }), | |
| s | |
| } | |
| , | |
| e | |
| }), | |
| //https://usrem-nnd.qliktech.com/single/?appid=27a08e58-903e-46e9-8593-de3ff9f99c8b&sheet=bda40c18-62df-4029-89f4-789efa45cfd7&opt=currsel&select=clearall&select=D1,1&select=DateD1,31918 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment