load: function (response) {
            if (lang.exists("WUActionResponse.ActionResults.WUActionResult", response)) {
                var wuMap = {};
                arrayUtil.forEach(workunits, function (item, index) {
                    wuMap[item.Wuid] = item;
                });
                arrayUtil.forEach(response.WUActionResponse.ActionResults.WUActionResult, function (item, index) {
                    if (item.Result.indexOf("Failed:") === 0) {
                        topic.publish("hpcc/brToaster", {
                            Severity: "Error",
                            Source: "WsWorkunits.WUAction",
                            Exceptions: [{ Source: item.Action + " " + item.Wuid, Message: item.Result }]
                        });
                    } else {
                        var wu = wuMap[item.Wuid];
                        if (actionType === "delete" && item.Result === "Success") {
                            wu.set("StateID", 999);
                            wu.set("State", "not found");
                        } else if (wu.refresh) {
                            wu.refresh();
                        }
                    }
                });
            }

            if (callback && callback.load) {
                callback.load(response);
            }
        },
Beispiel #2
0
        ]).then(lang.hitch(this, function (response) {
            var accountPermissions = {};
            arrayUtil.forEach(response[1], function (item, idx) {
                accountPermissions[item.PermissionName] = item;
            }, this);

            var data = [];
            arrayUtil.forEach(response[0], function (item, idx) {
                var accountPermission = accountPermissions[item.name];
                data.push(lang.mixin(item, {
                    __hpcc_type: "Resources",
                    __hpcc_id: this.parentRow.__hpcc_id + CONCAT_SYMBOL + item.name,
                    __hpcc_parent: this.parentRow,
                    DisplayName: item.description ? item.description : item.name,
                    AccountName: this.groupname,
                    allow_access: accountPermission ? accountPermission.allow_access : false,
                    allow_read: accountPermission ? accountPermission.allow_read : false,
                    allow_write: accountPermission ? accountPermission.allow_write : false,
                    allow_full: accountPermission ? accountPermission.allow_full : false,
                    deny_access: accountPermission ? accountPermission.deny_access : false,
                    deny_read: accountPermission ? accountPermission.deny_read : false,
                    deny_write: accountPermission ? accountPermission.deny_write : false,
                    deny_full: accountPermission ? accountPermission.deny_full : false
                }));
            }, this);
            options = options || {};
            this.setData(SimpleQueryEngine({}, { sort: options.sort })(data));
            return this.data;
        }));
RowFormatter.prototype.formatRow = function (columns, row, rowIdx) {
    rowIdx = rowIdx || 0;
    row = row || {};
    var context = this;
    var maxChildLen = 0;
    var colLenBefore = {};
    arrayUtil.forEach(columns, function (column) {
        if (!column.children && context._formattedRow[column.field] !== undefined) {
            colLenBefore[column.field] = ("" + context._formattedRow[column.field]).split(LINE_SPLITTER).length;
        }
        var rowArr = row instanceof Array ? row : [row];
        for (var colIdx = 0; colIdx < rowArr.length; ++colIdx) {
            var r = rowArr[colIdx];
            maxChildLen = Math.max(maxChildLen, context.formatCell(column, column.isRawHTML ? r[column.leafID] : safeEncode(r[column.leafID]), rowIdx));
        }
    });
    arrayUtil.forEach(columns, function (column) {
        if (!column.children) {
            var cellLength = ("" + context._formattedRow[column.field]).split(LINE_SPLITTER).length - (colLenBefore[column.field] || 0);
            var delta = maxChildLen - cellLength;
            if (delta > 0) {
                var paddingArr = [];
                paddingArr.length = delta + 1;
                var padding = paddingArr.join(LINE_SPLITTER2);
                context._formattedRow[column.field] += padding;
            }
        }
    });
    return maxChildLen;
};
Beispiel #4
0
    calcSubgraphVisibility: function (subgraph, localisationDepth) {
        if (localisationDepth < 0) {
            return;
        }

        if (localisationDepth > 0) {
            arrayUtil.forEach(subgraph.__hpcc_subgraphs, function (subgraph, idx) {
                this.calcSubgraphVisibility(subgraph, localisationDepth - 1);
            }, this);
        }

        arrayUtil.forEach(subgraph.__hpcc_subgraphs, function (subgraph, idx) {
            this.m_visibleSubgraphs[subgraph.__hpcc_id] = subgraph;
        }, this);
        arrayUtil.forEach(subgraph.__hpcc_vertices, function (vertex, idx) {
            this.m_visibleVertices[vertex.__hpcc_id] = vertex;
        }, this);

        //  Calculate edges that pass through the subgraph  ---
        var dedupEdges = {};
        arrayUtil.forEach(this.graph.edges, function (edge, idx) {
            if (edge.getSource().__hpcc_parent !== edge.getTarget().__hpcc_parent && subgraph === this.getCommonAncestor(edge)) {
                //  Only include one unique edge between subgraphs  ---
                if (!dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id]) {
                    dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id] = true;
                    this.m_visibleEdges[edge.__hpcc_id] = edge;
                }
            }
        }, this);
    },
 arrayUtil.forEach(treeNode.__hpcc_treeItem.__hpcc_children, function (child) {
     var serviceNode = this.createTreeNode(treeNode, child);
     var machines = [];
     var bindings = [];
     arrayUtil.forEach(child.__hpcc_children, function (gchild) {
         if (gchild instanceof TpMachine) {
             machines.push(gchild);
         } else if (gchild instanceof TpBinding) {
             bindings.push(gchild);
         }
     }, this);
     arrayUtil.forEach(bindings, function (binding) {
         var bindingNode = this.createTreeNode(serviceNode, binding);
         arrayUtil.forEach(machines, function (machine) {
             this.createTreeNode(bindingNode, machine);
         }, this);
     }, this);
     arrayUtil.forEach(machines, function (machine) {
         var machineNode = this.createTreeNode(serviceNode, machine);
         arrayUtil.forEach(bindings, function (binding) {
             this.createTreeNode(machineNode, binding);
         }, this);
     }, this);
     data.push(serviceNode);
 }, this);
Beispiel #6
0
export function downloadToCSV(grid, rows, fileName) {
    var csvContent = "";
    var headers = grid.columns;
    var container = [];
    var headerNames = [];

    for (var key in headers) {
        if (headers[key].selectorType !== 'checkbox') {
            if (!headers[key].label) {
                var str = csvEncode(headers[key].field);
                headerNames.push(str);
            } else {
                var str = csvEncode(headers[key].label);
                headerNames.push(str);
            }
        }
    }
    container.push(headerNames);

    arrayUtil.forEach(rows, function (cells, idx) {
        container.push(cells);
    });

    arrayUtil.forEach(container, function (header, idx) {
        var dataString = header.join(",");
        csvContent += dataString + "\n";
    });

    var download = function (content, fileName, mimeType) {
        var a = document.createElement('a');
        mimeType = mimeType || 'application/octet-stream';

        if (navigator.msSaveBlob) { // IE10
            return navigator.msSaveBlob(new Blob([content], { type: mimeType }), fileName);
        } else if ('download' in a) {
            a.href = 'data:' + mimeType + ',' + encodeURIComponent(content);
            a.setAttribute('download', fileName);
            document.body.appendChild(a);
            setTimeout(function () {
                a.click();
                document.body.removeChild(a);
            }, 66);
            return true;
        } else {
            var f = document.createElement('iframe');
            document.body.appendChild(f);
            f.src = 'data:' + mimeType + ',' + encodeURIComponent(content);

            setTimeout(function () {
                document.body.removeChild(f);
            }, 333);
            return true;
        }
    }
    download(csvContent, fileName, 'text/csv');
}
Beispiel #7
0
 calcVisibility2: function () {
     for (var key in this.m_visibleVertices) {
         var vertex = this.m_visibleVertices[key];
         arrayUtil.forEach(vertex.getInEdges(), function (edge, idx) {
             this.m_visibleEdges[edge.__hpcc_id] = edge;
         }, this);
         arrayUtil.forEach(vertex.getOutEdges(), function (edge, idx) {
             this.m_visibleEdges[edge.__hpcc_id] = edge;
         }, this);
         this.calcAncestorVisibility(vertex);
     }
     this.calcSemiVisibleVertices();
 },
Beispiel #8
0
 remove: function () {
     arrayUtil.forEach(this.__hpcc_subgraphs, function (subgraph) {
         subgraph.__hpcc_parent = this.__hpcc_parent;
     }, this);
     arrayUtil.forEach(this.__hpcc_vertices, function (vertex) {
         vertex.__hpcc_parent = this.__hpcc_parent;
     }, this);
     arrayUtil.forEach(this.__hpcc_edges, function (edge) {
         edge.__hpcc_parent = this.__hpcc_parent;
     }, this);
     delete this.__hpcc_parent;
     this.__hpcc_graph.removeItem(this);
 },
 load: function (response) {
     arrayUtil.forEach(workunits, function (item, index) {
         item.refresh();
     });
     /*  TODO:  Revisit after HPCC-9241 is fixed
     if (lang.exists("DFUWorkunitsActionResponse.ActionResults.WUActionResult", response)) {
         arrayUtil.forEach(response.WUActionResponse.ActionResults.WUActionResult, function (item, index) {
             if (item.Result.indexOf("Failed:") === 0) {
                 dojo.publish("hpcc/brToaster", {
                     message: "<h4>" + item.Action + " " + item.Wuid + "</h4>" + "<p>" + item.Result + "</p>",
                     type: "error",
                     duration: -1
                 });
             } else {
                 dojo.publish("hpcc/brToaster", {
                     message: "<h4>" + item.Action + " " + item.Wuid + "</h4>" + "<p>" + item.Result + "</p>",
                     type: "message"
                 });
             }
         });
     }
     */
     if (callback && callback.load) {
         callback.load(response);
     }
 },
 getChildren: function (parent, options) {
     var children = [];
     if (parent.TpMachines) {
         arrayUtil.forEach(parent.TpMachines.TpMachine, function (item, idx) {
             children.push({
                 calculatedID: item.Netaddress,
                 displayName: item.ConfigNetaddress !== item.Netaddress ? item.ConfigNetaddress + " [" + item.Netaddress + "]" : item.ConfigNetaddress,
                 NetAddress: item.Netaddress,
                 ConfigNetaddress: item.ConfigNetaddress,
                 type: "machine",
                 isMachine: true,
                 isDir: false,
                 OS: item.OS,
                 fullPath: parent.fullPath,
                 DropZone: parent.DropZone
             });
         });
         return QueryResults(children);
     } else if (parent.isMachine || parent.isDir) {
         var store = Observable(new FileListStore({
             parent: parent
         }));
         return store.query({
             Netaddr: parent.NetAddress,
             Path: parent.fullPath,
             Mask: "",
             OS: parent.OS
         });
     }
 }