123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
"use strict";
modulum('SessionEndWidget', ['WidgetBase', 'WidgetFactory'],
function(context, cls) {
cls.SessionEndWidget = context.oo.Class(cls.WidgetBase, function($super) {
return {
__name: "SessionEndWidget",
_closeApplicationEnd: null,
_restartApp: null,
_getGbcLog: null,
_chromeBar: null,
_htmlFilter: null,
_initElement: function() {
this._ignoreLayout = true;
$super._initElement.call(this);
this._closeApplicationEnd = this._element.getElementsByClassName("closeApplicationEnd")[0];
if (gbc.HostService.isUR()) {
this._closeApplicationEnd.classList.add("hidden");
}
this._restartApp = this._element.getElementsByClassName("restartApp")[0];
this._getGbcLog = this._element.querySelector(".gbcLogLink");
var chromeBarOpt = this.getBuildParameters();
chromeBarOpt.lightmode = true;
this._chromeBar = cls.WidgetFactory.createWidget("ChromeBar", chromeBarOpt);
this._element.prependChild(this._chromeBar.getElement());
this._chromeBar.setLightMode(true);
},
_initLayout: function() {
},
destroy: function() {
this._closeApplicationEnd = null;
this._restartApp = null;
if (this._htmlFilter) {
this._htmlFilter.destroy();
this._htmlFilter = null;
}
$super.destroy.call(this);
},
manageMouseClick: function(domEvent) {
var target = domEvent.target;
if (target.isElementOrChildOf(this._closeApplicationEnd)) {
this.emit(context.constants.widgetEvents.close);
} else if (target.isElementOrChildOf(this._restartApp)) {
this.emit(context.constants.widgetEvents.restart);
context.LogService.checkMemoryLogs({
clearHeader: false,
clearImages: false,
clearContent: true
});
} else if (target.isElementOrChildOf(this._getGbcLog)) {
gbc.LogService.download();
gbc.LogService.clearLog({
clearHeader: false,
clearImages: false,
clearContent: true
});
}
return true;
},
showSessionActions: function() {
var elements = this._element.getElementsByClassName('from-session') || [];
for (var i = 0; i < elements.length; i++) {
elements[i].removeClass('hidden');
}
if (gbc.LogService.isRecordingEnabled()) {
this._getGbcLog.removeClass('hidden');
}
},
showUAActions: function() {
this._element.getElementsByClassName('from-ua')[0].removeClass('hidden');
},
setHeader: function(header) {
this._element.getElementsByClassName('mt-card-header-text')[0].innerText = header;
},
setMessage: function(message) {
var messageElt = this._element.getElementsByClassName('message')[0];
messageElt.removeClass('hidden');
if (!this._htmlFilter) {
this._htmlFilter = cls.WidgetFactory.createWidget('HtmlFilterWidget', this.getBuildParameters());
}
messageElt.innerHTML = this._htmlFilter.sanitize(message);
},
setSessionID: function(id) {
this._element.getElementsByClassName('session')[0].removeClass('hidden');
this._element.getElementsByClassName('sessionID')[0].textContent = id;
},
setSessionLinks: function(base, session) {
this._element.querySelector('.uaLink>a').setAttribute('href', base + '/monitor/log/uaproxy-' + session);
this._element.querySelector('.vmLink>a').setAttribute('href', base + '/monitor/log/vm-' + session);
if (!context.DebugService.isActive()) {
this._element.querySelector('.uaLink').style.display = 'none';
this._element.querySelector('.vmLink').style.display = 'none';
}
},
setAuiLogUrl: function(session, file) {
this._element.querySelector('.auiLink>a').setAttribute('download', 'auiLog-' + session + '.log');
this._element.querySelector('.auiLink>a').setAttribute('href', 'file');
}
};
});
cls.WidgetFactory.registerBuilder('SessionEnd', cls.SessionEndWidget);
});