123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- /*##############################################################################
- # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################## */
- define([
- "dojo/_base/declare",
- "dojo/_base/lang",
- "dojo/dom",
- "dojo/request/iframe",
- "dijit/layout/_LayoutWidget",
- "dijit/_TemplatedMixin",
- "dijit/_WidgetsInTemplateMixin",
- "dijit/registry",
- "dojox/grid/enhanced/plugins/Pagination",
- "hpcc/ESPBase",
- "dojo/text!../templates/ResultWidget.html",
- "dijit/layout/BorderContainer",
- "dijit/Toolbar",
- "dijit/form/Button",
- "dijit/ToolbarSeparator",
- "dojox/grid/EnhancedGrid"
- ], function (declare, lang, dom, iframe,
- _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, registry,
- Pagination,
- ESPBase,
- template) {
- return declare("ResultWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
- templateString: template,
- baseClass: "ResultWidget",
- borderContainer: null,
- grid: null,
- initalized: false,
- loaded: false,
- buildRendering: function (args) {
- this.inherited(arguments);
- },
- postCreate: function (args) {
- this.inherited(arguments);
- this.borderContainer = registry.byId(this.id + "BorderContainer");
- this.grid = registry.byId(this.id + "Grid");
- },
- startup: function (args) {
- this.inherited(arguments);
- },
- resize: function (args) {
- this.inherited(arguments);
- this.borderContainer.resize();
- },
- layout: function (args) {
- this.inherited(arguments);
- },
- destroy: function (args) {
- this.inherited(arguments);
- },
- _doDownload: function (type) {
- //TODO Fix
- var base = new ESPBase();
- if (lang.exists("result.Sequence", this)) {
- var sequence = this.result.Sequence;
- var downloadPdfIframeName = "downloadIframe_" + sequence;
- var frame = iframe.create(downloadPdfIframeName);
- var url = base.getBaseURL() + "/WUResultBin?Format=" + type + "&Wuid=" + this.result.Wuid + "&Sequence=" + sequence;
- iframe.setSrc(frame, url, true);
- } else if (lang.exists("result.Name", this)) {
- var logicalName = this.result.Name;
- var downloadPdfIframeName = "downloadIframe_" + logicalName;
- var frame = iframe.create(downloadPdfIframeName);
- var url = base.getBaseURL() + "/WUResultBin?Format=" + type + "&Wuid=" + this.result.Wuid + "&LogicalName=" + logicalName;
- iframe.setSrc(frame, url, true);
- }
- },
- _onDownloadZip: function (args) {
- this._doDownload("zip");
- },
- _onDownloadGZip: function (args) {
- this._doDownload("gzip");
- },
- _onDownloadXLS: function (args) {
- this._doDownload("xls");
- },
- _onFileDetails: function (args) {
- alert("todo");
- },
- // Implementation ---
- onErrorClick: function (line, col) {
- },
- init: function (params) {
- if (this.initalized) {
- return;
- }
- this.initalized = true;
- this.result = params.result;
- //TODO: Encapsulate this IF into ESPResult.js
- if (params.result && params.result.canShowResults()) {
- this.grid.setStructure(params.result.getStructure());
- this.grid.setStore(params.result.getObjectStore());
- this.refresh();
- } else {
- this.grid.setStructure([
- {
- name: "##", width: "6"
- }
- ]);
- this.grid.showMessage("[undefined]");
- }
- },
- refresh: function () {
- if (this.result && !this.result.isComplete()) {
- this.grid.showMessage(this.result.getLoadingMessage());
- } else if (!this.loaded) {
- this.loaded = true;
- this.grid.setQuery({
- id: "*"
- });
- }
- }
- });
- });
|