versionBundle.debug.js 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Content Explorer
  5. *| (C) Copyright IBM Corp. 2015, 2018
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. define('bacontentnav/common/ui/LanguagePickerView',['../../lib/@waca/baglass/js/baglass/app/ContentView',
  12. '../../utils/GlassContextHelper',
  13. '../../nls/StringResource',
  14. '../../lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  15. 'jquery',
  16. 'underscore'
  17. ],
  18. function(ContentView, GlassContextHelper, StringResource, PropertyUIControl, $, _) {
  19. 'use strict';
  20. var LanguagePickerView = ContentView.extend({
  21. /*
  22. * @options.glassContext
  23. * @options.closeCallback - callback function on close.
  24. * @options.supportedContentLocales - (optional) an array of supported content locales as returned by Glass
  25. * @options.enabledLanguages - array of strings containing previously enabled languages
  26. */
  27. init: function(options) {
  28. LanguagePickerView.inherited('init', this, arguments);
  29. _.extend(this, options);
  30. if (!this.glassContext) {
  31. throw 'glassContext is not specified';
  32. }
  33. this._modifiedValues = {};
  34. this._userContentLocale = GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale');
  35. if (!this.enabledLanguages || this.enabledLanguages.length === 0) {
  36. this.enabledLanguages = [this._userContentLocale];
  37. this._modifiedValues[this._userContentLocale] = true;
  38. }
  39. this.enabledLanguages.forEach(function(language) {
  40. this._modifiedValues[language] = true;
  41. }.bind(this));
  42. },
  43. render: function() {
  44. return this._getContentLocales()
  45. .then(this._doRender.bind(this));
  46. },
  47. _doRender: function(contentLocales) {
  48. var spec = this._getSpec(contentLocales, this.enabledLanguages);
  49. this._propertyUIControl = new PropertyUIControl({
  50. 'glassContext': this.glassContext,
  51. 'el': this.$el,
  52. 'closeCallback': this._onClose.bind(this),
  53. 'items': [{
  54. 'type': 'Banner',
  55. 'centerLabel': true,
  56. 'backButton': this.slideout.overlay,
  57. 'value': StringResource.get('languages')
  58. }].concat(spec)
  59. });
  60. return this._propertyUIControl.render();
  61. },
  62. _getContentLocales: function() {
  63. if (this.supportedContentLocales) {
  64. return Promise.resolve(this.supportedContentLocales);
  65. }
  66. return GlassContextHelper.getContentLocales(this.glassContext).then(
  67. function(contentLocales) {
  68. this.supportedContentLocales = contentLocales;
  69. return this.supportedContentLocales;
  70. }.bind(this));
  71. },
  72. _getSpec: function(contentLocales, selectedLocales) {
  73. var itemsList = [];
  74. for (var key in contentLocales) {
  75. if (contentLocales.hasOwnProperty(key)) {
  76. itemsList.push({
  77. 'type': 'CheckBox',
  78. 'name': key,
  79. 'label': contentLocales[key],
  80. 'value': key,
  81. 'controlOnLeft': true,
  82. 'checked': (selectedLocales.indexOf(key) !== -1),
  83. 'onChange': this._onChange.bind(this)
  84. });
  85. }
  86. }
  87. return itemsList;
  88. },
  89. setFocus: function() {
  90. var currentItem = _.find(this._propertyUIControl.items, function(item) {
  91. return this.enabledLanguages.indexOf(item.name) !== -1;
  92. }.bind(this));
  93. if (currentItem !== null) {
  94. this._propertyUIControl.setFocus(currentItem.name);
  95. }
  96. },
  97. _onChange: function(name, value) {
  98. this._modifiedValues[name] = value;
  99. },
  100. _onClose: function() {
  101. this.slideout.hide();
  102. if (this.closeCallback) {
  103. this.closeCallback(this.getLanguages());
  104. }
  105. },
  106. getLanguages: function() {
  107. /*
  108. * Returns languages selected. If none is selected, it will return the value
  109. * as set in user preferences.
  110. */
  111. var languages = [];
  112. for (var key in this._modifiedValues) {
  113. if (this._modifiedValues.hasOwnProperty(key) && this._modifiedValues[key]) {
  114. languages.push(key);
  115. }
  116. }
  117. return languages;
  118. },
  119. //needed if view is rendered by PropertyUIControl
  120. getModifiedProperties: function() {
  121. return {
  122. 'languages': this.getLanguages()
  123. };
  124. },
  125. remove: function() {
  126. this._onClose();
  127. }
  128. });
  129. return LanguagePickerView;
  130. });
  131. /**
  132. * Licensed Materials - Property of IBM
  133. * IBM Cognos Products: Content Explorer
  134. * (C) Copyright IBM Corp. 2015, 2018
  135. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  136. */
  137. define('bi/content_apps/ui/CA_DateTimePicker',[
  138. 'bi/commons/ui/widgets/DatePicker',
  139. 'bi/commons/ui/widgets/TimePicker',
  140. 'bi/commons/utils/DateTimeUtils',
  141. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/BaseProperty',
  142. 'bacontentnav/utils/GlassContextHelper',
  143. 'bacontentnav/utils/UIHelper',
  144. 'underscore'
  145. ],
  146. function(DatePicker, TimePicker, DateTimeUtils, BaseProperty, GlassContextHelper, UIHelper, _) {
  147. 'use strict';
  148. //Implements the interface for use with PropertyUIControl
  149. var CA_DatePicker = BaseProperty.extend({
  150. init: function(options) {
  151. BaseProperty.inherited('init', this, arguments);
  152. _.extend(this, options);
  153. this._time = {};
  154. },
  155. doRender: function() {
  156. this._container = $('<div>', {
  157. 'class': 'ca_timeDatePickerContainer'
  158. });
  159. var $dateContainer = $('<div/>');
  160. this._container.append($dateContainer);
  161. this.$el.append(this._container);
  162. var options = {
  163. 'attributes': {
  164. 'firstDay': 1
  165. },
  166. 'drawNoEndDate': false,
  167. '$el': $dateContainer,
  168. 'timezone': GlassContextHelper.getUserPreference(this.glassContext, 'timeZoneID'),
  169. 'locale': GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale')
  170. };
  171. this._datePicker = new DatePicker(options);
  172. return this._datePicker.render().then(function() {
  173. var date = new Date();
  174. this._datePicker.setDateFormat('yy-mm-dd');
  175. this._datePicker.setDate(date);
  176. var $timeContainer = $('<div/>');
  177. this._container.append($timeContainer);
  178. this._timePicker = new TimePicker({
  179. '$el': $timeContainer,
  180. 'timezone': GlassContextHelper.getUserPreference(this.glassContext, 'timeZoneID'),
  181. 'attributes': {
  182. 'showMeridian': !DateTimeUtils.is24HrFormat(GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale'))
  183. }
  184. });
  185. this._timePicker.render();
  186. this._container.hide();
  187. }.bind(this));
  188. },
  189. getModifiedProperties: function() {
  190. this._time[this.name] = this._timePicker.getDateTimeUTC(this._datePicker.getDateObj());
  191. return this._time;
  192. },
  193. show: function() {
  194. this._container.slideDown(UIHelper.SLIDE_DURATION);
  195. },
  196. hide: function() {
  197. this._container.slideUp(UIHelper.SLIDE_DURATION);
  198. }
  199. });
  200. return CA_DatePicker;
  201. });
  202. /**
  203. * Licensed Materials - Property of IBM
  204. *
  205. * IBM Cognos Products: content-apps
  206. *
  207. * Copyright IBM Corp. 2016, 2018
  208. *
  209. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  210. */
  211. define('bi/content_apps/ui/CA_DeliveryPickerView',[
  212. 'bi/schedule/views/DeliveryPickerView',
  213. 'bi/content_apps/nls/StringResource',
  214. 'bi/schedule/views/OptionsSlideoutView'
  215. ],
  216. function(DeliveryPickerView, StringResource, OptionsSlideoutView) {
  217. 'use strict';
  218. /*
  219. * @options.closeCallback - callback to call on view close. It returns the delivery options. {delivery : <delivery options>}
  220. */
  221. var CA_DeliveryPickerView = OptionsSlideoutView.extend({
  222. init: function(options) {
  223. options.title = StringResource.get('delivery');
  224. CA_DeliveryPickerView.inherited('init', this, arguments);
  225. },
  226. render: function() {
  227. this._renderContent();
  228. return CA_DeliveryPickerView.inherited('render', this, arguments);
  229. },
  230. shouldShowMobile: function() {
  231. var mobileTypes = ['interactiveReport', 'report', 'query', 'analysis'];
  232. return ((mobileTypes.indexOf(this.objectInformation.type) !== -1) || ((this.objectInformation.type === 'reportView') && (mobileTypes.indexOf(this.objectInformation.base[0].type) !== -1)));
  233. },
  234. _renderContent: function() {
  235. if (this.content) {
  236. return;
  237. }
  238. var deliveryPickerViewOptions = {
  239. 'reportName': this.objectInformation.defaultName,
  240. 'showMobile': this.shouldShowMobile(),
  241. 'enableAdvancedSettings': true,
  242. 'glassContext': this.glassContext,
  243. 'deliveryOptions': this.deliveryOptions || {},
  244. '$toggler': $('<div></div>'),
  245. 'slideout': this.slideout,
  246. 'hasPermission': this.objectInformation.permissions,
  247. 'rawOptions': this.objectInformation.rawOptions
  248. };
  249. this._deliveryPickerView = new DeliveryPickerView(deliveryPickerViewOptions);
  250. this._deliveryPickerView.render();
  251. var deliveryContent = this._deliveryPickerView.getDeliveryContent(!this.burstSelected);
  252. this.content = $(deliveryContent);
  253. },
  254. _close: function() {
  255. this.remove();
  256. // Close off this pane
  257. this.slideout.hide({
  258. hideOnly: true
  259. });
  260. },
  261. remove: function() {
  262. if (this.closeCallback && typeof this.closeCallback === 'function') {
  263. this.closeCallback(this._deliveryPickerView.getDeliveryOptions());
  264. }
  265. },
  266. //Called by OptionsSlideoutView
  267. setUpCallback: function(content) {
  268. this._deliveryPickerView.setDeliveryOptions(content, null);
  269. }
  270. });
  271. return CA_DeliveryPickerView;
  272. });
  273. define('text!bi/content_apps/ui/templates/PowerPlayPromptPickerView.html',[],function () { return '<!-- Licensed Materials - Property of IBM\n \n IBM Cognos Products: Content Explorer\n \n (C) Copyright IBM Corp. 2017\n \n US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.\n-->\n<form id="ppForm" name="ppForm" action="v1/disp" method="post" >\n\t\t\t<input type="hidden" name="b_action" value="xts.run"/>\n\t\t\t{{?it.runNow}}\n\t\t\t\t<input type="hidden" name="m" value="portal/launch.xts"/>\n\t\t\t\t<input type="hidden" name="ui.tool" value="PowerplayStudio"/>\n\t\t\t\t<input type="hidden" name="ui.crnfrm" value="PDF"/>\n\t\t\t\t<input type="hidden" name="ui.crnp" value="true"/>\n\t\t\t\t<input type="hidden" name="ui.object" value="storeID(\'{{=it.reportId}}\')"/>\n\t\t\t\t<input type="hidden" name="launch.openJSStudioInFrame" value="true"/>\n\t\t\t\t<input type="hidden" name="ui.gateway" value="disp"/>\n\t\t\t\t<input type="hidden" name="ui.action" value="run"/>\n\t\t\t{{?}}\n\t\t\t{{?it.runBackground}}\n\t\t\t\t<input type="hidden" name="backgroundRun" value="{{=it.backgroundTime}}"/>\n\t\t\t\t<input type="hidden" name="m" value="portal/runWithOptions/report_confirm.xts"/>\n\t\t\t\t<input type="hidden" name="m_pp8ro_prompt" value="true"/>\n\t\t\t\t<input type="hidden" name="m_ro_saveOutput" value="true"/>\n\t\t\t\t<input type="hidden" name="m_class" value="powerPlay8Report"/>\n\t\t\t\t<input type="hidden" name="m_obj" value="storeID(\'{{=it.reportId}}\')"/>\n\t\t\t\t<input type="hidden" name="method" value="edit"/>\n\t\t\t\t<input type="hidden" name="showSummary" value="y"/>\n\t\t\t\t<input type="hidden" name="fromCA" value="true"/>\n\t\t\t\t<input type="hidden" name="backURL" value="disp?b_action=xts.run&m=portal/close.xts&ui.compid=ca"/>\n\t\t\t\t<input type="hidden" name="m_pp8ro_outputFormat" value="PDF"/>\n\t\t\t\t{{?it.languageOptions}}\n\t\t\t\t\t{{~it.languageOptions :lang:index}}\n\t\t\t\t\t\t<input type="hidden" name="language" value="{{=lang}}"/>\n\t\t\t\t\t\t<input type="hidden" name="m_ro_outputLocale" value="{{=lang}}"/>\n\t\t\t\t\t{{~}}\n\t\t\t\t{{?}}\n\t\t\t\t{{?it.executionDate}}\n\t\t\t\t\t<input type="hidden" name="p_runDate" value="{{=it.executionDate}}"/>\n\t\t\t\t\t<input type="hidden" name="p_runTime" value="{{=it.executionTime}}"/>\n\t\t\t\t\t<input type="hidden" name="txtDatedateFrom" value="{{=it.executionDate}}"/>\n\t\t\t\t\t<input type="hidden" name="minutestimeFrom" value="{{=it.displayMinutes}}"/>\n\t\t\t\t\t<input type="hidden" name="hourstimeFrom" value="{{=it.displayHours}}"/>\n\t\t\t\t\t<input type="hidden" name="AMPMtimeFrom" value="{{=it.amPM}}"/>\n\t\t\t\t\n\t\t\t\t{{?}}\n\t\t\t\t{{?it.ca_deliveryOptions}}\n\t\t\t\t\t<input type="hidden" name="m_ro_email" value=\'true\'/>\t\n\t\t\t\t\t<input type="hidden" name="m_sp_credential" value="CAMID(\'LDAP:u:uid=user0,ou=ottawa\')/credential[@name=\'Credential\']"/>\t\n\t\t\t\t\t<input type="hidden" name="ca_deliveryOptions" value=\'{{=it.ca_deliveryOptions}}\'/>\t\n\t\t\t\t\t<input type="hidden" name="hasRecipients" value=\'true\'/>\n\t\t\t\t\t<input type="hidden" name="emailDescription" value=\'{{=it.emailRecipients}}\'/>\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t<input type="hidden" name="deliverySection" value=\'true\'/>\t\n\t\t\t\t\t<input type="hidden" name="hasRecipients" value=\'true\'/>\t\n\t\t\t\t\t\n\t\t\t\t\t{{?it.emailAsAttachment}}\n\t\t\t\t\t\t<input type="hidden" name="m_ro_emailAsAttachment" value=\'true\'/>\t\n\t\t\t\t\t\t<input type="hidden" name="run_with_options_allowEmailAsAttachment" value=\'true\'/>\n\t\t\t\t\t{{?}}\n\t\t\t\t\t{{?it.emailAsURL}}\n\t\t\t\t\t\t<input type="hidden" name="m_ro_emailAsURL" value=\'true\'/>\t\n\t\t\t\t\t{{?}}\n\t\t\t\t\t{{?it.printer}}\n\t\t\t\t\t\t<input type="hidden" name="ro_printer_kw" value=\'printer\'/>\n\t\t\t\t\t\t<input type="hidden" name="select_printerName" value=\'{{=it.printer}}\'/>\n\t\t\t\t\t\t<input type="hidden" name="select_printerNameAddress" value=\'CAMID(":")/printer[@name="{{=it.printer}}"]\'/>\n\t\t\t\t\t\t<input type="hidden" name="m_ro_printer" value=\'CAMID(":")/printer[@name="{{=it.printer}}"]\'/>\n\t\t\t\t\t\t<input type="hidden" name="printeritem" value=\'CAMID(":")/printer[@name="{{=it.printer}}"]\'/>\n\t\t\t\t\t\t<input type="hidden" name="m_ro_printerAddress" value=\'{{=it.printer}}\'/>\n\t\t\t\t\t\t<input type="hidden" name="m_ro_print" value=\'true\'/>\n\t\t\t\t\t{{?}}\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t{{?}}\n\t\t\t{{?}}\n\t\t</form>\n';});
  274. /**
  275. * Licensed Materials - Property of IBM
  276. *
  277. * IBM Cognos Products: SHARE
  278. *
  279. * Copyright IBM Corp. 2017, 2018
  280. *
  281. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  282. */
  283. define('bi/content_apps/ui/PowerPlayPromptPickerView',[
  284. 'bi/schedule/views/PromptPickerView',
  285. 'jquery',
  286. 'q',
  287. 'doT',
  288. 'text!bi/content_apps/ui/templates/PowerPlayPromptPickerView.html'
  289. ],
  290. function(PromptPickerView, $, Q, dot, viewTemplate) {
  291. var view = PromptPickerView.extend({
  292. /** Allows for selecting parameter values for a particular report.
  293. * Uses the old UI. Parameters:
  294. * $el: Location where this View will display selected parameter values,
  295. * in the "name: value" format.
  296. * $toggler: link/button that launches the 'prompting dance'
  297. * reportId: the report to prompt for
  298. * values: Initial values to display. Not used to select the defaults in the prompting dance
  299. * glassContext: the glassContext
  300. */
  301. init: function(options) {
  302. void(options);
  303. view.inherited('init', this, arguments);
  304. },
  305. _updateForSubmit: function($iFrame) {
  306. $iFrame.find('.prompt-iframe').contents().find('form[name="ppForm"]').submit();
  307. },
  308. showPromptOverlay: function() {
  309. var deferred = Q.defer();
  310. var $iFrame = $('<div class=\'prompt-overlay\'><iframe title=\'{{=it.prompt_title}}\' class=\'prompt-iframe\'></iframe></div>');
  311. var htmlGenerator = dot.simpleTemplate(viewTemplate);
  312. var attributes = {
  313. reportId: this.reportId,
  314. backgroundTime: 'now'
  315. };
  316. if (this.ca_deliveryOptions) {
  317. attributes.ca_deliveryOptions = this.ca_deliveryOptions;
  318. attributes.emailRecipients = this.deliveryOptions.email.to.length + this.deliveryOptions.email.bcc.length + this.deliveryOptions.email.cc.length;
  319. attributes.emailAsAttachment = this.deliveryOptions.email.emailAsAttachment === true;
  320. attributes.emailAsURL = this.deliveryOptions.email.emailAsURL === true;
  321. if (this.deliveryOptions.print) {
  322. attributes.printer = this.deliveryOptions.print.name;
  323. }
  324. }
  325. if (this.languageOptions) {
  326. attributes.languageOptions = this.languageOptions;
  327. }
  328. if (this.executionTime) {
  329. var etArray = this.executionTime.split('T');
  330. attributes.executionDate = etArray[0];
  331. var timeArray = etArray[1].split('-');
  332. var dispArray = timeArray[0].split(':');
  333. attributes.displayHours = dispArray[0];
  334. attributes.displayMinutes = dispArray[1];
  335. attributes.executionTime = attributes.displayHours + ':' + attributes.displayMinutes + ':00.000';
  336. attributes.amPM = parseInt(attributes.displayHours) > 12 ? 'PM' : 'AM';
  337. attributes.backgroundTime = 'later';
  338. }
  339. $('body').append($iFrame);
  340. if (this.openInTab) {
  341. attributes.runNow = true;
  342. } else {
  343. attributes.runBackground = true;
  344. }
  345. $iFrame.find('.prompt-iframe').contents().find('html').html(htmlGenerator(attributes));
  346. if (this.openInTab) {
  347. $($iFrame.find('.prompt-iframe').contents().find('form[name="ppForm"]')).attr('target', '_blank');
  348. } else {
  349. window.ccModalCallBack = function() {
  350. delete window.ccModalCallBack;
  351. $iFrame.remove();
  352. };
  353. }
  354. this._updateForSubmit($iFrame);
  355. this.$promptOverlay = $('body').find('.prompt-overlay');
  356. if (this.openInTab) {
  357. $iFrame.remove();
  358. }
  359. deferred.resolve();
  360. return deferred.promise;
  361. }
  362. });
  363. return view;
  364. });
  365. /*
  366. *+------------------------------------------------------------------------+
  367. *| Licensed Materials - Property of IBM
  368. *| IBM Cognos Products: Content Explorer
  369. *| (C) Copyright IBM Corp. 2015, 2019
  370. *|
  371. *| US Government Users Restricted Rights - Use, duplication or disclosure
  372. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  373. *+------------------------------------------------------------------------+
  374. */
  375. define('bi/content_apps/RunAsOptionsView',[
  376. 'underscore',
  377. 'bi/glass/app/ContentView',
  378. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  379. 'bi/content_apps/nls/StringResource',
  380. 'bacontentnav/utils/ContentStoreObject',
  381. 'bi/commons/ui/Button',
  382. 'bacontentnav/utils/GlassContextHelper',
  383. 'bi/schedule/views/PromptPickerView',
  384. 'bacontentnav/common/ui/LanguagePickerView',
  385. 'bi/content_apps/ui/CA_DateTimePicker',
  386. 'bi/content_apps/ui/CA_DeliveryPickerView',
  387. 'bi/content_apps/PdfOptionsView',
  388. 'bi/content_apps/ui/PowerPlayPromptPickerView',
  389. 'bi/content_apps/utils/C10Utils',
  390. 'bacontentnav/utils/UIHelper',
  391. 'bi/content_apps/authoring/AuthoringHelper'
  392. ], function(_, ContentView, PropertyUIControl, StringResource, ContentStoreObject, UIButton, GlassContextHelper, PromptPickerView, LanguagePickerView, CA_DateTimePicker, CA_DeliveryPickerView, PdfOptionsView, PowerPlayPromptPickerView, C10Utils, UIHelper, AuthoringHelper) {
  393. 'use strict';
  394. var RunAsOptionsView = ContentView.extend({
  395. _getReportOutputFormat: function(options) {
  396. var selectedFormat = ContentStoreObject.getOption(options, ContentStoreObject.OPTION_OUTPUT_FORMAT);
  397. if (!AuthoringHelper.userCanGenerateFormat(this.glassContext, selectedFormat)){
  398. selectedFormat = 'HTML';
  399. }
  400. return selectedFormat;
  401. },
  402. init: function(options) {
  403. RunAsOptionsView.inherited('init', this, arguments);
  404. _.extend(this, options);
  405. this._userPermissions = options.objectInformation.permissions;
  406. this._supportedFormats = AuthoringHelper.getSupportedFormats(this.objectInformation);
  407. this._userContentLocale = GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale');
  408. this._userFormat = GlassContextHelper.getUserPreference(this.glassContext, 'format');
  409. this._outputFormat = this._getReportOutputFormat(options.objectInformation) ? this._getReportOutputFormat(options.objectInformation) : this._userFormat;
  410. this._selections = {};
  411. this._selections.formats = {};
  412. this._selections.formats[this._outputFormat] = true;
  413. this._requestParams = {};
  414. this._requestParams.options = {};
  415. AuthoringHelper.setReportType(this._requestParams, this.objectInformation);
  416. this._appController = this.glassContext.appController;
  417. this._promptValue = ContentStoreObject.getExecutionPrompt(this.objectInformation);
  418. },
  419. setFocus: function() {
  420. this.$el.find('button.primary').focus();
  421. },
  422. render: function() {
  423. this.$el.addClass('runAsOptionsView');
  424. var userHasPermission = _.contains(this._userPermissions, 'write') || _.contains(this._userPermissions, 'execute');
  425. var runAsItems = this._getRunAsItemsSpec(userHasPermission);
  426. var itemsSpec = _.compact(runAsItems);
  427. this._runOptionsControl = new PropertyUIControl({
  428. 'el': this.$el,
  429. 'items': itemsSpec,
  430. 'glassContext': this.glassContext,
  431. 'readOnly': !UIHelper.isValid(this.objectInformation)
  432. });
  433. return this._runOptionsControl.render().then(function() {
  434. this._runInBackgroundOptionsControl = this._runOptionsControl.getProperty('runInBackgroundOptions');
  435. this._runAsOptionsControl = this._runOptionsControl.getProperty('runAsOptions');
  436. // note: this is temporary (hopefully) - adding a wart to launch legacy UI for missing functionality in C11
  437. var $classicLink = $('<a style="padding-left:10px;cursor:pointer;">' + StringResource.get('classicView') + '</a>');
  438. $classicLink.on('primaryaction', function() {
  439. var morphletName = this.objectInformation.type === 'jobDefinition' ? 'portal/runWithOptions/jobDefinition.xts' : 'portal/runWithOptions/report.xts';
  440. C10Utils.openC10Morphlet(morphletName, this.objectInformation.type, this.objectInformation.id,[
  441. { m_name: this.objectInformation.defaultName }
  442. ]);
  443. }.bind(this));
  444. // can this be done a better way?
  445. var $parentEl = $(this.$el.find('.l_delivery').parent().parent());
  446. $parentEl.append($classicLink);
  447. if (!UIHelper.isValid(this.objectInformation)) {
  448. var footer = this._runOptionsControl.getProperty('runAsFooter');
  449. if (footer) {
  450. var okButton = footer.getProperty('okButton');
  451. if (okButton) {
  452. okButton.disable();
  453. }
  454. }
  455. }
  456. }.bind(this));
  457. },
  458. _getRunAsItemsSpec: function(userHasPermission) {
  459. return [
  460. this._getBannerSpec(),
  461. this._getSeparatorSpec(),
  462. userHasPermission && this._getRunInBackgroundToggleSpec(),
  463. this._getSeparatorSpec(),
  464. this._getRunInBackgroundOptionsSpec(),
  465. this._getRunAsOptionsSpec(),
  466. this._getFooterSpec()
  467. ];
  468. },
  469. _getFooterSpec: function() {
  470. return {
  471. 'type': 'Footer',
  472. 'name': 'runAsFooter',
  473. 'items': [{
  474. 'type': 'Button',
  475. 'name': 'okButton',
  476. 'label': StringResource.get('run'),
  477. 'onSelect': this._onRun.bind(this),
  478. 'primary': true
  479. }]
  480. };
  481. },
  482. _getBannerSpec: function() {
  483. return {
  484. 'type': 'Banner',
  485. 'name': 'runAsBanner',
  486. 'value': StringResource.get('runAs'),
  487. 'editable': false
  488. };
  489. },
  490. _renderButtons: function() {
  491. var buttonRow = $('<div>', {
  492. 'class': 'buttonRow'
  493. });
  494. this.$el.append(buttonRow);
  495. var runButton = new UIButton({
  496. 'buttonSpec': {
  497. 'label': StringResource.get('run'),
  498. 'onSelect': this._onRun.bind(this)
  499. }
  500. });
  501. runButton.render();
  502. buttonRow.append(runButton.$el);
  503. return Promise.resolve(true);
  504. },
  505. _getSeparatorSpec: function() {
  506. return {
  507. 'type': 'Separator'
  508. };
  509. },
  510. _getRunInBackgroundToggleSpec: function() {
  511. return {
  512. 'name': RunAsOptionsView.OPTION.RUN_IN_BG,
  513. 'checked': false,
  514. 'label': StringResource.get('runInBackgroundOption'),
  515. 'type': 'ToggleButton',
  516. 'onChange': this._toggleOptionsControl.bind(this)
  517. };
  518. },
  519. _toggleOptionsControl: function() {
  520. this._runInBackgroundOptionsControl.toggleCollapsibleSection();
  521. this._runAsOptionsControl.toggleCollapsibleSection();
  522. this._copySelectionForRunInBackgroundToggle();
  523. this._copyPromptForValuesOnRunInBackgroundChange();
  524. },
  525. _copyPromptForValuesOnRunInBackgroundChange: function() {
  526. var modifiedProperties = this._runOptionsControl.getModifiedProperties();
  527. var isRunInBackgroundChecked = modifiedProperties[RunAsOptionsView.OPTION.RUN_IN_BG];
  528. // get promptForValues checkbox control for both RunAs and RunInBackground
  529. var runAsPromptControl = this._runAsOptionsControl.getProperty(RunAsOptionsView.OPTION.PROMPT);
  530. var runInBackgroundPromptControl = this._runInBackgroundOptionsControl.getProperty(RunAsOptionsView.OPTION.PROMPT);
  531. // get prompt control to update, depending on how RunInBackground is toggled
  532. var prompControlToUpdate = isRunInBackgroundChecked ? runInBackgroundPromptControl : runAsPromptControl;
  533. var isPromptForValuesChecked = isRunInBackgroundChecked ? runAsPromptControl['checked'] : runInBackgroundPromptControl['checked'];
  534. // Propagate promptForValues to foreground run options control
  535. if (isPromptForValuesChecked) {
  536. if (!prompControlToUpdate.checked) prompControlToUpdate.check();
  537. } else {
  538. if (prompControlToUpdate.checked) prompControlToUpdate.uncheck();
  539. }
  540. },
  541. _copySelectionForRunInBackgroundToggle: function() {
  542. var noOfFormats = this._supportedFormats.length;
  543. if (noOfFormats === 1) {
  544. return;
  545. }
  546. var modifiedProperties = this._runOptionsControl.getModifiedProperties();
  547. if (modifiedProperties[RunAsOptionsView.OPTION.RUN_IN_BG]) {
  548. $.each(this._supportedFormats, function(i, format) {
  549. if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
  550. this._runOptionsControl.getProperty(format).uncheck();
  551. }
  552. }.bind(this));
  553. this._runOptionsControl.getProperty(modifiedProperties[RunAsOptionsView.OPTION.RUNFORMAT] || this._outputFormat).check();
  554. } else {
  555. var selectedFormat = null;
  556. // Loop through _supportedFormats to select the first supported format in order.
  557. $.each(this._supportedFormats, function(i, format) {
  558. if (modifiedProperties[format]) {
  559. selectedFormat = format;
  560. return false;
  561. }
  562. }.bind(this));
  563. this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.RUNFORMAT).setValue(selectedFormat || this._outputFormat);
  564. }
  565. },
  566. _getRunInBackgroundOptionsSpec: function() {
  567. return {
  568. 'type': 'CollapsibleSection',
  569. 'name': 'runInBackgroundOptions',
  570. 'hideSectionTitle': true,
  571. 'items': this._getRunInBackgroundFormatsSpec().concat(
  572. this._getSeparatorSpec(),
  573. this._getPromptForValuesOptionSpec(),
  574. this._getPromptGenerationHintText(this._promptValue),
  575. this._getAdvancedSectionSpec()
  576. )
  577. };
  578. },
  579. _getRunAsOptionsSpec: function() {
  580. return {
  581. 'type': 'CollapsibleSection',
  582. 'name': 'runAsOptions',
  583. 'hideSectionTitle': true,
  584. 'items': [this._getRunAsFormatsSpec(),
  585. this._getSeparatorSpec(),
  586. this._getPromptForValuesOptionSpec(),
  587. this._getSeparatorSpec()
  588. ],
  589. 'open': true
  590. };
  591. },
  592. _getRunInBackgroundFormatsSpec: function() {
  593. var noOfFormats = this._supportedFormats.length;
  594. if (noOfFormats === 1) {
  595. return [this._getSingleFormatSpec(this._supportedFormats[0])];
  596. }
  597. var itemsSpec = [];
  598. this._supportedFormats.forEach(function(format) {
  599. if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
  600. itemsSpec.push({
  601. 'type': 'CheckBox',
  602. 'name': format,
  603. 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
  604. 'value': format,
  605. 'controlOnLeft': true,
  606. 'checked': this._outputFormat === format,
  607. 'onChange': this._updateSelectedFormat.bind(this)
  608. });
  609. }
  610. }.bind(this));
  611. return [{
  612. 'type': 'CollapsibleSection',
  613. 'hideSectionTitle': true,
  614. 'open': true,
  615. 'name': RunAsOptionsView.OPTION.OUTPUTFORMAT,
  616. 'ariaLabel': StringResource.get('formatOptions'),
  617. 'items': itemsSpec
  618. }];
  619. },
  620. _getRunAsFormatsSpec: function() {
  621. var noOfFormats = this._supportedFormats.length;
  622. if (noOfFormats === 1) {
  623. return this._getSingleFormatSpec(this._supportedFormats[0]);
  624. }
  625. var itemsSpec = [];
  626. this._supportedFormats.forEach(function(format) {
  627. if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
  628. itemsSpec.push({
  629. 'name': format,
  630. 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
  631. 'value': format
  632. });
  633. }
  634. }.bind(this));
  635. return ({
  636. 'type': 'RadioButtonGroup',
  637. 'ariaLabel': StringResource.get('formatOptions'),
  638. 'name': RunAsOptionsView.OPTION.RUNFORMAT,
  639. 'value': this._outputFormat,
  640. 'controlOnLeft': true,
  641. 'separator': false,
  642. 'items': itemsSpec
  643. });
  644. },
  645. _getSingleFormatSpec: function(format) {
  646. return {
  647. 'type': 'SingleLineValue',
  648. 'name': format,
  649. 'label': StringResource.get(format),
  650. 'value': ''
  651. };
  652. },
  653. _getPromptForValuesOptionSpec: function() {
  654. return {
  655. 'type': 'CheckBox',
  656. 'name': RunAsOptionsView.OPTION.PROMPT,
  657. 'label': StringResource.get('promptForValues'),
  658. 'controlOnLeft': true,
  659. 'checked': ContentStoreObject.getExecutionPrompt(this.objectInformation),
  660. 'onChange': this._togglePromptValue.bind(this)
  661. };
  662. },
  663. _getPromptGenerationHintText: function(isPromptMeChecked) {
  664. return {
  665. 'type' : 'HintText',
  666. 'name' : 'promptGenerationHintText',
  667. 'label' : StringResource.get('promptGenerationHint'),
  668. 'visibility' : this._getCssVisibility(isPromptMeChecked)
  669. };
  670. },
  671. _togglePromptValue: function(controlName, value) {
  672. // Check actual value of control instead of negating previous value to avoid falling out of sync with Prompt checkbox
  673. this._promptValue = value;
  674. this._showHidePromptGenerationHintText(this._promptValue);
  675. },
  676. _showHidePromptGenerationHintText: function(isPromptMeChecked) {
  677. // Set hintText visibility
  678. var visibility = this._getCssVisibility(isPromptMeChecked);
  679. var hintText = this._runOptionsControl.getProperty('promptGenerationHintText');
  680. hintText.visibility = visibility;
  681. // Directly write visibility to element class to ensure it is always shown/hidden immediately when RunInBackground is toggled
  682. this.$el.find('.l_promptGenerationHintText').css('visibility', visibility);
  683. },
  684. _getCssVisibility: function(isVisible) {
  685. return isVisible ? 'visible' : 'hidden';
  686. },
  687. _getAdvancedSectionSpec: function() {
  688. var itemsSpec = [
  689. this._getRunNowOrLaterOptions(),
  690. this._getExecutionTimePicker(),
  691. this._getBurstOptionSpec(),
  692. this._getPDFOptionsSpec(),
  693. this._getLanguagesOptionSpec(),
  694. this._getDeliveryOptionsSpec()
  695. ];
  696. //some functions can return undefined so filter it out.
  697. var filteredItems = itemsSpec.filter(function(item) {
  698. return !!item;
  699. });
  700. return {
  701. 'type': 'CollapsibleSection',
  702. 'name': 'advancedProperties',
  703. 'label': StringResource.get('advancedProperties'),
  704. 'items': filteredItems
  705. };
  706. },
  707. _getRunNowOrLaterOptions: function() {
  708. return {
  709. 'type': 'HorizontalRadioButtonGroup',
  710. 'name': RunAsOptionsView.OPTION.RUN_NOW_OR_LATER,
  711. 'value': 'now',
  712. 'controlOnLeft': true,
  713. 'ariaLabel': StringResource.get('nowOrLaterRadioOptions'),
  714. 'onChange': this._toggleDatetimePicker.bind(this),
  715. 'items': [{
  716. 'name': RunAsOptionsView.OPTION.RUN_NOW,
  717. 'value': RunAsOptionsView.OPTION.RUN_NOW,
  718. 'label': StringResource.get('now')
  719. }, {
  720. 'label': StringResource.get('later'),
  721. 'name': RunAsOptionsView.OPTION.RUN_LATER,
  722. 'value': RunAsOptionsView.OPTION.RUN_LATER
  723. }]
  724. };
  725. },
  726. _toggleDatetimePicker: function(name, value) {
  727. if (this._lastRunNowOrLaterOption === value) {
  728. return;
  729. }
  730. //a different option is selected
  731. if (!this._datetimePicker) {
  732. this._datetimePicker = this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.EXECUTIONTIME);
  733. }
  734. if (value === RunAsOptionsView.OPTION.RUN_LATER) {
  735. this._datetimePicker.show();
  736. } else {
  737. this._datetimePicker.hide();
  738. }
  739. this._lastRunNowOrLaterOption = value;
  740. },
  741. _getExecutionTimePicker: function() {
  742. return {
  743. 'module': CA_DateTimePicker,
  744. 'name': RunAsOptionsView.OPTION.EXECUTIONTIME,
  745. 'glassContext': this.glassContext
  746. };
  747. },
  748. _getBurstOptionSpec: function() {
  749. if (ContentStoreObject.canBurst(this.objectInformation) && this.glassContext.hasCapability('canUseBursting')) {
  750. return {
  751. 'type': 'CheckBox',
  752. 'name': RunAsOptionsView.OPTION.BURST,
  753. 'label': StringResource.get('burst'),
  754. 'value': RunAsOptionsView.OPTION.BURST,
  755. 'onChange': this._updateBurstSelected.bind(this)
  756. };
  757. }
  758. },
  759. _getPDFOptionsSpec: function() {
  760. if (this._supportedFormats.length === 1 || !AuthoringHelper.userCanGenerateFormat(this.glassContext, 'PDF')) {
  761. return;
  762. }
  763. return {
  764. 'type': 'SingleLineValue',
  765. 'name': RunAsOptionsView.OPTION.ADVANCED_PDF,
  766. 'label': StringResource.get('pdf'),
  767. 'editCallback': this._showMoreOptionsPane.bind(this, this._getMorePDFOptionsSpec.bind(this)),
  768. 'hidden': true
  769. };
  770. },
  771. _getLanguagesOptionSpec: function() {
  772. return {
  773. 'type': 'SingleLineValue',
  774. 'name': RunAsOptionsView.OPTION.LANGUAGES,
  775. 'label': StringResource.get('languages'),
  776. 'editCallback': this._showMoreOptionsPane.bind(this, this._getMoreLanguageOptionsSpec.bind(this))
  777. };
  778. },
  779. _getDeliveryOptionsSpec: function() {
  780. return {
  781. 'type': 'SingleLineValue',
  782. 'name': RunAsOptionsView.OPTION.DELIVERY,
  783. 'label': StringResource.get('delivery'),
  784. 'editCallback': this._showMoreOptionsPane.bind(this, this._getMoreDeliveryOptionsSpec.bind(this))
  785. };
  786. },
  787. _showMoreOptionsPane: function(getContentSpecFunc) {
  788. if (typeof getContentSpecFunc !== 'function') {
  789. this.logger.debug('getContentSpecFunc is not a function');
  790. }
  791. var parentSlideout = this.slideout;
  792. getContentSpecFunc().then(function(spec) {
  793. this._slideout = this._appController.showSlideOut({
  794. 'position': 'left',
  795. 'parent': parentSlideout,
  796. 'width': '400',
  797. 'enableTabLooping': true,
  798. 'overlay': (spec.overlay === undefined) ? true : spec.overlay,
  799. 'content': spec.slideoutContent,
  800. 'label': spec.slideoutLabel
  801. });
  802. }.bind(this));
  803. },
  804. _getMoreDeliveryOptionsSpec: function() {
  805. var content = {
  806. 'module': CA_DeliveryPickerView,
  807. 'closeCallback': this._closeMoreDeliveryOptionsSlideout.bind(this),
  808. 'objectInformation': this.objectInformation,
  809. 'glassContext': this.glassContext,
  810. 'deliveryOptions': this._selections.delivery,
  811. 'burstSelected': this._selections[RunAsOptionsView.OPTION.BURST] ? true : false
  812. };
  813. var spec = {
  814. 'overlay': true,
  815. 'slideoutContent': content,
  816. 'slideoutLabel': StringResource.get('delivery')
  817. };
  818. return Promise.resolve(spec);
  819. },
  820. _getMoreLanguageOptionsSpec: function() {
  821. var content = {
  822. 'module': 'bi/content_apps/common/ui/LanguagePickerView',
  823. 'closeCallback': this._closeMoreLanguageOptionsSlideout.bind(this)
  824. };
  825. if (this._selections.languages) {
  826. content.enabledLanguages = this._selections.languages;
  827. }
  828. var spec = {
  829. 'slideoutContent': content,
  830. 'slideoutLabel': StringResource.get('languages')
  831. };
  832. return Promise.resolve(spec);
  833. },
  834. _closeMoreLanguageOptionsSlideout: function(selectedLanguages) {
  835. this._selections.languages = selectedLanguages;
  836. },
  837. _closeMoreDeliveryOptionsSlideout: function(selectedOptions) {
  838. this._selections.delivery = selectedOptions;
  839. },
  840. // Getting default values from report properties or previous selections
  841. _getDefaultPDFOptionValues: function() {
  842. if (this._selections.pdf) {
  843. return Promise.resolve({
  844. 'pdfOptions': this._selections.pdf
  845. });
  846. }
  847. if (this._defaultPDFOptionsValues) {
  848. return Promise.resolve(this._defaultPDFOptionsValues);
  849. }
  850. var options = {
  851. dataType: 'json',
  852. type: 'GET',
  853. url: ContentStoreObject.getSelfLink(this.objectInformation) + '?fields=options'
  854. };
  855. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  856. .then(function(jsonResponse) {
  857. var options = jsonResponse.data.data[0].options;
  858. if (!options) {
  859. return;
  860. }
  861. var defaultPDFOptions = options.filter(function(option) {
  862. return (RunAsOptionsView.PDF_OPTIONS.indexOf(option.name) !== -1);
  863. });
  864. this._defaultPDFOptionsValues = {
  865. 'pdfOptions': defaultPDFOptions
  866. };
  867. return this._defaultPDFOptionsValues;
  868. }.bind(this)).catch(this._handleRunError.bind(this));
  869. },
  870. _getMorePDFOptionsSpec: function() {
  871. var content = {
  872. 'module': PdfOptionsView,
  873. 'closeCallback': this._closeMorePDFOptionsSlideout.bind(this)
  874. };
  875. return this._getDefaultPDFOptionValues()
  876. .then(function(pdfOptions) {
  877. if (pdfOptions) {
  878. _.extend(content, pdfOptions);
  879. }
  880. var spec = {
  881. 'slideoutContent': content,
  882. 'slideoutLabel': StringResource.get('pdfOptions')
  883. };
  884. return spec;
  885. });
  886. },
  887. _closeMorePDFOptionsSlideout: function(pdfOptions) {
  888. this._selections.pdf = pdfOptions;
  889. },
  890. _onRun: function() {
  891. _.extend(this._selections, this._runOptionsControl.getModifiedProperties());
  892. this.logger.debug('RunAsOptionsView._onRun', this._selections);
  893. if (this._selections[RunAsOptionsView.OPTION.RUN_IN_BG]) {
  894. this._doRunInBackground();
  895. } else {
  896. this._doRunAs();
  897. }
  898. },
  899. _doRunAs: function() {
  900. this._appController.performAction(this._getActionId(), this._buildPayload());
  901. this._appController.hideSlideOut();
  902. },
  903. _getSelectedFormats: function(bRunInBackgroud) {
  904. var selectedFormats;
  905. if (bRunInBackgroud) {
  906. //returns an array
  907. if (this._supportedFormats.length === 1) {
  908. // Use the one and only supported format
  909. selectedFormats = this._supportedFormats;
  910. } else {
  911. var formats = [];
  912. for (var key in this._selections.formats) {
  913. if (this._selections.formats.hasOwnProperty(key) &&
  914. this._selections.formats[key]) {
  915. formats.push(key);
  916. }
  917. }
  918. selectedFormats = formats;
  919. }
  920. } else {
  921. // returns a string
  922. if (this._supportedFormats.length === 1) {
  923. selectedFormats = this._supportedFormats[0];
  924. } else {
  925. selectedFormats = this._selections[RunAsOptionsView.OPTION.RUNFORMAT] || this._outputFormat;
  926. }
  927. }
  928. return selectedFormats;
  929. },
  930. _updateBurstSelected: function(name, bValue) {
  931. this._selections[RunAsOptionsView.OPTION.BURST] = bValue;
  932. },
  933. _updateSelectedFormat: function(name, value) {
  934. this._selections.formats[name] = value;
  935. if (name === 'PDF' && AuthoringHelper.userCanGenerateFormat(this.glassContext, name)) {
  936. var pdfSection = this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.ADVANCED_PDF);
  937. if (value) {
  938. pdfSection.show();
  939. } else {
  940. pdfSection.hide();
  941. }
  942. }
  943. },
  944. _setOutputLocaleRequestParams: function() {
  945. if (this._selections.languages) {
  946. // setting outputLocale will explicitly override the report language
  947. this._requestParams.options.outputLocale = this._selections.languages;
  948. }
  949. },
  950. _setDeliveryOptionsRequestParams: function() {
  951. if (this._selections.delivery) {
  952. this._requestParams.options.delivery = this._selections.delivery;
  953. } else {
  954. this._requestParams.options.delivery = {
  955. 'save': {
  956. 'notify': false
  957. }
  958. };
  959. }
  960. },
  961. _setOutputFormatRequestParams: function() {
  962. var selectedOutputFormats = this._getSelectedFormats(true /*bRunInBackgroud*/ );
  963. this._requestParams.options.outputFormat = selectedOutputFormats;
  964. },
  965. _setSaveToCloudRequestParams: function() {
  966. if (this._selections.delivery && (this._selections.delivery.cloudLocation) && (this._selections.delivery.cloudLocation !== '')) {
  967. this._requestParams.options.saveToCloud = this._selections.delivery.cloudLocation;
  968. if ((this._selections.delivery.cloudName) && (this._selections.delivery.cloudName !== '')) {
  969. this._requestParams.options.cloudName = this._selections.delivery.cloudName;
  970. }
  971. }
  972. },
  973. _setExecutionTimeRequestParams: function() {
  974. if (this._selections[RunAsOptionsView.OPTION.RUN_NOW_OR_LATER] === RunAsOptionsView.OPTION.RUN_LATER && this._selections.executionTime) {
  975. if (Date.now() < Date.parse(this._selections.executionTime)) {
  976. this._requestParams.executionTime = this._selections.executionTime;
  977. } else {
  978. GlassContextHelper.displayToast(this.glassContext, StringResource.get('invalidTime'));
  979. throw 'Invalid time selected';
  980. }
  981. }
  982. },
  983. _setBurstOptionRequestParams: function() {
  984. if (this._selections[RunAsOptionsView.OPTION.BURST]) {
  985. this._requestParams.options.burst = true;
  986. }
  987. },
  988. _setParametersRequestParams: function(parameters) {
  989. if (parameters) {
  990. this._requestParams.parameters = parameters;
  991. }
  992. },
  993. _setPDFOptionsRequestParams: function() {
  994. if (!this._selections || !this._selections.pdf) {
  995. return;
  996. }
  997. this._requestParams.options.pdf = {};
  998. this._selections.pdf.forEach(function(option) {
  999. var value = option.value;
  1000. if ((option.name).indexOf('Password') !== -1 && option.value.length) {
  1001. var xmlDoc = $.parseXML(option.value);
  1002. var $pwd = $(xmlDoc).find('password');
  1003. if ($pwd.text().length) {
  1004. value = $pwd.text();
  1005. }
  1006. }
  1007. if (value) {
  1008. this._requestParams.options.pdf[option.name] = value;
  1009. }
  1010. }.bind(this));
  1011. },
  1012. _doRunInBackground: function() {
  1013. if (!this._getSelectedFormats(true /*bRunInBackground*/ ).length) {
  1014. GlassContextHelper.displayToast(this.glassContext,
  1015. StringResource.get('selectAFormat'), {
  1016. 'type': 'warning'
  1017. });
  1018. throw 'No format selected';
  1019. }
  1020. if (this._promptValue) {
  1021. this._showPromptPicker();
  1022. this._appController.hideSlideOut();
  1023. return;
  1024. }
  1025. this._executeRequest();
  1026. },
  1027. _onPromptFinish: function() {
  1028. this._executeRequest();
  1029. },
  1030. _updateRunOptionsForPowerPlayPrompt: function(options) {
  1031. if (this._selections && this._selections.delivery && this._selections.delivery.email) {
  1032. options.ca_deliveryOptions = C10Utils.getPowerPlayC10DeliveryOptions(this._selections.delivery.email);
  1033. }
  1034. },
  1035. _showPromptPicker: function(openInTab) {
  1036. var toggler = $('<div>', {
  1037. 'class': 'ca_promptpicker'
  1038. });
  1039. var options = {
  1040. 'reportId': this.objectInformation.id,
  1041. 'glassContext': this.glassContext,
  1042. 'onFinish': this._onPromptFinish.bind(this),
  1043. '$toggler': toggler,
  1044. 'deliveryOptions': this._selections.delivery,
  1045. 'languageOptions': this._selections.languages
  1046. };
  1047. if (openInTab) {
  1048. options.openInTab = true;
  1049. }
  1050. if (C10Utils.isPowerPlay(this.objectInformation.type)) {
  1051. if (this._selections.runNowOrLater === 'later') {
  1052. options.executionTime = this._selections.executionTime;
  1053. }
  1054. this._updateRunOptionsForPowerPlayPrompt(options);
  1055. this._promptPickerControl = new PowerPlayPromptPickerView(options);
  1056. } else {
  1057. this._promptPickerControl = new PromptPickerView(options);
  1058. }
  1059. this._promptPickerControl.showPromptOverlay();
  1060. },
  1061. _getRequestParams: function() {
  1062. return this._appController.hideSlideOut().then(function() {
  1063. this._setOutputFormatRequestParams();
  1064. this._setSaveToCloudRequestParams();
  1065. this._setExecutionTimeRequestParams();
  1066. this._setDeliveryOptionsRequestParams();
  1067. this._setBurstOptionRequestParams();
  1068. this._setPDFOptionsRequestParams();
  1069. this._setOutputLocaleRequestParams();
  1070. if (this._promptValue) {
  1071. this._setParametersRequestParams(this._promptPickerControl.getParameterValues());
  1072. }
  1073. }.bind(this));
  1074. },
  1075. // if options is empty, don't bother send it in data
  1076. _validRequestParamsOptions: function(){
  1077. var options = this._requestParams.options;
  1078. if( options == null ){
  1079. return;
  1080. }else{
  1081. var content = [];
  1082. for (var key in options) {
  1083. if (options[key] != null) {
  1084. content.push(options[key]);
  1085. }
  1086. }
  1087. if(content.length === 0){
  1088. delete this._requestParams.options;
  1089. }
  1090. }
  1091. },
  1092. _executeRequest: function() {
  1093. this._getRequestParams().then(function() {
  1094. this._validRequestParamsOptions();
  1095. var jsonData = JSON.stringify(this._requestParams);
  1096. var options = {
  1097. 'headers': {
  1098. 'Content-Type': 'application/vnd.ibm.bi.platform.execution+json; charset=UTF-8',
  1099. 'Accept': 'application/json'
  1100. },
  1101. 'datatype': 'json',
  1102. 'type': 'post',
  1103. 'url': 'v1/reports/' + this.objectInformation.id + '/executions',
  1104. 'data': jsonData
  1105. };
  1106. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  1107. .catch(this._handleRunError.bind(this));
  1108. }.bind(this));
  1109. },
  1110. _handleRunError: function(err) {
  1111. GlassContextHelper.showAjaxServiceError(this.glassContext, err);
  1112. },
  1113. _buildPayload: function() {
  1114. return {
  1115. 'glassContext': this.glassContext,
  1116. 'target': {
  1117. 'objectInformation': this.objectInformation,
  1118. 'itemId': this._getActionId(),
  1119. 'runOptions': {
  1120. 'prompt': this._promptValue,
  1121. 'format': this._getSelectedFormats()
  1122. },
  1123. 'activeObject': {
  1124. 'oListControl': this.listControl,
  1125. 'aSelectedContext': [this.objectInformation]
  1126. }
  1127. }
  1128. };
  1129. },
  1130. _getActionId: function() {
  1131. var actionId = RunAsOptionsView.ACTION_ID;
  1132. if (this.objectInformation.type.indexOf('powerPlay8Report') !== -1) {
  1133. actionId = 'com.ibm.bi.contentApps.defaultAction.' + this.objectInformation.type;
  1134. }
  1135. return actionId;
  1136. }
  1137. });
  1138. RunAsOptionsView.ACTION_ID = 'com.ibm.bi.contentApps.action.runAs';
  1139. RunAsOptionsView.SUPPORTED_FORMATS = {
  1140. 'all': ['spreadsheetML', 'xlsxData', 'PDF', 'HTML', 'CSV', 'XML'],
  1141. 'interactiveReport': ['HTML'],
  1142. 'powerPlay8Report': ['PDF']
  1143. };
  1144. /* names used to access controls */
  1145. RunAsOptionsView.OPTION = {
  1146. PROMPT: 'promptForValues',
  1147. RUNFORMAT: 'runFormat',
  1148. OUTPUTFORMAT: 'outputFormat',
  1149. DELIVERY: 'delivery',
  1150. EXECUTIONTIME: 'executionTime',
  1151. LANGUAGES: 'languages',
  1152. RUN_IN_BG: 'runInBackgroundChecked',
  1153. RUN_LATER: 'later',
  1154. RUN_NOW: 'now',
  1155. RUN_NOW_OR_LATER: 'runNowOrLater',
  1156. BURST: 'burst',
  1157. ADVANCED_PDF: 'advancedPDF'
  1158. };
  1159. RunAsOptionsView.PDF_OPTIONS = ['outputPageDefinition',
  1160. 'outputPageOrientation',
  1161. 'userPassword',
  1162. 'ownerPassword',
  1163. 'allowPrintQuality',
  1164. 'allowModifications',
  1165. 'allowAnnotations',
  1166. 'allowFieldCompletion',
  1167. 'allowAssembly',
  1168. 'allowContentCopy',
  1169. 'allowAccessibilitySupport'
  1170. ];
  1171. return RunAsOptionsView;
  1172. });
  1173. /*
  1174. *+------------------------------------------------------------------------+
  1175. *| Licensed Materials - Property of IBM
  1176. *| IBM Cognos Products: Content Explorer
  1177. *| (C) Copyright IBM Corp. 2015, 2018
  1178. *|
  1179. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1180. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1181. *+------------------------------------------------------------------------+
  1182. */
  1183. define('bi/content_apps/common/ui/list_actions/ViewReportAction',[
  1184. 'bacontentnav/common/ui/list_actions/ListAction',
  1185. 'bacontentnav/utils/ContentStoreObject',
  1186. 'bi/commons/utils/Downloader',
  1187. 'underscore'
  1188. ], function(ListAction, ContentStoreObject, Downloader, _) {
  1189. 'use strict';
  1190. var ViewReportAction = ListAction.extend({
  1191. canExecute: function(options) {
  1192. var selectedContext = options.target.activeObject.aSelectedContext;
  1193. if (!selectedContext || selectedContext.length > 1) {
  1194. return false;
  1195. }
  1196. return ContentStoreObject.hasPermissions(selectedContext[0], ['traverse', 'read']);
  1197. },
  1198. doAction: function(context) {
  1199. var selectedObjects = context.target.activeObject.aSelectedContext;
  1200. if (!selectedObjects || selectedObjects.length > 1) {
  1201. return Promise.reject(new Error('No objects selected'));
  1202. } else {
  1203. var selectedObject = selectedObjects[0];
  1204. return ContentStoreObject.getBaseObjectType(selectedObject).then(function(type) {
  1205. if (!this._isSupportedType(type)) {
  1206. return Promise.reject(new Error('Not supported type'));
  1207. } else {
  1208. var requestOptions = {
  1209. url: ContentStoreObject.getSelfLink(selectedObject),
  1210. type: 'GET',
  1211. dataType: 'json',
  1212. data: {
  1213. 'fields': 'defaultOutputFormat'
  1214. }
  1215. };
  1216. return context.glassContext.getCoreSvc('.Ajax').ajax(requestOptions)
  1217. .then(function(response) {
  1218. response = response && response.data;
  1219. if (response.data[0].defaultOutputFormat) {
  1220. var outputId = context.target.activeObject.outputId;
  1221. var download = context.target.activeObject.download;
  1222. var suffix = download ? '/content?download=true' : this._getSuffix(type);
  1223. var outputHref;
  1224. // If we're passed an output ID then we want to view a specific output and not simply the latest
  1225. if (outputId) {
  1226. outputHref = 'v1/disp/repository/sid/cm/oid/' + outputId + suffix;
  1227. } else {
  1228. outputHref = 'v1/disp/repository/sid/cm/rid/' + selectedObject.id + '/oid/default' + suffix;
  1229. }
  1230. if (download) {
  1231. var downloader = this._getDownloader({
  1232. url: outputHref,
  1233. logger: context.glassContext.appController.logger
  1234. });
  1235. downloader.doDownload();
  1236. } else {
  1237. if (type.indexOf('powerPlay8Report') !== -1) {
  1238. var name = ContentStoreObject.getName(selectedObject);
  1239. outputHref = this._getPP8ReportViewerUrl(outputId, name);
  1240. }
  1241. this._openWindow(outputHref);
  1242. }
  1243. return Promise.resolve();
  1244. } else {
  1245. return Promise.reject(new Error('No saved output'));
  1246. }
  1247. }.bind(this));
  1248. }
  1249. }.bind(this));
  1250. }
  1251. },
  1252. _getDownloader: function(options) {
  1253. return new Downloader(options);
  1254. },
  1255. _openWindow: function(outputHref) {
  1256. window.open(outputHref);
  1257. },
  1258. _getSuffix: function(type) {
  1259. var suffix;
  1260. switch (type) {
  1261. case 'interactiveReport':
  1262. suffix = '/content/mht/content';
  1263. break;
  1264. case 'powerPlay8Report':
  1265. case 'powerPlay8ReportView':
  1266. suffix = '/content?cv.id=_THIS_';
  1267. break;
  1268. default:
  1269. suffix = '';
  1270. break;
  1271. }
  1272. return suffix;
  1273. },
  1274. _isSupportedType: function(type) {
  1275. var isSupported = false;
  1276. switch (type) {
  1277. case 'interactiveReport':
  1278. case 'powerPlay8Report':
  1279. case 'powerPlay8ReportView':
  1280. isSupported = true;
  1281. break;
  1282. default:
  1283. break;
  1284. }
  1285. return isSupported;
  1286. },
  1287. _getPP8ReportViewerUrl: function(outputId, name) {
  1288. var url = 'v1/disp?b_action=cognosViewer&ui.action=view&ui.format=PDF&ui.object=storeID(%22' + outputId + '%22)&ui.name=' + _.escape(name);
  1289. url = url + '&cv.header=false&ui.backURL=%2fcps4%2fportlets%2fcommon%2fclose.html';
  1290. return url;
  1291. }
  1292. });
  1293. return ViewReportAction;
  1294. });
  1295. /*
  1296. *+------------------------------------------------------------------------+
  1297. *| Licensed Materials - Property of IBM
  1298. *|
  1299. *| IBM Cognos Products: content-apps
  1300. *|
  1301. *| (C) Copyright IBM Corp. 2015, 2021
  1302. *|
  1303. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1304. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1305. *+------------------------------------------------------------------------+
  1306. */
  1307. define('bi/content_apps/VersionsTab',[
  1308. 'require',
  1309. 'jquery',
  1310. 'bi/glass/app/ContentView',
  1311. 'bi/commons/ui/Slideout',
  1312. 'bi/content_apps/nls/StringResource',
  1313. 'bacontentnav/utils/UIHelper',
  1314. 'bacontentnav/utils/ContentStoreObject',
  1315. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  1316. 'bacontentnav/utils/GlassContextHelper',
  1317. 'bi/content_apps/common/ui/list_actions/ViewReportAction',
  1318. 'bi/commons/ui/dialogs/ConfirmationDialog',
  1319. 'bi/commons/utils/BidiUtil',
  1320. 'underscore'
  1321. ], function(localRequire, $, ContentView, Slideout, StringResource, UIHelper, ContentStoreObject, PropertyUIControl, GlassContextHelper, ViewReportAction, ConfirmationDialog, BidiUtil, _) {
  1322. 'use strict';
  1323. var _SUPPORTED_FORMATS = {
  1324. 'PDF': true,
  1325. 'HTML': true,
  1326. 'CSV': true,
  1327. 'spreadsheetML': true,
  1328. 'xlsxData': true,
  1329. 'XHTML': true,
  1330. 'XLWA': true,
  1331. 'XML': true,
  1332. 'HTMLFragment': true
  1333. };
  1334. var _FORMAT_ICONSTRING = {
  1335. 'xlsxdata':'common-excel_icon',
  1336. 'spreadsheetml':'common-excel_icon',
  1337. 'xlwa':'common-excel_icon',
  1338. 'xhtml':'common-html_icon',
  1339. 'html':'common-html_icon',
  1340. 'csv':'common-csv_icon',
  1341. 'pdf':'common-pdf_icon',
  1342. 'xml':'common-xml_icon',
  1343. 'default': 'common-savedoutput_report'
  1344. };
  1345. var VersionsTab = ContentView.extend({
  1346. /**
  1347. * @param options.el {node} - container dom node
  1348. */
  1349. init: function(options) {
  1350. VersionsTab.inherited('init', this, arguments);
  1351. _.extend(this, options);
  1352. this.noBurstKey = 'secretIBMNoBurstKey';
  1353. this.mockableViewInteractiveReportAction = ViewReportAction;
  1354. this.batchSize = Math.floor((window.innerHeight) / 18);
  1355. this.initialEndIndex = this.batchSize;
  1356. this.renderIndex = this.batchSize;
  1357. },
  1358. render: function() {
  1359. this._id = _.uniqueId('prop_');
  1360. return this._queryHistoriesVersions().then(function(res) {
  1361. if (!(res.historiesInfo || res.versionsInfo)) {
  1362. UIHelper.renderInfoMessage(this.$el, StringResource.get('noVersions'));
  1363. } else {
  1364. this.$el.addClass('versionsTab');
  1365. var mergedInfo = this._mergeVersionAndHistory(res.historiesInfo, res.versionsInfo);
  1366. mergedInfo.sort(function(a, b) {
  1367. a = new Date(ContentStoreObject.getRequestedTime(a));
  1368. b = new Date(ContentStoreObject.getRequestedTime(b));
  1369. return a > b ? -1 : a < b ? 1 : 0;
  1370. });
  1371. this.items = this._getItems(mergedInfo);
  1372. if (this.initialEndIndex > this.items.length) {
  1373. this.initialEndIndex = this.items.length;
  1374. }
  1375. this._oPropertyUIControl = new PropertyUIControl({
  1376. 'el': this.$el,
  1377. 'items': [{
  1378. 'name': 'showAllHistory',
  1379. 'label': StringResource.get('showAllHistory'),
  1380. 'checked': false,
  1381. 'type': 'CheckBox',
  1382. 'onChange': this._showAllHistoryChange.bind(this)
  1383. }, {
  1384. 'type': 'Separator'
  1385. }].concat(this.items.slice(0, this.initialEndIndex))
  1386. });
  1387. return this._oPropertyUIControl.render();
  1388. }
  1389. }.bind(this))
  1390. .then(function() {
  1391. this._showAllHistoryChange();
  1392. // Render the first page with an almost minimum number of rows and then render the subsequent pages with a size: 3 times bigger than the one for the first page.
  1393. this.batchSize *= 3;
  1394. this._scrollNode = this.$el.find('.containerUIControl');
  1395. $(this._scrollNode).on('scroll', this._onScroll.bind(this));
  1396. }.bind(this));
  1397. },
  1398. /**
  1399. * Render a batch of spec. items in [startIndex, endIndex)
  1400. * @startIndex Start index in the spec. items list
  1401. * @endIndex End index in the the spec. items list
  1402. */
  1403. _render: function(startIndex, endIndex) {
  1404. this.renderIndex = endIndex;
  1405. return this._oPropertyUIControl.renderItems(this.items.slice(startIndex, endIndex));
  1406. },
  1407. /**
  1408. * Handle scroll event
  1409. */
  1410. _onScroll: function(event) {
  1411. if (this._bScrollToBottom(event) === true) {
  1412. if (this.renderIndex >= this.items.length) {
  1413. return;
  1414. }
  1415. var endIndex = this.renderIndex + this.batchSize;
  1416. if (endIndex < this.items.length) {
  1417. return this._render(this.renderIndex, endIndex);
  1418. } else {
  1419. return this._render(this.renderIndex, this.items.length);
  1420. }
  1421. }
  1422. },
  1423. /**
  1424. * @return true if scrolling to the bottom of current pane
  1425. * false otherwise
  1426. */
  1427. _bScrollToBottom: function(event) {
  1428. var $target = $(event.target);
  1429. if ($target.scrollTop() + $target.innerHeight() >= ($target[0].scrollHeight - 20)) { // If we've scrolled to the bottom
  1430. return true;
  1431. }
  1432. return false;
  1433. },
  1434. /**
  1435. * @return object
  1436. */
  1437. _queryHistoriesVersions: function() {
  1438. var aPromises = [];
  1439. if (this.objectInfo) {
  1440. aPromises.push(ContentStoreObject.getHistories(this.objectInfo, 'output'));
  1441. aPromises.push(ContentStoreObject.getVersions(this.objectInfo, 'creationTime'));
  1442. }
  1443. return Promise.all(aPromises).then(function(results) {
  1444. return {
  1445. historiesInfo: results[0],
  1446. versionsInfo: results[1]
  1447. };
  1448. });
  1449. },
  1450. _handleGetOutputsSuccess: function(data) {
  1451. var outputs = data.data;
  1452. var index = data.index;
  1453. var outputsInfo = [];
  1454. if (outputs) {
  1455. outputs.forEach(function(output) {
  1456. if (!_SUPPORTED_FORMATS[output.format]) {
  1457. return;
  1458. }
  1459. var processedOutput = {
  1460. 'id': ContentStoreObject.getObjectId(output),
  1461. 'format': ContentStoreObject.getFormat(output),
  1462. 'content': ContentStoreObject.getOutputContentLink(output),
  1463. 'modificationTime': ContentStoreObject.getModificationTime(output, true, 'short')
  1464. };
  1465. if (processedOutput.format && processedOutput.content) {
  1466. var burstKey = ContentStoreObject.getBurstKey(output);
  1467. var locale = ContentStoreObject.getLocale(output);
  1468. if (burstKey) {
  1469. if (!outputsInfo[burstKey]) {
  1470. outputsInfo[burstKey] = [];
  1471. }
  1472. if (!outputsInfo[burstKey][locale]) {
  1473. outputsInfo[burstKey][locale] = [];
  1474. }
  1475. outputsInfo[burstKey][locale].push(processedOutput);
  1476. } else {
  1477. if (!outputsInfo[this.noBurstKey]) {
  1478. outputsInfo[this.noBurstKey] = [];
  1479. }
  1480. if (!outputsInfo[this.noBurstKey][locale]) {
  1481. outputsInfo[this.noBurstKey][locale] = [];
  1482. }
  1483. outputsInfo[this.noBurstKey][locale].push(processedOutput);
  1484. }
  1485. }
  1486. }.bind(this));
  1487. }
  1488. return { outputsInfo: outputsInfo, index: index };
  1489. },
  1490. /**
  1491. * @return array
  1492. */
  1493. _mergeVersionAndHistory: function(historiesInfo, versionsInfo) {
  1494. historiesInfo = historiesInfo || [];
  1495. versionsInfo = versionsInfo || [];
  1496. $.each(versionsInfo, function(i, v) {
  1497. var found = false;
  1498. $.each(historiesInfo, function(i, h) {
  1499. if (h.output && h.output.id === v.id) {
  1500. found = true;
  1501. return false;
  1502. }
  1503. });
  1504. if (!found) {
  1505. v[ContentStoreObject.REQUESTED_TIME] = ContentStoreObject.getCreationDate(v);
  1506. delete v[ContentStoreObject.CREATION_TIME];
  1507. v[ContentStoreObject.STATUS] = 'succeeded';
  1508. historiesInfo.push(v);
  1509. }
  1510. });
  1511. // Remove the history output which was kept in cache
  1512. $.each(historiesInfo, function(i, h) {
  1513. if (h.output && h.output.id) {
  1514. var outputid = h.output.id;
  1515. var found = false;
  1516. $.each(versionsInfo, function(i, v) {
  1517. if (v.id === outputid) {
  1518. found = true;
  1519. return false;
  1520. }
  1521. });
  1522. if (!found) {
  1523. h.output = null;
  1524. }
  1525. }
  1526. });
  1527. return historiesInfo;
  1528. },
  1529. _getItems: function(mergedInfo) {
  1530. this.mergedInfo = mergedInfo;
  1531. var items = [];
  1532. this.mergedInfo.forEach(function(historyInfo, index) {
  1533. var requestedTime = ContentStoreObject.getRequestedTime(historyInfo, true, 'medium');
  1534. var succeeded = (ContentStoreObject.getStatus(historyInfo) === 'succeeded');
  1535. var detailsLink = ContentStoreObject.getDetailsLink(this.mergedInfo[index]);
  1536. var hasDetails = detailsLink !== null;
  1537. var outputsLink = this._getOutputsLinkFromIndex(index);
  1538. var hasOutput = outputsLink !== null;
  1539. items.push({
  1540. 'type': 'SingleLineLinks',
  1541. 'name': index + '_versions',
  1542. 'role': 'group',
  1543. 'items': [{
  1544. 'align': 'left',
  1545. 'items': [{
  1546. 'type': 'icon',
  1547. 'class': succeeded ? 'versionReport' : 'versionStatusFailed',
  1548. 'svgIcon': succeeded ? hasOutput ? 'common-savedoutput_report' : 'common-savedoutput_reporthistory' : 'common-failed',
  1549. 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed'),
  1550. 'iconTooltip': StringResource.get('report')
  1551. }, {
  1552. 'type': 'text',
  1553. 'value': requestedTime,
  1554. 'class': 'versionText' + (hasOutput ? '' : ' hasNoOutput'),
  1555. 'clickCallback': hasOutput ? this._toggleOutputsSection.bind(this, index) : null
  1556. }]
  1557. }, {
  1558. 'align': 'right',
  1559. 'items': [{
  1560. 'type': 'icon',
  1561. 'class': 'versionDetailsLinks' + (hasDetails ? '' : ' disabled'),
  1562. 'svgIcon': 'common-info-moreinfo',
  1563. 'clickCallback': hasDetails ? this._openDetails.bind(this, index) : null,
  1564. 'iconTooltip': StringResource.get('showDetails'),
  1565. 'showRightArrow': true
  1566. }]
  1567. }]
  1568. });
  1569. items.push({
  1570. 'type': 'CollapsibleSection',
  1571. 'name': index + '_outputs',
  1572. 'label': requestedTime,
  1573. 'styleAsSimpleRow': true,
  1574. 'hideSectionTitle': true,
  1575. 'indent': 3.3,
  1576. 'items': [],
  1577. 'onOpenChange': this._openOutputsSection.bind(this, index)
  1578. });
  1579. items.push({
  1580. 'type': 'Separator'
  1581. });
  1582. }.bind(this));
  1583. return items;
  1584. },
  1585. _toggleOutputsSection: function(index, evt) {
  1586. /*eslint no-unused-vars: 0*/
  1587. this._getOutputSection(index).toggleCollapsibleSection();
  1588. },
  1589. _showAllHistoryRefresh: function() {
  1590. var showAllHistory = this._oPropertyUIControl.getProperty('showAllHistory').isChecked();
  1591. this._showAllHistoryChange(null, showAllHistory);
  1592. },
  1593. _showItem: function(i, elem) {
  1594. $(elem).removeClass('hidden');
  1595. },
  1596. _selectItem: function(elem) {
  1597. var selected = $(elem).closest('.propertyRow').nextUntil('.separator').addBack();
  1598. // Add the separator
  1599. selected = selected.add(selected.last().next());
  1600. return selected;
  1601. },
  1602. _hideItem: function(i, elem) {
  1603. this._selectItem(elem).addClass('hidden');
  1604. },
  1605. _removeItem: function(elem) {
  1606. this._selectItem(elem).remove();
  1607. },
  1608. _showAllHistoryChange: function(name, checked) {
  1609. if (checked) {
  1610. $('.itemContainerUIControl > div', this.$el).each(this._showItem.bind(this));
  1611. } else {
  1612. $('.itemContainerUIControl .hasNoOutput', this.$el).each(this._hideItem.bind(this));
  1613. }
  1614. },
  1615. _getOutputFromIndex: function(index) {
  1616. var obj = this.mergedInfo[index];
  1617. var oData = {};
  1618. if (_.isObject(obj.output)) {
  1619. oData[ContentStoreObject.OUTPUT] = [obj.output];
  1620. } else {
  1621. oData[ContentStoreObject.OUTPUT] = [obj];
  1622. }
  1623. return oData;
  1624. },
  1625. _getOutputsLinkFromIndex: function(index) {
  1626. var obj = this._getOutputFromIndex(index);
  1627. return ContentStoreObject.getOutputsLink(obj);
  1628. },
  1629. _getVersionLinkFromIndex: function(index) {
  1630. var obj = this._getOutputFromIndex(index);
  1631. return ContentStoreObject.getVersionLink(obj);
  1632. },
  1633. _openOutputsSection: function(index, name, open) {
  1634. if (open) {
  1635. var outputsLink = this._getOutputsLinkFromIndex(index);
  1636. this._getOutputs(outputsLink, index)
  1637. .then(this._handleGetOutputsSuccess.bind(this))
  1638. .then(this._getOutputsSectionPayload.bind(this))
  1639. .done(function(payload) {
  1640. var items = this._getItemsSpec(payload.outputsInfo, index, payload.items);
  1641. this._getOutputSection(index).refreshProperties(items);
  1642. }.bind(this));
  1643. }
  1644. },
  1645. _getVersionSection: function(index) {
  1646. var outputSectionId = index + '_versions';
  1647. return this._oPropertyUIControl.getProperty(outputSectionId);
  1648. },
  1649. _getOutputSection: function(index) {
  1650. var outputSectionId = index + '_outputs';
  1651. return this._oPropertyUIControl.getProperty(outputSectionId);
  1652. },
  1653. _openDetails: function(index) {
  1654. this._getDetails(index).then(function(details) {
  1655. var overlaySlideoutEl = $('<div>');
  1656. this.parentEl.append(overlaySlideoutEl);
  1657. var overlaySlideout = new Slideout({
  1658. 'glassContext': this.glassContext,
  1659. 'position': this.slideout.position,
  1660. 'el': overlaySlideoutEl,
  1661. 'width': '400',
  1662. 'content': {
  1663. 'module': 'bi/content_apps/VersionsDetailsView',
  1664. 'parentView': this,
  1665. 'objectInfo': this.objectInfo,
  1666. 'historyInfo': this.mergedInfo[index],
  1667. 'detailsInfo': details,
  1668. 'glassContext': this.glassContext
  1669. }
  1670. });
  1671. overlaySlideout.render()
  1672. .then(overlaySlideout.show());
  1673. }.bind(this));
  1674. },
  1675. _getOutputsSectionPayload: function(data) {
  1676. var outputsInfo = data.outputsInfo;
  1677. var index = data.index;
  1678. var items = [];
  1679. if (this._canDelete()) {
  1680. items.push({
  1681. 'type': 'SingleLineLinks',
  1682. 'items': [{
  1683. 'align': 'left',
  1684. 'items': [{
  1685. 'type': 'text',
  1686. 'value': StringResource.get('deleteReportVersion'),
  1687. 'class': 'versionText',
  1688. 'clickCallback': function() {
  1689. this._onClickDelete(index);
  1690. }.bind(this)
  1691. }]
  1692. }]
  1693. });
  1694. }
  1695. return GlassContextHelper.getContentLocales(this.glassContext).then(function(contentLocales) {
  1696. if (outputsInfo && Object.keys(outputsInfo).length > 0) {
  1697. var locale;
  1698. for (var burstKey in outputsInfo) {
  1699. if (outputsInfo.hasOwnProperty(burstKey)) {
  1700. if (burstKey !== this.noBurstKey) {
  1701. items.push({
  1702. 'type': 'SingleLineLinks',
  1703. 'items': [{
  1704. 'align': 'left',
  1705. 'items': [{
  1706. 'type': 'text',
  1707. 'class': 'wraptext versionText',
  1708. 'value': burstKey
  1709. }]
  1710. }]
  1711. });
  1712. }
  1713. for (locale in outputsInfo[burstKey]) {
  1714. if (outputsInfo[burstKey].hasOwnProperty(locale)) {
  1715. items = items.concat(this._getLocaleSectionPayload(locale, contentLocales[locale], outputsInfo[burstKey][locale]));
  1716. }
  1717. }
  1718. items.push({
  1719. 'type': 'Separator'
  1720. });
  1721. }
  1722. }
  1723. } else {
  1724. items.push({
  1725. 'type': 'SingleLineLinks',
  1726. 'items': [{
  1727. 'align': 'left',
  1728. 'items': [{
  1729. 'type': 'text',
  1730. 'class': 'versionText',
  1731. 'value': StringResource.get('noSavedOutputs')
  1732. }]
  1733. }]
  1734. });
  1735. }
  1736. return Promise.resolve({
  1737. items: items,
  1738. outputsInfo: outputsInfo
  1739. });
  1740. }.bind(this));
  1741. },
  1742. _getLocaleSectionPayload: function(locale, fullLocale, aOutputs) {
  1743. var items = [];
  1744. var outputItems = [];
  1745. outputItems.push({
  1746. 'type': 'text',
  1747. 'class': 'versionsLocale',
  1748. 'value': locale.toUpperCase()
  1749. });
  1750. outputItems.push({
  1751. 'type': 'text',
  1752. 'class': 'versionsLocale',
  1753. 'value': fullLocale,
  1754. 'name': locale,
  1755. 'hidden': true
  1756. });
  1757. aOutputs.forEach(function(output) {
  1758. outputItems.push({
  1759. 'type': 'icon',
  1760. 'class': 'versionsOutput',
  1761. 'name': 'outputlink',
  1762. 'svgIcon': this._getOutputIconString(output.format),
  1763. 'clickCallback': this._openOutput.bind(this, output, false),
  1764. 'iconTooltip': StringResource.get(output.format),
  1765. 'ariaLabelledby': locale
  1766. });
  1767. if (this._getOutputDefaultAction(output.format) === 'interactive') {
  1768. outputItems.push({
  1769. 'type': 'icon',
  1770. 'class': 'versionsOutput',
  1771. 'name': 'outputlink',
  1772. 'svgIcon': 'common-download',
  1773. 'clickCallback': this._openOutput.bind(this, output, true),
  1774. 'iconTooltip': StringResource.get('download'),
  1775. 'ariaLabelledby': locale
  1776. });
  1777. }
  1778. }.bind(this));
  1779. items.push({
  1780. 'type': 'SingleLineLinks',
  1781. 'items': [{
  1782. 'align': 'left',
  1783. 'items': outputItems
  1784. }]
  1785. });
  1786. return items;
  1787. },
  1788. _getOutputIconString: function(format) {
  1789. return _FORMAT_ICONSTRING[format.toLowerCase()] || _FORMAT_ICONSTRING['default'];
  1790. },
  1791. _getOutputDefaultAction: function(format) {
  1792. var value;
  1793. switch (format.toLowerCase()) {
  1794. case 'xhtml':
  1795. value = 'interactive';
  1796. break;
  1797. default:
  1798. value = 'view';
  1799. break;
  1800. }
  1801. return value;
  1802. },
  1803. _getDetails: function(index) {
  1804. if (this.mergedInfo && this.mergedInfo[index]) {
  1805. var options = {
  1806. dataType: 'json',
  1807. type: 'GET',
  1808. url: ContentStoreObject.getDetailsLink(this.mergedInfo[index])
  1809. };
  1810. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  1811. .then(function(response) {
  1812. if (response && response.data) {
  1813. return Promise.resolve(response.data.data);
  1814. } else {
  1815. return Promise.reject(new Error('No details data'));
  1816. }
  1817. });
  1818. } else {
  1819. return Promise.reject(new Error('No details'));
  1820. }
  1821. },
  1822. _getOutputs: function(outputsLink, index) {
  1823. if (outputsLink) {
  1824. var options = {
  1825. dataType: 'json',
  1826. type: 'GET',
  1827. url: outputsLink
  1828. };
  1829. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  1830. .then(function(response) {
  1831. if (response && response.data) {
  1832. return Promise.resolve({ data: response.data.data, index: index });
  1833. } else {
  1834. return Promise.reject(new Error('No outputs data'));
  1835. }
  1836. });
  1837. } else {
  1838. //resolve anyways if there are no reportVersions with this history
  1839. return Promise.resolve({});
  1840. }
  1841. },
  1842. _openOutput: function(output, download) {
  1843. // let the output handlers have the first chance
  1844. return this._handleOutput({
  1845. output: output,
  1846. report: this.objectInfo,
  1847. glassContext: this.glassContext,
  1848. download: download
  1849. })
  1850. .then(function(isHandled) {
  1851. if (!isHandled) {
  1852. // get values from options
  1853. var id = output.id;
  1854. var modificationTime = output.modificationTime;
  1855. var format = output.format;
  1856. var url = output.content;
  1857. var defaultAction = this._getOutputDefaultAction(format);
  1858. var viewAction, actionContext;
  1859. switch (defaultAction) {
  1860. case 'interactive':
  1861. // This is just a temporary solution for GA. Viewing saved output
  1862. // should use contributions
  1863. viewAction = new this.mockableViewInteractiveReportAction();
  1864. actionContext = {
  1865. 'glassContext': this.glassContext,
  1866. 'target': {
  1867. 'activeObject': {
  1868. 'aSelectedContext': [this.objectInfo],
  1869. 'outputId': id,
  1870. 'download': !!download
  1871. },
  1872. 'itemId': 'com.ibm.bi.contentApps.defaultAction.interactiveReport'
  1873. }
  1874. };
  1875. viewAction.doAction(actionContext);
  1876. break;
  1877. case 'view':
  1878. if (this.objectInfo.type && this.objectInfo.type.indexOf('powerPlay8Report') > -1) {
  1879. viewAction = new this.mockableViewInteractiveReportAction();
  1880. actionContext = {
  1881. 'glassContext': this.glassContext,
  1882. 'target': {
  1883. 'activeObject': {
  1884. 'aSelectedContext': [this.objectInfo],
  1885. 'outputId': id,
  1886. 'download': !!download
  1887. },
  1888. runOptions: {
  1889. prompt: true
  1890. },
  1891. 'itemId': 'com.ibm.bi.contentApps.defaultAction.powerPlay8Report'
  1892. }
  1893. };
  1894. viewAction.doAction(actionContext);
  1895. this._addToMRU(this.objectInfo);
  1896. } else {
  1897. this.glassContext.appController.openAppView('savedoutput', this._getReportPayload(id, modificationTime, format, url));
  1898. this._addToMRU(this.objectInfo);
  1899. }
  1900. break;
  1901. default:
  1902. this.glassContext.appController.openAppView('savedoutput', this._getReportPayload(id, modificationTime, format, url));
  1903. this._addToMRU(this.objectInfo);
  1904. break;
  1905. }
  1906. }
  1907. return Promise.resolve();
  1908. }.bind(this));
  1909. },
  1910. _addToMRU: function(objInfo) {
  1911. return this.glassContext.getSvc('.Content').then(function(contentSvc) {
  1912. contentSvc.addToMRU(objInfo);
  1913. });
  1914. },
  1915. _getReportPayload: function(id, modificationTime, format, url) {
  1916. var title = this.objectInfo.defaultName + ' - ' + modificationTime + ' - ' + format.toUpperCase();
  1917. return {
  1918. 'content': {
  1919. 'path': url,
  1920. 'title': title,
  1921. 'id': id,
  1922. 'reportId': ContentStoreObject.getObjectId(this.objectInfo),
  1923. 'type': ContentStoreObject.getType(this.objectInfo),
  1924. 'permissions': ContentStoreObject.getPermissions(this.objectInfo),
  1925. 'runInAdvancedViewer': ContentStoreObject.getRunInAdvancedViewer(this.objectInfo)
  1926. }
  1927. };
  1928. },
  1929. _getItemsSpec: function(outputsInfo, index, outputSectionPayload) {
  1930. if (outputsInfo && Object.keys(outputsInfo).length > 0) {
  1931. var rightItems = {
  1932. 'align': 'right',
  1933. 'items': [{
  1934. 'type': 'SingleLineLinks',
  1935. 'name': 'sectionRunHistory',
  1936. 'items': []
  1937. }]
  1938. };
  1939. var items = [{
  1940. 'type': 'Split',
  1941. 'label': 'Split',
  1942. 'name': 'Split' + this.id,
  1943. 'items': [{
  1944. 'align': 'left',
  1945. 'items': outputSectionPayload
  1946. }, rightItems]
  1947. }];
  1948. return items;
  1949. } else {
  1950. return outputSectionPayload;
  1951. }
  1952. },
  1953. _canDelete: function() {
  1954. if (this.objectInfo && this.objectInfo.permissions) {
  1955. return ContentStoreObject.hasPermissions(this.objectInfo, ['write']);
  1956. }
  1957. return true;
  1958. },
  1959. _onClickDelete: function(index) {
  1960. var oDialog = new ConfirmationDialog('confirmDelete', StringResource.get('confirmDelete'), StringResource.get('confirmDeleteMessage'));
  1961. oDialog.confirm(function() {
  1962. this._deleteVersion(index);
  1963. this.hasReportVersion = false;
  1964. }.bind(this));
  1965. oDialog.renderContent($('<div>'));
  1966. oDialog._container().addClass('contentDeleteConfirmDialog');
  1967. },
  1968. _handleDeleteVersionSuccess: function(index) {
  1969. var versionSection = this._getVersionSection(index);
  1970. var versionSectionNode = versionSection.getPropertyNode();
  1971. var outputSection = this._getOutputSection(index);
  1972. $('.versionText', versionSectionNode).removeClass('clickable').addClass('hasNoOutput');
  1973. this._showAllHistoryRefresh();
  1974. if ($('.versionDetailsLinks', versionSectionNode).hasClass('disabled')) {
  1975. this._removeItem(versionSectionNode);
  1976. }
  1977. var use = $('.versionReport .svgIcon use', versionSectionNode);
  1978. use.attr('xlink:href', '#common-savedoutput_reporthistory');
  1979. outputSection.getPropertyNode().remove();
  1980. var sText = StringResource.get('toastDoneDeletingSingular', {
  1981. 'nameOfItem': BidiUtil.enforceTextDirection(StringResource.get('reportOutputVersion'))
  1982. });
  1983. this.glassContext.appController.showToast(sText);
  1984. },
  1985. _deleteVersion: function(index) {
  1986. var versionLink = this._getVersionLinkFromIndex(index);
  1987. if (versionLink) {
  1988. var options = {
  1989. dataType: 'json',
  1990. type: 'DELETE',
  1991. url: versionLink + '?force=true&recursive=true'
  1992. };
  1993. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  1994. .then(this._handleDeleteVersionSuccess.bind(this, index))
  1995. .catch(function(err) { GlassContextHelper.showAjaxServiceError(this.glassContext, err); }.bind(this));
  1996. } else {
  1997. return Promise.resolve();
  1998. }
  1999. },
  2000. // consider moving to a helper/utility that can load other handlers
  2001. _initOutputHandlers: function() {
  2002. if (this._outputHandlers) {
  2003. return Promise.resolve();
  2004. } else {
  2005. return this.glassContext.appController.findCollection('com.ibm.bi.contentApps.authoring.outputHandlers')
  2006. .then(function(collectionItems) {
  2007. this._outputHandlers = [];
  2008. var outputHandlersPromises = [];
  2009. _.each(collectionItems, function(item) {
  2010. outputHandlersPromises.push(
  2011. new Promise(function(resolve) {
  2012. localRequire([item.outputHandler], function(HandlerModule) {
  2013. this._outputHandlers.push(new HandlerModule());
  2014. resolve();
  2015. }.bind(this));
  2016. }.bind(this)));
  2017. }.bind(this));
  2018. return Promise.all(outputHandlersPromises);
  2019. }.bind(this));
  2020. }
  2021. },
  2022. _handleOutput: function(options) {
  2023. return this._initOutputHandlers()
  2024. .then(function() {
  2025. if (this._getOutputDefaultAction(options.output.format) === 'interactive' && options.download) {
  2026. return Promise.resolve(false);
  2027. }
  2028. var maxPriority = -1;
  2029. var currentHandler;
  2030. _.each(this._outputHandlers || [], function(outputHandler) {
  2031. var outputHandlerPriority = outputHandler.getPriority();
  2032. if (outputHandlerPriority > maxPriority && outputHandler.canExecute(options)) {
  2033. currentHandler = outputHandler;
  2034. maxPriority = outputHandlerPriority;
  2035. }
  2036. });
  2037. if (currentHandler) {
  2038. currentHandler.execute(options);
  2039. return Promise.resolve(true);
  2040. } else {
  2041. return Promise.resolve(false);
  2042. }
  2043. }.bind(this));
  2044. }
  2045. });
  2046. return VersionsTab;
  2047. });
  2048. /*
  2049. *+------------------------------------------------------------------------+
  2050. *| Licensed Materials - Property of IBM
  2051. *| IBM Cognos Products: Content Explorer
  2052. *| (C) Copyright IBM Corp. 2015, 2018
  2053. *|
  2054. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2055. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2056. *+----
  2057. */
  2058. define('bi/content_apps/ArchivesTab',['q',
  2059. 'bi/glass/app/ContentView',
  2060. 'bi/content_apps/nls/StringResource',
  2061. 'bi/content_apps/utils/C10Utils',
  2062. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  2063. 'underscore'
  2064. ], function(Q, View, StringResource, C10Utils, PropertyUIControl, _) {
  2065. 'use strict';
  2066. var ArchivesTab = View.extend({
  2067. /**
  2068. @paran options.el {node} - container dom node
  2069. **/
  2070. init: function(options) {
  2071. ArchivesTab.inherited('init', this, arguments);
  2072. _.extend(this, options);
  2073. },
  2074. _viewArchivedVersion: function() {
  2075. C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
  2076. 'output_tab': 'arch'
  2077. }, {
  2078. 'm_name': this.objectInfo.defaultName
  2079. }]);
  2080. },
  2081. render: function() {
  2082. var deferred = Q.defer();
  2083. this._id = _.uniqueId('prop_');
  2084. this._oPropertyUIControl = new PropertyUIControl({
  2085. 'el': this.$el,
  2086. 'glassContext': this.glassContext,
  2087. 'items': [{
  2088. 'name': 'viewArchivedVersions',
  2089. 'type': 'SingleLineLinks',
  2090. 'items': [{
  2091. 'align': 'left',
  2092. 'items': [{
  2093. 'type': 'text',
  2094. 'value': StringResource.get('viewRunHistory')
  2095. }]
  2096. }, {
  2097. 'align': 'right',
  2098. 'items': [{
  2099. 'type': 'text',
  2100. 'value': StringResource.get('viewArchivedVersions'),
  2101. 'clickCallback': this._viewArchivedVersion.bind(this)
  2102. }]
  2103. }]
  2104. }]
  2105. });
  2106. this._oPropertyUIControl.render().then(function() {
  2107. deferred.resolve(this);
  2108. }.bind(this));
  2109. return deferred.promise;
  2110. }
  2111. });
  2112. return ArchivesTab;
  2113. });
  2114. /*
  2115. *+------------------------------------------------------------------------+
  2116. *| Licensed Materials - Property of IBM
  2117. *| IBM Cognos Products: Content Explorer
  2118. *| (C) Copyright IBM Corp. 2015, 2018
  2119. *|
  2120. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2121. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2122. *+------------------------------------------------------------------------+
  2123. */
  2124. define('bi/content_apps/VersionsView',[
  2125. 'bi/glass/app/ContentView',
  2126. 'bi/content_apps/nls/StringResource',
  2127. 'bacontentnav/utils/ContentStoreObject',
  2128. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  2129. 'bi/content_apps/VersionsTab',
  2130. 'bi/content_apps/ArchivesTab',
  2131. 'underscore'
  2132. ],
  2133. function(ContentView, StringResource, ContentStoreObject, PropertyUIControl, VersionsTab, ArchivesTab, _) {
  2134. 'use strict';
  2135. var VersionsView = ContentView.extend({
  2136. init: function(options) {
  2137. VersionsView.inherited('init', this, arguments);
  2138. _.extend(this, options);
  2139. },
  2140. render: function() {
  2141. this._containerElement = $('<div>', {
  2142. 'class': 'propertyUIControl versionsView'
  2143. });
  2144. this.$el.append(this._containerElement);
  2145. return this._getAdditionalInfo().then(function() {
  2146. this._oPropertyUIControl = this._getPropertyUIControl({
  2147. 'el': this.$el,
  2148. 'glassContext': this.glassContext,
  2149. 'slideout': this.slideout,
  2150. 'animatedSpinner': true,
  2151. 'items': [{
  2152. 'name': 'versions',
  2153. 'value': StringResource.get('versions'),
  2154. 'type': 'Banner'
  2155. }, {
  2156. 'type': 'TabControl',
  2157. 'items': [{
  2158. 'name': StringResource.get('versions'),
  2159. 'module': VersionsTab,
  2160. 'objectInfo': this.objectInformation,
  2161. 'glassContext': this.glassContext,
  2162. 'slideout': this.slideout,
  2163. 'parentEl': this.$el
  2164. }, {
  2165. 'name': StringResource.get('archives'),
  2166. 'module': ArchivesTab,
  2167. 'objectInfo': this.objectInformation,
  2168. 'glassContext': this.glassContext,
  2169. 'slideout': this.slideout
  2170. }]
  2171. }]
  2172. });
  2173. return this._oPropertyUIControl.render();
  2174. }.bind(this));
  2175. },
  2176. _getPropertyUIControl: function(options) {
  2177. return new PropertyUIControl(options);
  2178. },
  2179. _getAdditionalInfo: function() {
  2180. return this.glassContext.getCoreSvc('.Ajax').ajax({
  2181. dataType: 'json',
  2182. type: 'GET',
  2183. url: ContentStoreObject.getSelfLink(this.objectInformation),
  2184. data: {
  2185. fields: 'permissions,' + ContentStoreObject.RUN_IN_ADVANCED_VIEWER
  2186. }
  2187. }).then(function(response) {
  2188. var data = response.data && response.data.data;
  2189. if (data) {
  2190. _.extend(this.objectInformation, data[0]);
  2191. } else {
  2192. return Promise.reject(new Error('No additional information'));
  2193. }
  2194. }.bind(this));
  2195. }
  2196. });
  2197. return VersionsView;
  2198. });
  2199. /*
  2200. *+------------------------------------------------------------------------+
  2201. *| Licensed Materials - Property of IBM
  2202. *| IBM Cognos Products: Content Explorer
  2203. *| (C) Copyright IBM Corp. 2015, 2020
  2204. *|
  2205. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2206. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2207. *+------------------------------------------------------------------------+
  2208. */
  2209. define('bi/content_apps/VersionsDetailsView',[
  2210. 'q',
  2211. 'jquery',
  2212. 'bi/glass/app/ContentView',
  2213. 'bi/content_apps/nls/StringResource',
  2214. 'bacontentnav/utils/ContentStoreObject',
  2215. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  2216. 'bacontentnav/utils/GlassContextHelper',
  2217. 'bi/content_apps/utils/C10Utils',
  2218. 'underscore'
  2219. ],
  2220. function(Q, $, ContentView, StringResource, ContentStoreObject, PropertyUIControl, GlassContextHelper, C10Utils, _) {
  2221. 'use strict';
  2222. var VersionsDetailsView = ContentView.extend({
  2223. init: function(options) {
  2224. VersionsDetailsView.inherited('init', this, arguments);
  2225. _.extend(this, options);
  2226. },
  2227. render: function() {
  2228. var deferred = Q.defer();
  2229. this._getItems().then(function(items) {
  2230. this.$el.addClass('versionsDetails');
  2231. this._oPropertyUIControl = new PropertyUIControl({
  2232. 'el': this.$el,
  2233. 'glassContext': this.glassContext,
  2234. 'slideout': this.slideout,
  2235. 'items': items
  2236. });
  2237. return this._oPropertyUIControl.render();
  2238. }.bind(this)).done(deferred.resolve);
  2239. return deferred.promise;
  2240. },
  2241. _getItems: function() {
  2242. var deferred = Q.defer();
  2243. var succeeded = (ContentStoreObject.getStatus(this.historyInfo) === 'succeeded');
  2244. var items = [{
  2245. 'type': 'Banner',
  2246. 'name': 'detailsBanner',
  2247. 'value': ContentStoreObject.getRequestedTime(this.historyInfo, true, 'medium'),
  2248. 'centerLabel': true,
  2249. 'backButton': true,
  2250. 'editable': false,
  2251. 'readOnly': true,
  2252. 'onClose': function() {
  2253. this.slideout.hide();
  2254. }.bind(this)
  2255. }, {
  2256. 'type': 'Separator'
  2257. }, {
  2258. 'type': 'SingleLineLinks',
  2259. 'name': 'actionbar',
  2260. 'items': [{
  2261. 'align': 'left',
  2262. 'items': [{
  2263. 'type': 'icon',
  2264. 'class': succeeded ? 'versionStatusSuccessful' : 'versionStatusFailed',
  2265. 'svgIcon': succeeded ? 'common-successful' : 'common-failed',
  2266. 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed'),
  2267. 'iconTooltip': succeeded ? StringResource.get('successful') : StringResource.get('failed')
  2268. }, {
  2269. 'type': 'text',
  2270. 'class': 'versionStatusText',
  2271. 'role': 'status',
  2272. 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed')
  2273. }]
  2274. }]
  2275. }, {
  2276. 'type': 'SingleLineLinks',
  2277. 'name': 'historydetails',
  2278. 'items': [{
  2279. 'align': 'right',
  2280. 'items': [{
  2281. 'type': 'text',
  2282. 'value': StringResource.get('runHistoryDetails'),
  2283. 'class': 'historydetailsText',
  2284. 'clickCallback': this._viewRunHistory.bind(this),
  2285. 'showRightArrow': true
  2286. }]
  2287. }]
  2288. }];
  2289. if (ContentStoreObject.getMessages(this.detailsInfo)) {
  2290. items.push({
  2291. 'type': 'CollapsibleSection',
  2292. 'name': 'errorMessages',
  2293. 'open': true,
  2294. 'label': StringResource.get('errorMessages'),
  2295. 'items': this._getMessageItems()
  2296. });
  2297. }
  2298. this._getOptionsItems().then(function(optionsItems) {
  2299. items = items.concat([{
  2300. 'type': 'CollapsibleSection',
  2301. 'name': 'runTime',
  2302. 'open': true,
  2303. 'label': StringResource.get('runTime'),
  2304. 'items': [{
  2305. 'type': 'SingleLineValue',
  2306. 'name': 'requestTime',
  2307. 'label': StringResource.get('requestTime'),
  2308. 'value': ContentStoreObject.getRequestedTime(this.historyInfo, true, 'medium')
  2309. }, {
  2310. 'type': 'Separator'
  2311. }, {
  2312. 'type': 'SingleLineValue',
  2313. 'name': 'startTime',
  2314. 'label': StringResource.get('startTime'),
  2315. 'value': ContentStoreObject.getExecutionTime(this.historyInfo, true, 'medium')
  2316. }, {
  2317. 'type': 'Separator'
  2318. }, {
  2319. 'type': 'SingleLineValue',
  2320. 'name': 'endTime',
  2321. 'label': StringResource.get('endTime'),
  2322. 'value': ContentStoreObject.getCompletionTime(this.historyInfo, true, 'medium')
  2323. }]
  2324. }]);
  2325. if (this.objectInfo.type !== 'jupyterNotebook') {
  2326. items.push({
  2327. 'type': 'CollapsibleSection',
  2328. 'name': 'options',
  2329. 'open': true,
  2330. 'label': this.objectInfo.type === 'jobDefinition' ? StringResource.get('job') : StringResource.get('report'),
  2331. 'items': optionsItems
  2332. });
  2333. }
  2334. var parameters = ContentStoreObject.getDetailsReportVersionParameters(this.detailsInfo);
  2335. if (parameters) {
  2336. items = items.concat([{
  2337. 'type': 'CollapsibleSection',
  2338. 'name': 'promptValues',
  2339. 'label': StringResource.get('promptValues'),
  2340. 'items': this._getPromptValuesItems(parameters)
  2341. }]);
  2342. }
  2343. deferred.resolve(items);
  2344. }.bind(this));
  2345. return deferred.promise;
  2346. },
  2347. _getMessageItems: function() {
  2348. var items = [];
  2349. var msgIconClass = 'versionMessageIcon ';
  2350. var svgIcon = '';
  2351. ContentStoreObject.getMessages(this.detailsInfo).forEach(function(msg, counter) {
  2352. var severity = ContentStoreObject.getMessageSeverity(msg);
  2353. var iconClass = '';
  2354. switch (severity) {
  2355. case 'error':
  2356. case 'fatal':
  2357. iconClass = msgIconClass + 'versionErrorIcon';
  2358. svgIcon = 'common-close-cancel-error';
  2359. break;
  2360. case 'warn':
  2361. iconClass = msgIconClass + 'versionWarningIcon';
  2362. svgIcon = 'common-warning-hollow';
  2363. break;
  2364. case 'debug':
  2365. iconClass = msgIconClass + 'versionDebugIcon';
  2366. svgIcon = 'common-debug';
  2367. break;
  2368. case 'info':
  2369. iconClass = msgIconClass + 'versionInfoIcon';
  2370. svgIcon = 'common-information';
  2371. break;
  2372. }
  2373. items.push({
  2374. 'type': 'SingleLineLinks',
  2375. 'name': 'messages_' + counter,
  2376. 'items': [{
  2377. 'align': 'left',
  2378. 'items': [{
  2379. 'type': 'icon',
  2380. 'class': iconClass,
  2381. 'svgIcon': svgIcon,
  2382. 'value': StringResource.get(severity),
  2383. 'iconTooltip': StringResource.get(severity)
  2384. }, {
  2385. 'type': 'text',
  2386. 'class': 'wraptext textSelectable',
  2387. 'value': ContentStoreObject.getMessageDetail(msg)
  2388. }]
  2389. }]
  2390. });
  2391. });
  2392. return items;
  2393. },
  2394. _getOptionsItems: function() {
  2395. var options = ContentStoreObject.getDetailsReportVersionOptions(this.detailsInfo);
  2396. var deferred = Q.defer();
  2397. if (options) {
  2398. this._getReportLanguages(options).then(function(languages) {
  2399. // todo: of job type, don't push formats
  2400. var items = [];
  2401. if (this.objectInfo.type !== 'jobDefinition'){
  2402. items.push({
  2403. 'type': 'TextArea',
  2404. 'name': 'formats',
  2405. 'label': StringResource.get('formats'),
  2406. 'value': this._getReportFormats(options),
  2407. 'editable': false,
  2408. 'multiline': false
  2409. },{
  2410. 'type': 'Separator'
  2411. });
  2412. }
  2413. items.push({
  2414. 'type': 'TextArea',
  2415. 'name': 'languages',
  2416. 'label': StringResource.get('languages'),
  2417. 'value': languages,
  2418. 'editable': false,
  2419. 'multiline': false
  2420. });
  2421. var location = ContentStoreObject.getLocation(this.objectInfo);
  2422. if (location) {
  2423. items = items.concat([{
  2424. 'type': 'Separator'
  2425. }, {
  2426. 'type': 'SingleLineValue',
  2427. 'name': 'location',
  2428. 'label': StringResource.get('location'),
  2429. 'value': location
  2430. }]);
  2431. }
  2432. deferred.resolve(items);
  2433. }.bind(this));
  2434. } else {
  2435. deferred.resolve([{
  2436. 'type': 'SingleLineLinks',
  2437. 'items': [{
  2438. 'align': 'left',
  2439. 'items': [{
  2440. 'type': 'text',
  2441. 'class': 'wraptext',
  2442. 'value': StringResource.get('noReportOptionsAvailable')
  2443. }]
  2444. }]
  2445. }]);
  2446. }
  2447. return deferred.promise;
  2448. },
  2449. _getReportFormats: function(options) {
  2450. var formatsArray = this._getReportVersionOption(options, 'outputFormat');
  2451. var formatsLabelArray = [];
  2452. if (formatsArray) {
  2453. if (_.isArray(formatsArray)) {
  2454. formatsArray.forEach(function(format) {
  2455. formatsLabelArray.push(StringResource.get(format));
  2456. });
  2457. } else {
  2458. formatsLabelArray.push(StringResource.get(formatsArray));
  2459. }
  2460. return this._getDelimitedStringFromArray(formatsLabelArray);
  2461. } else {
  2462. return StringResource.get('unavailable');
  2463. }
  2464. },
  2465. _getReportLanguages: function(options) {
  2466. var localeArray = this._getReportVersionOption(options, 'outputLocale');
  2467. var deferred = Q.defer();
  2468. if (localeArray) {
  2469. GlassContextHelper.getContentLocales(this.glassContext).then(function(contentLocales) {
  2470. var languages = [];
  2471. // Make sure we have an object in case getContentLocales promise returns undefined
  2472. contentLocales = contentLocales || {};
  2473. localeArray.forEach(function(locale) {
  2474. languages.push(contentLocales[locale]);
  2475. });
  2476. deferred.resolve(this._getDelimitedStringFromArray(languages));
  2477. }.bind(this));
  2478. } else {
  2479. deferred.resolve(StringResource.get('unavailable'));
  2480. }
  2481. return deferred.promise;
  2482. },
  2483. _getDelimitedStringFromArray: function(array) {
  2484. if (array) {
  2485. return array.join(', ');
  2486. }
  2487. return null;
  2488. },
  2489. _getReportVersionOption: function(options, name) {
  2490. var grepResult = $.grep(options, function(e) {
  2491. return e.name === name;
  2492. });
  2493. return grepResult.length === 1 && grepResult[0].value ? grepResult[0].value : null;
  2494. },
  2495. _getPromptValuesItems: function(parameters) {
  2496. var items = [];
  2497. var promptValues = ContentStoreObject.getPromptsDisplayValues(parameters, true);
  2498. promptValues.forEach(function(prompt) {
  2499. items.push({
  2500. 'type': 'SingleLineLinks',
  2501. 'items': [{
  2502. 'align': 'left',
  2503. 'items': [{
  2504. 'type': 'text',
  2505. 'class': 'promptNameText textSelectable',
  2506. 'value': _.escape(prompt.name + ':')
  2507. }]
  2508. }]
  2509. }, {
  2510. 'type': 'SingleLineLinks',
  2511. 'items': [{
  2512. 'align': 'left',
  2513. 'items': [{
  2514. 'type': 'text',
  2515. 'class': 'wraptext textSelectable',
  2516. 'value': _.escape(prompt.display)
  2517. }]
  2518. }]
  2519. }, {
  2520. 'type': 'Separator'
  2521. });
  2522. });
  2523. return items;
  2524. },
  2525. _viewRunHistory: function() {
  2526. var options = [{
  2527. 'm_name': this.objectInfo.defaultName
  2528. }];
  2529. C10Utils.openC10Morphlet(C10Utils.morphletMap.viewHistory, this.objectInfo.type, this.historyInfo.id, options);
  2530. }
  2531. });
  2532. return VersionsDetailsView;
  2533. });
  2534. define("js/content_apps/versionBundle", function(){});