123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- /*##############################################################################
- # 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/lang",
- "dojo/_base/array",
- "dojo/_base/fx",
- "dojo/_base/window",
- "dojo/dom",
- "dojo/dom-style",
- "dojo/dom-geometry",
- "dojo/io-query",
- "dojo/topic",
- "dojo/ready",
- "dojox/html/entities",
- "dojox/widget/Toaster",
- "dojox/widget/Standby"
- ], function (lang, arrayUtil, fx, baseWindow, dom, domStyle, domGeometry, ioQuery, topic, ready,
- entities, Toaster, Standby) {
- var initUi = function () {
- var params = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) == "?" ? 1 : 0)));
- require(
- ["hpcc/" + params.Widget],
- function (WidgetClass) {
- var webParams = {
- id: "stub",
- "class": "hpccApp"
- };
- if (params.TabPosition) {
- lang.mixin(webParams, {
- TabPosition: params.TabPosition
- });
- }
- if (params.ReadOnly) {
- lang.mixin(webParams, {
- readOnly: params.ReadOnly
- });
- }
- var widget = WidgetClass.fixCircularDependency ? new WidgetClass.fixCircularDependency(webParams) : new WidgetClass(webParams);
- var standbyBackground = new Standby({
- color: "#FAFAFA",
- text: "",
- centerIndicator: "text",
- target: "stub"
- });
- dojo.body().appendChild(standbyBackground.domNode);
- standbyBackground.startup();
- standbyBackground.hpccShowCount = 0;
- topic.subscribe("hpcc/standbyBackgroundShow", function () {
- if (standbyBackground.hpccShowCount++ == 0) {
- standbyBackground.show();
- }
- });
- topic.subscribe("hpcc/standbyBackgroundHide", function () {
- if (--standbyBackground.hpccShowCount <= 0) {
- standbyBackground.hpccShowCount = 0;
- standbyBackground.hide();
- }
- });
- var standbyForeground = new Standby({
- zIndex: 1000,
- target: "stub"
- });
- dojo.body().appendChild(standbyForeground.domNode);
- standbyForeground.startup();
- standbyForeground.hpccShowCount = 0;
- topic.subscribe("hpcc/standbyForegroundShow", function () {
- standbyForeground.show();
- ++standbyForeground.hpccShowCount;
- });
- topic.subscribe("hpcc/standbyForegroundHide", function () {
- if (--standbyForeground.hpccShowCount <= 0) {
- standbyForeground.hpccShowCount = 0;
- standbyForeground.hide();
- }
- });
- var myToaster = new Toaster({
- id: 'hpcc_toaster',
- positionDirection: 'br-left'
- });
- topic.subscribe("hpcc/brToaster", function (topic) {
- if (lang.exists("Exceptions", topic)) {
- var context = this;
- arrayUtil.forEach(topic.Exceptions, function (_item, idx) {
- var item = lang.mixin({
- Severity: topic.Severity,
- Source: topic.Source
- }, _item);
- if ((item.Source === "WsWorkunits.WUInfo" && item.Code === 20080) ||
- (item.Source === "WsWorkunits.WUQuery" && item.Code === 20081)) {
- } else {
- var message = "<h4>" + entities.encode(item.Source) + "</h4><p>" + entities.encode(item.Message) + "</p>";
- myToaster.setContent(message, item.Severity, item.Severity === "Error" ? -1 : null);
- myToaster.show();
- }
- });
- }
- });
- if (widget) {
- widget.placeAt(dojo.body(), "last");
- widget.startup();
- widget.init(params);
- }
- document.title = widget.getTitle ? widget.getTitle() : params.Widget;
- /*
- dojo.publish("hpccMessageTopic", {
- type: "warning",
- message: "testing"
- });
- */
- }
- );
- },
- startLoading = function (targetNode) {
- var overlayNode = dom.byId("loadingOverlay");
- if ("none" == domStyle.get(overlayNode, "display")) {
- var coords = domGeometry.getMarginBox(targetNode || baseWindow.body());
- domGeometry.setMarginBox(overlayNode, coords);
- domStyle.set(dom.byId("loadingOverlay"), {
- display: "block",
- opacity: 1
- });
- }
- },
- endLoading = function () {
- fx.fadeOut({
- node: dom.byId("loadingOverlay"),
- duration: 175,
- onEnd: function (node) {
- domStyle.set(node, "display", "none");
- }
- }).play();
- };
- return {
- init: function () {
- startLoading();
- ready(function () {
- initUi();
- endLoading();
- });
- }
- };
- });
|