bitfront-library
Version:
Angular CLI project with components and classes used by other Angular projects of the BIT foundation.
205 lines • 14.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HQLComponent = void 0;
var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms");
var hql_1 = require("../shared/data/hql");
var message_service_1 = require("../../shared/service/message.service");
var developer_service_1 = require("../shared/service/developer.service");
var global_constants_1 = require("../../shared/global.constants");
var bitmessage_1 = require("../../shared/data/bitmessage");
var i0 = require("@angular/core");
var i1 = require("../shared/service/developer.service");
var i2 = require("@angular/forms");
var i3 = require("../../shared/service/message.service");
var i4 = require("../../shared/component/bit-header.component");
var i5 = require("../../shared/directive/focus-register.directive");
var i6 = require("../../shared/component/bit-footer.component");
/**
* Clase que implementa la consulta de información con consultas HQL.
*/
var HQLComponent = /** @class */ (function () {
/** Constructor de la clase. */
function HQLComponent(developerService, formBuilder, messageService) {
this.developerService = developerService;
this.formBuilder = formBuilder;
this.messageService = messageService;
this.breadcrumb = [];
this.messages = new Map();
}
/** Inicializa la ficha: define la validación. */
HQLComponent.prototype.ngOnInit = function () {
this.init();
this.hqlControl = this.formBuilder.control(this.hql.hql, [forms_1.Validators.required]);
this.breadcrumb = [];
this.breadcrumb.push({ label: "Developer" });
this.breadcrumb.push({ label: "SQL/HQL" });
this.messages.set(global_constants_1.PageStatus.Init, "Introdueixi el SQL/HQL");
this.messages.set(global_constants_1.PageStatus.Searching, "Executant la sentència");
this.messages.set(global_constants_1.PageStatus.FinishSearch, "Sentència executada correctament");
};
/** Inicializa el componente. */
HQLComponent.prototype.init = function () {
this.status = global_constants_1.PageStatus.Init;
this.hql = hql_1.HQL.newObject();
this.hql.reset();
};
/** Envía la consulta/ejecución de HQL. */
HQLComponent.prototype.sendSHQL = function (esHQL, execute, simulate) {
var _this = this;
// Evitamos iniciar una nueva búsqueda cuando la anterior aún está en curso (p. ej., double click)
if (this.status === global_constants_1.PageStatus.Searching) {
return;
}
this.status = global_constants_1.PageStatus.Searching;
//this._developerService.sendHQLTest()
Object.assign(this.hql, { hql: this.hqlControl.value });
this.developerService.sendSHQL(esHQL, this.hql, execute, simulate).subscribe(function (result) {
_this.hql = result;
_this.status = global_constants_1.PageStatus.FinishSearch;
}, function (error) {
_this.status = global_constants_1.PageStatus.Error;
var titulo = simulate ? "Resultat de la simulació" : "Error";
var cuerpo = error.text + (error.trazaError ? "\nTraça:\n" + error.trazaError : "");
_this.messageService.sendMessage(new bitmessage_1.BitMessage(titulo, cuerpo));
});
};
/** Limpia la información de consulta/ejecución. */
HQLComponent.prototype.resetForm = function () {
this.init();
};
Object.defineProperty(HQLComponent.prototype, "searchInitiated", {
/** Flag: la página está realizando la búsqueda. */
get: function () {
return this.status === global_constants_1.PageStatus.Init;
},
enumerable: false,
configurable: true
});
Object.defineProperty(HQLComponent.prototype, "searching", {
/** Flag: la página está realizando la búsqueda. */
get: function () {
return this.status === global_constants_1.PageStatus.Searching;
},
enumerable: false,
configurable: true
});
Object.defineProperty(HQLComponent.prototype, "searchFinished", {
/** Flag: la página ha finalizado la última búsqueda. */
get: function () {
return this.status === global_constants_1.PageStatus.FinishSearch;
},
enumerable: false,
configurable: true
});
Object.defineProperty(HQLComponent.prototype, "diagnostic", {
/** Información de debug. */
get: function () {
return JSON.stringify(this.hql);
},
enumerable: false,
configurable: true
});
HQLComponent.ɵfac = function HQLComponent_Factory(t) { return new (t || HQLComponent)(i0.ɵɵdirectiveInject(i1.DeveloperService), i0.ɵɵdirectiveInject(i2.FormBuilder), i0.ɵɵdirectiveInject(i3.MessageService)); };
HQLComponent.ɵcmp = i0.ɵɵdefineComponent({ type: HQLComponent, selectors: [["hql"]], decls: 41, vars: 13, consts: [[3, "noToolbar", "breadcrumb"], [1, "panel", "panel-filtro"], [1, "panel-heading"], [1, "panel-body"], ["role", "form"], [1, "form-group"], [1, "row"], [1, "col-xs-12"], ["id", "hql", "name", "hql", 1, "form-control", "h-200", 3, "formControl"], [1, "panel-footer", "text-center"], ["role", "group", 1, "btn-group"], ["type", "reset", 1, "btn", "btn-default", 3, "click"], [1, "glyphicon", "glyphicon-erase"], ["type", "reset", 1, "btn", "btn-default", 3, "disabled", "click"], [1, "glyphicon", "glyphicon-search"], ["type", "reset", 1, "btn", "btn-info", 3, "disabled", "click"], [1, "glyphicon", "glyphicon-send"], ["type", "reset", 1, "btn", "btn-warning", 3, "disabled", "click"], [1, "glyphicon", "glyphicon-flash"], [1, "mensaje", 3, "hidden"], [2, "height", "150px"], ["type", "form", 3, "paginator", "status", "messages"]], template: function HQLComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "bit-header", 0);
i0.ɵɵelementStart(1, "div", 1);
i0.ɵɵelementStart(2, "div", 2);
i0.ɵɵelement(3, "i");
i0.ɵɵtext(4, "\u00A0\u00A0\u00A0SQL/HQL ");
i0.ɵɵelementEnd();
i0.ɵɵelementStart(5, "div", 3);
i0.ɵɵelementStart(6, "form", 4);
i0.ɵɵelementStart(7, "div", 5);
i0.ɵɵelementStart(8, "div", 6);
i0.ɵɵelementStart(9, "div", 7);
i0.ɵɵelement(10, "textarea", 8);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(11, "div", 9);
i0.ɵɵelementStart(12, "div", 10);
i0.ɵɵelementStart(13, "button", 11);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_13_listener() { return ctx.resetForm(); });
i0.ɵɵtext(14, "Neteja\u00A0\u00A0");
i0.ɵɵelement(15, "span", 12);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(16, "div", 10);
i0.ɵɵelementStart(17, "button", 13);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_17_listener() { return ctx.sendSHQL(false, false, false); });
i0.ɵɵtext(18, "Query SQL\u00A0\u00A0");
i0.ɵɵelement(19, "span", 14);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(20, "div", 10);
i0.ɵɵelementStart(21, "button", 13);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_21_listener() { return ctx.sendSHQL(true, false, false); });
i0.ɵɵtext(22, "Query HQL\u00A0\u00A0");
i0.ɵɵelement(23, "span", 14);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(24, "div", 10);
i0.ɵɵelementStart(25, "button", 15);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_25_listener() { return ctx.sendSHQL(false, false, true); });
i0.ɵɵtext(26, "Simula SQL\u00A0\u00A0");
i0.ɵɵelement(27, "span", 16);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(28, "div", 10);
i0.ɵɵelementStart(29, "button", 17);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_29_listener() { return ctx.sendSHQL(false, true, false); });
i0.ɵɵtext(30, "Executa SQL\u00A0\u00A0");
i0.ɵɵelement(31, "span", 18);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(32, "div", 10);
i0.ɵɵelementStart(33, "button", 17);
i0.ɵɵlistener("click", function HQLComponent_Template_button_click_33_listener() { return ctx.sendSHQL(true, true, false); });
i0.ɵɵtext(34, "Executa HQL\u00A0\u00A0");
i0.ɵɵelement(35, "span", 18);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(36, "div");
i0.ɵɵelementStart(37, "pre", 19);
i0.ɵɵtext(38);
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelement(39, "div", 20);
i0.ɵɵelement(40, "bit-footer", 21);
} if (rf & 2) {
i0.ɵɵproperty("noToolbar", true)("breadcrumb", ctx.breadcrumb);
i0.ɵɵadvance(10);
i0.ɵɵproperty("formControl", ctx.hqlControl);
i0.ɵɵadvance(7);
i0.ɵɵproperty("disabled", !ctx.hqlControl.valid);
i0.ɵɵadvance(4);
i0.ɵɵproperty("disabled", !ctx.hqlControl.valid);
i0.ɵɵadvance(4);
i0.ɵɵproperty("disabled", !ctx.hqlControl.valid);
i0.ɵɵadvance(4);
i0.ɵɵproperty("disabled", !ctx.hqlControl.valid);
i0.ɵɵadvance(4);
i0.ɵɵproperty("disabled", !ctx.hqlControl.valid);
i0.ɵɵadvance(4);
i0.ɵɵproperty("hidden", !ctx.hql.resultado);
i0.ɵɵadvance(1);
i0.ɵɵtextInterpolate(ctx.hql.resultado);
i0.ɵɵadvance(2);
i0.ɵɵproperty("paginator", false)("status", ctx.status)("messages", ctx.messages);
} }, directives: [i4.BitHeaderComponent, i2.ɵangular_packages_forms_forms_ba, i2.NgControlStatusGroup, i2.NgForm, i5.FocusRegisterDirective, i2.DefaultValueAccessor, i2.NgControlStatus, i2.FormControlDirective, i6.BitFooterComponent], encapsulation: 2 });
return HQLComponent;
}());
exports.HQLComponent = HQLComponent;
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HQLComponent, [{
type: core_1.Component,
args: [{
selector: "hql",
template: "\n\n <bit-header [noToolbar]=\"true\" [breadcrumb]=breadcrumb></bit-header>\n\n <div class=\"panel panel-filtro\">\n <div class=\"panel-heading\">\n <i></i> SQL/HQL\n </div>\n <div class=\"panel-body\">\n <form role=\"form\"> <!-- #f=\"ngForm\"-->\n <div class=\"form-group\">\n <div class=\"row\">\n <div class=\"col-xs-12\">\n <textarea class=\"form-control h-200\" id=\"hql\" name=\"hql\" [formControl]=\"hqlControl\"></textarea>\n </div>\n </div>\n </div>\n </form>\n </div>\n <div class=\"panel-footer text-center\">\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-default\" (click)=\"resetForm()\">Neteja <span class=\"glyphicon glyphicon-erase\"></span></button>\n </div>\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-default\" [disabled]=\"!hqlControl.valid\" (click)=\"sendSHQL(false, false, false)\">Query SQL <span class=\"glyphicon glyphicon-search\"></span></button>\n </div>\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-default\" [disabled]=\"!hqlControl.valid\" (click)=\"sendSHQL(true, false, false)\">Query HQL <span class=\"glyphicon glyphicon-search\"></span></button>\n </div>\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-info\" [disabled]=\"!hqlControl.valid\" (click)=\"sendSHQL(false, false, true)\">Simula SQL <span class=\"glyphicon glyphicon-send\"></span></button>\n </div>\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-warning\" [disabled]=\"!hqlControl.valid\" (click)=\"sendSHQL(false, true, false)\">Executa SQL <span class=\"glyphicon glyphicon-flash\"></span></button>\n </div>\n <div class=\"btn-group\" role=\"group\">\n <button type=\"reset\" class=\"btn btn-warning\" [disabled]=\"!hqlControl.valid\" (click)=\"sendSHQL(true, true, false)\">Executa HQL <span class=\"glyphicon glyphicon-flash\"></span></button>\n </div>\n </div>\n </div>\n\n <div>\n <pre class=\"mensaje\" [hidden]=\"!hql.resultado\">{{hql.resultado}}</pre> <!-- (!searchFinished || errorMessage)-->\n </div>\n <div style=\"height: 150px;\">\n </div>\n\n <bit-footer [paginator]=\"false\" type=\"form\" [status]=\"status\" [messages]=\"messages\"></bit-footer>\n\n <!--footer class=\"footer navbar-fixed-bottom\">\n <ul class=\"navbar-right\">\n <li>\n <span class=\"mensaje mensaje-informacion\" *ngIf=\"searchInitiated\"><i class=\"glyphicon glyphicon-info-sign\"></i>Introdueixi el HQL i premi \"Query\" o \"Execute\"</span>\n <span class=\"mensaje mensaje-informacion\" *ngIf=\"searching\">Cercant...</span>\n <span class=\"mensaje mensaje-error\" *ngIf=\"searchFinished && !errorMessage\"><i class=\"glyphicon glyphicon-alert\"></i>HQL executat</span>\n <span class=\"mensaje mensaje-error\" *ngIf=\"errorMessage\"><i class=\"glyphicon glyphicon-alert\"></i>{{errorMessage}}</span>\n </li>\n </ul>\n </footer-->\n "
}]
}], function () { return [{ type: i1.DeveloperService }, { type: i2.FormBuilder }, { type: i3.MessageService }]; }, null); })();
//# sourceMappingURL=hql.component.js.map