123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bacontentnav/common/ui/LanguagePickerView',['../../lib/@waca/baglass/js/baglass/app/ContentView',
- '../../utils/GlassContextHelper',
- '../../nls/StringResource',
- '../../lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'jquery',
- 'underscore'
- ],
- function(ContentView, GlassContextHelper, StringResource, PropertyUIControl, $, _) {
- 'use strict';
- var LanguagePickerView = ContentView.extend({
- /*
- * @options.glassContext
- * @options.closeCallback - callback function on close.
- * @options.supportedContentLocales - (optional) an array of supported content locales as returned by Glass
- * @options.enabledLanguages - array of strings containing previously enabled languages
- */
- init: function(options) {
- LanguagePickerView.inherited('init', this, arguments);
- _.extend(this, options);
- if (!this.glassContext) {
- throw 'glassContext is not specified';
- }
- this._modifiedValues = {};
- this._userContentLocale = GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale');
- if (!this.enabledLanguages || this.enabledLanguages.length === 0) {
- this.enabledLanguages = [this._userContentLocale];
- this._modifiedValues[this._userContentLocale] = true;
- }
- this.enabledLanguages.forEach(function(language) {
- this._modifiedValues[language] = true;
- }.bind(this));
- },
- render: function() {
- return this._getContentLocales()
- .then(this._doRender.bind(this));
- },
- _doRender: function(contentLocales) {
- var spec = this._getSpec(contentLocales, this.enabledLanguages);
- this._propertyUIControl = new PropertyUIControl({
- 'glassContext': this.glassContext,
- 'el': this.$el,
- 'closeCallback': this._onClose.bind(this),
- 'items': [{
- 'type': 'Banner',
- 'centerLabel': true,
- 'backButton': this.slideout.overlay,
- 'value': StringResource.get('languages')
- }].concat(spec)
- });
- return this._propertyUIControl.render();
- },
- _getContentLocales: function() {
- if (this.supportedContentLocales) {
- return Promise.resolve(this.supportedContentLocales);
- }
- return GlassContextHelper.getContentLocales(this.glassContext).then(
- function(contentLocales) {
- this.supportedContentLocales = contentLocales;
- return this.supportedContentLocales;
- }.bind(this));
- },
- _getSpec: function(contentLocales, selectedLocales) {
- var itemsList = [];
- for (var key in contentLocales) {
- if (contentLocales.hasOwnProperty(key)) {
- itemsList.push({
- 'type': 'CheckBox',
- 'name': key,
- 'label': contentLocales[key],
- 'value': key,
- 'controlOnLeft': true,
- 'checked': (selectedLocales.indexOf(key) !== -1),
- 'onChange': this._onChange.bind(this)
- });
- }
- }
- return itemsList;
- },
- setFocus: function() {
- var currentItem = _.find(this._propertyUIControl.items, function(item) {
- return this.enabledLanguages.indexOf(item.name) !== -1;
- }.bind(this));
- if (currentItem !== null) {
- this._propertyUIControl.setFocus(currentItem.name);
- }
- },
- _onChange: function(name, value) {
- this._modifiedValues[name] = value;
- },
- _onClose: function() {
- this.slideout.hide();
- if (this.closeCallback) {
- this.closeCallback(this.getLanguages());
- }
- },
- getLanguages: function() {
- /*
- * Returns languages selected. If none is selected, it will return the value
- * as set in user preferences.
- */
- var languages = [];
- for (var key in this._modifiedValues) {
- if (this._modifiedValues.hasOwnProperty(key) && this._modifiedValues[key]) {
- languages.push(key);
- }
- }
- return languages;
- },
- //needed if view is rendered by PropertyUIControl
- getModifiedProperties: function() {
- return {
- 'languages': this.getLanguages()
- };
- },
- remove: function() {
- this._onClose();
- }
- });
- return LanguagePickerView;
- });
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Content Explorer
- * (C) Copyright IBM Corp. 2015, 2018
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define('bi/content_apps/ui/CA_DateTimePicker',[
- 'bi/commons/ui/widgets/DatePicker',
- 'bi/commons/ui/widgets/TimePicker',
- 'bi/commons/utils/DateTimeUtils',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/BaseProperty',
- 'bacontentnav/utils/GlassContextHelper',
- 'bacontentnav/utils/UIHelper',
- 'underscore'
- ],
- function(DatePicker, TimePicker, DateTimeUtils, BaseProperty, GlassContextHelper, UIHelper, _) {
- 'use strict';
- //Implements the interface for use with PropertyUIControl
- var CA_DatePicker = BaseProperty.extend({
- init: function(options) {
- BaseProperty.inherited('init', this, arguments);
- _.extend(this, options);
- this._time = {};
- },
- doRender: function() {
- this._container = $('<div>', {
- 'class': 'ca_timeDatePickerContainer'
- });
- var $dateContainer = $('<div/>');
- this._container.append($dateContainer);
- this.$el.append(this._container);
- var options = {
- 'attributes': {
- 'firstDay': 1
- },
- 'drawNoEndDate': false,
- '$el': $dateContainer,
- 'timezone': GlassContextHelper.getUserPreference(this.glassContext, 'timeZoneID'),
- 'locale': GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale')
- };
- this._datePicker = new DatePicker(options);
- return this._datePicker.render().then(function() {
- var date = new Date();
- this._datePicker.setDateFormat('yy-mm-dd');
- this._datePicker.setDate(date);
- var $timeContainer = $('<div/>');
- this._container.append($timeContainer);
- this._timePicker = new TimePicker({
- '$el': $timeContainer,
- 'timezone': GlassContextHelper.getUserPreference(this.glassContext, 'timeZoneID'),
- 'attributes': {
- 'showMeridian': !DateTimeUtils.is24HrFormat(GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale'))
- }
- });
- this._timePicker.render();
- this._container.hide();
- }.bind(this));
- },
- getModifiedProperties: function() {
- this._time[this.name] = this._timePicker.getDateTimeUTC(this._datePicker.getDateObj());
- return this._time;
- },
- show: function() {
- this._container.slideDown(UIHelper.SLIDE_DURATION);
- },
- hide: function() {
- this._container.slideUp(UIHelper.SLIDE_DURATION);
- }
- });
- return CA_DatePicker;
- });
- /**
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: content-apps
- *
- * Copyright IBM Corp. 2016, 2018
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define('bi/content_apps/ui/CA_DeliveryPickerView',[
- 'bi/schedule/views/DeliveryPickerView',
- 'bi/content_apps/nls/StringResource',
- 'bi/schedule/views/OptionsSlideoutView'
- ],
- function(DeliveryPickerView, StringResource, OptionsSlideoutView) {
- 'use strict';
- /*
- * @options.closeCallback - callback to call on view close. It returns the delivery options. {delivery : <delivery options>}
- */
- var CA_DeliveryPickerView = OptionsSlideoutView.extend({
- init: function(options) {
- options.title = StringResource.get('delivery');
- CA_DeliveryPickerView.inherited('init', this, arguments);
- },
- render: function() {
- this._renderContent();
- return CA_DeliveryPickerView.inherited('render', this, arguments);
- },
- shouldShowMobile: function() {
- var mobileTypes = ['interactiveReport', 'report', 'query', 'analysis'];
- return ((mobileTypes.indexOf(this.objectInformation.type) !== -1) || ((this.objectInformation.type === 'reportView') && (mobileTypes.indexOf(this.objectInformation.base[0].type) !== -1)));
- },
- _renderContent: function() {
- if (this.content) {
- return;
- }
- var deliveryPickerViewOptions = {
- 'reportName': this.objectInformation.defaultName,
- 'showMobile': this.shouldShowMobile(),
- 'enableAdvancedSettings': true,
- 'glassContext': this.glassContext,
- 'deliveryOptions': this.deliveryOptions || {},
- '$toggler': $('<div></div>'),
- 'slideout': this.slideout,
- 'hasPermission': this.objectInformation.permissions,
- 'rawOptions': this.objectInformation.rawOptions
- };
- this._deliveryPickerView = new DeliveryPickerView(deliveryPickerViewOptions);
- this._deliveryPickerView.render();
- var deliveryContent = this._deliveryPickerView.getDeliveryContent(!this.burstSelected);
- this.content = $(deliveryContent);
- },
- _close: function() {
- this.remove();
- // Close off this pane
- this.slideout.hide({
- hideOnly: true
- });
- },
- remove: function() {
- if (this.closeCallback && typeof this.closeCallback === 'function') {
- this.closeCallback(this._deliveryPickerView.getDeliveryOptions());
- }
- },
- //Called by OptionsSlideoutView
- setUpCallback: function(content) {
- this._deliveryPickerView.setDeliveryOptions(content, null);
- }
- });
- return CA_DeliveryPickerView;
- });
- 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';});
- /**
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: SHARE
- *
- * Copyright IBM Corp. 2017, 2018
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define('bi/content_apps/ui/PowerPlayPromptPickerView',[
- 'bi/schedule/views/PromptPickerView',
- 'jquery',
- 'q',
- 'doT',
- 'text!bi/content_apps/ui/templates/PowerPlayPromptPickerView.html'
- ],
- function(PromptPickerView, $, Q, dot, viewTemplate) {
- var view = PromptPickerView.extend({
- /** Allows for selecting parameter values for a particular report.
- * Uses the old UI. Parameters:
- * $el: Location where this View will display selected parameter values,
- * in the "name: value" format.
- * $toggler: link/button that launches the 'prompting dance'
- * reportId: the report to prompt for
- * values: Initial values to display. Not used to select the defaults in the prompting dance
- * glassContext: the glassContext
- */
- init: function(options) {
- void(options);
- view.inherited('init', this, arguments);
- },
- _updateForSubmit: function($iFrame) {
- $iFrame.find('.prompt-iframe').contents().find('form[name="ppForm"]').submit();
- },
- showPromptOverlay: function() {
- var deferred = Q.defer();
- var $iFrame = $('<div class=\'prompt-overlay\'><iframe title=\'{{=it.prompt_title}}\' class=\'prompt-iframe\'></iframe></div>');
- var htmlGenerator = dot.simpleTemplate(viewTemplate);
- var attributes = {
- reportId: this.reportId,
- backgroundTime: 'now'
- };
- if (this.ca_deliveryOptions) {
- attributes.ca_deliveryOptions = this.ca_deliveryOptions;
- attributes.emailRecipients = this.deliveryOptions.email.to.length + this.deliveryOptions.email.bcc.length + this.deliveryOptions.email.cc.length;
- attributes.emailAsAttachment = this.deliveryOptions.email.emailAsAttachment === true;
- attributes.emailAsURL = this.deliveryOptions.email.emailAsURL === true;
- if (this.deliveryOptions.print) {
- attributes.printer = this.deliveryOptions.print.name;
- }
- }
- if (this.languageOptions) {
- attributes.languageOptions = this.languageOptions;
- }
- if (this.executionTime) {
- var etArray = this.executionTime.split('T');
- attributes.executionDate = etArray[0];
- var timeArray = etArray[1].split('-');
- var dispArray = timeArray[0].split(':');
- attributes.displayHours = dispArray[0];
- attributes.displayMinutes = dispArray[1];
- attributes.executionTime = attributes.displayHours + ':' + attributes.displayMinutes + ':00.000';
- attributes.amPM = parseInt(attributes.displayHours) > 12 ? 'PM' : 'AM';
- attributes.backgroundTime = 'later';
- }
- $('body').append($iFrame);
- if (this.openInTab) {
- attributes.runNow = true;
- } else {
- attributes.runBackground = true;
- }
- $iFrame.find('.prompt-iframe').contents().find('html').html(htmlGenerator(attributes));
- if (this.openInTab) {
- $($iFrame.find('.prompt-iframe').contents().find('form[name="ppForm"]')).attr('target', '_blank');
- } else {
- window.ccModalCallBack = function() {
- delete window.ccModalCallBack;
- $iFrame.remove();
- };
- }
- this._updateForSubmit($iFrame);
- this.$promptOverlay = $('body').find('.prompt-overlay');
- if (this.openInTab) {
- $iFrame.remove();
- }
- deferred.resolve();
- return deferred.promise;
- }
- });
- return view;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2019
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/RunAsOptionsView',[
- 'underscore',
- 'bi/glass/app/ContentView',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'bi/commons/ui/Button',
- 'bacontentnav/utils/GlassContextHelper',
- 'bi/schedule/views/PromptPickerView',
- 'bacontentnav/common/ui/LanguagePickerView',
- 'bi/content_apps/ui/CA_DateTimePicker',
- 'bi/content_apps/ui/CA_DeliveryPickerView',
- 'bi/content_apps/PdfOptionsView',
- 'bi/content_apps/ui/PowerPlayPromptPickerView',
- 'bi/content_apps/utils/C10Utils',
- 'bacontentnav/utils/UIHelper',
- 'bi/content_apps/authoring/AuthoringHelper'
- ], function(_, ContentView, PropertyUIControl, StringResource, ContentStoreObject, UIButton, GlassContextHelper, PromptPickerView, LanguagePickerView, CA_DateTimePicker, CA_DeliveryPickerView, PdfOptionsView, PowerPlayPromptPickerView, C10Utils, UIHelper, AuthoringHelper) {
- 'use strict';
- var RunAsOptionsView = ContentView.extend({
- _getReportOutputFormat: function(options) {
- var selectedFormat = ContentStoreObject.getOption(options, ContentStoreObject.OPTION_OUTPUT_FORMAT);
- if (!AuthoringHelper.userCanGenerateFormat(this.glassContext, selectedFormat)){
- selectedFormat = 'HTML';
- }
- return selectedFormat;
- },
- init: function(options) {
- RunAsOptionsView.inherited('init', this, arguments);
- _.extend(this, options);
- this._userPermissions = options.objectInformation.permissions;
- this._supportedFormats = AuthoringHelper.getSupportedFormats(this.objectInformation);
- this._userContentLocale = GlassContextHelper.getUserPreference(this.glassContext, 'contentLocale');
- this._userFormat = GlassContextHelper.getUserPreference(this.glassContext, 'format');
- this._outputFormat = this._getReportOutputFormat(options.objectInformation) ? this._getReportOutputFormat(options.objectInformation) : this._userFormat;
- this._selections = {};
- this._selections.formats = {};
- this._selections.formats[this._outputFormat] = true;
- this._requestParams = {};
- this._requestParams.options = {};
- AuthoringHelper.setReportType(this._requestParams, this.objectInformation);
- this._appController = this.glassContext.appController;
- this._promptValue = ContentStoreObject.getExecutionPrompt(this.objectInformation);
- },
- setFocus: function() {
- this.$el.find('button.primary').focus();
- },
- render: function() {
- this.$el.addClass('runAsOptionsView');
- var userHasPermission = _.contains(this._userPermissions, 'write') || _.contains(this._userPermissions, 'execute');
- var runAsItems = this._getRunAsItemsSpec(userHasPermission);
- var itemsSpec = _.compact(runAsItems);
- this._runOptionsControl = new PropertyUIControl({
- 'el': this.$el,
- 'items': itemsSpec,
- 'glassContext': this.glassContext,
- 'readOnly': !UIHelper.isValid(this.objectInformation)
- });
- return this._runOptionsControl.render().then(function() {
- this._runInBackgroundOptionsControl = this._runOptionsControl.getProperty('runInBackgroundOptions');
- this._runAsOptionsControl = this._runOptionsControl.getProperty('runAsOptions');
- // note: this is temporary (hopefully) - adding a wart to launch legacy UI for missing functionality in C11
- var $classicLink = $('<a style="padding-left:10px;cursor:pointer;">' + StringResource.get('classicView') + '</a>');
- $classicLink.on('primaryaction', function() {
- var morphletName = this.objectInformation.type === 'jobDefinition' ? 'portal/runWithOptions/jobDefinition.xts' : 'portal/runWithOptions/report.xts';
- C10Utils.openC10Morphlet(morphletName, this.objectInformation.type, this.objectInformation.id,[
- { m_name: this.objectInformation.defaultName }
- ]);
- }.bind(this));
- // can this be done a better way?
- var $parentEl = $(this.$el.find('.l_delivery').parent().parent());
- $parentEl.append($classicLink);
- if (!UIHelper.isValid(this.objectInformation)) {
- var footer = this._runOptionsControl.getProperty('runAsFooter');
- if (footer) {
- var okButton = footer.getProperty('okButton');
- if (okButton) {
- okButton.disable();
- }
- }
- }
- }.bind(this));
- },
- _getRunAsItemsSpec: function(userHasPermission) {
- return [
- this._getBannerSpec(),
- this._getSeparatorSpec(),
- userHasPermission && this._getRunInBackgroundToggleSpec(),
- this._getSeparatorSpec(),
- this._getRunInBackgroundOptionsSpec(),
- this._getRunAsOptionsSpec(),
- this._getFooterSpec()
- ];
- },
- _getFooterSpec: function() {
- return {
- 'type': 'Footer',
- 'name': 'runAsFooter',
- 'items': [{
- 'type': 'Button',
- 'name': 'okButton',
- 'label': StringResource.get('run'),
- 'onSelect': this._onRun.bind(this),
- 'primary': true
- }]
- };
- },
- _getBannerSpec: function() {
- return {
- 'type': 'Banner',
- 'name': 'runAsBanner',
- 'value': StringResource.get('runAs'),
- 'editable': false
- };
- },
- _renderButtons: function() {
- var buttonRow = $('<div>', {
- 'class': 'buttonRow'
- });
- this.$el.append(buttonRow);
- var runButton = new UIButton({
- 'buttonSpec': {
- 'label': StringResource.get('run'),
- 'onSelect': this._onRun.bind(this)
- }
- });
- runButton.render();
- buttonRow.append(runButton.$el);
- return Promise.resolve(true);
- },
- _getSeparatorSpec: function() {
- return {
- 'type': 'Separator'
- };
- },
- _getRunInBackgroundToggleSpec: function() {
- return {
- 'name': RunAsOptionsView.OPTION.RUN_IN_BG,
- 'checked': false,
- 'label': StringResource.get('runInBackgroundOption'),
- 'type': 'ToggleButton',
- 'onChange': this._toggleOptionsControl.bind(this)
- };
- },
- _toggleOptionsControl: function() {
- this._runInBackgroundOptionsControl.toggleCollapsibleSection();
- this._runAsOptionsControl.toggleCollapsibleSection();
- this._copySelectionForRunInBackgroundToggle();
- this._copyPromptForValuesOnRunInBackgroundChange();
- },
- _copyPromptForValuesOnRunInBackgroundChange: function() {
- var modifiedProperties = this._runOptionsControl.getModifiedProperties();
- var isRunInBackgroundChecked = modifiedProperties[RunAsOptionsView.OPTION.RUN_IN_BG];
- // get promptForValues checkbox control for both RunAs and RunInBackground
- var runAsPromptControl = this._runAsOptionsControl.getProperty(RunAsOptionsView.OPTION.PROMPT);
- var runInBackgroundPromptControl = this._runInBackgroundOptionsControl.getProperty(RunAsOptionsView.OPTION.PROMPT);
- // get prompt control to update, depending on how RunInBackground is toggled
- var prompControlToUpdate = isRunInBackgroundChecked ? runInBackgroundPromptControl : runAsPromptControl;
- var isPromptForValuesChecked = isRunInBackgroundChecked ? runAsPromptControl['checked'] : runInBackgroundPromptControl['checked'];
- // Propagate promptForValues to foreground run options control
- if (isPromptForValuesChecked) {
- if (!prompControlToUpdate.checked) prompControlToUpdate.check();
- } else {
- if (prompControlToUpdate.checked) prompControlToUpdate.uncheck();
- }
- },
- _copySelectionForRunInBackgroundToggle: function() {
- var noOfFormats = this._supportedFormats.length;
- if (noOfFormats === 1) {
- return;
- }
- var modifiedProperties = this._runOptionsControl.getModifiedProperties();
- if (modifiedProperties[RunAsOptionsView.OPTION.RUN_IN_BG]) {
- $.each(this._supportedFormats, function(i, format) {
- if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
- this._runOptionsControl.getProperty(format).uncheck();
- }
- }.bind(this));
- this._runOptionsControl.getProperty(modifiedProperties[RunAsOptionsView.OPTION.RUNFORMAT] || this._outputFormat).check();
- } else {
- var selectedFormat = null;
- // Loop through _supportedFormats to select the first supported format in order.
- $.each(this._supportedFormats, function(i, format) {
- if (modifiedProperties[format]) {
- selectedFormat = format;
- return false;
- }
- }.bind(this));
- this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.RUNFORMAT).setValue(selectedFormat || this._outputFormat);
- }
- },
- _getRunInBackgroundOptionsSpec: function() {
- return {
- 'type': 'CollapsibleSection',
- 'name': 'runInBackgroundOptions',
- 'hideSectionTitle': true,
- 'items': this._getRunInBackgroundFormatsSpec().concat(
- this._getSeparatorSpec(),
- this._getPromptForValuesOptionSpec(),
- this._getPromptGenerationHintText(this._promptValue),
- this._getAdvancedSectionSpec()
- )
- };
- },
- _getRunAsOptionsSpec: function() {
- return {
- 'type': 'CollapsibleSection',
- 'name': 'runAsOptions',
- 'hideSectionTitle': true,
- 'items': [this._getRunAsFormatsSpec(),
- this._getSeparatorSpec(),
- this._getPromptForValuesOptionSpec(),
- this._getSeparatorSpec()
- ],
- 'open': true
- };
- },
- _getRunInBackgroundFormatsSpec: function() {
- var noOfFormats = this._supportedFormats.length;
- if (noOfFormats === 1) {
- return [this._getSingleFormatSpec(this._supportedFormats[0])];
- }
- var itemsSpec = [];
- this._supportedFormats.forEach(function(format) {
- if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
- itemsSpec.push({
- 'type': 'CheckBox',
- 'name': format,
- 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
- 'value': format,
- 'controlOnLeft': true,
- 'checked': this._outputFormat === format,
- 'onChange': this._updateSelectedFormat.bind(this)
- });
- }
- }.bind(this));
- return [{
- 'type': 'CollapsibleSection',
- 'hideSectionTitle': true,
- 'open': true,
- 'name': RunAsOptionsView.OPTION.OUTPUTFORMAT,
- 'ariaLabel': StringResource.get('formatOptions'),
- 'items': itemsSpec
- }];
- },
- _getRunAsFormatsSpec: function() {
- var noOfFormats = this._supportedFormats.length;
- if (noOfFormats === 1) {
- return this._getSingleFormatSpec(this._supportedFormats[0]);
- }
- var itemsSpec = [];
- this._supportedFormats.forEach(function(format) {
- if (AuthoringHelper.userCanGenerateFormat(this.glassContext, format)) {
- itemsSpec.push({
- 'name': format,
- 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
- 'value': format
- });
- }
- }.bind(this));
- return ({
- 'type': 'RadioButtonGroup',
- 'ariaLabel': StringResource.get('formatOptions'),
- 'name': RunAsOptionsView.OPTION.RUNFORMAT,
- 'value': this._outputFormat,
- 'controlOnLeft': true,
- 'separator': false,
- 'items': itemsSpec
- });
- },
- _getSingleFormatSpec: function(format) {
- return {
- 'type': 'SingleLineValue',
- 'name': format,
- 'label': StringResource.get(format),
- 'value': ''
- };
- },
- _getPromptForValuesOptionSpec: function() {
- return {
- 'type': 'CheckBox',
- 'name': RunAsOptionsView.OPTION.PROMPT,
- 'label': StringResource.get('promptForValues'),
- 'controlOnLeft': true,
- 'checked': ContentStoreObject.getExecutionPrompt(this.objectInformation),
- 'onChange': this._togglePromptValue.bind(this)
- };
- },
- _getPromptGenerationHintText: function(isPromptMeChecked) {
- return {
- 'type' : 'HintText',
- 'name' : 'promptGenerationHintText',
- 'label' : StringResource.get('promptGenerationHint'),
- 'visibility' : this._getCssVisibility(isPromptMeChecked)
- };
- },
- _togglePromptValue: function(controlName, value) {
- // Check actual value of control instead of negating previous value to avoid falling out of sync with Prompt checkbox
- this._promptValue = value;
- this._showHidePromptGenerationHintText(this._promptValue);
- },
- _showHidePromptGenerationHintText: function(isPromptMeChecked) {
- // Set hintText visibility
- var visibility = this._getCssVisibility(isPromptMeChecked);
- var hintText = this._runOptionsControl.getProperty('promptGenerationHintText');
- hintText.visibility = visibility;
- // Directly write visibility to element class to ensure it is always shown/hidden immediately when RunInBackground is toggled
- this.$el.find('.l_promptGenerationHintText').css('visibility', visibility);
- },
- _getCssVisibility: function(isVisible) {
- return isVisible ? 'visible' : 'hidden';
- },
- _getAdvancedSectionSpec: function() {
- var itemsSpec = [
- this._getRunNowOrLaterOptions(),
- this._getExecutionTimePicker(),
- this._getBurstOptionSpec(),
- this._getPDFOptionsSpec(),
- this._getLanguagesOptionSpec(),
- this._getDeliveryOptionsSpec()
- ];
- //some functions can return undefined so filter it out.
- var filteredItems = itemsSpec.filter(function(item) {
- return !!item;
- });
- return {
- 'type': 'CollapsibleSection',
- 'name': 'advancedProperties',
- 'label': StringResource.get('advancedProperties'),
- 'items': filteredItems
- };
- },
- _getRunNowOrLaterOptions: function() {
- return {
- 'type': 'HorizontalRadioButtonGroup',
- 'name': RunAsOptionsView.OPTION.RUN_NOW_OR_LATER,
- 'value': 'now',
- 'controlOnLeft': true,
- 'ariaLabel': StringResource.get('nowOrLaterRadioOptions'),
- 'onChange': this._toggleDatetimePicker.bind(this),
- 'items': [{
- 'name': RunAsOptionsView.OPTION.RUN_NOW,
- 'value': RunAsOptionsView.OPTION.RUN_NOW,
- 'label': StringResource.get('now')
- }, {
- 'label': StringResource.get('later'),
- 'name': RunAsOptionsView.OPTION.RUN_LATER,
- 'value': RunAsOptionsView.OPTION.RUN_LATER
- }]
- };
- },
- _toggleDatetimePicker: function(name, value) {
- if (this._lastRunNowOrLaterOption === value) {
- return;
- }
- //a different option is selected
- if (!this._datetimePicker) {
- this._datetimePicker = this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.EXECUTIONTIME);
- }
- if (value === RunAsOptionsView.OPTION.RUN_LATER) {
- this._datetimePicker.show();
- } else {
- this._datetimePicker.hide();
- }
- this._lastRunNowOrLaterOption = value;
- },
- _getExecutionTimePicker: function() {
- return {
- 'module': CA_DateTimePicker,
- 'name': RunAsOptionsView.OPTION.EXECUTIONTIME,
- 'glassContext': this.glassContext
- };
- },
- _getBurstOptionSpec: function() {
- if (ContentStoreObject.canBurst(this.objectInformation) && this.glassContext.hasCapability('canUseBursting')) {
- return {
- 'type': 'CheckBox',
- 'name': RunAsOptionsView.OPTION.BURST,
- 'label': StringResource.get('burst'),
- 'value': RunAsOptionsView.OPTION.BURST,
- 'onChange': this._updateBurstSelected.bind(this)
- };
- }
- },
- _getPDFOptionsSpec: function() {
- if (this._supportedFormats.length === 1 || !AuthoringHelper.userCanGenerateFormat(this.glassContext, 'PDF')) {
- return;
- }
- return {
- 'type': 'SingleLineValue',
- 'name': RunAsOptionsView.OPTION.ADVANCED_PDF,
- 'label': StringResource.get('pdf'),
- 'editCallback': this._showMoreOptionsPane.bind(this, this._getMorePDFOptionsSpec.bind(this)),
- 'hidden': true
- };
- },
- _getLanguagesOptionSpec: function() {
- return {
- 'type': 'SingleLineValue',
- 'name': RunAsOptionsView.OPTION.LANGUAGES,
- 'label': StringResource.get('languages'),
- 'editCallback': this._showMoreOptionsPane.bind(this, this._getMoreLanguageOptionsSpec.bind(this))
- };
- },
- _getDeliveryOptionsSpec: function() {
- return {
- 'type': 'SingleLineValue',
- 'name': RunAsOptionsView.OPTION.DELIVERY,
- 'label': StringResource.get('delivery'),
- 'editCallback': this._showMoreOptionsPane.bind(this, this._getMoreDeliveryOptionsSpec.bind(this))
- };
- },
- _showMoreOptionsPane: function(getContentSpecFunc) {
- if (typeof getContentSpecFunc !== 'function') {
- this.logger.debug('getContentSpecFunc is not a function');
- }
- var parentSlideout = this.slideout;
- getContentSpecFunc().then(function(spec) {
- this._slideout = this._appController.showSlideOut({
- 'position': 'left',
- 'parent': parentSlideout,
- 'width': '400',
- 'enableTabLooping': true,
- 'overlay': (spec.overlay === undefined) ? true : spec.overlay,
- 'content': spec.slideoutContent,
- 'label': spec.slideoutLabel
- });
- }.bind(this));
- },
- _getMoreDeliveryOptionsSpec: function() {
- var content = {
- 'module': CA_DeliveryPickerView,
- 'closeCallback': this._closeMoreDeliveryOptionsSlideout.bind(this),
- 'objectInformation': this.objectInformation,
- 'glassContext': this.glassContext,
- 'deliveryOptions': this._selections.delivery,
- 'burstSelected': this._selections[RunAsOptionsView.OPTION.BURST] ? true : false
- };
- var spec = {
- 'overlay': true,
- 'slideoutContent': content,
- 'slideoutLabel': StringResource.get('delivery')
- };
- return Promise.resolve(spec);
- },
- _getMoreLanguageOptionsSpec: function() {
- var content = {
- 'module': 'bi/content_apps/common/ui/LanguagePickerView',
- 'closeCallback': this._closeMoreLanguageOptionsSlideout.bind(this)
- };
- if (this._selections.languages) {
- content.enabledLanguages = this._selections.languages;
- }
- var spec = {
- 'slideoutContent': content,
- 'slideoutLabel': StringResource.get('languages')
- };
- return Promise.resolve(spec);
- },
- _closeMoreLanguageOptionsSlideout: function(selectedLanguages) {
- this._selections.languages = selectedLanguages;
- },
- _closeMoreDeliveryOptionsSlideout: function(selectedOptions) {
- this._selections.delivery = selectedOptions;
- },
- // Getting default values from report properties or previous selections
- _getDefaultPDFOptionValues: function() {
- if (this._selections.pdf) {
- return Promise.resolve({
- 'pdfOptions': this._selections.pdf
- });
- }
- if (this._defaultPDFOptionsValues) {
- return Promise.resolve(this._defaultPDFOptionsValues);
- }
- var options = {
- dataType: 'json',
- type: 'GET',
- url: ContentStoreObject.getSelfLink(this.objectInformation) + '?fields=options'
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(function(jsonResponse) {
- var options = jsonResponse.data.data[0].options;
- if (!options) {
- return;
- }
- var defaultPDFOptions = options.filter(function(option) {
- return (RunAsOptionsView.PDF_OPTIONS.indexOf(option.name) !== -1);
- });
- this._defaultPDFOptionsValues = {
- 'pdfOptions': defaultPDFOptions
- };
- return this._defaultPDFOptionsValues;
- }.bind(this)).catch(this._handleRunError.bind(this));
- },
- _getMorePDFOptionsSpec: function() {
- var content = {
- 'module': PdfOptionsView,
- 'closeCallback': this._closeMorePDFOptionsSlideout.bind(this)
- };
- return this._getDefaultPDFOptionValues()
- .then(function(pdfOptions) {
- if (pdfOptions) {
- _.extend(content, pdfOptions);
- }
- var spec = {
- 'slideoutContent': content,
- 'slideoutLabel': StringResource.get('pdfOptions')
- };
- return spec;
- });
- },
- _closeMorePDFOptionsSlideout: function(pdfOptions) {
- this._selections.pdf = pdfOptions;
- },
- _onRun: function() {
- _.extend(this._selections, this._runOptionsControl.getModifiedProperties());
- this.logger.debug('RunAsOptionsView._onRun', this._selections);
- if (this._selections[RunAsOptionsView.OPTION.RUN_IN_BG]) {
- this._doRunInBackground();
- } else {
- this._doRunAs();
- }
- },
- _doRunAs: function() {
- this._appController.performAction(this._getActionId(), this._buildPayload());
- this._appController.hideSlideOut();
- },
- _getSelectedFormats: function(bRunInBackgroud) {
- var selectedFormats;
- if (bRunInBackgroud) {
- //returns an array
- if (this._supportedFormats.length === 1) {
- // Use the one and only supported format
- selectedFormats = this._supportedFormats;
- } else {
- var formats = [];
- for (var key in this._selections.formats) {
- if (this._selections.formats.hasOwnProperty(key) &&
- this._selections.formats[key]) {
- formats.push(key);
- }
- }
- selectedFormats = formats;
- }
- } else {
- // returns a string
- if (this._supportedFormats.length === 1) {
- selectedFormats = this._supportedFormats[0];
- } else {
- selectedFormats = this._selections[RunAsOptionsView.OPTION.RUNFORMAT] || this._outputFormat;
- }
- }
- return selectedFormats;
- },
- _updateBurstSelected: function(name, bValue) {
- this._selections[RunAsOptionsView.OPTION.BURST] = bValue;
- },
- _updateSelectedFormat: function(name, value) {
- this._selections.formats[name] = value;
- if (name === 'PDF' && AuthoringHelper.userCanGenerateFormat(this.glassContext, name)) {
- var pdfSection = this._runOptionsControl.getProperty(RunAsOptionsView.OPTION.ADVANCED_PDF);
- if (value) {
- pdfSection.show();
- } else {
- pdfSection.hide();
- }
- }
- },
- _setOutputLocaleRequestParams: function() {
- if (this._selections.languages) {
- // setting outputLocale will explicitly override the report language
- this._requestParams.options.outputLocale = this._selections.languages;
- }
- },
- _setDeliveryOptionsRequestParams: function() {
- if (this._selections.delivery) {
- this._requestParams.options.delivery = this._selections.delivery;
- } else {
- this._requestParams.options.delivery = {
- 'save': {
- 'notify': false
- }
- };
- }
- },
- _setOutputFormatRequestParams: function() {
- var selectedOutputFormats = this._getSelectedFormats(true /*bRunInBackgroud*/ );
- this._requestParams.options.outputFormat = selectedOutputFormats;
- },
- _setSaveToCloudRequestParams: function() {
- if (this._selections.delivery && (this._selections.delivery.cloudLocation) && (this._selections.delivery.cloudLocation !== '')) {
- this._requestParams.options.saveToCloud = this._selections.delivery.cloudLocation;
- if ((this._selections.delivery.cloudName) && (this._selections.delivery.cloudName !== '')) {
- this._requestParams.options.cloudName = this._selections.delivery.cloudName;
- }
- }
- },
- _setExecutionTimeRequestParams: function() {
- if (this._selections[RunAsOptionsView.OPTION.RUN_NOW_OR_LATER] === RunAsOptionsView.OPTION.RUN_LATER && this._selections.executionTime) {
- if (Date.now() < Date.parse(this._selections.executionTime)) {
- this._requestParams.executionTime = this._selections.executionTime;
- } else {
- GlassContextHelper.displayToast(this.glassContext, StringResource.get('invalidTime'));
- throw 'Invalid time selected';
- }
- }
- },
- _setBurstOptionRequestParams: function() {
- if (this._selections[RunAsOptionsView.OPTION.BURST]) {
- this._requestParams.options.burst = true;
- }
- },
- _setParametersRequestParams: function(parameters) {
- if (parameters) {
- this._requestParams.parameters = parameters;
- }
- },
- _setPDFOptionsRequestParams: function() {
- if (!this._selections || !this._selections.pdf) {
- return;
- }
- this._requestParams.options.pdf = {};
- this._selections.pdf.forEach(function(option) {
- var value = option.value;
- if ((option.name).indexOf('Password') !== -1 && option.value.length) {
- var xmlDoc = $.parseXML(option.value);
- var $pwd = $(xmlDoc).find('password');
- if ($pwd.text().length) {
- value = $pwd.text();
- }
- }
- if (value) {
- this._requestParams.options.pdf[option.name] = value;
- }
- }.bind(this));
- },
- _doRunInBackground: function() {
- if (!this._getSelectedFormats(true /*bRunInBackground*/ ).length) {
- GlassContextHelper.displayToast(this.glassContext,
- StringResource.get('selectAFormat'), {
- 'type': 'warning'
- });
- throw 'No format selected';
- }
- if (this._promptValue) {
- this._showPromptPicker();
- this._appController.hideSlideOut();
- return;
- }
- this._executeRequest();
- },
- _onPromptFinish: function() {
- this._executeRequest();
- },
- _updateRunOptionsForPowerPlayPrompt: function(options) {
- if (this._selections && this._selections.delivery && this._selections.delivery.email) {
- options.ca_deliveryOptions = C10Utils.getPowerPlayC10DeliveryOptions(this._selections.delivery.email);
- }
- },
- _showPromptPicker: function(openInTab) {
- var toggler = $('<div>', {
- 'class': 'ca_promptpicker'
- });
- var options = {
- 'reportId': this.objectInformation.id,
- 'glassContext': this.glassContext,
- 'onFinish': this._onPromptFinish.bind(this),
- '$toggler': toggler,
- 'deliveryOptions': this._selections.delivery,
- 'languageOptions': this._selections.languages
- };
- if (openInTab) {
- options.openInTab = true;
- }
- if (C10Utils.isPowerPlay(this.objectInformation.type)) {
- if (this._selections.runNowOrLater === 'later') {
- options.executionTime = this._selections.executionTime;
- }
- this._updateRunOptionsForPowerPlayPrompt(options);
- this._promptPickerControl = new PowerPlayPromptPickerView(options);
- } else {
- this._promptPickerControl = new PromptPickerView(options);
- }
- this._promptPickerControl.showPromptOverlay();
- },
- _getRequestParams: function() {
- return this._appController.hideSlideOut().then(function() {
- this._setOutputFormatRequestParams();
- this._setSaveToCloudRequestParams();
- this._setExecutionTimeRequestParams();
- this._setDeliveryOptionsRequestParams();
- this._setBurstOptionRequestParams();
- this._setPDFOptionsRequestParams();
- this._setOutputLocaleRequestParams();
- if (this._promptValue) {
- this._setParametersRequestParams(this._promptPickerControl.getParameterValues());
- }
- }.bind(this));
- },
- // if options is empty, don't bother send it in data
- _validRequestParamsOptions: function(){
- var options = this._requestParams.options;
- if( options == null ){
- return;
- }else{
- var content = [];
- for (var key in options) {
- if (options[key] != null) {
- content.push(options[key]);
- }
- }
- if(content.length === 0){
- delete this._requestParams.options;
- }
- }
- },
- _executeRequest: function() {
- this._getRequestParams().then(function() {
- this._validRequestParamsOptions();
- var jsonData = JSON.stringify(this._requestParams);
- var options = {
- 'headers': {
- 'Content-Type': 'application/vnd.ibm.bi.platform.execution+json; charset=UTF-8',
- 'Accept': 'application/json'
- },
- 'datatype': 'json',
- 'type': 'post',
- 'url': 'v1/reports/' + this.objectInformation.id + '/executions',
- 'data': jsonData
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .catch(this._handleRunError.bind(this));
- }.bind(this));
- },
- _handleRunError: function(err) {
- GlassContextHelper.showAjaxServiceError(this.glassContext, err);
- },
- _buildPayload: function() {
- return {
- 'glassContext': this.glassContext,
- 'target': {
- 'objectInformation': this.objectInformation,
- 'itemId': this._getActionId(),
- 'runOptions': {
- 'prompt': this._promptValue,
- 'format': this._getSelectedFormats()
- },
- 'activeObject': {
- 'oListControl': this.listControl,
- 'aSelectedContext': [this.objectInformation]
- }
- }
- };
- },
- _getActionId: function() {
- var actionId = RunAsOptionsView.ACTION_ID;
- if (this.objectInformation.type.indexOf('powerPlay8Report') !== -1) {
- actionId = 'com.ibm.bi.contentApps.defaultAction.' + this.objectInformation.type;
- }
- return actionId;
- }
- });
- RunAsOptionsView.ACTION_ID = 'com.ibm.bi.contentApps.action.runAs';
- RunAsOptionsView.SUPPORTED_FORMATS = {
- 'all': ['spreadsheetML', 'xlsxData', 'PDF', 'HTML', 'CSV', 'XML'],
- 'interactiveReport': ['HTML'],
- 'powerPlay8Report': ['PDF']
- };
- /* names used to access controls */
- RunAsOptionsView.OPTION = {
- PROMPT: 'promptForValues',
- RUNFORMAT: 'runFormat',
- OUTPUTFORMAT: 'outputFormat',
- DELIVERY: 'delivery',
- EXECUTIONTIME: 'executionTime',
- LANGUAGES: 'languages',
- RUN_IN_BG: 'runInBackgroundChecked',
- RUN_LATER: 'later',
- RUN_NOW: 'now',
- RUN_NOW_OR_LATER: 'runNowOrLater',
- BURST: 'burst',
- ADVANCED_PDF: 'advancedPDF'
- };
- RunAsOptionsView.PDF_OPTIONS = ['outputPageDefinition',
- 'outputPageOrientation',
- 'userPassword',
- 'ownerPassword',
- 'allowPrintQuality',
- 'allowModifications',
- 'allowAnnotations',
- 'allowFieldCompletion',
- 'allowAssembly',
- 'allowContentCopy',
- 'allowAccessibilitySupport'
- ];
- return RunAsOptionsView;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/common/ui/list_actions/ViewReportAction',[
- 'bacontentnav/common/ui/list_actions/ListAction',
- 'bacontentnav/utils/ContentStoreObject',
- 'bi/commons/utils/Downloader',
- 'underscore'
- ], function(ListAction, ContentStoreObject, Downloader, _) {
- 'use strict';
- var ViewReportAction = ListAction.extend({
- canExecute: function(options) {
- var selectedContext = options.target.activeObject.aSelectedContext;
- if (!selectedContext || selectedContext.length > 1) {
- return false;
- }
- return ContentStoreObject.hasPermissions(selectedContext[0], ['traverse', 'read']);
- },
- doAction: function(context) {
- var selectedObjects = context.target.activeObject.aSelectedContext;
- if (!selectedObjects || selectedObjects.length > 1) {
- return Promise.reject(new Error('No objects selected'));
- } else {
- var selectedObject = selectedObjects[0];
- return ContentStoreObject.getBaseObjectType(selectedObject).then(function(type) {
- if (!this._isSupportedType(type)) {
- return Promise.reject(new Error('Not supported type'));
- } else {
- var requestOptions = {
- url: ContentStoreObject.getSelfLink(selectedObject),
- type: 'GET',
- dataType: 'json',
- data: {
- 'fields': 'defaultOutputFormat'
- }
- };
- return context.glassContext.getCoreSvc('.Ajax').ajax(requestOptions)
- .then(function(response) {
- response = response && response.data;
- if (response.data[0].defaultOutputFormat) {
- var outputId = context.target.activeObject.outputId;
- var download = context.target.activeObject.download;
- var suffix = download ? '/content?download=true' : this._getSuffix(type);
- var outputHref;
- // If we're passed an output ID then we want to view a specific output and not simply the latest
- if (outputId) {
- outputHref = 'v1/disp/repository/sid/cm/oid/' + outputId + suffix;
- } else {
- outputHref = 'v1/disp/repository/sid/cm/rid/' + selectedObject.id + '/oid/default' + suffix;
- }
- if (download) {
- var downloader = this._getDownloader({
- url: outputHref,
- logger: context.glassContext.appController.logger
- });
- downloader.doDownload();
- } else {
- if (type.indexOf('powerPlay8Report') !== -1) {
- var name = ContentStoreObject.getName(selectedObject);
- outputHref = this._getPP8ReportViewerUrl(outputId, name);
- }
- this._openWindow(outputHref);
- }
- return Promise.resolve();
- } else {
- return Promise.reject(new Error('No saved output'));
- }
- }.bind(this));
- }
- }.bind(this));
- }
- },
- _getDownloader: function(options) {
- return new Downloader(options);
- },
- _openWindow: function(outputHref) {
- window.open(outputHref);
- },
- _getSuffix: function(type) {
- var suffix;
- switch (type) {
- case 'interactiveReport':
- suffix = '/content/mht/content';
- break;
- case 'powerPlay8Report':
- case 'powerPlay8ReportView':
- suffix = '/content?cv.id=_THIS_';
- break;
- default:
- suffix = '';
- break;
- }
- return suffix;
- },
- _isSupportedType: function(type) {
- var isSupported = false;
- switch (type) {
- case 'interactiveReport':
- case 'powerPlay8Report':
- case 'powerPlay8ReportView':
- isSupported = true;
- break;
- default:
- break;
- }
- return isSupported;
- },
- _getPP8ReportViewerUrl: function(outputId, name) {
- var url = 'v1/disp?b_action=cognosViewer&ui.action=view&ui.format=PDF&ui.object=storeID(%22' + outputId + '%22)&ui.name=' + _.escape(name);
- url = url + '&cv.header=false&ui.backURL=%2fcps4%2fportlets%2fcommon%2fclose.html';
- return url;
- }
- });
- return ViewReportAction;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *|
- *| IBM Cognos Products: content-apps
- *|
- *| (C) Copyright IBM Corp. 2015, 2021
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/VersionsTab',[
- 'require',
- 'jquery',
- 'bi/glass/app/ContentView',
- 'bi/commons/ui/Slideout',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/UIHelper',
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bacontentnav/utils/GlassContextHelper',
- 'bi/content_apps/common/ui/list_actions/ViewReportAction',
- 'bi/commons/ui/dialogs/ConfirmationDialog',
- 'bi/commons/utils/BidiUtil',
- 'underscore'
- ], function(localRequire, $, ContentView, Slideout, StringResource, UIHelper, ContentStoreObject, PropertyUIControl, GlassContextHelper, ViewReportAction, ConfirmationDialog, BidiUtil, _) {
- 'use strict';
- var _SUPPORTED_FORMATS = {
- 'PDF': true,
- 'HTML': true,
- 'CSV': true,
- 'spreadsheetML': true,
- 'xlsxData': true,
- 'XHTML': true,
- 'XLWA': true,
- 'XML': true,
- 'HTMLFragment': true
- };
- var _FORMAT_ICONSTRING = {
- 'xlsxdata':'common-excel_icon',
- 'spreadsheetml':'common-excel_icon',
- 'xlwa':'common-excel_icon',
- 'xhtml':'common-html_icon',
- 'html':'common-html_icon',
- 'csv':'common-csv_icon',
- 'pdf':'common-pdf_icon',
- 'xml':'common-xml_icon',
- 'default': 'common-savedoutput_report'
- };
- var VersionsTab = ContentView.extend({
- /**
- * @param options.el {node} - container dom node
- */
- init: function(options) {
- VersionsTab.inherited('init', this, arguments);
- _.extend(this, options);
- this.noBurstKey = 'secretIBMNoBurstKey';
- this.mockableViewInteractiveReportAction = ViewReportAction;
- this.batchSize = Math.floor((window.innerHeight) / 18);
- this.initialEndIndex = this.batchSize;
- this.renderIndex = this.batchSize;
- },
- render: function() {
- this._id = _.uniqueId('prop_');
- return this._queryHistoriesVersions().then(function(res) {
- if (!(res.historiesInfo || res.versionsInfo)) {
- UIHelper.renderInfoMessage(this.$el, StringResource.get('noVersions'));
- } else {
- this.$el.addClass('versionsTab');
- var mergedInfo = this._mergeVersionAndHistory(res.historiesInfo, res.versionsInfo);
- mergedInfo.sort(function(a, b) {
- a = new Date(ContentStoreObject.getRequestedTime(a));
- b = new Date(ContentStoreObject.getRequestedTime(b));
- return a > b ? -1 : a < b ? 1 : 0;
- });
- this.items = this._getItems(mergedInfo);
- if (this.initialEndIndex > this.items.length) {
- this.initialEndIndex = this.items.length;
- }
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'items': [{
- 'name': 'showAllHistory',
- 'label': StringResource.get('showAllHistory'),
- 'checked': false,
- 'type': 'CheckBox',
- 'onChange': this._showAllHistoryChange.bind(this)
- }, {
- 'type': 'Separator'
- }].concat(this.items.slice(0, this.initialEndIndex))
- });
- return this._oPropertyUIControl.render();
- }
- }.bind(this))
- .then(function() {
- this._showAllHistoryChange();
- // 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.
- this.batchSize *= 3;
- this._scrollNode = this.$el.find('.containerUIControl');
- $(this._scrollNode).on('scroll', this._onScroll.bind(this));
- }.bind(this));
- },
- /**
- * Render a batch of spec. items in [startIndex, endIndex)
- * @startIndex Start index in the spec. items list
- * @endIndex End index in the the spec. items list
- */
- _render: function(startIndex, endIndex) {
- this.renderIndex = endIndex;
- return this._oPropertyUIControl.renderItems(this.items.slice(startIndex, endIndex));
- },
- /**
- * Handle scroll event
- */
- _onScroll: function(event) {
- if (this._bScrollToBottom(event) === true) {
- if (this.renderIndex >= this.items.length) {
- return;
- }
- var endIndex = this.renderIndex + this.batchSize;
- if (endIndex < this.items.length) {
- return this._render(this.renderIndex, endIndex);
- } else {
- return this._render(this.renderIndex, this.items.length);
- }
- }
- },
- /**
- * @return true if scrolling to the bottom of current pane
- * false otherwise
- */
- _bScrollToBottom: function(event) {
- var $target = $(event.target);
- if ($target.scrollTop() + $target.innerHeight() >= ($target[0].scrollHeight - 20)) { // If we've scrolled to the bottom
- return true;
- }
- return false;
- },
- /**
- * @return object
- */
- _queryHistoriesVersions: function() {
- var aPromises = [];
- if (this.objectInfo) {
- aPromises.push(ContentStoreObject.getHistories(this.objectInfo, 'output'));
- aPromises.push(ContentStoreObject.getVersions(this.objectInfo, 'creationTime'));
- }
- return Promise.all(aPromises).then(function(results) {
- return {
- historiesInfo: results[0],
- versionsInfo: results[1]
- };
- });
- },
- _handleGetOutputsSuccess: function(data) {
- var outputs = data.data;
- var index = data.index;
- var outputsInfo = [];
- if (outputs) {
- outputs.forEach(function(output) {
- if (!_SUPPORTED_FORMATS[output.format]) {
- return;
- }
- var processedOutput = {
- 'id': ContentStoreObject.getObjectId(output),
- 'format': ContentStoreObject.getFormat(output),
- 'content': ContentStoreObject.getOutputContentLink(output),
- 'modificationTime': ContentStoreObject.getModificationTime(output, true, 'short')
- };
- if (processedOutput.format && processedOutput.content) {
- var burstKey = ContentStoreObject.getBurstKey(output);
- var locale = ContentStoreObject.getLocale(output);
- if (burstKey) {
- if (!outputsInfo[burstKey]) {
- outputsInfo[burstKey] = [];
- }
- if (!outputsInfo[burstKey][locale]) {
- outputsInfo[burstKey][locale] = [];
- }
- outputsInfo[burstKey][locale].push(processedOutput);
- } else {
- if (!outputsInfo[this.noBurstKey]) {
- outputsInfo[this.noBurstKey] = [];
- }
- if (!outputsInfo[this.noBurstKey][locale]) {
- outputsInfo[this.noBurstKey][locale] = [];
- }
- outputsInfo[this.noBurstKey][locale].push(processedOutput);
- }
- }
- }.bind(this));
- }
- return { outputsInfo: outputsInfo, index: index };
- },
- /**
- * @return array
- */
- _mergeVersionAndHistory: function(historiesInfo, versionsInfo) {
- historiesInfo = historiesInfo || [];
- versionsInfo = versionsInfo || [];
- $.each(versionsInfo, function(i, v) {
- var found = false;
- $.each(historiesInfo, function(i, h) {
- if (h.output && h.output.id === v.id) {
- found = true;
- return false;
- }
- });
- if (!found) {
- v[ContentStoreObject.REQUESTED_TIME] = ContentStoreObject.getCreationDate(v);
- delete v[ContentStoreObject.CREATION_TIME];
- v[ContentStoreObject.STATUS] = 'succeeded';
- historiesInfo.push(v);
- }
- });
- // Remove the history output which was kept in cache
- $.each(historiesInfo, function(i, h) {
- if (h.output && h.output.id) {
- var outputid = h.output.id;
- var found = false;
- $.each(versionsInfo, function(i, v) {
- if (v.id === outputid) {
- found = true;
- return false;
- }
- });
- if (!found) {
- h.output = null;
- }
- }
- });
- return historiesInfo;
- },
- _getItems: function(mergedInfo) {
- this.mergedInfo = mergedInfo;
- var items = [];
- this.mergedInfo.forEach(function(historyInfo, index) {
- var requestedTime = ContentStoreObject.getRequestedTime(historyInfo, true, 'medium');
- var succeeded = (ContentStoreObject.getStatus(historyInfo) === 'succeeded');
- var detailsLink = ContentStoreObject.getDetailsLink(this.mergedInfo[index]);
- var hasDetails = detailsLink !== null;
- var outputsLink = this._getOutputsLinkFromIndex(index);
- var hasOutput = outputsLink !== null;
- items.push({
- 'type': 'SingleLineLinks',
- 'name': index + '_versions',
- 'role': 'group',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'icon',
- 'class': succeeded ? 'versionReport' : 'versionStatusFailed',
- 'svgIcon': succeeded ? hasOutput ? 'common-savedoutput_report' : 'common-savedoutput_reporthistory' : 'common-failed',
- 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed'),
- 'iconTooltip': StringResource.get('report')
- }, {
- 'type': 'text',
- 'value': requestedTime,
- 'class': 'versionText' + (hasOutput ? '' : ' hasNoOutput'),
- 'clickCallback': hasOutput ? this._toggleOutputsSection.bind(this, index) : null
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'icon',
- 'class': 'versionDetailsLinks' + (hasDetails ? '' : ' disabled'),
- 'svgIcon': 'common-info-moreinfo',
- 'clickCallback': hasDetails ? this._openDetails.bind(this, index) : null,
- 'iconTooltip': StringResource.get('showDetails'),
- 'showRightArrow': true
- }]
- }]
- });
- items.push({
- 'type': 'CollapsibleSection',
- 'name': index + '_outputs',
- 'label': requestedTime,
- 'styleAsSimpleRow': true,
- 'hideSectionTitle': true,
- 'indent': 3.3,
- 'items': [],
- 'onOpenChange': this._openOutputsSection.bind(this, index)
- });
- items.push({
- 'type': 'Separator'
- });
- }.bind(this));
- return items;
- },
- _toggleOutputsSection: function(index, evt) {
- /*eslint no-unused-vars: 0*/
- this._getOutputSection(index).toggleCollapsibleSection();
- },
- _showAllHistoryRefresh: function() {
- var showAllHistory = this._oPropertyUIControl.getProperty('showAllHistory').isChecked();
- this._showAllHistoryChange(null, showAllHistory);
- },
- _showItem: function(i, elem) {
- $(elem).removeClass('hidden');
- },
- _selectItem: function(elem) {
- var selected = $(elem).closest('.propertyRow').nextUntil('.separator').addBack();
- // Add the separator
- selected = selected.add(selected.last().next());
- return selected;
- },
- _hideItem: function(i, elem) {
- this._selectItem(elem).addClass('hidden');
- },
- _removeItem: function(elem) {
- this._selectItem(elem).remove();
- },
- _showAllHistoryChange: function(name, checked) {
- if (checked) {
- $('.itemContainerUIControl > div', this.$el).each(this._showItem.bind(this));
- } else {
- $('.itemContainerUIControl .hasNoOutput', this.$el).each(this._hideItem.bind(this));
- }
- },
- _getOutputFromIndex: function(index) {
- var obj = this.mergedInfo[index];
- var oData = {};
- if (_.isObject(obj.output)) {
- oData[ContentStoreObject.OUTPUT] = [obj.output];
- } else {
- oData[ContentStoreObject.OUTPUT] = [obj];
- }
- return oData;
- },
- _getOutputsLinkFromIndex: function(index) {
- var obj = this._getOutputFromIndex(index);
- return ContentStoreObject.getOutputsLink(obj);
- },
- _getVersionLinkFromIndex: function(index) {
- var obj = this._getOutputFromIndex(index);
- return ContentStoreObject.getVersionLink(obj);
- },
- _openOutputsSection: function(index, name, open) {
- if (open) {
- var outputsLink = this._getOutputsLinkFromIndex(index);
- this._getOutputs(outputsLink, index)
- .then(this._handleGetOutputsSuccess.bind(this))
- .then(this._getOutputsSectionPayload.bind(this))
- .done(function(payload) {
- var items = this._getItemsSpec(payload.outputsInfo, index, payload.items);
- this._getOutputSection(index).refreshProperties(items);
- }.bind(this));
- }
- },
- _getVersionSection: function(index) {
- var outputSectionId = index + '_versions';
- return this._oPropertyUIControl.getProperty(outputSectionId);
- },
- _getOutputSection: function(index) {
- var outputSectionId = index + '_outputs';
- return this._oPropertyUIControl.getProperty(outputSectionId);
- },
- _openDetails: function(index) {
- this._getDetails(index).then(function(details) {
- var overlaySlideoutEl = $('<div>');
- this.parentEl.append(overlaySlideoutEl);
- var overlaySlideout = new Slideout({
- 'glassContext': this.glassContext,
- 'position': this.slideout.position,
- 'el': overlaySlideoutEl,
- 'width': '400',
- 'content': {
- 'module': 'bi/content_apps/VersionsDetailsView',
- 'parentView': this,
- 'objectInfo': this.objectInfo,
- 'historyInfo': this.mergedInfo[index],
- 'detailsInfo': details,
- 'glassContext': this.glassContext
- }
- });
- overlaySlideout.render()
- .then(overlaySlideout.show());
- }.bind(this));
- },
- _getOutputsSectionPayload: function(data) {
- var outputsInfo = data.outputsInfo;
- var index = data.index;
- var items = [];
- if (this._canDelete()) {
- items.push({
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('deleteReportVersion'),
- 'class': 'versionText',
- 'clickCallback': function() {
- this._onClickDelete(index);
- }.bind(this)
- }]
- }]
- });
- }
- return GlassContextHelper.getContentLocales(this.glassContext).then(function(contentLocales) {
- if (outputsInfo && Object.keys(outputsInfo).length > 0) {
- var locale;
- for (var burstKey in outputsInfo) {
- if (outputsInfo.hasOwnProperty(burstKey)) {
- if (burstKey !== this.noBurstKey) {
- items.push({
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'wraptext versionText',
- 'value': burstKey
- }]
- }]
- });
- }
- for (locale in outputsInfo[burstKey]) {
- if (outputsInfo[burstKey].hasOwnProperty(locale)) {
- items = items.concat(this._getLocaleSectionPayload(locale, contentLocales[locale], outputsInfo[burstKey][locale]));
- }
- }
- items.push({
- 'type': 'Separator'
- });
- }
- }
- } else {
- items.push({
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'versionText',
- 'value': StringResource.get('noSavedOutputs')
- }]
- }]
- });
- }
- return Promise.resolve({
- items: items,
- outputsInfo: outputsInfo
- });
- }.bind(this));
- },
- _getLocaleSectionPayload: function(locale, fullLocale, aOutputs) {
- var items = [];
- var outputItems = [];
- outputItems.push({
- 'type': 'text',
- 'class': 'versionsLocale',
- 'value': locale.toUpperCase()
- });
- outputItems.push({
- 'type': 'text',
- 'class': 'versionsLocale',
- 'value': fullLocale,
- 'name': locale,
- 'hidden': true
- });
- aOutputs.forEach(function(output) {
- outputItems.push({
- 'type': 'icon',
- 'class': 'versionsOutput',
- 'name': 'outputlink',
- 'svgIcon': this._getOutputIconString(output.format),
- 'clickCallback': this._openOutput.bind(this, output, false),
- 'iconTooltip': StringResource.get(output.format),
- 'ariaLabelledby': locale
- });
- if (this._getOutputDefaultAction(output.format) === 'interactive') {
- outputItems.push({
- 'type': 'icon',
- 'class': 'versionsOutput',
- 'name': 'outputlink',
- 'svgIcon': 'common-download',
- 'clickCallback': this._openOutput.bind(this, output, true),
- 'iconTooltip': StringResource.get('download'),
- 'ariaLabelledby': locale
- });
- }
- }.bind(this));
- items.push({
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': outputItems
- }]
- });
- return items;
- },
- _getOutputIconString: function(format) {
- return _FORMAT_ICONSTRING[format.toLowerCase()] || _FORMAT_ICONSTRING['default'];
- },
- _getOutputDefaultAction: function(format) {
- var value;
- switch (format.toLowerCase()) {
- case 'xhtml':
- value = 'interactive';
- break;
- default:
- value = 'view';
- break;
- }
- return value;
- },
- _getDetails: function(index) {
- if (this.mergedInfo && this.mergedInfo[index]) {
- var options = {
- dataType: 'json',
- type: 'GET',
- url: ContentStoreObject.getDetailsLink(this.mergedInfo[index])
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(function(response) {
- if (response && response.data) {
- return Promise.resolve(response.data.data);
- } else {
- return Promise.reject(new Error('No details data'));
- }
- });
- } else {
- return Promise.reject(new Error('No details'));
- }
- },
- _getOutputs: function(outputsLink, index) {
- if (outputsLink) {
- var options = {
- dataType: 'json',
- type: 'GET',
- url: outputsLink
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(function(response) {
- if (response && response.data) {
- return Promise.resolve({ data: response.data.data, index: index });
- } else {
- return Promise.reject(new Error('No outputs data'));
- }
- });
- } else {
- //resolve anyways if there are no reportVersions with this history
- return Promise.resolve({});
- }
- },
- _openOutput: function(output, download) {
- // let the output handlers have the first chance
- return this._handleOutput({
- output: output,
- report: this.objectInfo,
- glassContext: this.glassContext,
- download: download
- })
- .then(function(isHandled) {
- if (!isHandled) {
- // get values from options
- var id = output.id;
- var modificationTime = output.modificationTime;
- var format = output.format;
- var url = output.content;
- var defaultAction = this._getOutputDefaultAction(format);
- var viewAction, actionContext;
- switch (defaultAction) {
- case 'interactive':
- // This is just a temporary solution for GA. Viewing saved output
- // should use contributions
- viewAction = new this.mockableViewInteractiveReportAction();
- actionContext = {
- 'glassContext': this.glassContext,
- 'target': {
- 'activeObject': {
- 'aSelectedContext': [this.objectInfo],
- 'outputId': id,
- 'download': !!download
- },
- 'itemId': 'com.ibm.bi.contentApps.defaultAction.interactiveReport'
- }
- };
- viewAction.doAction(actionContext);
- break;
- case 'view':
- if (this.objectInfo.type && this.objectInfo.type.indexOf('powerPlay8Report') > -1) {
- viewAction = new this.mockableViewInteractiveReportAction();
- actionContext = {
- 'glassContext': this.glassContext,
- 'target': {
- 'activeObject': {
- 'aSelectedContext': [this.objectInfo],
- 'outputId': id,
- 'download': !!download
- },
- runOptions: {
- prompt: true
- },
- 'itemId': 'com.ibm.bi.contentApps.defaultAction.powerPlay8Report'
- }
- };
- viewAction.doAction(actionContext);
- this._addToMRU(this.objectInfo);
- } else {
- this.glassContext.appController.openAppView('savedoutput', this._getReportPayload(id, modificationTime, format, url));
- this._addToMRU(this.objectInfo);
- }
- break;
- default:
- this.glassContext.appController.openAppView('savedoutput', this._getReportPayload(id, modificationTime, format, url));
- this._addToMRU(this.objectInfo);
- break;
- }
- }
- return Promise.resolve();
- }.bind(this));
- },
- _addToMRU: function(objInfo) {
- return this.glassContext.getSvc('.Content').then(function(contentSvc) {
- contentSvc.addToMRU(objInfo);
- });
- },
- _getReportPayload: function(id, modificationTime, format, url) {
- var title = this.objectInfo.defaultName + ' - ' + modificationTime + ' - ' + format.toUpperCase();
- return {
- 'content': {
- 'path': url,
- 'title': title,
- 'id': id,
- 'reportId': ContentStoreObject.getObjectId(this.objectInfo),
- 'type': ContentStoreObject.getType(this.objectInfo),
- 'permissions': ContentStoreObject.getPermissions(this.objectInfo),
- 'runInAdvancedViewer': ContentStoreObject.getRunInAdvancedViewer(this.objectInfo)
- }
- };
- },
- _getItemsSpec: function(outputsInfo, index, outputSectionPayload) {
- if (outputsInfo && Object.keys(outputsInfo).length > 0) {
- var rightItems = {
- 'align': 'right',
- 'items': [{
- 'type': 'SingleLineLinks',
- 'name': 'sectionRunHistory',
- 'items': []
- }]
- };
- var items = [{
- 'type': 'Split',
- 'label': 'Split',
- 'name': 'Split' + this.id,
- 'items': [{
- 'align': 'left',
- 'items': outputSectionPayload
- }, rightItems]
- }];
- return items;
- } else {
- return outputSectionPayload;
- }
- },
- _canDelete: function() {
- if (this.objectInfo && this.objectInfo.permissions) {
- return ContentStoreObject.hasPermissions(this.objectInfo, ['write']);
- }
- return true;
- },
- _onClickDelete: function(index) {
- var oDialog = new ConfirmationDialog('confirmDelete', StringResource.get('confirmDelete'), StringResource.get('confirmDeleteMessage'));
- oDialog.confirm(function() {
- this._deleteVersion(index);
- this.hasReportVersion = false;
- }.bind(this));
- oDialog.renderContent($('<div>'));
- oDialog._container().addClass('contentDeleteConfirmDialog');
- },
- _handleDeleteVersionSuccess: function(index) {
- var versionSection = this._getVersionSection(index);
- var versionSectionNode = versionSection.getPropertyNode();
- var outputSection = this._getOutputSection(index);
- $('.versionText', versionSectionNode).removeClass('clickable').addClass('hasNoOutput');
- this._showAllHistoryRefresh();
- if ($('.versionDetailsLinks', versionSectionNode).hasClass('disabled')) {
- this._removeItem(versionSectionNode);
- }
- var use = $('.versionReport .svgIcon use', versionSectionNode);
- use.attr('xlink:href', '#common-savedoutput_reporthistory');
- outputSection.getPropertyNode().remove();
- var sText = StringResource.get('toastDoneDeletingSingular', {
- 'nameOfItem': BidiUtil.enforceTextDirection(StringResource.get('reportOutputVersion'))
- });
- this.glassContext.appController.showToast(sText);
- },
- _deleteVersion: function(index) {
- var versionLink = this._getVersionLinkFromIndex(index);
- if (versionLink) {
- var options = {
- dataType: 'json',
- type: 'DELETE',
- url: versionLink + '?force=true&recursive=true'
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(this._handleDeleteVersionSuccess.bind(this, index))
- .catch(function(err) { GlassContextHelper.showAjaxServiceError(this.glassContext, err); }.bind(this));
- } else {
- return Promise.resolve();
- }
- },
- // consider moving to a helper/utility that can load other handlers
- _initOutputHandlers: function() {
- if (this._outputHandlers) {
- return Promise.resolve();
- } else {
- return this.glassContext.appController.findCollection('com.ibm.bi.contentApps.authoring.outputHandlers')
- .then(function(collectionItems) {
- this._outputHandlers = [];
- var outputHandlersPromises = [];
- _.each(collectionItems, function(item) {
- outputHandlersPromises.push(
- new Promise(function(resolve) {
- localRequire([item.outputHandler], function(HandlerModule) {
- this._outputHandlers.push(new HandlerModule());
- resolve();
- }.bind(this));
- }.bind(this)));
- }.bind(this));
- return Promise.all(outputHandlersPromises);
- }.bind(this));
- }
- },
- _handleOutput: function(options) {
- return this._initOutputHandlers()
- .then(function() {
- if (this._getOutputDefaultAction(options.output.format) === 'interactive' && options.download) {
- return Promise.resolve(false);
- }
- var maxPriority = -1;
- var currentHandler;
- _.each(this._outputHandlers || [], function(outputHandler) {
- var outputHandlerPriority = outputHandler.getPriority();
- if (outputHandlerPriority > maxPriority && outputHandler.canExecute(options)) {
- currentHandler = outputHandler;
- maxPriority = outputHandlerPriority;
- }
- });
- if (currentHandler) {
- currentHandler.execute(options);
- return Promise.resolve(true);
- } else {
- return Promise.resolve(false);
- }
- }.bind(this));
- }
- });
- return VersionsTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+----
- */
- define('bi/content_apps/ArchivesTab',['q',
- 'bi/glass/app/ContentView',
- 'bi/content_apps/nls/StringResource',
- 'bi/content_apps/utils/C10Utils',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'underscore'
- ], function(Q, View, StringResource, C10Utils, PropertyUIControl, _) {
- 'use strict';
- var ArchivesTab = View.extend({
- /**
- @paran options.el {node} - container dom node
- **/
- init: function(options) {
- ArchivesTab.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _viewArchivedVersion: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
- 'output_tab': 'arch'
- }, {
- 'm_name': this.objectInfo.defaultName
- }]);
- },
- render: function() {
- var deferred = Q.defer();
- this._id = _.uniqueId('prop_');
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'items': [{
- 'name': 'viewArchivedVersions',
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('viewRunHistory')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('viewArchivedVersions'),
- 'clickCallback': this._viewArchivedVersion.bind(this)
- }]
- }]
- }]
- });
- this._oPropertyUIControl.render().then(function() {
- deferred.resolve(this);
- }.bind(this));
- return deferred.promise;
- }
- });
- return ArchivesTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/VersionsView',[
- 'bi/glass/app/ContentView',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bi/content_apps/VersionsTab',
- 'bi/content_apps/ArchivesTab',
- 'underscore'
- ],
- function(ContentView, StringResource, ContentStoreObject, PropertyUIControl, VersionsTab, ArchivesTab, _) {
- 'use strict';
- var VersionsView = ContentView.extend({
- init: function(options) {
- VersionsView.inherited('init', this, arguments);
- _.extend(this, options);
- },
- render: function() {
- this._containerElement = $('<div>', {
- 'class': 'propertyUIControl versionsView'
- });
- this.$el.append(this._containerElement);
- return this._getAdditionalInfo().then(function() {
- this._oPropertyUIControl = this._getPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'animatedSpinner': true,
- 'items': [{
- 'name': 'versions',
- 'value': StringResource.get('versions'),
- 'type': 'Banner'
- }, {
- 'type': 'TabControl',
- 'items': [{
- 'name': StringResource.get('versions'),
- 'module': VersionsTab,
- 'objectInfo': this.objectInformation,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'parentEl': this.$el
- }, {
- 'name': StringResource.get('archives'),
- 'module': ArchivesTab,
- 'objectInfo': this.objectInformation,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout
- }]
- }]
- });
- return this._oPropertyUIControl.render();
- }.bind(this));
- },
- _getPropertyUIControl: function(options) {
- return new PropertyUIControl(options);
- },
- _getAdditionalInfo: function() {
- return this.glassContext.getCoreSvc('.Ajax').ajax({
- dataType: 'json',
- type: 'GET',
- url: ContentStoreObject.getSelfLink(this.objectInformation),
- data: {
- fields: 'permissions,' + ContentStoreObject.RUN_IN_ADVANCED_VIEWER
- }
- }).then(function(response) {
- var data = response.data && response.data.data;
- if (data) {
- _.extend(this.objectInformation, data[0]);
- } else {
- return Promise.reject(new Error('No additional information'));
- }
- }.bind(this));
- }
- });
- return VersionsView;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/VersionsDetailsView',[
- 'q',
- 'jquery',
- 'bi/glass/app/ContentView',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bacontentnav/utils/GlassContextHelper',
- 'bi/content_apps/utils/C10Utils',
- 'underscore'
- ],
- function(Q, $, ContentView, StringResource, ContentStoreObject, PropertyUIControl, GlassContextHelper, C10Utils, _) {
- 'use strict';
- var VersionsDetailsView = ContentView.extend({
- init: function(options) {
- VersionsDetailsView.inherited('init', this, arguments);
- _.extend(this, options);
- },
- render: function() {
- var deferred = Q.defer();
- this._getItems().then(function(items) {
- this.$el.addClass('versionsDetails');
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'items': items
- });
- return this._oPropertyUIControl.render();
- }.bind(this)).done(deferred.resolve);
- return deferred.promise;
- },
- _getItems: function() {
- var deferred = Q.defer();
- var succeeded = (ContentStoreObject.getStatus(this.historyInfo) === 'succeeded');
- var items = [{
- 'type': 'Banner',
- 'name': 'detailsBanner',
- 'value': ContentStoreObject.getRequestedTime(this.historyInfo, true, 'medium'),
- 'centerLabel': true,
- 'backButton': true,
- 'editable': false,
- 'readOnly': true,
- 'onClose': function() {
- this.slideout.hide();
- }.bind(this)
- }, {
- 'type': 'Separator'
- }, {
- 'type': 'SingleLineLinks',
- 'name': 'actionbar',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'icon',
- 'class': succeeded ? 'versionStatusSuccessful' : 'versionStatusFailed',
- 'svgIcon': succeeded ? 'common-successful' : 'common-failed',
- 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed'),
- 'iconTooltip': succeeded ? StringResource.get('successful') : StringResource.get('failed')
- }, {
- 'type': 'text',
- 'class': 'versionStatusText',
- 'role': 'status',
- 'value': succeeded ? StringResource.get('successful') : StringResource.get('failed')
- }]
- }]
- }, {
- 'type': 'SingleLineLinks',
- 'name': 'historydetails',
- 'items': [{
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('runHistoryDetails'),
- 'class': 'historydetailsText',
- 'clickCallback': this._viewRunHistory.bind(this),
- 'showRightArrow': true
- }]
- }]
- }];
- if (ContentStoreObject.getMessages(this.detailsInfo)) {
- items.push({
- 'type': 'CollapsibleSection',
- 'name': 'errorMessages',
- 'open': true,
- 'label': StringResource.get('errorMessages'),
- 'items': this._getMessageItems()
- });
- }
- this._getOptionsItems().then(function(optionsItems) {
- items = items.concat([{
- 'type': 'CollapsibleSection',
- 'name': 'runTime',
- 'open': true,
- 'label': StringResource.get('runTime'),
- 'items': [{
- 'type': 'SingleLineValue',
- 'name': 'requestTime',
- 'label': StringResource.get('requestTime'),
- 'value': ContentStoreObject.getRequestedTime(this.historyInfo, true, 'medium')
- }, {
- 'type': 'Separator'
- }, {
- 'type': 'SingleLineValue',
- 'name': 'startTime',
- 'label': StringResource.get('startTime'),
- 'value': ContentStoreObject.getExecutionTime(this.historyInfo, true, 'medium')
- }, {
- 'type': 'Separator'
- }, {
- 'type': 'SingleLineValue',
- 'name': 'endTime',
- 'label': StringResource.get('endTime'),
- 'value': ContentStoreObject.getCompletionTime(this.historyInfo, true, 'medium')
- }]
- }]);
- if (this.objectInfo.type !== 'jupyterNotebook') {
- items.push({
- 'type': 'CollapsibleSection',
- 'name': 'options',
- 'open': true,
- 'label': this.objectInfo.type === 'jobDefinition' ? StringResource.get('job') : StringResource.get('report'),
- 'items': optionsItems
- });
- }
- var parameters = ContentStoreObject.getDetailsReportVersionParameters(this.detailsInfo);
- if (parameters) {
- items = items.concat([{
- 'type': 'CollapsibleSection',
- 'name': 'promptValues',
- 'label': StringResource.get('promptValues'),
- 'items': this._getPromptValuesItems(parameters)
- }]);
- }
- deferred.resolve(items);
- }.bind(this));
- return deferred.promise;
- },
- _getMessageItems: function() {
- var items = [];
- var msgIconClass = 'versionMessageIcon ';
- var svgIcon = '';
- ContentStoreObject.getMessages(this.detailsInfo).forEach(function(msg, counter) {
- var severity = ContentStoreObject.getMessageSeverity(msg);
- var iconClass = '';
- switch (severity) {
- case 'error':
- case 'fatal':
- iconClass = msgIconClass + 'versionErrorIcon';
- svgIcon = 'common-close-cancel-error';
- break;
- case 'warn':
- iconClass = msgIconClass + 'versionWarningIcon';
- svgIcon = 'common-warning-hollow';
- break;
- case 'debug':
- iconClass = msgIconClass + 'versionDebugIcon';
- svgIcon = 'common-debug';
- break;
- case 'info':
- iconClass = msgIconClass + 'versionInfoIcon';
- svgIcon = 'common-information';
- break;
- }
- items.push({
- 'type': 'SingleLineLinks',
- 'name': 'messages_' + counter,
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'icon',
- 'class': iconClass,
- 'svgIcon': svgIcon,
- 'value': StringResource.get(severity),
- 'iconTooltip': StringResource.get(severity)
- }, {
- 'type': 'text',
- 'class': 'wraptext textSelectable',
- 'value': ContentStoreObject.getMessageDetail(msg)
- }]
- }]
- });
- });
- return items;
- },
- _getOptionsItems: function() {
- var options = ContentStoreObject.getDetailsReportVersionOptions(this.detailsInfo);
- var deferred = Q.defer();
- if (options) {
- this._getReportLanguages(options).then(function(languages) {
- // todo: of job type, don't push formats
- var items = [];
- if (this.objectInfo.type !== 'jobDefinition'){
- items.push({
- 'type': 'TextArea',
- 'name': 'formats',
- 'label': StringResource.get('formats'),
- 'value': this._getReportFormats(options),
- 'editable': false,
- 'multiline': false
- },{
- 'type': 'Separator'
- });
- }
- items.push({
- 'type': 'TextArea',
- 'name': 'languages',
- 'label': StringResource.get('languages'),
- 'value': languages,
- 'editable': false,
- 'multiline': false
- });
- var location = ContentStoreObject.getLocation(this.objectInfo);
- if (location) {
- items = items.concat([{
- 'type': 'Separator'
- }, {
- 'type': 'SingleLineValue',
- 'name': 'location',
- 'label': StringResource.get('location'),
- 'value': location
- }]);
- }
- deferred.resolve(items);
- }.bind(this));
- } else {
- deferred.resolve([{
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'wraptext',
- 'value': StringResource.get('noReportOptionsAvailable')
- }]
- }]
- }]);
- }
- return deferred.promise;
- },
- _getReportFormats: function(options) {
- var formatsArray = this._getReportVersionOption(options, 'outputFormat');
- var formatsLabelArray = [];
- if (formatsArray) {
- if (_.isArray(formatsArray)) {
- formatsArray.forEach(function(format) {
- formatsLabelArray.push(StringResource.get(format));
- });
- } else {
- formatsLabelArray.push(StringResource.get(formatsArray));
- }
- return this._getDelimitedStringFromArray(formatsLabelArray);
- } else {
- return StringResource.get('unavailable');
- }
- },
- _getReportLanguages: function(options) {
- var localeArray = this._getReportVersionOption(options, 'outputLocale');
- var deferred = Q.defer();
- if (localeArray) {
- GlassContextHelper.getContentLocales(this.glassContext).then(function(contentLocales) {
- var languages = [];
- // Make sure we have an object in case getContentLocales promise returns undefined
- contentLocales = contentLocales || {};
- localeArray.forEach(function(locale) {
- languages.push(contentLocales[locale]);
- });
- deferred.resolve(this._getDelimitedStringFromArray(languages));
- }.bind(this));
- } else {
- deferred.resolve(StringResource.get('unavailable'));
- }
- return deferred.promise;
- },
- _getDelimitedStringFromArray: function(array) {
- if (array) {
- return array.join(', ');
- }
- return null;
- },
- _getReportVersionOption: function(options, name) {
- var grepResult = $.grep(options, function(e) {
- return e.name === name;
- });
- return grepResult.length === 1 && grepResult[0].value ? grepResult[0].value : null;
- },
- _getPromptValuesItems: function(parameters) {
- var items = [];
- var promptValues = ContentStoreObject.getPromptsDisplayValues(parameters, true);
- promptValues.forEach(function(prompt) {
- items.push({
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'promptNameText textSelectable',
- 'value': _.escape(prompt.name + ':')
- }]
- }]
- }, {
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'wraptext textSelectable',
- 'value': _.escape(prompt.display)
- }]
- }]
- }, {
- 'type': 'Separator'
- });
- });
- return items;
- },
- _viewRunHistory: function() {
- var options = [{
- 'm_name': this.objectInfo.defaultName
- }];
- C10Utils.openC10Morphlet(C10Utils.morphletMap.viewHistory, this.objectInfo.type, this.historyInfo.id, options);
- }
- });
- return VersionsDetailsView;
- });
- define("js/content_apps/versionBundle", function(){});
|