app.directive('objectEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", allowEditValues: "=?", allowNewKeys: "=?", allowEditKeys: "=?", allowDeleteKeys: "=?", keyPlaceholder: "=?" }, transclude: false, controller: ctrl_5f3dd39edd634d71eadb48ba, template: `
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • `, bindToController: true};}); function ctrl_5f3dd39edd634d71eadb48ba($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.t = function() { return (!this.bindingParent || !this.bindingName || !this.bindingParent[this.bindingName]) ? "null" : typeof(this.bindingParent[this.bindingName]); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3dd39edd634d71eadb48ba', ctrl_5f3dd39edd634d71eadb48ba); app.directive('layoutEditorElement', function() { return { scope: { selected: "=?" }, controller: ctrl_5f3dd6c450a9cc72d8fcbfd0, template: `
    {{directiveScope.dragging}} {{directiveScope.unique}}
    `, bindToController: true};}); function ctrl_5f3dd6c450a9cc72d8fcbfd0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; this.unique = createUniqueTag(); this.dragging = false; this.selected = false; $timeout(() => { var element = document.getElementById(this.unique); element.onmousedown = (e) => { this.startTop = element.offsetTop; this.dragging = true; $scope.$apply(); }; document.onmousemove = (e) => { if (this.dragging) { element.style.top = (e.clientY) + "px"; element.style.left = (e.clientX) + "px"; $scope.$apply(); } }; document.onmouseup = (e) => { this.dragging = false; $scope.$apply(); }; }, 1000); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: layoutEditorElement failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3dd6c450a9cc72d8fcbfd0', ctrl_5f3dd6c450a9cc72d8fcbfd0); app.directive('baseList', function() { return { scope: { inWindow: "=?", modelName: "=", layout: "=?", query: "=?", sort: "=?", selectionMode: "=?", bindingName: "=?", bindingParent: "=?", showHeader: "=?", showTitle: "=?", allowNew: "=?", allowDeleteAll: "=?", limit: "=?", skip: "=?", reloadRate: "=?", initValues: "=?", records: "=?", fillToTop: "=?", allowInlineEdit: "=?", totalCount: "=?", //For ref by ext only rowFontSize: "=?", persistentReload: "=?", invertHeader: "=?" }, controller: ctrl_5f3e8c3d50a9cc72d8fcbfd2, template: `
     
    ⚠ {{directiveScope.error}}
     
     {{directiveScope.skip | number}} to {{directiveScope.limit + directiveScope.skip > directiveScope.totalCount ? directiveScope.totalCount : directiveScope.limit + directiveScope.skip | number}} of {{directiveScope.totalCount | number}}  Updating every {{directiveScope.reloadRate / 1000 | number}} second{{directiveScope.reloadRate / 1000 > 1 ? "s" : ""}}

    Query JSON: {{directiveScope.editableQuery}}
    {{directiveScope.sort[field.name] ? (directiveScope.sort[field.name] == 'asc' ? '▲ ' : '▼ ') : ''}}{{field.label}}
    {{field.label}}

    {{line}}
    {{directiveScope.truncateString(record[field.name] == null ? ' ' : record[field.name])}}
    `, bindToController: true};}); function ctrl_5f3e8c3d50a9cc72d8fcbfd2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.quickSearchTerm = ""; this.query = this.query || {}; this.editableQuery = {}; this.sort = this.sort || {}; this.showTitle = this.showTitle || true; this.showQuery = false; this.skip = this.skip || 0; this.limit = this.limit == null ? ($scope.$root.models[this.modelName].default_query_limit ?? 25) : this.limit; this.loading = true; this.error = null; this.unique = createUniqueTag(); this.firstLoad = false; try { this.parentModal = $scope.$parent.$parent.$parent.directiveScope ? $scope.$parent.$parent.$parent.directiveScope.directiveRef : null; } catch (e) { } this.editingField = { record: null, field: null, value: null }; this.getRowspan = function(_record, _field, _index) { if (!$scope.directiveScope.records || !_field.merge_adjacent_values_vertically || _record[_field.name] == null || _record[_field.name].length == 0) { return 1; } if ( //First record, or the last record's value was different (_index == 0 || $scope.directiveScope.records[_index - 1][_field.name] != _record[_field.name]) && //Not the last record, and the next record's value matches (_index != $scope.directiveScope.records.length - 1 || $scope.directiveScope.records[_index + 1] == _record[_field.name])) { //Find the number of subsequent records with this value var i = _index; for(; i < $scope.directiveScope.records.length; i++) { if (JSON.stringify($scope.directiveScope.records[i][_field.name]) != JSON.stringify(_record[_field.name])) { break; } } return i - _index; } return 1; } this.getRowspanDisplay = function(_record, _field, _index) { //Should display the if not merging, or if the previous value is different and the next is the same if (!$scope.directiveScope.records || !_field.merge_adjacent_values_vertically || _record[_field.name] == null || _record[_field.name].length == 0) { return true; } //First record, or previous value is different return _index == 0 || JSON.stringify($scope.directiveScope.records[_index - 1][_field.name]) != JSON.stringify(_record[_field.name]); } this.editField = function(_record, _field, _currentValue) { $scope.directiveScope.editingField.record = _record; $scope.directiveScope.editingField.field = _field; $scope.directiveScope.editingField.value = cloneObject(_currentValue); postProcessJSON($scope.directiveScope.editingField.value); } this.cancelEdit = function() { Object.assign($scope.directiveScope.editingField, { record: null, field: null, value: null }); } this.saveEdit = function() { var updates = {}; updates[$scope.directiveScope.editingField.field] = $scope.directiveScope.editingField.value; updateRecord($scope, $http, $scope.directiveScope.modelName, $scope.directiveScope.editingField.record, updates, (result) => { $scope.$root.$emit("showAlert", "Record updated", "success"); $scope.directiveScope.cancelEdit(); $scope.directiveScope.reloadRecords(); }); } //Normalize attributes if (!this.modelName) { this.error = this.modelName this.error = "Model name not provided" this.loading = false; return; } if (!$scope.$root.models[this.modelName]) { this.error = "'" + this.modelName + "' model not found or permission denied", this.loading = false; return; } this.updateEditableQuery = function() { $scope.directiveScope.editableQuery = JSON.parse(JSON.stringify($scope.directiveScope.query)); } this.qsKeypress = function(_event) { if (_event.key == "Enter") { $scope.directiveScope.performQuickSearch(); } }; this.performQuickSearch = function() { $scope.directiveScope.query = constructGlobalSearch($scope, $scope.directiveScope.modelName, $scope.directiveScope.quickSearchTerm); $scope.directiveScope.updateEditableQuery(); }; this.viewRecordModal = { id: null, model: null, layout: null }; //Evaluate role permissions for referenced table this.allowUpdate = $scope.$root.roles.some((role) => { return role.allow_all_models || role.update_models.includes($scope.directiveScope.modelName); }); this.allowInsert = $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes($scope.directiveScope.modelName); }); this.allowCopy = $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes($scope.directiveScope.modelName); }); this.allowDelete = $scope.$root.roles.some((role) => { return role.allow_all_models || role.delete_models.includes($scope.directiveScope.modelName); }); this.loadModelData(); //Multiple selection mode? if (this.selectionMode == "multiple") { //Init array on bound record prop this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; } //Set sort if defined (or use layout default, if defined) this.sort = (this.sort && typeof(this.sort) == "object" && Object.keys(this.sort).length > 0) ? this.sort : (this.layoutRecord.initial_sort || {}); //Get records this.reloadRecords(); //Set reload rate if defined (or use layout default, if defined) this.reloadRate = this.reloadRate || this.layoutRecord.default_reload_rate; //Kill old interval (if exists) if ($scope.directiveScope.reloadIntervalId) { $interval.cancel($scope.directiveScope.reloadIntervalId); $scope.directiveScope.reloadIntervalId = null; } //Set up interval if > 250ms (to avoid accidental 1ms blasts) if ($scope.directiveScope.reloadRate > 250) { $scope.directiveScope.reloadIntervalId = $interval(() => { //Don't load if already loading var visible = $("#base_list_" + $scope.directiveScope.unique).parent().is(":visible"); if ((visible || $scope.directiveScope.persistentReload) && !$scope.directiveScope.loading) { $scope.directiveScope.reloadRecords(); } }, $scope.directiveScope.reloadRate); } } this.rebuildRecordActionSelections = function() { // Build header selections var defaultHeaderActions = $scope.$root.listHeaderActions ?? []; var modelHeaderActions = ($scope.directiveScope.modelData ?? {}).list_header_actions ?? []; var layoutHeaderActions = ($scope.directiveScope.layoutRecord ?? {}).header_actions ?? []; var headerActionSelections = generateRecordActionSelections($scope, $http, $sce, [ ...defaultHeaderActions, (modelHeaderActions.length > 0 ? "6791b6136732d8705b66b39a" : null), ...modelHeaderActions, (layoutHeaderActions.length > 0 ? "6791b6136732d8705b66b39a" : null), ...layoutHeaderActions ].filter((id) => { return id != null; })); $scope.directiveScope.headerContextSelections = headerActionSelections; // Build record selections var defaultRecordActions = $scope.$root.listRecordActions ?? []; var modelRecordActions = ($scope.directiveScope.modelData ?? {}).list_record_actions ?? []; var layoutRecordActions = ($scope.directiveScope.layoutRecord ?? {}).record_actions ?? []; var recordActionSelections = generateRecordActionSelections($scope, $http, $sce, [ ...defaultRecordActions, (modelRecordActions.length > 0 ? "6791b6136732d8705b66b39a" : null), ...modelRecordActions, (layoutRecordActions.length > 0 ? "6791b6136732d8705b66b39a" : null), ...layoutRecordActions ].filter((id) => { return id != null; })); $scope.directiveScope.recordContextSelections = recordActionSelections; } this.truncateString = function(_string, _maxLength) { _maxLength = _maxLength || 50; if (_string && _string.length > _maxLength) { return _string.substring(0, _maxLength) + "..."; } else { return _string; } } $scope.$watch("directiveScope.query", function(_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { //TLM $scope.directiveScope.skip = 0; $scope.directiveScope.reloadRecords(); } }); this.loadModelData = function() { //Get layout var defaultLayoutId = $scope.$root.models[$scope.directiveScope.modelName].default_list || ($scope.$root.models[$scope.directiveScope.modelName].parent ? $scope.$root.models[$scope.$root.models[$scope.directiveScope.modelName].parent].default_list : null); $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { //Return the specified (or default form) layout return ($scope.directiveScope.layout && $scope.directiveScope.layout == l._id) || (!$scope.directiveScope.layout && l._id == defaultLayoutId); }); //Check layout if (!$scope.directiveScope.layoutRecord) { //Not found $scope.directiveScope.error = "Layout not found" $scope.directiveScope.loading = false; return; } $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; //Add global fields if enabled if ($scope.directiveScope.layoutRecord.display_global_fields && !$scope.directiveScope.layoutRecord.globalFieldLoaded) { Object.keys($scope.$root.globalFields).forEach((fieldName) => { //Only show global fields with __display set if (!$scope.$root.globalFields[fieldName].__display) { return; } var field = $scope.$root.globalFields[fieldName]; $scope.directiveScope.layoutRecord.fields.push({ _id: "test", order: 9999999, row_order: 9999999, placement: "left", name: fieldName, label: $scope.directiveScope.getLabel(fieldName), field_type: "read", control: field.__default_read_control ? field.__default_read_control : null }); }); $scope.directiveScope.layoutRecord.globalFieldLoaded = true; } //Get model data $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; //Add defaultWriteControl for column filtering $scope.directiveScope.layoutRecord.fields.forEach((field) => { if (field.name && !["file", "dynamic_object", "structured_object"].includes(($scope.directiveScope.modelData.fields[field.name] || { type: "unknown" }).type)) { field.filterControl = getDefaultControls($scope, $scope.directiveScope.modelName, field.name).singular_write; } }); //Save applicable layouts $scope.directiveScope.layoutSelections = {}; $scope.$root.layouts.filter((l) => { return l._type == "list_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }).forEach((layout) => { $scope.directiveScope.layoutSelections[layout._id] = { label: layout.display, icon: ($scope.$root.models[layout.model].icon ? $scope.$root.models[layout.model].icon.link : null), class: "ghost" }; }); if ($scope.directiveScope.inWindow) { $("#favicon").attr("href", $scope.directiveScope.modelData.icon ? $scope.directiveScope.modelData.icon.link : null); document.title = "KIM - " + $scope.directiveScope.modelData.plural_name; } //Save applicable layouts $scope.directiveScope.applicableLayouts = $scope.$root.layouts.filter((l) => { return l._type == "list_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }); //Set title of parent window (if on root form) if ($scope.directiveScope.inWindow) { document.title = "KIM - " + $scope.directiveScope.modelData.plural_name; } // Build record actions $scope.directiveScope.rebuildRecordActionSelections(); }; this.updateCurrentURL = function() { $scope.listUrl = "/list?model=" + $scope.directiveScope.modelName + "&query=" + JSON.stringify($scope.directiveScope.query) + "&sort=" + JSON.stringify($scope.directiveScope.sort) + "&skip=" + $scope.directiveScope.skip + "&limit=" + $scope.directiveScope.limit + "&layout=" + $scope.directiveScope.layoutRecord._id + "&reloadRate=" + $scope.directiveScope.reloadRate; setUrl($location, $scope.listUrl) } this.applyEditableQuery = function() { $scope.directiveScope.query = $scope.directiveScope.editableQuery; } this.reloadRecords = function() { $scope.directiveScope.updateEditableQuery(); $scope.directiveScope.loading = true; retrieveRecords($scope.directiveScope, $http, $scope.directiveScope.modelName, { query: $scope.directiveScope.query, sort: $scope.directiveScope.sort, skip: $scope.directiveScope.skip, limit: $scope.directiveScope.limit, populate: $scope.directiveScope.layoutRecord.fields.filter((field) => { return field.populate_mode == "yes"; }).map((field) => { return field.name; }) }, (response) => { $scope.directiveScope.totalCount = response.total_count; response.records.forEach((r) => { r.__trackingId = hashCode(JSON.stringify(r)); }); $scope.directiveScope.records = response.records; $scope.directiveScope.loading = false; if ($scope.directiveScope.inWindow) { $scope.directiveScope.updateCurrentURL(); } //Update binding records $scope.directiveScope.records.forEach((r) => { var existingBindingRecord = $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && Array.isArray($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].find((b) => { return b._id == r._id; }) : null; if (existingBindingRecord) { Object.assign(existingBindingRecord, r); } }); $scope.directiveScope.firstLoad = true; }); } this.changeLayout = function() { setTimeout(function() { $scope.directiveScope.loadModelData(); $scope.directiveScope.updateCurrentURL(); safeApply($scope); }, 1); } this.nextChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip += $scope.directiveScope.limit; $scope.directiveScope.reloadRecords(); } this.previousChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip = Math.max(0, $scope.directiveScope.skip - $scope.directiveScope.limit); $scope.directiveScope.reloadRecords(); } this.firstChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip = 0; $scope.directiveScope.reloadRecords(); } this.endChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip = $scope.directiveScope.totalCount - $scope.directiveScope.limit; $scope.directiveScope.reloadRecords(); } this.invertSort = function(_field) { $scope.directiveScope.firstLoad = false; //Already sorting?' var newDir = "asc"; if ($scope.directiveScope.sort && Object.keys($scope.directiveScope.sort).length > 0) { //Yes, get default or inverted dir newDir = $scope.directiveScope.sort[_field.name] ? { asc: "desc", desc: "asc" } [$scope.directiveScope.sort[_field.name]] : "asc"; } $scope.directiveScope.sort = {}; $scope.directiveScope.sort[_field.name] = newDir; $scope.directiveScope.reloadRecords(); } this.cancel = function() { $scope.directiveScope.parentModal.hide(); } this.done = function() { $scope.directiveScope.parentModal.hide(); } this.cancel = function() { $scope.directiveScope.parentModal.hide(); } this.isSelected = function(_record) { return $scope.directiveScope.selectionMode == "multiple" ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].some((b) => { return b && b._id && b._id == _record._id; }) : false; }; this.getRowClass = function(_record) { try { var classSelection = $scope.directiveScope.modelData.fields[$scope.directiveScope.layoutRecord.class_field].selections[_record[$scope.directiveScope.layoutRecord.class_field]]; } catch (e) {} return $scope.directiveScope.selectionMode == "multiple" && $scope.directiveScope.isSelected(_record) ? "bg-primary text-light" : ( classSelection && $scope.directiveScope.layoutRecord.class_field && $scope.directiveScope.layoutRecord.class_color ? 'bg-gradient-from-left-' + classSelection.class : 'bg-white' ); } this.rowClick = function(_record) { if ($scope.directiveScope.selectionMode == "multiple") { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].some((r) => { return r && (r._id == _record._id) })) { //Remove $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((r) => { return r && (r._id != _record._id); }); } else { //Add (must be set this way to trigger events) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].concat([_record]); } } } this.rowDoubleClick = function(_record) { if ($scope.directiveScope.selectionMode == "single") { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _record; $scope.directiveScope.parentModal.hide(); } else if ($scope.directiveScope.selectionMode == "multiple") { } else if ($scope.directiveScope.inWindow) { //Normal mode, open record console.log($scope.directiveScope.layoutRecord); window.location.href = "/form?model=" + $scope.directiveScope.modelName + "&_id=" + (_record._id ?? "") + ($scope.directiveScope.layoutRecord.default_form_layout ? ("&layout=" + $scope.directiveScope.layoutRecord.default_form_layout) : "") + "&reloadRate=" + $scope.directiveScope.layoutRecord.default_form_reload_rate; } else { //Normal mode, show modal of record $scope.directiveScope.viewRecordModal.id = null; $timeout(() => { $scope.directiveScope.viewRecordModal.layout = ($scope.directiveScope.layoutRecord.default_form_layout || null); $scope.directiveScope.viewRecordModal.model = $scope.directiveScope.modelName; $scope.directiveScope.viewRecordModal.reloadRate = ($scope.directiveScope.layoutRecord.default_form_reload_rate || null); $scope.directiveScope.viewRecordModal.id = _record._id; $scope.directiveScope.viewRecordModal.show(); }, 1); } } this.openInNewTab = function() { window.open($scope.listUrl, "_blank"); } this.AddToBinding = function(_record) { //Add record (must be distinct if {distinct} is true) if (($scope.directiveScope.distinct && !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].find((r) => { return r._id == _record._id; })) || !$scope.directiveScope.distinct) { _record.$selected = true; } }; this.RemoveFromBinding = function(_record) { //Remove _record.$selected = false; }; this.getLabel = function(_name) { return _name.split("_").map((c) => { return c.charAt(0).toUpperCase() + c.slice(1); }).join(" "); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseList failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8c3d50a9cc72d8fcbfd2', ctrl_5f3e8c3d50a9cc72d8fcbfd2); app.directive('dynamicController', function() { return { scope: { supportingJs: "=?", htmlPath: "=?", modelName: "=?", record: "=?", field: "=?", fieldModel: "=?", encodedHtml: "=?" }, controller: ctrl_5f3e8c7050a9cc72d8fcbfd3, template: `
    `, bindToController: true};}); function ctrl_5f3e8c7050a9cc72d8fcbfd3($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; /* $scope.record = this.record; $scope.field = this.field; $scope.modelName = this.modelName; $scope.encodedHtml = this.encodedHtml; $scope.fieldModel = this.fieldModel; */ this.decodeHtml = function() { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } } Object.defineProperty($scope, "record", { get: function() { return $scope.directiveScope.record; } }); Object.defineProperty($scope, "field", { get: function() { return $scope.directiveScope.field; } }); Object.defineProperty($scope, "modelName", { get: function() { return $scope.directiveScope.modelName; } }); Object.defineProperty($scope, "encodedHtml", { get: function() { return $scope.directiveScope.encodedHtml; } }); Object.defineProperty($scope, "fieldModel", { get: function() { return $scope.directiveScope.fieldModel; } }); $scope.$watch('directiveScope.encodedHtml', function (_new, _old, scope) { if (JSON.stringify(_new) == JSON.stringify(_old)) { return; } $scope.directiveScope.decodeHtml(); }); //Inject all control angular-controllers into scope new Function("$scope", "$http", "$location", "$timeout", "$rootScope", "record", this.supportingJs) ( $scope, $http, $location, $timeout, $rootScope, this.record); this.decodeHtml(); this.supportingJsLoaded = true; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicController failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8c7050a9cc72d8fcbfd3', ctrl_5f3e8c7050a9cc72d8fcbfd3); app.directive('modelSelection', function() { return { scope: { parentsOnly: "=?", onChange: "&", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) placeholder: "=?", allowFreeEntry: "=?", rootModel: "=?" }, controller: ctrl_5f3e8d0450a9cc72d8fcbfd6, template: `
    `, bindToController: true};}); function ctrl_5f3e8d0450a9cc72d8fcbfd6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.parentsOnly = this.parentsOnly == null ? false : this.parentsOnly; this.unique = createUniqueTag(); this.search = ""; this.show = false; this.allowFreeEntry = this.allowFreeEntry == null ? false : this.allowFreeEntry; $scope.directiveScope = this; //Get models getModels($scope, $http, (data) => { $scope.directiveScope.modelsData = data; $scope.directiveScope.childModels = {}; $scope.directiveScope.parentModels = {}; Object.keys($scope.directiveScope.modelsData).forEach((modelName) => { var model = $scope.directiveScope.modelsData[modelName]; if (!$scope.directiveScope.rootModel || [model.parent, modelName].includes($scope.directiveScope.rootModel)) { if (!model.parent) { $scope.directiveScope.parentModels[modelName] = model; } else { $scope.directiveScope.childModels[model.parent] = $scope.directiveScope.childModels[model.parent] || {}; $scope.directiveScope.childModels[model.parent][modelName] = model; } } }); $scope.directiveScope.search = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; }); }; this.cancel = function() { $scope.directiveScope.show = false; } this.checkForFreeEntry = function(_freeEntry) { if ($scope.directiveScope.allowFreeEntry) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _freeEntry; } } this.select = function(_modelName) { var previousValue = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _modelName; $scope.directiveScope.search = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; if ($scope.directiveScope.onChange && _modelName != previousValue) { $scope.directiveScope.onChange(); } $scope.directiveScope.show = false; }; this.clear = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; $scope.directiveScope.search = ""; if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(); } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8d0450a9cc72d8fcbfd6', ctrl_5f3e8d0450a9cc72d8fcbfd6); app.directive('singleReferenceSelection', function() { return { scope: { searchFilter: "=?", display: "=?", //Field to display (default if not provided) onChange: "&", subTextField: "=?", refModel: "=", allowNew: "=?", allowView: "=?", allowEdit: "=?", displayRecord: "=?", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) layoutName: "=", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used viewLayout: "=?", placeholder: "=?", allowInteraction: "=?", //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) displayTextClass: "=?", //Whether to apply the context_class to the text displayIcon: "=?", searchLimit: "=?" }, controller: ctrl_5f3e8d3350a9cc72d8fcbfd7, template: `
    None {{directiveScope.getDisplayText()}}
    {{$root.models[directiveScope.refModel].fields[directiveScope.subTextField].selections[directiveScope.displayRecord[directiveScope.subTextField]].label || directiveScope.displayRecord[directiveScope.subTextField]}}
    `, bindToController: true};}); function ctrl_5f3e8d3350a9cc72d8fcbfd7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.listModal = {}; this.currentRecordModal = {}; this.newRecordModal = { newRecord: {} }; this.searchLimit = this.searchLimit ?? ($scope.$root.models[this.refModel] ?? { default_query_limit: 10 }).default_query_limit; this.searchRunning = false; this.searchFilter = this.searchFilter ?? ""; this.searchResults = {}; this.searchOptions = {}; this.searchTotal = 0; this.searchSkip = 0; this.getDisplayText = function() { var displayField = $scope.directiveScope.display ?? ($scope.$root.models[$scope.directiveScope.displayRecord._type ?? $scope.directiveScope.refModel].display_field ?? "_id"); var displayValue = $scope.directiveScope.displayRecord[displayField]; var displaySelections = $scope.$root.models[$scope.directiveScope.displayRecord._type ?? $scope.directiveScope.refModel].fields[displayField].selections ?? {}; return displaySelections && displaySelections[displayValue] ? displaySelections[displayValue].label : displayValue; } this.onSearchFocus = function(h) { if(Object.keys($scope.directiveScope.searchResults).length == 0) { $scope.directiveScope.performSearch(); } } this.performSearch = function(_term) { _term = _term ?? $scope.directiveScope.searchFilter ?? ""; $scope.directiveScope.searchRunning = true; $scope.directiveScope.searchResults = {}; var q = { $and: [ $scope.directiveScope.refQualifier, constructGlobalSearch($scope, $scope.directiveScope.refModel, _term) ] }; var s = {}; s[$scope.directiveScope.display ?? $scope.$root.models[$scope.directiveScope.refModel].display_field] = "asc"; $scope.directiveScope.searchOptions = {}; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: q, sort: s, limit: $scope.directiveScope.searchLimit, skip: $scope.directiveScope.searchSkip }, (searchResponse) => { $scope.directiveScope.searchTotal = searchResponse.total_count; //Add results selections searchResponse.records.forEach((result) => { var model = result._type ?? $scope.directiveScope.refModel; var label = result[$scope.directiveScope.display ?? ($scope.$root.models[model].display_field)] ?? ""; // Append value of field including _term (for UI matching) if (label != null && !label.toLowerCase().includes(_term.toLowerCase())) { for (var fieldName of Object.keys($scope.$root.models[model].fields)) { if (typeof(result[fieldName]) == "string" && result[fieldName].toString().toLowerCase().includes(_term.toLowerCase())) { label += " (" + result[fieldName].truncate(20) + ")"; /* try { atob(result[fieldName]); label += " (" + btoa(_term) + ")"; } catch (e) { label += " (" + result[fieldName] + ")"; } */ break; } } } label = label.length == 0 ? "" + result._id + "" : label; $scope.directiveScope.searchResults[result._id] = { label: label, icon: result.icon ? result.icon.link : ($scope.$root.models[result._type ?? $scope.directiveScope.refModel].icon.link), subIcon: result.context_icon }; }); if ($scope.directiveScope.searchTotal > searchResponse.records.length + $scope.directiveScope.searchSkip) { //Add 'next' selection $scope.directiveScope.searchOptions.next = { label: "Show next " + $scope.directiveScope.searchLimit + " (of " + $scope.directiveScope.searchTotal + ")...", icon: "/media/right_arrow_icon.png", class: "theme", onClick: function() { $scope.directiveScope.searchSkip += $scope.directiveScope.searchLimit; $scope.directiveScope.performSearch(); } } } if ($scope.directiveScope.searchSkip > 0) { //Add 'previous' selection $scope.directiveScope.searchOptions.previous = { label: "Show previous " + $scope.directiveScope.searchLimit + " (of " + $scope.directiveScope.searchTotal + ")...", icon: "/media/left_arrow_icon.png", class: "theme", onClick: function() { $scope.directiveScope.searchSkip -= $scope.directiveScope.searchLimit; $scope.directiveScope.performSearch(); } } } $scope.directiveScope.searchRunning = false; //Need to run again? if (_term != ($scope.directiveScope.searchFilter ?? "")) { $scope.directiveScope.performSearch(); } }); } this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; this.displayIcon = this.displayIcon == null ? true : this.displayIcon; $scope.directiveScope = this; this.unique = createUniqueTag(); this.loading = false; this.refQualifier = this.refQualifier ?? {}; //Normlize binding (to single id string or null) if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && this.bindingParent[this.bindingName] && typeof(this.bindingParent[this.bindingName]) == "object") { //Load in the populated record this.displayRecord = this.bindingParent[this.bindingName]; //If in interactive mode, set the binding to the _id, otherwise leave as is (possibly populated) this.bindingParent[this.bindingName] = this.allowInteraction ? this.displayRecord._id : this.displayRecord; } else { //id or null provded, load bound record this.loading = true; if (this.bindingParent[this.bindingName]) { //Get existing record this.loadDisplayRecord(); } else { this.displayRecord = null; this.loading = false; } } //Wach for search filter change $scope.$watch("directiveScope.searchFilter", (_new, _old) => { _new = _new ?? ""; _old = _old ?? ""; if (_new.length == 0 && _old.length > 0) { $scope.directiveScope.searchSkip = 0; } if (_new != _old && !$scope.directiveScope.searchRunning) { $scope.directiveScope.performSearch(); } }); //Watch for ref qualifier change $scope.$watch("directiveScope.refQualifier", (_new, _old) => { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.searchSkip = 0; $scope.directiveScope.performSearch(); } }); //Watch for binding change $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (newValue, oldValue, scope) { if (newValue != oldValue && !$scope.directiveScope.displayUpdating) { $scope.directiveScope.bindingUpdating = true; $scope.directiveScope.loadDisplayRecord(() => { $scope.directiveScope.bindingUpdating = false; }); } }, true); //Watch for record change $scope.$watch('directiveScope.displayRecord', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.displayUpdating = true; //If in interactive mode, set the binding to the _id, otherwise leave as is (possibly populated) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.displayUpdating = false; $scope.directiveScope.onChange(); } }, true); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); } this.loadDisplayRecord = function(_then) { if (!$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { // Null reference, clear display record $scope.directiveScope.displayRecord = null; $scope.directiveScope.loading = false; if (_then) { _then(); } } else { // Non-null, load display record retrieveRecord($scope, $http, $scope.directiveScope.refModel, { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }, cached: true }, (record) => { $scope.directiveScope.displayRecord = record; $scope.directiveScope.loading = false; if (_then) { _then(); } }); } } this.showCurrent = function(_event) { if ($scope.directiveScope.allowView && $scope.directiveScope.displayRecord) { if (_event.ctrlKey) { // CTRL pressed, open in new tab window.open("/form?model=" + $scope.directiveScope.refModel + "&_id=" + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName], '_blank'); } else if (_event.shiftKey) { // Shift pressed, open in new window window.open("/form?model=" + $scope.directiveScope.refModel + "&_id=" + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } else { // No CTRL key, show in modal this.currentRecordModal.show(() => { this.loadDisplayRecord(); }); } } } this.showNew = function() { this.newRecordModal.newRecord = {}; this.newRecordModal.show(() => { if (this.newRecordModal.newRecord._id) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = this.newRecordModal.newRecord._id.toString(); this.loadDisplayRecord(); this.newRecordModal.newRecord = {}; } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8d3350a9cc72d8fcbfd7', ctrl_5f3e8d3350a9cc72d8fcbfd7); app.directive('singleReferenceDropdownSelection', function() { return { scope: { title: "=", display: "=?", refModel: "=", refQualifier: "=?", sort: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) onChange: "&", displayRecord: "=?", allowInteraction: "=?", selectSingleResult: "=?" }, controller: ctrl_5f3e8d6850a9cc72d8fcbfd8, template: ` `, bindToController: true};}); function ctrl_5f3e8d6850a9cc72d8fcbfd8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.display = this.display == null ? $scope.$root.models[this.refModel].display_field : this.display; $scope.directiveScope = this; this.updateDisplayRecord = function() { if (!$scope.directiveScope.bindingParent || !$scope.directiveScope.bindingName || !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || !$scope.directiveScope.selections) { $scope.directiveScope.displayRecord = null; } else { $scope.directiveScope.displayRecord = $scope.directiveScope.selections[$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]].record; } } //Populate selections retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: ($scope.directiveScope.refQualifier ? $scope.directiveScope.refQualifier : {}), sort: ($scope.directiveScope.sort || {}) }, (response) => { $scope.directiveScope.selections = { }; response.records.forEach((record) => { $scope.directiveScope.selections[record._id] = { label: record[$scope.directiveScope.display], icon: record.icon ? record.icon.link : ($scope.$root.models[record._type || $scope.directiveScope.refModel].icon.link), record: record }; }); if ($scope.directiveScope.selectSingleResult && response.records.length == 1) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = response.records[0]._id; } }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Update display record if binding changes $scope.directiveScope.updateDisplayRecord(); }); $scope.$watch("directiveScope.selections", () => { //Update display record if selections change (sometimes the binding is set before the selections are available) $scope.directiveScope.updateDisplayRecord(); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceDropdownSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8d6850a9cc72d8fcbfd8', ctrl_5f3e8d6850a9cc72d8fcbfd8); app.directive('multipleReferenceSelection', function() { return { scope: { onChange: "&", allowNew: "=?", allowInteraction: "=?", allowDuplicates: "=?", title: "=", refModel: "=", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) distinct: "=", displayRecords: "=?", //For exaternal reference only layoutName: "=?", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used ordered: "=?", limit: "=?", allowSelectAll: "=?", subIconField: "=?", displayTextClass: "=?", displayField: "=?", onClickOverride: "=?", maxHeight: "=?", subTextField: "=?" }, controller: ctrl_5f3e8d9c50a9cc72d8fcbfd9, template: `
    `, bindToController: true};}); function ctrl_5f3e8d9c50a9cc72d8fcbfd9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; $scope.directiveScope = this; this.ordered = this.ordered == null ? true : this.ordered; this.allowDuplicates = this.allowDuplicates == null ? true : this.allowDuplicates; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] == null ? [] : this.bindingParent[this.bindingName]; this.newRecordModal = { id: null }; this.allowDropMethod = function(_drop, _drag) { return _drag != _drop && _drag != _drop - 1; } this.onDrop = function(_drop, _drag) { $scope.directiveScope.moveRecord(_drag, _drop); } this.newRecordFilter = ""; this.newRecordId = null; this.newEntryElement = createUniqueTag(); waitForElement(this.newEntryElement, (e) => { $scope.directiveScope.newEntryElement = e; }); $scope.$watch('directiveScope.newRecordId', function (_new, _old) { if (_new && !_old) { if ($scope.directiveScope.allowDuplicates || !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].includes(_new)) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push(_new); } $scope.directiveScope.newRecordId = null; $scope.directiveScope.newRecordFilter = ""; $scope.directiveScope.updateDisplay(); safeApply($scope); } }); this.maxHeight = this.maxHeight ?? 200; this.displayRecords = []; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.refQualifier = this.refQualifier == null ? {} : this.refQualifier; $scope.parentBaseFormScope = searchFullScope($scope.$parent, "directiveScope") //CLone ref qualifier into malleable object this.qualifier = {}; Object.assign(this.qualifier, this.refQualifier); //Create unique tag this.unique = createUniqueTag() //Normalize binding (to array of id strings or empty array) if (Array.isArray(this.bindingParent[this.bindingName]) && this.bindingParent[this.bindingName].some((v) => { return typeof(v) == "object"; })) { //Array of objects provided Object.assign(this.displayRecords, this.bindingParent[this.bindingName]); } else { $scope.directiveScope.updateDisplay(); } $scope.$watch('directiveScope.displayRecords', function (_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.updateBinding(); } }); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.updateDisplay(); } }, true); }; this.selectionsQualifier = { value: null, get binding() { var q = { $and: (() => { return $scope.directiveScope.refQualifier ? [$scope.directiveScope.refQualifier] : []; })() } //Add unique clause if (!$scope.directiveScope.allowDuplicates && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].length > 0) { q.$and.push({ _id: { $nin: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }}); } if (JSON.stringify($scope.directiveScope.selectionsQualifier.value) != JSON.stringify(q)) { $scope.directiveScope.selectionsQualifier.value = q; } return $scope.directiveScope.selectionsQualifier.value; } } this.updateDisplay = function() { if (!$scope.directiveScope.loading) { $scope.directiveScope.loading = true //Array of IDs supplied, populate dispalyRecords if (!$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.displayRecords = []; $scope.directiveScope.updateBinding(); $scope.directiveScope.loading = false; } else { retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: { _id: { $in: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } } }, (response) => { $scope.directiveScope.displayRecords = []; //Set displayRecords in same order as binding to avoid reordering for(var i in $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { var record = response.records.find((r) => { return r._id == $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][i]; }); if (record) { record._list_tag = "v_" + record._id + "_" + i; $scope.directiveScope.displayRecords.push(cloneObject(record)); } } $scope.directiveScope.updateBinding(); $scope.directiveScope.loading = false; }); } } } this.removeEntry = function(_index) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].removeIndex(_index); } this.updateBinding = function() { if (!$scope.directiveScope.loading) { $scope.directiveScope.loading = true $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecords.filter((r) => { return r && r._id; }).map((r) => { return r._id }); $scope.directiveScope.loading = false; $scope.directiveScope.onChange(); } } this.moveRecord = function(_index, _newIndex) { $scope.directiveScope.displayRecords.splice(_newIndex, 0, $scope.directiveScope.displayRecords.splice(_index, 1)[0]); $scope.directiveScope.updateBinding(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleReferenceSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8d9c50a9cc72d8fcbfd9', ctrl_5f3e8d9c50a9cc72d8fcbfd9); app.directive('baseAlert', function() { return { scope: {}, controller: ctrl_5f3e8dca50a9cc72d8fcbfda, template: ` `, bindToController: true};}); function ctrl_5f3e8dca50a9cc72d8fcbfda($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { $scope.currentTimeout = null; $scope.$root.lowestAlertScope = Math.min($scope.$id, $scope.$root.lowestAlertScope ?? 999999); $scope.$root.$on('showAlert', function(event, _message, _severity, _timeout) { if ($scope.$id == $scope.$root.lowestAlertScope) { if ($scope.currentTimeout) { $timeout.cancel($scope.currentTimeout); } _severity = _severity ? _severity : "primary"; $scope.severity = _severity; $scope.text = _message ; $scope.visible = true; $scope.loaded = true; $scope.currentTimeout = $timeout(() => { $scope.visible = false; }, Math.max(2000, _timeout || _message.split(" ").length * 500)); } }); $scope.toTrusted = function(_html) { return $sce.trustAsHtml(_html); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseAlert failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8dca50a9cc72d8fcbfda', ctrl_5f3e8dca50a9cc72d8fcbfda); app.directive('nodeRelationMap', function() { return { scope: { nodes: "=", relations: "=?", options: "=?", onNodeSelection: "=?", onRelationSelection: "=?" }, controller: ctrl_5f3e8e5a50a9cc72d8fcbfdc, template: `
    Building node map...
    `, bindToController: true};}); function ctrl_5f3e8e5a50a9cc72d8fcbfdc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { $element.append($compile("
    ")($scope)); this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; var defaults = { height: "500px", width: "100%", nodes: { shape: 'image', size: 20 }, edges: { arrows: "to" }, layout: { improvedLayout: true, hierarchical: { // direction: "UD", //sortMethod: "directed" } }, physics: { enabled: false } }; Object.assign(defaults, this.options); this.options = defaults; waitForElement('nodemap_' + this.unique, (element) => { $scope.directiveScope.container = element; $scope.directiveScope.redraw(); }); $scope.$watch('directiveScope.nodes', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.redraw(); } }, true); $scope.$watch('directiveScope.relations', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.redraw(); } }, true); }; this.redraw = function() { this.network = new vis.Network(this.container, { nodes: new vis.DataSet(this.nodes || []), edges: new vis.DataSet(this.relations || []) }, this.options); this.network.stabilize(10); this.network.on("selectNode", (_data) => { if (this.onNodeSelection) { this.onNodeSelection(_data); } }); this.network.on("selectEdge", (_data) => { if (this.onRelationSelection) { this.onRelationSelection(_data); } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nodeRelationMap failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8e5a50a9cc72d8fcbfdc', ctrl_5f3e8e5a50a9cc72d8fcbfdc); app.directive('workflowProgress', function() { return { scope: { stages: "=?", bindingParent: "=?", bindingName: "=?", setBindingOnSelection: "=?", onStageSelection: "=?" }, controller: ctrl_5f3e8e7650a9cc72d8fcbfdd, template: `
    `, bindToController: true};}); function ctrl_5f3e8e7650a9cc72d8fcbfdd($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.setBindingOnSelection = this.setBindingOnSelection == null ? true : this.setBindingOnSelection; this.stageSelected = function(_stageId) { if ($scope.directiveScope.setBindingOnSelection && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _stageId; } if ($scope.directiveScope.onStageSelection) { $scope.directiveScope.onStageSelection(_stageId); } } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: workflowProgress failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8e7650a9cc72d8fcbfdd', ctrl_5f3e8e7650a9cc72d8fcbfdd); app.directive('singleFileUpload', function() { return { scope: { bindingParent: "=", bindingName: "=", acceptedExtensions: "=?", imagePreview: "=?", imagePreviewSize: "=?", allowDownload: "=?", readOnly: "=?", //Remove this later allowInteraction: "=?", showPreview: "=?", showTag: "=?", showFile: "=?", truncateLength: "=?", allowPrint: "=?", printerSelectionQualifier: "=?", defaultPrinter: "=?" //For initial set }, controller: ctrl_5f3e8eb050a9cc72d8fcbfde, template: `
    {{directiveScope.truncate(directiveScope.bindingParent[directiveScope.bindingName].name)}}.{{directiveScope.bindingParent[directiveScope.bindingName].extension}} {{directiveScope.formatDataSize(directiveScope.bindingParent[directiveScope.bindingName].size)}} {{directiveScope.bindingParent[directiveScope.bindingName].data && !directiveScope.bindingParent[directiveScope.bindingName].link ? " - Pending" : ""}}
    {{directiveScope.getTrustedResourceUrl(directiveScope.bindingParent[directiveScope.bindingName].link)}}
    Printer
    `, bindToController: true};}); function ctrl_5f3e8eb050a9cc72d8fcbfde($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.formatDataSize = formatDataSize; this.showFile = this.showFile == null ? true : this.showFile; this.imagePreviewExtensions = ["png", "jpg", "jpeg", "ico", "bmp", "webp"]; this.showPreview = this.showPreview == null ? true : this.showPreview; this.trustAsResourceUrl = function(_url) { return $sce.trustAsResourceUrl(_url); } this.truncateLength = this.truncateLength == null ? 999 : this.truncateLength; this.allowDownload = this.allowDownload == null ? true : this.allowDownload; this.printer = this.defaultPrinter ? this.defaultPrinter + "" : null; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; $scope.directiveScope = this; this.previewModal = { buttons: {} }; if (this.allowPrint) { this.previewModal.buttons.print = { label: "Print", class: "primary" }; } if (this.allowDownload) { this.previewModal.buttons.download = { label: "Download", class: "success" }; } this.showPreviewModal = function() { if ($scope.directiveScope.showPreview) { $scope.directiveScope.firstOpen = true; $scope.directiveScope.previewModal.title = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].name + " (" + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].extension + ")", $scope.directiveScope.previewModal.show((selection) => { if (selection == "print") { printLink($scope, $http, $scope.directiveScope.printer, $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, { }, () => { }); } else if (selection == "download") { downloadLink($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].name + "." + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].extension); } }); } else { window.open($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, '_blank'); } } this.truncate = function(_string) { return _string.truncate($scope.directiveScope.truncateLength); } this.formatSize = function(_size) { if (_size > 1073741823) { return (_size / 1073741824).toFixed(0) + " GB"; } else if (_size > 1048575) { return (_size / 1048576).toFixed(0) + " MB"; } else if (_size > 1023) { return (_size / 1024).toFixed(0) + " KB"; } else { return _size + " Bytes"; } } this.openBrowser = function() { $("#" + this.unique).click(); }; this.changed = function(_event){ var reader = new FileReader(); var targetFile = _event.target.files[0]; reader.readAsDataURL(targetFile); var nameSplit = targetFile.name.split("."); reader.onloadend = (e) => { //Build file payload to be handled at the model level this.bindingParent[this.bindingName] = { data: reader.result.split(",")[1], extension: nameSplit.length > 1 ? nameSplit.pop() : "", name: nameSplit.join("."), size: targetFile.size, }; $rootScope.$digest(); }; } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleFileUpload failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8eb050a9cc72d8fcbfde', ctrl_5f3e8eb050a9cc72d8fcbfde); app.directive('multipleFileUpload', function() { return { scope: { bindingParent: "=", bindingName: "=", acceptedExtensions: "=?", imagePreview: "=?", imagePreviewSize: "=?", allowDownload: "=?", showTags: "=?", allowInteraction: "=?" }, controller: ctrl_5f3e8ed650a9cc72d8fcbfdf, template: `
    `, bindToController: true};}); function ctrl_5f3e8ed650a9cc72d8fcbfdf($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowDownload = this.allowDownload == null ? true : this.this.allowDownload; this.imagePreviewSize = this.imagePreviewSize == null ? 100 : this.imagePreviewSize; $scope.directiveScope = this; this.newUpload = null; $scope.$watch("directiveScope.newUpload", function (newValue, oldValue, scope) { if ($scope.directiveScope.newUpload) { $scope.directiveScope.newUpload.unique = new Date().getTime(); $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push($scope.directiveScope.newUpload); $scope.directiveScope.newUpload = null; } }); this.removeEntry = function(_index) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].removeIndex(_index); } this.moveFile = function(_index, _newIndex) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].splice(_newIndex, 0, $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].splice(_index, 1)[0]); } this.allowDropMethod = function(_drop, _drag) { return _drag != _drop && _drag != _drop - 1; } this.onDrop = function(_drop, _drag) { $scope.directiveScope.moveFile(_drag, _drop); } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleFileUpload failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3e8ed650a9cc72d8fcbfdf', ctrl_5f3e8ed650a9cc72d8fcbfdf); app.directive('printTemplateRenderer', function() { return { scope: { templateId: "=", templateData: "=?", fileType: "=?", modelName: "=?", modelQuery: "=?" } , controller: ctrl_5f4ff2e22c4f26499f6f39ec, template: `
    `, bindToController: true};}); function ctrl_5f4ff2e22c4f26499f6f39ec($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { //Break binding of value this.unique = createUniqueTag(); this.templateData = this.templateData || {}; $scope.directiveScope = this; this.url = ""; this.fileType = this.fileType || "png" this.update(); } $scope.$watch("directiveScope.templateId", () => { $scope.directiveScope.update(); }); $scope.$watch("directiveScope.templateData", () => { $scope.directiveScope.update(); }, true); $scope.$watch("directiveScope.fileType", () => { $scope.directiveScope.update(); }, true); $scope.$watch("directiveScope.modelName", () => { $scope.directiveScope.update(); }); $scope.$watch("directiveScope.modelQuery", () => { $scope.directiveScope.update(); }, true); this.update = function() { $scope.directiveScope.url = "/api/render/template/" + $scope.directiveScope.templateId + "/image/" + $scope.directiveScope.fileType + "?data=" + btoa(unescape(encodeURIComponent(JSON.stringify($scope.directiveScope.templateData)))) + ($scope.directiveScope.modelName ? ("&modelName=" + $scope.directiveScope.modelName) : "") + ($scope.directiveScope.modelQuery ? ("&modelQuery=" + btoa(unescape(encodeURIComponent(JSON.stringify($scope.directiveScope.modelQuery))))) : ""); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printTemplateRenderer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f4ff2e22c4f26499f6f39ec', ctrl_5f4ff2e22c4f26499f6f39ec); app.directive('barcode', function() { return { scope: { value: "=", type: "=?", includeText: "=?", actualLength: "=?", actualWidth: "=?", square: "=?", barColor: "=?", backgroundColor: "=?" } , controller: ctrl_5f50418e0c22a85c66acf7e0, template: `
    {{directiveScope.value}}
    `, bindToController: true};}); function ctrl_5f50418e0c22a85c66acf7e0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.type = this.type || "code128"; this.mmL = this.actualLength || 20; this.mmW = this.actualWidth || 20; this.barColor = this.barColor || "#000000"; this.backgroundColor = this.backgroundColor || "#ffffff"; if (this.square) { var s = Math.min(this.mmL, this.mmW); this.mmL = s; this.mmW = s; } $scope.$watch("directiveScope.value", () => { $scope.directiveScope.url = "/api/barcode/generate/" + $scope.directiveScope.type + "/" + encodeURIComponent(btoa($scope.directiveScope.value)) + "?length=" + $scope.directiveScope.mmL + "&width=" + $scope.directiveScope.mmW + "&includeText=" + JSON.stringify(!!$scope.directiveScope.includeText) + "&base64=true" + "&barColor=" + $scope.directiveScope.barColor + "&backgroundColor=" + $scope.directiveScope.backgroundColor }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: barcode failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f50418e0c22a85c66acf7e0', ctrl_5f50418e0c22a85c66acf7e0); app.directive('encodedContainer', function() { return { scope: { encodedHtml: "=" }, controller: ctrl_5f52eecf577d7429fcaa0466, template: `
    `, bindToController: true};}); function ctrl_5f52eecf577d7429fcaa0466($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch('directiveScope.encodedHtml', function (newValue, oldValue, scope) { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: encodedContainer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f52eecf577d7429fcaa0466', ctrl_5f52eecf577d7429fcaa0466); app.directive('arrayEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", defaultValue: "=?", columnNames: "=?", onChange: "&" }, transclude: { value1: "?value1", value2: "?value2", value3: "?value3", value4: "?value4", value5: "?value5", value6: "?value6", value7: "?value7", value8: "?value8", value9: "?value9", value10: "?value10", value11: "?value11", value12: "?value12", value13: "?value13", value14: "?value14", value15: "?value15", value16: "?value16", value17: "?value17", value18: "?value18", value19: "?value19", value20: "?value20" }, controller: ctrl_5f559ae6ad965a684404dd15, template: `
    {{columnName}}
    `, bindToController: true};}); function ctrl_5f559ae6ad965a684404dd15($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.defaultValue = this.defaultValue != null ? this.defaultValue : null; this.columnNames = this.columnNames != null ? this.columnNames : []; $scope.directiveScope = this; this.addValue = function() { this.bindingParent[this.bindingName].push(cloneObject(this.defaultValue)); if (this.onChange) { this.onChange(); } } this.removeValue = function(_index) { this.bindingParent[this.bindingName].splice(_index, 1); } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: arrayEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f559ae6ad965a684404dd15', ctrl_5f559ae6ad965a684404dd15); app.directive('dynamicAngularControl', function() { return { scope: { supportingJs: "=?", encodedHtml: "=" }, controller: ctrl_5f6bdf5c67ff216a389cb7b7, template: `
    `, bindToController: true};}); function ctrl_5f6bdf5c67ff216a389cb7b7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch('directiveScope.encodedHtml', function (newValue, oldValue, scope) { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } }); $scope.$watch('directiveScope.supportingJs', function (newValue, oldValue, scope) { try { new Function("$appScope", "$scope", "$http", "$sce", "$location", "$timeout", "$rootScope", $scope.directiveScope.supportingJs)($scope.$parent.$parent, $scope, $http, $sce, $location, $timeout, $rootScope); } catch (e) { console.log("Error initializing Dynamic Angular Control directive: " + e); } }); this.scriptLoaded = true; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicAngularControl failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f6bdf5c67ff216a389cb7b7', ctrl_5f6bdf5c67ff216a389cb7b7); app.directive('printTemplateEditor', function() { return { scope: { templateId: "=", value: "=", field: "=?", x: "=", y: "=", length: "=?", width: "=?", rotation: "=?", borderStyle: "=?", borderWidth: "=?", borderColor: "=?", borderRadius: "=?", parameters: "=?" } , controller: ctrl_5f74faca382d7210bac7e482, template: `
    `, bindToController: true};}); function ctrl_5f74faca382d7210bac7e482($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { //Break binding of value this.unique = createUniqueTag(); $scope.directiveScope = this; //Set defaults/static this.x = this.x || 0; this.y = this.y || 0; this.rotation = this.rotation || 0; this.parameters = this.parameters || {}; //Get template record retrieveRecord($scope, $http, "print_template", { query: { _id: this.templateId }}, (templateRecord) => { //Set default dimensions this.length = this.length || (templateRecord.default_length || 10); this.width = this.width || (templateRecord.default_width || 10); if (this.rotation >= 270) { this.yOffset = this.width; this.xOffset = 0; } else if (this.rotation >= 180) { this.yOffset = this.length; this.xOffset = this.width; } else if (this.rotation >= 90 ) { this.yOffset = 0; this.xOffset = this.length; } else { this.yOffset = 0; this.xOffset = 0; } //Merge template parameters with baseParameters templateRecord.parameters = templateRecord.parameters || {}; //Apply parameter defaults to unassigned Object.keys(templateRecord.parameters).forEach((parameter) => { this.parameters[parameter] = this.parameters.hasOwnProperty(parameter) ? this.parameters[parameter] : templateRecord.parameters[parameter].default; }); //Decode HTML templateRecord.decodedHtml = templateRecord.html.length > 1 ? decodeHtml(templateRecord.html) : null; this.templateRecord = templateRecord; }); }; function toRad(_deg) { return _deg * (Math.PI / 180); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printTemplateEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f74faca382d7210bac7e482', ctrl_5f74faca382d7210bac7e482); app.directive('toggleSwitch', function() { return { scope: { bindingName: "=", bindingParent: "=", onChange: "&", readOnly: "=?", trueLabel: "=?", falseLabel: "=?", trueClass: "=?", falseClass: "=?", trueImage: "=?", falseImage: "=?", size: "=?" }, controller: ctrl_5f8838ff9b63ee50b8a3f515, template: ` `, bindToController: true};}); function ctrl_5f8838ff9b63ee50b8a3f515($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.size = this.size == null ? "slim" : this.size; this.trueLabel = this.trueLabel == null ? "Yes" : this.trueLabel; this.falseLabel = this.falseLabel == null ? "No" : this.falseLabel; this.trueClass = this.trueClass == null ? "success" : this.trueClass; this.falseClass = this.falseClass == null ? "secondary" : this.falseClass; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: toggleSwitch failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f8838ff9b63ee50b8a3f515', ctrl_5f8838ff9b63ee50b8a3f515); app.directive('pressureTestResults', function() { return { scope: { item: "=", pressureTest: "=", bindingParent: "=?", bindingName: "=?", selectedIndex: "=?" }, controller: ctrl_5f8e29545abe620cedb62fb4, template: `
    Unit Test Points Avg. Deviation Polynomial Result Cal Card
    {{unitResults.points.length}}
    {{unitResults.average_deviation | number}} {{directiveScope.itemRecord.pressure_unit_symbol_mode}} ({{(unitResults.average_deviation_percent) * 100 | number }}%)
    m: {{unitResults.polynomial.m | number}} b: {{unitResults.polynomial.b | number}}
    {{unitResults.pass != null ? (unitResults.pass ? 'Pass' : 'Fail') : 'Incomplete'}}
    Timestamp Supply V. Temperature °C Applied Px. {{directiveScope.itemRecord.pressure_unit_symbol_mode}} Analog Output {{directiveScope.itemRecord.output_unit_symbol}} Px. Output {{directiveScope.itemRecord.pressure_unit_symbol_mode}} Deviation Result
    {{point.timestamp | date:'medium'}} {{point.supply_voltage | number}} {{point.temperature | number}} {{point.pressure_applied | number}} {{point.analog_measured | number}} {{point.pressure_measured | number}} {{point.deviation | number}} ({{point.deviation_percent * 100 | number}}%) {{point.pass ? 'PASS' : 'FAIL'}}
    Rendering... `, bindToController: true};}); function ctrl_5f8e29545abe620cedb62fb4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.calCardModal = { viewCalCard: function(_unitId) { $scope.directiveScope.calCardModal.renderUrl = "/api/render/template/" + $scope.directiveScope.itemRecord.series_data.calibration_card_template + "/image/pdf?modelName=pressure_test&modelQuery=" + btoa(JSON.stringify({ _id: $scope.directiveScope.pressureTest })) //+ "&data=" + btoa(JSON.stringify({ unitId: _unitId })); $scope.directiveScope.calCardModal.show(); } }; this.itemRecord = { accuracy: 0 }; retrieveRecord($scope, $http, "virtual_sage_item", { query: { _id: this.item }}, (itemRecord) => { this.itemRecord = itemRecord; }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pressureTestResults failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f8e29545abe620cedb62fb4', ctrl_5f8e29545abe620cedb62fb4); app.directive('lineChart', function() { return { scope: { seriesConfig: "=?", seriesData: "=?", axisXLabel: "=?", axisYLabel: "=?", printMode: "=?", axisYMax: "=?", axisYMin: "=?", chartOptions: "=?" }, controller: ctrl_5f8f3f5c4a10fc529fe4b9cc, template: `
    In Development
    `, bindToController: true};}); function ctrl_5f8f3f5c4a10fc529fe4b9cc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; //Configure watch $scope.$watch('[directiveScope.seriesConfig, directiveScope.seriesData]', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); this.chartOptions = { devicePixelRatio: this.printMode ? 8 : 1, responsive: true, maintainAspectRatio: false, usePointStyle: true, scales: { yAxes: [{ ticks: { fontSize: 10, weight: "strong", min: $scope.directiveScope.axisYMin, max: $scope.directiveScope.axisYMax }, scaleLabel: { display: true, labelString: this.axisYLabel, fontSize: 10, fontWeight: "strong", padding: 0 } }], xAxes: [{ ticks: { fontSize: 10, weight: "strong" }, scaleLabel: { display: true, labelString: this.axisXLabel, fontSize: 10, fontWeight: "strong", padding: 0 } }] } }; }; this.process = function() { //Get array of series names from seriesConfig this.chartSeries = Object.values(this.seriesConfig).map((s) => { return s.label; }); //Get array of X axis values this.chartLabels = Object.keys(this.seriesData); //Sort the X axis labels if theyre all numbers if (!this.chartLabels.some((l) => { return isNaN(parseFloat(l)); })) { this.chartLabels = this.chartLabels.sort((a, b) => { return parseFloat(a) > parseFloat(b) ? 1 : -1; }); } //Generate chartData (array (of arrays of Y values), one for each series) this.chartData = Object.keys(this.seriesConfig).map((seriesName) => { return this.chartLabels.map((label) => { var point = this.seriesData[label]; return point[seriesName] ? point[seriesName].value : null; }); }); //Generate chartColors this.chartColors = Object.keys(this.seriesConfig).map((c) => { return { pointRadius: 0 //pointBorderColor: Object.values(this.seriesData).map((d) => { return d[c].pointColor; }), //pointBackgroundColor: Object.values(this.seriesData).map((d) => { return d[c].pointColor; }) }; }); //Generate chartDatasetOverride this.chartDatasetOverride = Object.values(this.seriesConfig).map((c) => { return { backgroundColor: c.fillColor, fill: c.fill ? c.fillMode : false, borderColor: c.lineColor }; }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: lineChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f8f3f5c4a10fc529fe4b9cc', ctrl_5f8f3f5c4a10fc529fe4b9cc); app.directive('spinner', function() { return { scope: { } , controller: ctrl_5f96205725699c5e58d816f2, template: `
    `, bindToController: true};}); function ctrl_5f96205725699c5e58d816f2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; // Added this comment }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: spinner failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f96205725699c5e58d816f2', ctrl_5f96205725699c5e58d816f2); app.directive('tabContainer', function() { return { scope: { tabs: "=?", currentTab: "=?", dynamic: "=?" //True: will populate tabs with their respective 'html' property, otherwise use the static transclusion }, transclude: true, controller: ctrl_5f995a73b6a2e144ba7ac6b5, template: `
    `, bindToController: true};}); function ctrl_5f995a73b6a2e144ba7ac6b5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.tabs = this.tabs || {}; this.unique = createUniqueTag(); $scope.directiveScope = this; this.dynamic = this.dynamic || false; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: tabContainer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f995a73b6a2e144ba7ac6b5', ctrl_5f995a73b6a2e144ba7ac6b5); app.directive('booleanDisplay', function() { return { scope: { bindingName: "=", bindingParent: "=", trueLabel: "=?", falseLabel: "=?", onChange: "&" }, controller: ctrl_5f9ac932e0aef53f2ef0e004, template: ` `, bindToController: true};}); function ctrl_5f9ac932e0aef53f2ef0e004($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: booleanDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f9ac932e0aef53f2ef0e004', ctrl_5f9ac932e0aef53f2ef0e004); app.directive('progressBar', function() { return { scope: { displayStyle:"=?", bindingName: "=", bindingParent: "=", valueMax: "=?", valueMin: "=?", barClass: "=?", textClass: "=?", text: "=?", height: "=?" }, controller: ctrl_5f9ad4b6c7e18c4624d307d2, template: `
    {{directiveScope.text}}
    {{directiveScope.text}}
    `, bindToController: true};}); function ctrl_5f9ad4b6c7e18c4624d307d2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayStyle = this.displayStyle == null ? "bar" : this.displayStyle; this.valueMax = this.valueMax == null ? 1 : this.valueMax; this.valueMin = this.valueMin == null ? 0 : this.valueMin; this.barClass = this.barClass == null ? 'primary' : this.barClass; this.textClass = this.textClass == null ? (this.displayStyle == "ring" ? 'secondary' : 'light') : this.textClass; } // ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: progressBar failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f9ad4b6c7e18c4624d307d2', ctrl_5f9ad4b6c7e18c4624d307d2); app.directive('hoverFlip', function() { return { scope: { }, transclude: { default: "default", flip: "flip" }, controller: ctrl_5f9cbb4a3b8b3d61285a5a30, template: `
    `, bindToController: true};}); function ctrl_5f9cbb4a3b8b3d61285a5a30($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: hoverFlip failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f9cbb4a3b8b3d61285a5a30', ctrl_5f9cbb4a3b8b3d61285a5a30); app.directive('modal', function() { return { scope: { directiveRef: "=", title: "=?", buttons: "=?", allowClose: "=?", large: "=?", container: " { b.enabled = (b.enable == null ? () => { return true; } : (typeof(b.enable) == "boolean" ? () => { return b.enable; } : new Function("directiveScope", b.enable) ) ); }); //Set up reference object scope.directiveScope.directiveRef.hide = function() { setTimeout(() => { $("#" + scope.directiveScope.unique).modal('hide'); scope.directiveScope.directiveRef.visible = false; }, 200); } $(document).on('hidden.bs.modal', "#" + scope.directiveScope.unique, () => { if (scope.directiveScope.then) { scope.directiveScope.then(); } }); scope.directiveScope.directiveRef.show = function(_then) { scope.directiveScope.then = (button) => { if (button == null || scope.directiveScope.buttons[button].closeOnSelection != false) { scope.directiveScope.directiveRef.hide(); } if(_then) { _then(button, scope.directiveScope.directiveRef); } } scope.directiveScope.firstOpen = true; if (!scope.directiveScope.directiveRef.visible) { scope.directiveScope.directiveRef.visible = true; safeApply(scope); $("#" + scope.directiveScope.unique).appendTo("body").modal('show'); } } }, controller: ctrl_5f9e3eee6795b23a923439b9, template: ``, bindToController: true};}); function ctrl_5f9e3eee6795b23a923439b9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope._ISMODAL = true; this.unique = createUniqueTag(); this.container = this.container == null ? true : this.container; this.getModalDepth = function(_scope, _depth) { _scope = _scope ?? $scope; _depth = _depth ?? 0; if (_scope._ISMODAL) { _depth += 1; } if (_scope.$parent) { _depth = $scope.directiveScope.getModalDepth(_scope.$parent, _depth); } return _depth; } this.modalDepth = this.getModalDepth() - 1; }; /* Buttons ex: { ok: { label: "OK", closeOnSelection: true, class: "success" enable: *** Method String or Boolean, default is enabled (expect weird null coalescing from the parser) *** } } */ ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modal failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f9e3eee6795b23a923439b9', ctrl_5f9e3eee6795b23a923439b9); app.directive('codeEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?", mode: "=", expanded: "=?", allowExpand: "=?", expandedHeight: "=?", collapsedHeight: "=?", lineNumbers: "=?", }, controller: ctrl_5fa96ad509f1de3faafea4f4, template: `
    {{directiveScope.syntaxError}}
    `, bindToController: true};}); function ctrl_5fa96ad509f1de3faafea4f4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.readOnly = this.readOnly == null ? false : this.readOnly; this.allowExpand = this.allowExpand == null ? true : this.allowExpand; this.lineNumbers = this.lineNumbers == null ? true : this.lineNumbers; this.expanded = false; this.expandedHeight = this.expandedHeight == null ? 1000 : this.expandedHeight; this.collapsedHeight = this.collapsedHeight == null ? 200 : this.collapsedHeight; this.base64 = ["html","base64"].includes(this.mode); this.language = (["json", "object", "javascript"].includes(this.mode)) ? "javascript" : (this.mode == "html" ? "htmlmixed" : ""); this.unique = createUniqueTag(); this.syntaxError = ""; $scope.directiveScope = this; waitForElement("code_mirror_element_" + $scope.directiveScope.unique, (element) => { this.element = element; this.initEditor(); this.processBindingChange(); }); this.contextSelections = { addDirectiveHtml: { label: "Add Directive", icon: "/file-cache/model/5f3dd101a426c73ff92f6bae/icon", contextSelections: { a: { label: "TEST" } } }, addModelFunction: { label: "Add Module Function", icon: "/file-cache/model/5ecd669c1fc0331ca65dfd49/icon" } } }; this.$doCheck = function() { /* if ($scope.directiveScope.element){ console.log(JSON.parse(JSON.stringify($scope.directiveScope.element.parentElement ))); } if ($scope.directiveScope.element && $scope.directiveScope.editor && !$scope.directiveScope.fullyInitialized && !this.element.attributes.hidden) { setTimeout(() => { $scope.directiveScope.fullyInitialized = true; $scope.directiveScope.editor.refresh(); }, 1) } */ } this.processEditorChange = function() { if ($scope.directiveScope.processingBindingChange || $scope.directiveScope.readOnly) { return; } $scope.directiveScope.processingEditorChange = true; if ($scope.directiveScope.mode == "object") { try { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = JSON.parse($scope.directiveScope.editor.getValue()); $scope.directiveScope.syntaxError = null; } catch(e) { $scope.directiveScope.syntaxError = e; } } else if ($scope.directiveScope.base64) { try { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = encodeHtml($scope.directiveScope.editor.getValue()); $scope.directiveScope.syntaxError = null; } catch(e) { $scope.directiveScope.syntaxError = e; } } else { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.editor.getValue(); } $scope.$root.$digest(); $scope.directiveScope.processingEditorChange = false; } this.processBindingChange = function() { if ($scope.directiveScope.processingEditorChange) { return; } $scope.directiveScope.processingBindingChange = true; try { if( $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] == undefined) { $scope.directiveScope.editor.setValue(""); } else if ($scope.directiveScope.mode == "object") { $scope.directiveScope.editor.setValue(JSON.stringify($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName], null, 2)); } else if ($scope.directiveScope.base64) { $scope.directiveScope.editor.setValue(decodeHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName])); } else { $scope.directiveScope.editor.setValue($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } catch(e) {} $scope.directiveScope.processingBindingChange = false; } this.initEditor = function() { $scope.directiveScope.editor = CodeMirror.fromTextArea($scope.directiveScope.element, { lineNumbers: $scope.directiveScope.lineNumbers, mode: $scope.directiveScope.language, htmlMode: $scope.directiveScope.mode == "html", theme: "mdn-like", viewportMargin: Infinity, readOnly: $scope.directiveScope.readOnly, gutters: [], autoRefresh: true }); //Set watches $scope.$watch("directiveScope.bindingParent", () => { $scope.directiveScope.processBindingChange(); }); $scope.$watch("directiveScope.bindingName", () => { $scope.directiveScope.processBindingChange(); }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.processBindingChange(); }); $scope.directiveScope.editor.on("change", () => { $scope.directiveScope.processEditorChange(); }); $scope.directiveScope.editor.setSize(null, $scope.directiveScope.collapsedHeight); $scope.directiveScope.editor.refresh(); $scope.$apply(); } this.resize = function() { $scope.directiveScope.expanded = !$scope.directiveScope.expanded; $scope.directiveScope.editor.setSize(null, $scope.directiveScope.expanded ? $scope.directiveScope.expandedHeight : $scope.directiveScope.collapsedHeight); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: codeEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fa96ad509f1de3faafea4f4', ctrl_5fa96ad509f1de3faafea4f4); app.directive('indicator', function() { return { scope: { bindingParent: "=", bindingName: "=", values: "=", showIcon: "=?", iconLocation: "=?" }, controller: ctrl_5fc90953f8db3c543ba5f881, template: ` `, bindToController: true};}); function ctrl_5fc90953f8db3c543ba5f881($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.showIcon = this.showIcon == null ? true : this.showIcon; this.iconLocation = this.iconLocation == null ? "left" : this.iconLocation; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: indicator failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fc90953f8db3c543ba5f881', ctrl_5fc90953f8db3c543ba5f881); app.directive('singleReferenceAutocompleteSelection', function() { return { scope: { onChange: "&", refModel: "=", selectionFields: "=?", refQualifier: "=", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) placeholder: "=?", readOnly: "=?", selectedRecord: "=?", //Should not be written to, only for external reference keywordMode: "=?" //Treats spaces as wildcards }, controller: ctrl_5fce4d91fc2fe31573f2fc9c, template: `
    `, bindToController: true};}); function ctrl_5fce4d91fc2fe31573f2fc9c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.search = ""; this.showOptions = false; $scope.directiveScope = this; this.loading = true; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.selectedRecord = null; this.bindingValid = function() { return this.bindingParent && this.bindingName; } this.filtered = function() { return JSON.stringify(this.refQualifier).length > 2; } this.loadOptions(); //Set display field this.displayField = $scope.$root.models[this.refModel].display_field; //Configure value watches $scope.$watch(["directiveScope.bindingParent", "directiveScope.bindingName"], function () { $scope.directiveScope.updateSelectedRecordFromBinding(); }); //Configure qualifer watches $scope.$watch("directiveScope.refQualifier", function(_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.loadOptions(); } }); //Configure selectedRecord watch $scope.$watch("directiveScope.selectedRecord", function(_new, _old) { if (JSON.stringify(_old) != JSON.stringify(_new)) { $scope.directiveScope.search = $scope.directiveScope.selectedRecord ? $scope.directiveScope.selectedRecord[$scope.directiveScope.displayField] : ""; if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(); } } }); }; this.updateSelectedRecordFromBinding = function() { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && typeof($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) == "object") { $scope.directiveScope.selectedRecord = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; $scope.directiveScope.search = $scope.directiveScope.selectedRecord ? $scope.directiveScope.selectedRecord[$scope.directiveScope.displayField] : ""; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id; } else { //Get binding value var bindingId = $scope.directiveScope.bindingValid() ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] : null; //Updated selectedRecord $scope.directiveScope.selectedRecord = ($scope.directiveScope.options || []).find((option) => { return option._id == bindingId; }); } } }; this.loadOptions = function() { this.loading = true; retrieveRecords($scope.directiveScope, $http, $scope.directiveScope.refModel, { query: ($scope.directiveScope.refQualifier ? $scope.directiveScope.refQualifier : {}), sort: ($scope.directiveScope.sort || {}), select: ($scope.directiveScope.selectionFields || []) }, (response) => { //Populate all options $scope.directiveScope.options = response.records; //Update selected record $scope.directiveScope.updateSelectedRecordFromBinding(); //Check if current selected record is in options if ($scope.directiveScope.selectedRecord && !$scope.directiveScope.options.some((option) => { return option._id == $scope.directiveScope.selectedRecord._id; })) { $scope.directiveScope.selectedRecord = null; } this.loading = false; }); }; this.matchesSearch = function(_option) { return (!this.search || this.search.length < 1) || this.keywordMode ? (new RegExp(".*" + this.search.toLowerCase().split(" ").join(".*") + ".*")).test(_option[this.displayField].toLowerCase()) : _option[this.displayField].toLowerCase().includes(this.search.toLowerCase()) }; //Called when a user makes or clears a selection (not when updated from binding) this.select = function(_optionId, _stop) { this.selectedRecord = _optionId ? this.options.find((o) => { return o._id == _optionId; }) : null; if (this.bindingValid()) { this.bindingParent[this.bindingName] = _optionId; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceAutocompleteSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fce4d91fc2fe31573f2fc9c', ctrl_5fce4d91fc2fe31573f2fc9c); app.directive('selection', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", values: "=", onChange: "=?", placeholder: "=?", allowNull: "=?", showIcon: "=?", iconLocation: "=?" }, controller: ctrl_5fd90bf2080f5069e2d21a10, template: ` `, bindToController: true};}); function ctrl_5fd90bf2080f5069e2d21a10($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.allowNull = this.allowNull == null ? true : this.allowNull; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.showIcon = this.showIcon == null ? true : this.showIcon; this.showSelections = false; this.select = function(_key) { $scope.directiveScope.selecting = true; $scope.directiveScope.showSelections = false; if (_key == null || $scope.directiveScope.values[_key].selectable != false) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key, $scope.directiveScope); } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: selection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fd90bf2080f5069e2d21a10', ctrl_5fd90bf2080f5069e2d21a10); app.directive('contextMenu', function() { return { scope: { }, controller: ctrl_5fe807156ffaae7d29690585, template: ` `, bindToController: true};}); function ctrl_5fe807156ffaae7d29690585($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.getCallingEnvironment = function(_selectionKey, _selectionValue) { return { selectionKey: _selectionKey, selectionValue: _selectionValue, target: this.target, scope: $scope, rootScope: $rootScope, http: $http }; } this.showSelection = function(_selectionKey, _selectionValue) { return _selectionValue.dynamicDisplay ? _selectionValue.dynamicDisplay($scope.directiveScope.getCallingEnvironment(_selectionKey, _selectionValue)) : (_selectionValue.display != false) } this.showSeperator = function(_index) { // Hide if there are no previous visible selections before the next previous seperator (or start of array) for(var i = _index - 1; i > 0; i--) { var k = Object.keys($scope.directiveScope.selections)[i]; var v = $scope.directiveScope.selections[k]; if (v.seperator) { return false; } else if ($scope.directiveScope.showSelection(k, v)) { for(var i = _index + 1; i < Object.keys($scope.directiveScope.selections).length - 1; i++) { var k = Object.keys($scope.directiveScope.selections)[i]; var v = $scope.directiveScope.selections[k]; if (v.seperator) { return false; } else if ($scope.directiveScope.showSelection(k, v)) { return true; } } return false; } } return false; } this.select = function(_selectionKey, _selectionValue) { var callingEnvironment = $scope.directiveScope.getCallingEnvironment(_selectionKey, _selectionValue); if (_selectionValue.onClick) { _selectionValue.onClick(callingEnvironment); } else { $rootScope.$emit('contextMenuSelected', callingEnvironment); } } waitForElement(this.unique, () => { $('body').on('click', function(e) { $("#" + $scope.directiveScope.unique).removeClass("show"); }); $('body').on('contextmenu', function(e) { var data = $scope.directiveScope.findContextData(e.target); if (data) { $scope.directiveScope.target = data.target; $scope.directiveScope.selections = data.selections; $scope.$digest(); var pos = $scope.directiveScope.setContextMenuPostion(e, $("#" + $scope.directiveScope.unique)); $("#" + $scope.directiveScope.unique).css({ top: pos.y + "px", left: pos.x + "px", }).addClass("show"); return false; } else { $("#" + $scope.directiveScope.unique).removeClass("show"); } }); $('body').on('click', function(e) { $rootScope.$emit('closeContextMenus'); }); }); this.findContextData = function(_element) { if (_element.attributes && _element.dataset.contextSelections) { var elementScope = angular.element(_element).scope(); return { element: _element, scope: elementScope, selections: elementScope.$eval(_element.dataset.contextSelections), target: elementScope.$eval(_element.dataset.contextTarget) }; } else if (_element.parentNode) { return this.findContextData(_element.parentNode); } else { return null; } } //https://stackoverflow.com/a/11802841/9048430 this.setContextMenuPostion = function(event, contextMenu) { var mousePosition = {}; var menuPostion = {}; var menuDimension = {}; menuDimension.x = contextMenu.outerWidth(); menuDimension.y = contextMenu.outerHeight(); mousePosition.x = event.pageX; mousePosition.y = event.pageY; if (mousePosition.x + menuDimension.x > $(window).width() + $(window).scrollLeft()) { menuPostion.x = mousePosition.x - menuDimension.x; } else { menuPostion.x = mousePosition.x; } if (mousePosition.y + menuDimension.y > $(window).height() + $(window).scrollTop()) { menuPostion.y = mousePosition.y - menuDimension.y; } else { menuPostion.y = mousePosition.y; } return menuPostion; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: contextMenu failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fe807156ffaae7d29690585', ctrl_5fe807156ffaae7d29690585); app.directive('filetypeIcon', function() { return { scope: { bindingParent: "=", bindingName: "=" }, controller: ctrl_5fe950ac6ffaae7d29690779, template: ``, bindToController: true};}); function ctrl_5fe950ac6ffaae7d29690779($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.map = [ { e: ["mpg"], u: "1609126079401" }, { e: ["mov"], u: "1609126082387" }, { e: ["avi"], u: "1609126098752" }, { e: ["txt"], u: "1609126102053" }, { e: ["xml"], u: "1609126104833" }, { e: ["json"], u: "1609126113897" }, { e: ["css"], u: "1609126116704" }, { e: ["csv"], u: "1609126124269" }, { e: ["html", "htm"], u: "1609126128069" }, { e: ["xls", "xlsx", "xlsm"], u: "1609126148458" }, { e: ["doc", "docx", "docm"], u: "1609126151207" }, { e: ["pdf"], u: "1609126155001" }, { e: ["tif", "tiff"], u: "1609126158269" }, { e: ["psd"], u: "1609126162257" }, { e: ["ps"], u: "1609126166852" }, { e: ["png"], u: "1609126172657" }, { e: ["jpg", "jpeg"], u: "1609126175199" }, { e: ["gif"], u: "1609126179119" }, { e: ["ai"], u: "1609126182192" }, { e: ["wof", "woff"], u: "1609126199330" }, { e: ["ttf"], u: "1609126201785" }, { e: ["otf"], u: "1609126208979" }, { e: ["exe"], u: "1609126233658" }, { e: ["wma"], u: "1609126238907" }, { e: ["wav"], u: "1609126241987" }, { e: ["ogg"], u: "1609126245058" }, { e: ["mp3"], u: "1609126249507" }, { e: ["aac"], u: "1609126254405" }, { e: ["zip"], u: "1609126257022" }, { e: ["rar"], u: "1609126262077" }, { e: ["7z"], u: "1609126268267" }, { e: ["js"], u: "1609127733294" } ]; this.getLink = function() { var mapEntry = (this.bindingParent && this.bindingName && this.bindingParent[this.bindingName]) ? this.map.find((entry) => { return entry.e.includes(this.bindingParent[this.bindingName]); }) : null; return "/file-cache/directive/5fe950ac6ffaae7d29690779/resources/" + (mapEntry ? mapEntry.u : "1609126550832"); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: filetypeIcon failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5fe950ac6ffaae7d29690779', ctrl_5fe950ac6ffaae7d29690779); app.directive('modelFieldEditor', function() { return { scope: { field: "=", containerUnique: "=?" }, transclude: false, controller: ctrl_5ff7c14469c2ba7220dbde86, template: `






    `, bindToController: true};}); function ctrl_5ff7c14469c2ba7220dbde86($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.containerUnique = this.containerUnique == null ? "accordion" : this.containerUnique; this.typeSelections = { string: { label: 'String' }, decimal: { label: 'Decimal' }, integer: { label: 'Integer' }, boolean: { label: 'Boolean' }, reference: { label: 'Reference' }, dynamicObject: { label: 'Dynamic Object' }, staticObject: { label: 'Static Object' }, file: { label: 'File' } }; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5ff7c14469c2ba7220dbde86', ctrl_5ff7c14469c2ba7220dbde86); app.directive('wysiwygHtmlEditor', function() { return { scope: { bindingName: "=", bindingParent: "=", fileSourceRecord: "=?", fileSourceRecordType: "=?" }, controller: ctrl_600110dab7f9de36415ec499, template: `
    { $scope.directiveScope.editorElement = pellElement; window.pell.init({ element: $scope.directiveScope.editorElement, onChange: $scope.directiveScope.controlChanged, defaultParagraphSeparator: 'div', styleWithCSS: false, actions: [...["bold", "underline", "italic", "strikethrough", "olist", "ulist"], ...$scope.directiveScope.customFunctions] }); $scope.directiveScope.bindingChanged(); }); this.processingControlChange = false; this.processingBindingChange = false; this.bindingChanged = function() { if (!$scope.directiveScope.processingControlChange && $scope.directiveScope.editorElement) { $scope.directiveScope.processingBindingChange = true; $scope.directiveScope.editorElement.content.innerHTML = decodeHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); $scope.directiveScope.processingBindingChange = false } }; this.controlChanged = function(_newValue) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && !$scope.directiveScope.processingBindingChange && $scope.directiveScope.editorElement) { $scope.directiveScope.processingControlChange = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = encodeHtml(_newValue); safeApply($scope); $scope.directiveScope.processingControlChange = false } }; this.getCurrentRecordFiles = function() { var files = []; var modelDef = $scope.$root.models[$scope.directiveScope.fileSourceRecord && $scope.directiveScope.fileSourceRecord._type ? $scope.directiveScope.fileSourceRecord._type : $scope.directiveScope.fileSourceRecordType]; Object.keys(modelDef.fields).forEach((f) => { if (modelDef.fields[f].type == "file") { if (modelDef.fields[f].array) { ($scope.directiveScope.fileSourceRecord[f] || []).forEach((file) => { var toPush = cloneObject(file); toPush.source = f; files.push(toPush); }); } else if ($scope.directiveScope.fileSourceRecord[f]) { var toPush = cloneObject($scope.directiveScope.fileSourceRecord[f]); toPush.source = f; files.push(toPush); } } }); return files; }; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", $scope.directiveScope.bindingChanged); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: wysiwygHtmlEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_600110dab7f9de36415ec499', ctrl_600110dab7f9de36415ec499); app.directive('objectTreeEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", showCondition: "=?", selectedValue: "=?", keyDisplay: "=?", d: "=?", allowAddToRoot: "=?", allowAddToChild: "=?", allowRemove: "=?", }, transclude: false, controller: ctrl_6017567c6714f94558f41734, template: ` `, bindToController: true};}); function ctrl_6017567c6714f94558f41734($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] == null ? {} : this.bindingParent[this.bindingName]; this.showCondition = this.showCondition == null ? (() => { return true; }) : this.showCondition; this.keyDisplay = this.keyDisplay == null ? ((_key) => { return _key; }) : this.keyDisplay; this.d = this.d == null ? 0 : this.d; this.isObject = function(_value) { return typeof(_value) == "object"; } this.selectValue = function(_value) { this.selectedValue = _value; } this.addRootValue = function() { var key = prompt("Please enter a new key"); if (key.length > 0) { this.bindingParent[this.bindingName][key] = { __type: "string" }; } } this.cloneValue = function(_value) { var newKey = prompt("Please enter a new key"); if (key.length > 0) { this.bindingParent[this.bindingName][newKey] = {}; Object.assign(this.bindingParent[this.bindingName][newKey], _value); } } this.addChildValue = function(_parent) { var key = prompt("Please enter a new key"); if (key.length > 0) { _parent[key] = { __type: "string" }; } } this.removeValue = function(_name) { if (confirm("Are you sure you want to remove '" + _name + "'")) { delete this.bindingParent[this.bindingName][_name]; } } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectTreeEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6017567c6714f94558f41734', ctrl_6017567c6714f94558f41734); app.directive('selectionsConfig', function() { return { scope: { bindingParent: "=", bindingName: "=" }, controller: ctrl_601958f9aad0c41503076221, template: `
    Value Label Selectable Icon Class
    {{value}}
    `, bindToController: true};}); function ctrl_601958f9aad0c41503076221($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] == null ? {} : this.bindingParent[this.bindingName]; this.canAddValue = function() { return !Object.keys(this.bindingParent[this.bindingName]).includes(this.newValue); } this.removeValue = function(_value) { delete this.bindingParent[this.bindingName][_value]; } this.addValue = function() { if (this.canAddValue()) { this.bindingParent[this.bindingName][this.newValue] = {}; this.newValue = ""; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: selectionsConfig failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_601958f9aad0c41503076221', ctrl_601958f9aad0c41503076221); app.directive('modelFieldSelection', function() { return { scope: { modelName: "=", bindingParent: "=", bindingName: "=", placeholder: "=?", onChange: "=?", allowNull: "=?", fieldQualifier: "=?", queryableOnly: "=?" }, transclude: false, controller: ctrl_6020c1821eab984ea8111ef5, template: ` `, bindToController: true};}); function ctrl_6020c1821eab984ea8111ef5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.fieldQualifier = this.fieldQualifier || (() => { return true; }); this.unique = createUniqueTag(); this.populateSelections = function() { this.values = { }; Object.keys($scope.$root.models[this.modelName].fields).filter((f) => { return this.fieldQualifier($scope.$root.models[this.modelName].fields[f], f); }).sort().forEach((fieldName) => { try { var field = $scope.$root.models[this.modelName].fields[fieldName]; if (!field.queryable && !this.queryableOnly) { return; } var referencedModel = field.reference_model ? getModelById($scope, field.reference_model) : {}; var typeDisplay = field.type == "reference" ? ((field.array ? ("Array of " + referencedModel.plural_name) : referencedModel.singular_name)) : ((field.array ? "Array of " : "") + field.type + (field.array ? "s" : "")); this.values[fieldName] = { label: (field.display_name || fieldName) + (field.type == "reference" ? (" (" + typeDisplay + ")") : ""), icon: ((field.type == "reference") ? (referencedModel.icon ? referencedModel.icon.link : null) : ("/media/icons/" + field.type + ".png")) }; } catch (e) {} }); } $scope.$watch("directiveScope.modelName", function() { $scope.directiveScope.populateSelections(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6020c1821eab984ea8111ef5', ctrl_6020c1821eab984ea8111ef5); app.directive('modelFieldIndicator', function() { return { scope: { modelName: "=", bindingParent: "=", bindingName: "=", placeholder: "=?" }, transclude: false, controller: ctrl_6025622502fc51372236d071, template: ` `, bindToController: true};}); function ctrl_6025622502fc51372236d071($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.populateSelections = function() { this.values = { }; Object.keys($scope.$root.models[this.modelName].fields).forEach((fieldName) => { var field = $scope.$root.models[this.modelName].fields[fieldName]; var referencedModel = (field.reference_model ? getModelById($scope, field.reference_model) : {}) || {}; this.values[fieldName] = { label: fieldName, icon: (field.type == "reference" ? (referencedModel.icon || {}).link : null) }; }); } $scope.$watch("directiveScope.modelName", function() { $scope.directiveScope.populateSelections(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldIndicator failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6025622502fc51372236d071', ctrl_6025622502fc51372236d071); app.directive('virtualModelJoinEditor', function() { return { scope: { value: "=", type: "=?", length: "=?", width: "=?" } , controller: ctrl_603465a82503af58f757b1a9, template: ``, bindToController: true};}); function ctrl_603465a82503af58f757b1a9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: virtualModelJoinEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_603465a82503af58f757b1a9', ctrl_603465a82503af58f757b1a9); app.directive('electricalConnectionDisplay', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_603dacac6175413b5604ed86, template: `
    Bus {{directiveScope.bindingParent[directiveScope.bindingName].connection_data == 'wire_connection' ? 'Wire' : 'Pin'}}
    {{bus}} {{v}}
    `, bindToController: true};}); function ctrl_603dacac6175413b5604ed86($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_603dacac6175413b5604ed86', ctrl_603dacac6175413b5604ed86); app.directive('electricalConnectionBusConfig', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_603efe9bdb33e129dcdc3a82, template: `
    Pin #
    Layer #

    Primary Color
    Secondary Color
    Conductor Color
    `, bindToController: true};}); function ctrl_603efe9bdb33e129dcdc3a82($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || { layer: 0}; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionBusConfig failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_603efe9bdb33e129dcdc3a82', ctrl_603efe9bdb33e129dcdc3a82); app.directive('hexColorSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?" }, controller: ctrl_603fb71c92a6ba5827669f89, template: `#{{directiveScope.bindingParent[directiveScope.bindingName]}}
    `, bindToController: true};}); function ctrl_603fb71c92a6ba5827669f89($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.readOnly = this.readOnly == null ? false : true; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].startsWith("#")) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].replace("#",""); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: hexColorSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_603fb71c92a6ba5827669f89', ctrl_603fb71c92a6ba5827669f89); app.directive('colorSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?" }, controller: ctrl_603fc02a92a6ba5827669f97, template: `
    `, bindToController: true};}); function ctrl_603fc02a92a6ba5827669f97($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.colorRecord = null; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: colorSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_603fc02a92a6ba5827669f97', ctrl_603fc02a92a6ba5827669f97); app.directive('numericStepper', function() { return { scope: { bindingParent: "=", bindingName: "=", majorStep: "=?", minorStep: "=?", min: "=?", max: "=?", invertButtons: "=?", onChange: "=?" }, controller: ctrl_60422df7f9bc7338074fcd1b, template: `
    {{directiveScope.bindingParent[directiveScope.bindingName]}}
    `, bindToController: true};}); function ctrl_60422df7f9bc7338074fcd1b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.majorStep = this.majorStep == null ? 10 : this.majorStep; this.minorStep = this.minorStep == null ? 1 : this.minorStep; this.max = this.max == null ? 10000 : this.max; this.min = this.min == null ? 0 : this.min; this.mod = function(_delta) { _delta *= this.invertButtons ? -1 : 1; var newValue = this.bindingParent[this.bindingName] + _delta; if (newValue >= this.min && newValue <= this.max) { this.bindingParent[this.bindingName] = newValue; if (this.onChange) { this.onChange(); } } } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: numericStepper failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_60422df7f9bc7338074fcd1b', ctrl_60422df7f9bc7338074fcd1b); app.directive('electricalConnectionBusDisplay', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_60491d9366066a78a84b899d, template: `
    `, bindToController: true};}); function ctrl_60491d9366066a78a84b899d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionBusDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_60491d9366066a78a84b899d', ctrl_60491d9366066a78a84b899d); app.directive('baseForm', function() { return { scope: { inWindow: "=?", modelName: "=", invertHeader: "=?", layout: "=?", initValues: "=?", bindingName: "=?", bindingParent: "=?", allowInsert: " .application-message { opacity: 0; } .application-parent:hover .application-message { opacity: 1; }
     
    ⚠ {{directiveScope.error}}
    {{directiveScope.record._id ? directiveScope.record._id : '{New Record}'}}
    {{directiveScope.record[field.name]}}
    {{directiveScope.record[field.name]}}
    {{directiveScope.trimNote(field.noteProcessed)}}
    {{field.noteProcessed}}
    `, bindToController: true};}); function ctrl_5f3dd70950a9cc72d8fcbfd1($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BOUND TO ID STRING this.$onInit = function() { this.screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); this.headerContextSelections = {}; this.reloadIntervalId = null; this.modifiedFields = []; this.parentModal = $scope.$parent.$parent.$parent.directiveScope ? $scope.$parent.$parent.$parent.directiveScope.directiveRef : null; $scope.directiveScope = this; this.unique = createUniqueTag(); this.error = null; this.loading = false; this.tabStates = {}; this.showHeader = this.showHeader == null ? true : this.showHeader; this.checkForCtrlCode = function(_event) { _event.preventDefault(); if (_event.ctrlKey && String.fromCharCode(_event.which).toLowerCase()) { _event.preventDefault(); } }; // Get permissions for referenced table this.allowUpdate = (this.allowUpdate != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.update_models.includes(this.modelName); }); this.allowInsert = (this.allowInsert != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes(this.modelName); }); this.allowCopy = (this.allowCopy != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes(this.modelName); }); this.allowDelete = (this.allowDelete != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.delete_models.includes(this.modelName); }); // Get model and layout data this.loadModelData(() => { // Now load/handle record data $scope.directiveScope.reloadRecord(); // Set watch $scope.$watch('[directiveScope.modelName, directiveScope.bindingParent, directiveScope.bindingName, directiveScope.bindingParent[directiveScope.bindingName]]', function(_new, _old) { if (_new != _old) { $scope.directiveScope.loadModelData(() => { $scope.directiveScope.reloadRecord(); }); } }); $scope.$watch("directiveScope.record", (_new, _old) => { // Was this a record refresh change? if (!$scope.directiveScope.loading && _new && _old) { // No, UI change, get all the fields that were changed (should usually be only 1, but complex controls may update more) var update = {}; [...Object.keys(_new), ...Object.keys(_old)].distinct().forEach((fieldName) => { // If this field was changed and any of the layout fields for this field are flagged to update on change, add value to update object if (JSON.stringify(_new[fieldName]) != JSON.stringify(_old[fieldName]) && $scope.directiveScope.layoutRecord.fields.some((f) => { return f.name == fieldName && f.update_on_change; })) { update[fieldName] = _new[fieldName]; } }); // Are there any updates to push? if (Object.keys(update).length > 0) { // Yes, apply update updateRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, $scope.directiveScope.record._id, update, (resp) => { if (resp.success) { $scope.$root.$emit('showAlert', "Fields '" + Object.keys(update).join(", ") + "' updated successfully", "success"); // $scope.directiveScope.reloadRecord(); } }); } } //Update dynamic stuff $scope.directiveScope.layoutRecord.fields.forEach((f) => { if (f.note && $scope.directiveScope.record) { var result = replaceRelationFields($scope.directiveScope, f.note); if (result.replacedFields.length > 0) { try { f.noteProcessed = JSON.parse(result.output); } catch (e) { f.noteProcessed = f.note; } } else { f.noteProcessed = f.note; } } }); }, true); }); }; this.changeLayout = () => { $scope.directiveScope.loadModelData(); if ($scope.directiveScope.inWindow) { $scope.directiveScope.rebuildRecordActions(); $scope.directiveScope.updateCurrentURL(); } } this.loadModelData = function(_then) { $scope.directiveScope.error = null; //Evaluate attributes if (!$scope.directiveScope.modelName) { $scope.directiveScope.error = "Model name not provided" $scope.directiveScope.loading = false; if (_then) { _then(); } return; } if (!$scope.$root.models[$scope.directiveScope.modelName]) { $scope.directiveScope.error = "'" + $scope.directiveScope.modelName + "' model not found or permission denied", $scope.directiveScope.loading = false; if (_then) { _then(); } return; } //Get model data $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; //Set title of parent window (if on root form) if ($scope.directiveScope.inWindow) { $("#favicon").attr("href", $scope.directiveScope.modelData.icon ? $scope.directiveScope.modelData.icon.link : null); document.title = "KIM - " + $scope.directiveScope.modelData.singular_name; } //Save applicable layouts $scope.directiveScope.layoutSelections = {}; $scope.$root.layouts.filter((l) => { return l._type == "form_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }).forEach((layout) => { $scope.directiveScope.layoutSelections[layout._id] = { label: layout.display, icon: ($scope.$root.models[layout.model].icon ? $scope.$root.models[layout.model].icon.link : null), class: "ghost" }; }); //Get layout var defaultLayoutId = !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.$root.models[$scope.directiveScope.modelName].default_new_form ? $scope.$root.models[$scope.directiveScope.modelName].default_new_form : $scope.$root.models[$scope.directiveScope.modelName].default_form; $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { //Return the specified (or default form) layout return ( $scope.directiveScope.layout && $scope.directiveScope.layout == l._id && l._type == "form_layout" && ( l.model == $scope.directiveScope.modelName || l.model == $scope.$root.models[$scope.directiveScope.modelName].parent ) ) || (!$scope.directiveScope.layout && l._id == defaultLayoutId); }); //Layout OK? if (!$scope.directiveScope.layoutRecord) { //Not found $scope.directiveScope.error = "Layout not found"; if (_then) { _then(); } return; } $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; //Add global fields if enabled if ($scope.directiveScope.layoutRecord.display_global_fields && !$scope.directiveScope.layoutRecord.globalFieldLoaded) { $scope.directiveScope.layoutRecord.fields.push({ row: 500, row_order: 0, placement: "left", default: "System Fields", field_type: "angular", control: $scope.$root.globalControls.find((c) => { return c._id == "5e41675a7db3990140f5d64a"; }), parameters: { icon: $scope.$root.segments.find((s) => { return s._id == "5fbe7fb6c40e463f74f3eabd"; }).icon.link } }); Object.keys($scope.$root.globalFields).forEach((fieldName) => { var field = $scope.$root.globalFields[fieldName]; if (!field.__display) { return; } $scope.directiveScope.layoutRecord.fields.push({ row: 501, row_order: 0, size: 3, placement: "left", name: fieldName, label: $scope.directiveScope.getLabel(fieldName), field_type: field.__default_write_control ? "write" : "read", control: field.__readonly ? ( field.__default_read_control ? field.__default_read_control : null) : ( field.__default_write_control ? field.__default_write_control : null), tab: "System Fields" }); }); $scope.directiveScope.layoutRecord.globalFieldLoaded = true; } //Update field groupings $scope.directiveScope.groupedFields = groupByProperty($scope.directiveScope.layoutRecord.fields, "row"); $scope.directiveScope.orderedRowIndexes = Object.keys($scope.directiveScope.groupedFields).sort((a, b) => { return parseFloat(a) > parseFloat(b) ? 1 : -1; }); //Set reload rate if defined (or use layout default, if defined) $scope.directiveScope.reloadRate = $scope.directiveScope.reloadRate || $scope.directiveScope.layoutRecord.default_reload_rate; //Kill old interval (if exists) if ($scope.directiveScope.reloadIntervalId) { $interval.cancel($scope.directiveScope.reloadIntervalId); $scope.directiveScope.reloadIntervalId = null; } //Set up interval if > 250ms (to avoid accidental 1ms blasts) if ($scope.directiveScope.reloadRate > 250) { $scope.directiveScope.reloadIntervalId = $interval(() => { //Don't load if already loading var visible = $("#base_form_" + $scope.directiveScope.unique).parent().is(":visible"); if (visible && !$scope.directiveScope.loading) { $scope.directiveScope.reloadRecord(); } }, $scope.directiveScope.reloadRate); } // Build record actions $scope.directiveScope.rebuildRecordActions(); //Set popovers in a second setTimeout(() => { $scope.directiveScope.layoutRecord.fields.forEach((field) => { if ($scope.directiveScope.modelData.fields[field.name]) { $("#field_label_" + field.name).popover({ title: field.label, html: true, content: atob($scope.directiveScope.modelData.fields[field.name].description || ""), container: 'body' }); } }); $('.popover-dismiss').popover({ trigger: 'focus' }) }, 1000); // if (_then) { _then(); } } this.new = function() { $scope.directiveScope.record = { _id: "" }; $scope.directiveScope.loadModelData(() => { Object.keys($scope.directiveScope.modelData.fields).forEach((fieldName) => { if ($scope.directiveScope.modelData.fields[fieldName].default != null) { $scope.directiveScope.record[fieldName] = $scope.directiveScope.modelData.fields[fieldName].default; } }); }); $scope.directiveScope.updateCurrentURL(); } this.rebuildRecordActions = function() { var defaultRecordActions = $scope.$root.formRecordActions ?? []; var modelRecordActions = ($scope.directiveScope.modelData ?? {}).form_record_actions ?? []; var layoutRecordActions = ($scope.directiveScope.layoutRecord ?? {}).record_actions ?? []; var recordActions = generateRecordActionSelections($scope, $http, $sce, [ ...defaultRecordActions, (modelRecordActions.length > 0 ? "sep1" : null), ...modelRecordActions, (layoutRecordActions.length > 0 ? "sep2" : null), ...layoutRecordActions ].filter((id) => { return id != null; })); $scope.directiveScope.headerContextSelections = recordActions; } this.getZIndex = function(_row) { return 9999 - Math.round(_row); } this.reloadRecord = function() { $scope.directiveScope.loading = true; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { //Normalize binding (to single id string or null) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] ? ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) : null; } if (!$scope.directiveScope.modelName || !$scope.directiveScope.layoutRecord) { //No model provided, cancel all $scope.directiveScope.loading = false; } else if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Id provided, retrieve record retrieveRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, { noCache: true, query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }, populate: $scope.directiveScope.layoutRecord.fields.filter((field) => { return ["yes", "custom"].includes(field.populate_mode); }).map((field) => { return field.populate_mode == "yes" ? field.name : { path: field.name, populate: field.populate }; }) }, (record) => { //Record OK? if (!record) { //Not found $scope.directiveScope.loading = false; $scope.directiveScope.error = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] + " not found in '" + $scope.directiveScope.modelName + "' model"; return; } //Record OK, init bound record if null $scope.directiveScope.record = $scope.directiveScope.record || {}; //Apply record values to bindings Object.assign($scope.directiveScope.record, record); // Is the record's _type more specific than the requested modelName? if ($scope.directiveScope.record._type && ($scope.directiveScope.record._type != $scope.directiveScope.modelName)) { // Yes, are we currently using a default layout? if ($scope.directiveScope.modelData.default_form == $scope.directiveScope.layout) { // Yes, switch to the default of the new _type $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { return l._id == $scope.$root.models[$scope.directiveScope.record._type].default_form; }); $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; } // Update directive properties $scope.directiveScope.modelName = $scope.directiveScope.record._type; $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; } if ($scope.directiveScope.inWindow) { $scope.directiveScope.updateCurrentURL(); document.title = "KIM - " + $scope.directiveScope.modelData.singular_name + " '" + $scope.directiveScope.record[$scope.directiveScope.modelData.display_field] + "' "; } //Update field groupings $scope.directiveScope.groupedFields = groupByProperty($scope.directiveScope.layoutRecord.fields, "row"); $scope.directiveScope.modifiedFields = []; $scope.directiveScope.loading = false; }); } else { //No id specified, create empty record with default values $scope.directiveScope.record = {}; //Load defaults from model Object.keys($scope.directiveScope.modelData.fields).forEach((fieldName) => { if ($scope.directiveScope.modelData.fields[fieldName].default != null) { $scope.directiveScope.record[fieldName] = $scope.directiveScope.modelData.fields[fieldName].default; } }); //Load defaults from layout $scope.directiveScope.layoutRecord.fields.forEach((field) => { $scope.directiveScope.record[field.name] = field.default || $scope.directiveScope.record[field.name]; }); //Load init values (if supplied) Object.assign($scope.directiveScope.record, $scope.directiveScope.initValues || {}); $scope.directiveScope.loading = false; } }; this.update = function(_then) { $scope.directiveScope.loading = true; //Move read only fields to $readonly to avoid overwriting, they should not have been edited var writtenRecord = { _readonly: {} }; //Evaluate all fields + _id [...$scope.directiveScope.layoutRecord.fields, ...[{ name: "_id" }, { name: "_meta" }]].filter((fieldDef) => { //Only return write/angular fields and _id return fieldDef.field_type == "angular" || fieldDef.field_type == "write" || fieldDef.name == "_id" || fieldDef.name == "_meta"; }).forEach((fieldDef) => { //Copy values from record writtenRecord[fieldDef.name] = cloneObject($scope.directiveScope.record[fieldDef.name]); }); // Copy explicit values if designated if ($scope.directiveScope.layoutRecord.explicit_update_fields) { $scope.directiveScope.layoutRecord.explicit_update_fields.forEach((fieldName) => { writtenRecord[fieldName] = cloneObject($scope.directiveScope.record[fieldName]); }); } $scope.directiveScope.layoutRecord.fields.filter((fieldDef) => { return fieldDef.field_type == "read"; }).forEach((fieldDef) => { //Write readonly fields to _readonly writtenRecord._readonly[fieldDef.name] = cloneObject($scope.directiveScope.record[fieldDef.name]); }); //POST modifications updateRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, $scope.directiveScope.record._id, writtenRecord, (resp) => { if (resp.success) { //$scope.directiveScope.loading = false; //Show the succefss alert for a second, then take next action $scope.$root.$emit('showAlert', "Record updated successfully", "success"); if ($scope.directiveScope.onUpdate) { $scope.directiveScope.onUpdate($scope.directiveScope.record._id); } if (_then == "exit") { $scope.directiveScope.exit(); return; } else if (typeof(_then) == "function") { _then(); } //Apply server side record data (would use the response but it doesnt honor model accessors) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = resp.record._id; $scope.directiveScope.reloadRecord(); //Object.assign($scope.directiveScope.record, resp.record); } else { //Failed, display error var errorString = "Failed to update record

    " + ((resp.errors || []).map((error) => { return (error.source ? (`` + error.source + `: `) : ``) + error.message; }).join("
    ")); $scope.$root.$emit('showAlert', errorString, "danger"); if (typeof(_then) == "function") { _then(); } } $scope.directiveScope.loading = false; }); }; this.insert = function(_then) { var applicationAction = $scope.directiveScope.modelData.application_action ? $scope.$root.models.model.fields.application_action.selections[$scope.directiveScope.modelData.application_action].label : null; if (confirm("Are you sure you want to insert a new record?" + (applicationAction ? "\r\n\r\nNOTE: " + applicationAction + " required to apply": ""))) { $scope.directiveScope.loading = true; //Remove _id if it already exists var record = cloneObject($scope.directiveScope.record); delete record._id; insertRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, record, (resp) => { if (resp.success) { $scope.$root.$emit('showAlert', "Record inserted successfully", "success"); if ($scope.directiveScope.onInsert) { $scope.directiveScope.onInsert(resp.record._id); } //Show the success alert for a second, then take next action if (_then == "exit") { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = cloneObject(resp.record); $scope.directiveScope.record = resp.record; $scope.directiveScope.exit(); } //Apply server side record data (would use the response but it doesnt honor model accessors) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = resp.record._id; $scope.directiveScope.reloadRecord(); //Object.assign($scope.directiveScope.record, resp.record); //If the default_new_form is in use, chance layout to default form if ($scope.directiveScope.layoutRecord._id == $scope.$root.models[$scope.directiveScope.modelName].default_new_form) { $scope.directiveScope.layout = $scope.$root.models[$scope.directiveScope.modelName].default_form; } } else { //Failed, display error var errorString = "Failed to insert record

    " + ((resp.errors || []).map((error) => { return (error.source ? (`` + error.source + `: `) : ``) + error.message; }).join("
    ")); $scope.$root.$emit('showAlert', errorString, "danger"); } $scope.directiveScope.loading = false; }); } }; this.exit = function() { if ($scope.directiveScope.inWindow) { if (history.length < 2) { close(); } else if (!document.referrer.split("/")[3]) { window.history.back(); } else { window.location = document.referrer; } } else { $scope.directiveScope.parentModal.hide(); } } this.cancel = function() { $scope.directiveScope.parentModal.hide(); }; this.viewInTab = function() { window.open(window.location.href, '_blank'); } this.updateCurrentURL = function() { $scope.formUrl = "/form?model=" + $scope.directiveScope.modelName + "&_id=" + ($scope.directiveScope.record._id) + "&reloadRate=" + $scope.directiveScope.reloadRate + "&layout=" + $scope.directiveScope.layoutRecord._id; $location.url($scope.formUrl).replace(); } this.getFieldClass = function(_field) { return $scope.directiveScope.record._id ? "" : ($scope.$root.models[$scope.directiveScope.modelName].fields[_field.name] && $scope.$root.models[$scope.directiveScope.modelName].fields[_field.name].required ? ("p-2 border-left border-" + (($scope.directiveScope.record[_field.name] == null || $scope.directiveScope.record[_field.name].length == 0) ? "warning" : "success")) : ""); } this.getLabel = function(_name) { return _name.split("_").map((c) => { return c.charAt(0).toUpperCase() + c.slice(1); }).join(" "); } this.fieldIsEmpty = function(_field) { var value = ($scope.directiveScope.record || {})[_field]; //Not true/false return ![true, false].includes(value) && ( //Is null value == null || //Is empty array (Array.isArray(value) && value.length == 0) || //Is empty object or null date (typeof(value) == "object" && (!value.getDate && Object.keys(value).length == 0)) ); } this.openInNewTab = function() { window.open("/form?model=" + $scope.directiveScope.modelName + "&_id=" + $scope.directiveScope.record._id, "_blank"); } this.trimNote = function(_note) { return (_note || "").split("\n").filter((l,i) => { return i != 0; }).join("\n"); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseForm failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_5f3dd70950a9cc72d8fcbfd1', ctrl_5f3dd70950a9cc72d8fcbfd1); app.directive('autocompleteSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", selections: "=", invert: "=?", onChange: "=?", placeholder: "=?", searchFilter: "=?", onFocus: "=?", contextSelections: "=?", staticSelections: "=?", allowInteraction: "=?", clearFilterOnLostFocus: "=?" }, controller: ctrl_607830f28e940c6ba3c3fa2d, template: ` `, bindToController: true};}); function ctrl_607830f28e940c6ba3c3fa2d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.dropdownUnique = createUniqueTag(); waitForElement(this.dropdownUnique, (e) => { $scope.directiveScope.dropdownElement = e; }); this.menuUnique = createUniqueTag(); waitForElement(this.menuUnique, (e) => { $scope.directiveScope.menuElement = e; }); this.searchFilter = this.searchFilter ?? ""; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.clearFilterOnLostFocus = this.clearFilterOnLostFocus == null ? true : this.clearFilterOnLostFocus; this.hide = function() { setTimeout(() => { if ($scope.directiveScope.menuElement) { $scope.directiveScope.menuElement.classList.remove("show"); } if ($scope.directiveScope.clearFilterOnLostFocus) { $scope.directiveScope.searchFilter = ""; safeApply($scope); } }, 1); } this.totalSelectionsCount = function() { return Object.keys($scope.directiveScope.selections ?? {}).length + Object.keys($scope.directiveScope.staticSelections ?? {}).length; } this.getLabelWithMatch = function(_label) { try { return btoa( ($scope.directiveScope.searchFilter ?? "").length > 0 ? ( _label.replace( new RegExp("(" + $scope.directiveScope.searchFilter + ")", "i"), `$&` ) ) : _label ); } catch (e) { return null; } } this.selections = this.selections || {}; this.onInputFocus = function(){ if ($scope.directiveScope.onFocus) { $scope.directiveScope.onFocus($scope.directiveScope); } } this.matchesFilter = function(_value) { if (!_value || !$scope.directiveScope.selections[_value]) { return false; } return ($scope.directiveScope.searchFilter || "").length == 0 || _value.toLowerCase().includes($scope.directiveScope.searchFilter.toLowerCase()) || ($scope.directiveScope.selections[_value] || { label: "" }).label.toLowerCase().includes($scope.directiveScope.searchFilter.toLowerCase()); }; this.select = function(_key) { if ($scope.directiveScope.selections[_key].selectable != false) { $scope.directiveScope.searchFilter = ""; //$scope.directiveScope.selections[_key].label.toString(); if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key); } } } this.staticSelection = function(_selectionKey) { if ($scope.directiveScope.staticSelections[_selectionKey].onClick) { $scope.directiveScope.staticSelections[_selectionKey].onClick() } else { $scope.directiveScope.select(_selectionKey) } setTimeout(() => { if (!$scope.directiveScope.menuElement.classList.contains("show")) { $scope.directiveScope.menuElement.classList.add("show"); } }, 1); }; angular.element(document).on('click', (_v) => { if (!_v.target.classList.contains("dropdown-item")) { $scope.directiveScope.hide(); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: autocompleteSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_607830f28e940c6ba3c3fa2d', ctrl_607830f28e940c6ba3c3fa2d); app.directive('modalTextEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_60cc0af19c39054a99348675, template: ` {{directiveScope.bindingParent[directiveScope.bindingName]}} None {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_60cc0af19c39054a99348675($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalTextEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_60cc0af19c39054a99348675', ctrl_60cc0af19c39054a99348675); app.directive('modalScriptEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", mode: "=", subtext: "=?" }, controller: ctrl_60cc0cfa9c39054a99348676, template: `

    {{directiveScope.bindingParent[directiveScope.bindingName] || " "}}

    {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_60cc0cfa9c39054a99348676($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalScriptEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_60cc0cfa9c39054a99348676', ctrl_60cc0cfa9c39054a99348676); app.directive('loadingBox', function() { return { scope: { message: "=?", subMessage: "=?", icon: "=?", iconCircle: "=?", iconSize: "=?" }, controller: ctrl_60d38e86d8342a28c4756b43, template: `
    Keller Information Management
    `, bindToController: true};}); function ctrl_60d38e86d8342a28c4756b43($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.loaded = false; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: loadingBox failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_60d38e86d8342a28c4756b43', ctrl_60d38e86d8342a28c4756b43); app.directive('nFPADiamond', function() { return { scope: { flammability: "=?", health: "=?", reactivity: "=?", misc: "=?" }, controller: ctrl_6102b1c99bbdc92c0d8db4a5, template: `

    0

    0

    0

    0

    `, bindToController: true};}); function ctrl_6102b1c99bbdc92c0d8db4a5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nFPADiamond failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6102b1c99bbdc92c0d8db4a5', ctrl_6102b1c99bbdc92c0d8db4a5); app.directive('menuContainer', function() { return { scope: { containerData: "=", onSelection: "=", searchCollector: "=", depth: "=?" }, controller: ctrl_610b4698fb29f524c0cc0735, template: `
  • {{directiveScope.containerData.title}}
  • `, bindToController: true};}); function ctrl_610b4698fb29f524c0cc0735($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = async function() { $scope.directiveScope = this; this.id = createUniqueTag(); this.useHtmlLabel = (this.containerData.label_html || "").length > 2; $rootScope.$on('contextMenuSelected', function(_event, _selection) { }); this.select = function(_selectionKey, _selectionValue) { var callingEnvironment = { selectionKey: _selectionKey, selectionValue: _selectionValue, scope: $scope, rootScope: $rootScope, http: $http }; if (_selectionValue.onClick) { _selectionValue.onClick(callingEnvironment); } else { $scope.directiveScope.onSelection(callingEnvironment); } }; this.selectContext = function(_callingEnvironment) { $scope.directiveScope.onSelection(_callingEnvironment); }; if (this.containerData.dropdown_enabled) { try { this.selections = await (new Function("scope", "rootScope", "http", "return new Promise((resolve) => {\r\n" + this.containerData.content_script + "\r\n});"))($scope, getRootScope($scope), $http); this.selections = this.selections || {}; //Set up context selections w/ links Object.keys(this.selections).forEach((selectionKey) => { var selection = this.selections[selectionKey]; if (selection.contextSelections) { Object.keys(selection.contextSelections).forEach((contextSelectionKey) => { var contextSelection = selection.contextSelections[contextSelectionKey]; contextSelection.onClick = contextSelection.onClick || $scope.directiveScope.selectContext; }); } }); Object.assign(this.searchCollector, this.selections); safeApply($scope); } catch (e) { this.selections = { "error": { label: "Error: " + e, class: "danger" } }; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: menuContainer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_610b4698fb29f524c0cc0735', ctrl_610b4698fb29f524c0cc0735); app.directive('ciDependencyMap', function() { return { scope: { rootQuery: "=", rootModel: "=?", allowedModelsQuery: "=?", parentalRelations: "=?", dynamicRelations: "=?", networkRelations: "=?", powerRelations: "=?", showDependants: "=?", showDependencies: "=?", depthLevels: "=?", mapOptions: "=?", onCiSelection: "=" }, link: function(s, e, a) { //Get background color of closest parent, use to set dark mode var p = e[0].parentElement; do { var c = getColorComponents(window.getComputedStyle(p).backgroundColor); if (c.r != 0 || c.g != 0 || c.b != 0) { s.directiveScope.darkMode = c.r < 128 && c.g < 128 && c.b < 128; console.log(s.directiveScope.darkMode); return; } p = p.parentElement; } while(p != null); function getColorComponents(_colorString) { try { _colorString = _colorString.replace("rgba", "rgb").split("rgb(")[1].split(")")[0]; var cs = _colorString.split(", "); return { r: parseInt(cs[0]), g: parseInt(cs[1]), b: parseInt(cs[2]), } } catch (e) { return {} } } } , controller: ctrl_615d9d92fc8f6522e5addce2, template: `
    Building relation map...
    `, bindToController: true};}); function ctrl_615d9d92fc8f6522e5addce2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.levelCount = 0; this.selectedCi = null this.nodes = []; this.relations = []; this.rootModel = this.rootModel || "cmdb_ci"; this.allowedModelsQuery = this.allowedModelsQuery || {}; this.parentalRelations = this.parentalRelations || true; this.dynamicRelations = this.dynamicRelations || true; this.networkRelations = this.networkRelations || true; this.powerRelations = this.powerRelations || true; this.depthLevels = this.depthLevels || true; this.showDependants = this.showDependants || false; this.showDependencies = this.showDependencies || false; this.dynamicColor = "#2859d4aa"; this.networkColor = "#3fd428aa"; this.powerColor = "#d42828aa"; this.parentalColor = "#cb28d4aa"; this.okColor = "#00ff00aa"; this.degradedColor = "#ffff00aa"; this.errorColor = "#ff0000aa"; this.lastNodeClickTime = null; this.options = { height: "100%", edges:{ smooth: { forceDirection: "none", roundness: 0.35 }, arrows: { to: { enabled: false }, middle: { enabled: true } } }, layout: { randomSeed: 1, improvedLayout: true, hierarchical: { enabled: true, direction: "DU", sortMethod: 'directed', shakeTowards: 'leaves', levelSeparation: 200, nodeSpacing: 300 } }, physics: { enabled: false, solver: "repulsion", repulsion: { centralGravity: 0.0001, springLength: 200, springConstant: 0.01, nodeDistance: 1000, damping: 0.09 } } }; this.update(); $scope.$watch("directiveScope.rootQuery", () => { $scope.directiveScope.update(); }); $scope.$watch("directiveScope.allowedModelsQuery", () => { $scope.directiveScope.update(); }); this.viewCiModal = {}; }; this.stateGlyphs = { ok: "✔️", degraded: "⚠️", error: "❌" }; this.update = function() { if (!this.loading) { this.levelCount = 0; mergeObjects(this.options, this.mapOptions); this.nodes = []; this.relations = []; this.modelLevels = []; this.loading = true; if (this.rootQuery && (this.rootModel != "cmdb_ci" || Object.keys(this.rootQuery).length > 0)) { $http.get( "/api/cmdb/" + JSON.stringify(this.rootQuery) + "/dependencies?rootModel=" + this.rootModel + "&allowedModelsQuery=" + JSON.stringify(this.allowedModelsQuery) + "&getDependants=" + this.showDependants + "&getDependencies=" + this.showDependencies , { withCredentials: true }).then( function(json){ json.data.forEach((result) => { $scope.directiveScope.addNode({ id: result.ci._id, ci: result.ci, label: $scope.directiveScope.stateGlyphs[result.ci.state] + " [" + $scope.$root.models[result.ci._type].singular_name + "]\r\n" + result.ci[$scope.$root.models[result.ci._type].display_field], image: result.ci.icon ? result.ci.icon.link : $scope.$root.models[result.ci._type].icon.link, level: 0 }); if($scope.directiveScope.showDependencies) { $scope.directiveScope.processDependencies(result, 1); } if($scope.directiveScope.showDependants) { $scope.directiveScope.processDependants(result, -1); } }); $scope.directiveScope.options.layout.hierarchical.levelSeparation = Math.min(500, Math.max(200, $scope.directiveScope.levelCount * 60)); $scope.directiveScope.initialized = true; $scope.directiveScope.loading = false; }); } else { this.initialized = true; this.loading = false; } } } this.buildTooltip = function(_ci) { if ($scope.$$phase) { return; } var model = $scope.$root.models[_ci._type]; var tooltip = document.createElement("div"); tooltip.innerHTML = `
    ` + _ci[model.display_field] + `
    ` + model.singular_name + `
    `; return tooltip; } this.processDependencies = function(_data, _level) { this.levelCount = Math.max(_level, this.levelCount); _level = _level || 0; if (this.parentalRelations) { _data.dependencies.forEach((dependency) => { try { this.addNode({ id: dependency.ci._id, ci: dependency.ci, label: $scope.directiveScope.stateGlyphs[dependency.ci.state] + " [" + $scope.$root.models[dependency.ci._type].singular_name + "]\r\n" + dependency.ci[$scope.$root.models[dependency.ci._type].display_field], image: dependency.ci.icon ? dependency.ci.icon.link : $scope.$root.models[dependency.ci._type].icon.link, level: this.depthLevels ? _level : this.getModelLevel(dependency.ci._type) + 1, // title: this.buildTooltip(dependency.ci) }); this.addRelation({ to: _data.ci._id, from: dependency.ci._id, color: { color: this[dependency.highestState + "Color"] } }); } catch (e) { console.log("Invalid Node: " + e); } this.processDependencies(dependency, _level + 1); }); } }; this.processDependants = function(_data, _level) { _level = _level || 0; if (this.parentalRelations) { _data.dependants.forEach((dependant) => { try { this.addNode({ id: dependant.ci._id, ci: dependant.ci, label: "[" + $scope.$root.models[dependant.ci._type].singular_name + "]\r\n" + dependant.ci[$scope.$root.models[dependant.ci._type].display_field], image: dependant.ci.icon ? dependant.ci.icon.link : $scope.$root.models[dependant.ci._type].icon.link, level: this.depthLevels ? _level : ((this.getModelLevel(dependant.ci._type) + 1) * -1), }); this.addRelation({ to: dependant.ci._id, from: _data.ci._id, color: { color: this[dependant.ci.state + "Color"] } }); } catch (e) { console.log("Invalid Node: " + e); } this.processDependants(dependant, _level - 1); }); } }; this.addNode = function(_newNode) { if (!this.nodes.some((node) => { return node.id == _newNode.id; })) { _newNode.font = { color: this.darkMode ? "#ffffff" : "#000000" } this.nodes.push(_newNode); } } this.addRelation = function(_newRelation) { if (!this.relations.some((relation) => { return relation.to == _newRelation.to && relation.from == _newRelation.from ; })) { _newRelation.color = _newRelation.color ? _newRelation.color : {}; _newRelation.color.highlight = "#dddd00"; this.relations.push(_newRelation); } } this.getModelLevel = function(_model) { var index = this.modelLevels.indexOf(_model); if (index == -1) { this.modelLevels.push(_model); return this.modelLevels.length - 1; } else { return index; } } this.onNodeSelection = function(_data) { var node = $scope.directiveScope.nodes.find((node) => { return node.id == _data.nodes[0]; }); if ($scope.directiveScope.selectedCi == node.ci && (new Date() - $scope.directiveScope.lastNodeClickTime) < 500) { //Dispose and re-init the modal form $scope.directiveScope.viewCiModal.ci = null; $scope.$apply(); $scope.directiveScope.viewCiModal.ci = $scope.directiveScope.selectedCi; $scope.$apply(); //Show the modal $scope.directiveScope.viewCiModal.show(); } $scope.directiveScope.selectedCi = node.ci; $scope.directiveScope.lastNodeClickTime = new Date(); if ($scope.directiveScope.onCiSelection) { $scope.directiveScope.onCiSelection($scope.directiveScope.selectedCi); } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: ciDependencyMap failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_615d9d92fc8f6522e5addce2', ctrl_615d9d92fc8f6522e5addce2); app.directive('employeeReportsChart', function() { return { scope: { isChild: "=?", bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_618d2dd29f946576ec692490, template: `{{directiveScope.employee.full_name}}
    {{directiveScope.employee.position}} `, bindToController: true};}); function ctrl_618d2dd29f946576ec692490($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; console.log(this); this.employee = null; this.reports = []; retrieveRecord($scope, $http, "employee", { query: { _id: this.bindingParent[this.bindingName] } }, (record) => { $scope.directiveScope.employee = record; }); retrieveRecords($scope, $http, "employee", { query: { supervisor: this.bindingParent[this.bindingName] }, select: ["_id", "full_name"] }, (result) => { $scope.directiveScope.reports = result.records; console.log($scope.directiveScope); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: employeeReportsChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_618d2dd29f946576ec692490', ctrl_618d2dd29f946576ec692490); app.directive('referenceSelection', function() { return { scope: { display: "=?", //Field to display (default if not provided) onChange: "&", refModel: "=", allowNew: "=?", allowView: "=?", allowEdit: "=?", allowSelection: "=?", displayRecord: "=?", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) layoutName: "=", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used allowInteraction: "=?" //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) }, controller: ctrl_618d43be9f946576ec6924a6, template: `
     {{directiveScope.loading ? 'Loading...' : (directiveScope.displayRecord[directiveScope.display ? directiveScope.display : $root.models[directiveScope.refModel].display_field])}}
    `, bindToController: true};}); function ctrl_618d43be9f946576ec6924a6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.listModal = {}; this.currentRecordModal = {}; this.newRecordModal = { newRecord: {} }; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; $scope.directiveScope = this; this.unique = createUniqueTag(); this.loading = false; this.refQualifier = this.refQualifier || {}; //Normlize binding (to single id string or null) //this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] ? (typeof(this.bindingParent[this.bindingName]) == "object" ? this.bindingParent[this.bindingName]._id : this.bindingParent[this.bindingName]) : null; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && this.bindingParent[this.bindingName] && typeof(this.bindingParent[this.bindingName]) == "object") { this.displayRecord = this.bindingParent[this.bindingName]; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName]._id; } else { //Init load bound record this.loading = true; if (this.bindingParent[this.bindingName]) { //Get existing record this.loadDisplayRecord(); } else { this.displayRecord = null; this.loading = false; } } //Watch for binding change $scope.$watch('[directiveScope.bindingParent, directiveScope.bindingName, directiveScope.bindingParent[directiveScope.bindingName]]', function (newValue, oldValue, scope) { if (newValue != oldValue && !$scope.directiveScope.displayUpdating) { $scope.directiveScope.bindingUpdating = true; $scope.directiveScope.loadDisplayRecord(() => { $scope.directiveScope.bindingUpdating = false; }); } }, true); //Watch for record change $scope.$watch('directiveScope.displayRecord', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.displayUpdating = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.displayUpdating = false; $scope.directiveScope.onChange(); } }, true); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); } this.loadDisplayRecord = function(_fresh, _then) { if (!this.bindingParent[this.bindingName]) { this.displayRecord = null; this.loading = false; if (_then) { _then(); } } else if (_fresh) { retrieveRecord($scope, $http, this.refModel, { query: { _id: this.bindingParent[this.bindingName] }}, (record) => { this.displayRecord = record; this.loading = false; if (_then) { _then(); } }); } else { retrieveRecord($scope, $http, this.refModel, { query: { _id: this.bindingParent[this.bindingName] }}, (record) => { this.displayRecord = record; this.loading = false; if (_then) { _then(); } }); } } this.showCurrent = function() { if (this.allowView && this.displayRecord) { this.currentRecordModal.show(() => { this.loadDisplayRecord(true); }); } } this.showNew = function() { this.newRecordModal.newRecord = {}; this.newRecordModal.show(() => { if (this.newRecordModal.newRecord._id) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = this.newRecordModal.newRecord._id; this.loadDisplayRecord(true); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: referenceSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_618d43be9f946576ec6924a6', ctrl_618d43be9f946576ec6924a6); app.directive('pieChart', function() { return { scope: { values: "=", height: "=?", width: "=?", showLegend: "=?" }, controller: ctrl_61ba54770e56cf722b8d22ed, template: `
    `, bindToController: true};}); function ctrl_61ba54770e56cf722b8d22ed($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; // this.height = this.height || 200; // this.width = this.width || 200; this.options = { maintainAspectRatio: false, elements: { arc: { borderWidth: 1, circular: false } }, legend: ($scope.directiveScope.showLegend ? { display: true, position: "left", align: "start", maxWidth: 100, labels: { padding: 2, font: { size: 5 } } } : null) }; //Process plot objects this.process(); //Configure watch $scope.$watch('directiveScope.values', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); }; this.process = function() { //Build this.labels = Object.keys(this.values); this.data = Object.values(this.values); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pieChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61ba54770e56cf722b8d22ed', ctrl_61ba54770e56cf722b8d22ed); app.directive('addressEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", validateMethod: "=?", //should return an object { field_name: "error", ...} formatMethod: "=?" //should modify the values directly }, controller: ctrl_61e279aaa826a737863a211c, template: `
    {{directiveScope.validationErrors.company}}
    {{directiveScope.validationErrors.address_1}}
    {{directiveScope.validationErrors.address_2}}
    {{directiveScope.validationErrors.address_3}}
    {{directiveScope.validationErrors.phone}}
    {{directiveScope.validationErrors.fax}}
    {{directiveScope.validationErrors.contact}}
    {{directiveScope.validationErrors.city}}
    {{directiveScope.validationErrors.state}}
    {{directiveScope.validationErrors.postal_code}}
    {{directiveScope.validationErrors.country}}
    {{directiveScope.validationErrors.email}}
    `, bindToController: true};}); function ctrl_61e279aaa826a737863a211c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.validationErrors = {}; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.formatting = false; this.default = { address_1: "", address_2: "", address_3: "", city: "", state: "", country: "", company: "", contact: "", postal_code: "", phone: "", fax: "", email: "", tax_id: "" }; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new , _old) => { //Normalize binding $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || {}; Object.keys($scope.directiveScope.default).forEach((k) => { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][k] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][k] || $scope.directiveScope.default[k]; }); //Format and validate if ($scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { if (!$scope.directiveScope.formatting && $scope.directiveScope.formatMethod && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.formatting = true; $scope.directiveScope.formatMethod($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); $scope.directiveScope.formatting = false; } if ($scope.directiveScope.validateMethod && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.validationErrors = $scope.directiveScope.validateMethod($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } }, true); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61e279aaa826a737863a211c', ctrl_61e279aaa826a737863a211c); app.directive('shippingDetailsEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61e27e46a826a737863a211e, template: `
    `, bindToController: true};}); function ctrl_61e27e46a826a737863a211e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; if (this.bindingParent && this.bindingName) { this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || { transportation: { bill_to: "shipper", account_number: null }, transportation: { bill_to: "shipper", account_number: null }, transportation: { bill_to: "shipper", account_number: null } }; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingDetailsEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61e27e46a826a737863a211e', ctrl_61e27e46a826a737863a211e); app.directive('singleReferenceSearch', function() { return { scope: { title: "=", display: "=?", refModel: "=", refQualifier: "=?", displayRecord: "=?", searchFields: "=?", //Can be string or array of strings populate: "=?", sort: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) onChange: "&" }, controller: ctrl_61e4a8fc00f61e070a6522fe, template: `
    `, bindToController: true};}); function ctrl_61e4a8fc00f61e070a6522fe($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.display = this.display == null ? $scope.$root.models[this.refModel].display_field : this.display; this.searchFields = this.searchFields == null ? this.display : this.searchFields; this.search = ""; this.populate = this.populate || {}; this.searching = false; this.focused = false; $scope.directiveScope = this; $scope.parentBaseFormScope = searchFullScope($scope.$parent, "directiveScope"); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if (!$scope.directiveScope.settingBinding) { retrieveRecord($scope, $http, $scope.directiveScope.refModel, { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }, populate: $scope.directiveScope.populate }, (record) => { $scope.directiveScope.settingDisplay = true; $scope.directiveScope.displayRecord = record; $scope.directiveScope.settingDisplay = false; $scope.directiveScope.search = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord[this.display] : ($scope.directiveScope.focused ? $scope.directiveScope.search : ""); }); } }); $scope.$watch("directiveScope.displayRecord", () => { if (!$scope.directiveScope.settingDisplay) { $scope.directiveScope.settingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.settingBinding = false; } }); this.searchChanged = function() { this.settingBinding = true; this.bindingParent[this.bindingName] = null; this.settingBinding = false; } this.keypress = function(_event) { if (_event.originalEvent.charCode == 13) { this.doSearch(); } } this.clear = function() { this.settingBinding = true; this.bindingParent[this.bindingName] = null; this.settingBinding = false; this.search = ""; } this.doSearch = function() { //Populate selections this.searching = true; var query = { $or: (Array.isArray(this.searchFields) ? this.searchFields : [searchFields]).map((f) => { var fq = {}; fq[f] = this.search; return fq; }) }; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: query , limit: 1, populate: $scope.directiveScope.populate }, (response) => { $scope.directiveScope.displayRecord = response.total_count == 1 ? response.records[0] : null; $scope.directiveScope.searching = false; }); } this.searchChanged(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceSearch failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61e4a8fc00f61e070a6522fe', ctrl_61e4a8fc00f61e070a6522fe); app.directive('shippingProgress', function() { return { scope: { stages: "=?" }, controller: ctrl_61e65d79b18ddf0e58ef5d5b, template: `
    {{stage.subtext}}
    `, bindToController: true};}); function ctrl_61e65d79b18ddf0e58ef5d5b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; ; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingProgress failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61e65d79b18ddf0e58ef5d5b', ctrl_61e65d79b18ddf0e58ef5d5b); app.directive('shipmentTrackingDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61e665450bdbba0f24577bae, template: `
    Package {{$index + 1}} of {{directiveScope.bindingParent[directiveScope.bindingName].packages.length}}:
    {{package.currentStatus.toTitleCase()}}
    Expected Delivery Date: {{package.scheduledDeliveryDate | date}}
    `, bindToController: true};}); function ctrl_61e665450bdbba0f24577bae($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shipmentTrackingDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61e665450bdbba0f24577bae', ctrl_61e665450bdbba0f24577bae); app.directive('addressDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61eb8a0321702358e0553219, template: `

    {{directiveScope.bindingParent[directiveScope.bindingName].address_1}}
    {{directiveScope.bindingParent[directiveScope.bindingName].address_2}}
    {{directiveScope.bindingParent[directiveScope.bindingName].address_3}}
    {{directiveScope.bindingParent[directiveScope.bindingName].city}}, {{directiveScope.bindingParent[directiveScope.bindingName].state}} {{directiveScope.bindingParent[directiveScope.bindingName].postal_code}} {{directiveScope.bindingParent[directiveScope.bindingName].country}}

    {{directiveScope.bindingParent[directiveScope.bindingName].company}}

    {{directiveScope.bindingParent[directiveScope.bindingName].contact}}

    {{directiveScope.bindingParent[directiveScope.bindingName].email}}

    {{directiveScope.bindingParent[directiveScope.bindingName].phone}}

    {{directiveScope.bindingParent[directiveScope.bindingName].fax}}
    `, bindToController: true};}); function ctrl_61eb8a0321702358e0553219($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.bindingParent[this.bindingName] = !this.bindingParent[this.bindingName] || typeof(this.bindingParent[this.bindingName]) != "object" ? {} : this.bindingParent[this.bindingName]; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61eb8a0321702358e0553219', ctrl_61eb8a0321702358e0553219); app.directive('shippingTrackingNumberPackageDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61ebc0512c72ca5c503f523d, template: `
    Package {{$index + 1}} of {{directiveScope.bindingParent[directiveScope.bindingName].length}}
    {{package.number}} {{package.state == "in_transit" ? (package.location.city + ", " + package.location.state + " " + package.location.postal_code + " " + package.location.country) : ""}}
    {{activity.timestamp | date}} {{activity.state == "in_transit" ? (activity.location.city + ", " + activity.location.state + " " + activity.location.postal_code + " " + activity.location.country) : ""}}
    `, bindToController: true};}); function ctrl_61ebc0512c72ca5c503f523d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingTrackingNumberPackageDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61ebc0512c72ca5c503f523d', ctrl_61ebc0512c72ca5c503f523d); app.directive('shippingPaymentEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", addressValidateMethod: "=?", addressFormatMethod: "=?", shipperAccount: "=?", shipperAddress: "=?", receiverAccount: "=?", receiverAddress: "=?", thirdPartyAccount: "=?", thirdPartyAddress: "=?" }, controller: ctrl_61ecccf39d099561895d5e48, template: `









    `, bindToController: true};}); function ctrl_61ecccf39d099561895d5e48($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.tabs = { shipping: { visible: true, label: "Shipping Charges" }, duties_and_taxes: { visible: true, label: "Duties & Taxes" }, broker: { visible: true, label: "Broker" } }; this.updateShippingFields = function() { $scope.directiveScope.updateFields("shipping"); }; this.updateDutiesAndTaxesFields = function() { $scope.directiveScope.updateFields("duties_and_taxes"); }; this.updateBrokerFields = function() { $scope.directiveScope.updateFields("broker"); }; this.updateFields = function(_area) { var party = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_area].responsible_party; if (party == "third_party") { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_area].courier_account_number = $scope.directiveScope.thirdPartyAccount || ""; $scope.directiveScope.cloneAddress( $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_area].address, $scope.directiveScope.thirdPartyAddress || {} ); } else { var account = $scope.directiveScope[party + "Account"]; if (account) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_area].courier_account_number = account; } //Only update address if its available and different var address = $scope.directiveScope[party + "Address"]; if (address) { $scope.directiveScope.cloneAddress( $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_area].address, address ); } } } this.cloneAddress = function(_target, _source) { var n = {}; _source = _source || {}; [...Object.keys(_source), ...Object.keys(_target)].forEach((k) => { n[k] = _source[k] }); Object.assign(_target, n); } this.updateShippingFields(); this.updateDutiesAndTaxesFields(); this.updateBrokerFields(); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingPaymentEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61ecccf39d099561895d5e48', ctrl_61ecccf39d099561895d5e48); app.directive('addressDisplayMinimal', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61ecd4b286904661c0c80e9f, template: `{{directiveScope.bindingParent[directiveScope.bindingName].address_1 + " " + directiveScope.bindingParent[directiveScope.bindingName].address_2 + " " + directiveScope.bindingParent[directiveScope.bindingName].address_3 + " " + directiveScope.bindingParent[directiveScope.bindingName].city + ", " + directiveScope.bindingParent[directiveScope.bindingName].state + " " + directiveScope.bindingParent[directiveScope.bindingName].postal_code}}`, bindToController: true};}); function ctrl_61ecd4b286904661c0c80e9f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressDisplayMinimal failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61ecd4b286904661c0c80e9f', ctrl_61ecd4b286904661c0c80e9f); app.directive('shippingChargesDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61ed1fdd4f33f863a2ec6ff0, template: `
    Total Charge:  
    {{directiveScope.bindingParent[directiveScope.bindingName].total_charge | currency}}
    -
     {{message.source}}: {{message.message}}
    `, bindToController: true};}); function ctrl_61ed1fdd4f33f863a2ec6ff0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingChargesDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61ed1fdd4f33f863a2ec6ff0', ctrl_61ed1fdd4f33f863a2ec6ff0); app.directive('barChart', function() { return { scope: { maxHeight: "=?", axisXLabel: "=?", axisYLabel: "=?", series: "=?", stack: "=?" }, controller: ctrl_61f7df52926e9304e2bf8351, template: `
    `, bindToController: true};}); function ctrl_61f7df52926e9304e2bf8351($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { /* Series Data Format [ [ { value, barColor, label, hoverTitle, hoverBody } ] ] */ this.$onInit = function() { $scope.directiveScope = this; this.chartData = {}; this.chartSeries = []; this.chartColors = []; this.chartOptions = {}; this.datasetOverride = []; //Process plot objects this.process(); //Configure watch $scope.$watch('directiveScope.series', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); }; this.process = function() { this.series = this.series || []; this.chartOptions = { responsive: true, maintainAspectRatio: false, tooltips: { yAlign: 'top', bodyFontSize: 14, callbacks: { title: (_tooltipItem, _data) => { return _tooltipItem.map((value) => { return $scope.directiveScope.series[value.datasetIndex].values[value.index].hoverTitle })[0]; }, label: (_tooltipItem, _data) => { return $scope.directiveScope.series[_tooltipItem.datasetIndex].values[_tooltipItem.index].hoverBody } } }, scales: { yAxes: [{ stacked: true, ticks: { suggestedMin: 0, suggestedMax: 100, fontSize: 12, fontColor: "#aaaaaa" }, scaleLabel: { display: true, fontSize: 15, labelString: this.axisYLabel } }], xAxes: [{ stacked: true, ticks: { fontColor: "#aaaaaa", fontSize: 12 }, scaleLabel: { display: true, fontSize: 15, labelString: this.axisXLabel } }] } }; this.chartSeries = []; this.chartData = []; this.chartDatasetOverride = []; //Collect x axis values this.chartLabels = this.series.map((seriesEntry) => { return seriesEntry.values.map((value) => { return value.x }); }).flat().distinct(); //Itterate through array of arrays in binding this.series.forEach((seriesEntry) => { this.chartSeries.push(seriesEntry.label); var seriesData = []; var bgColors = []; seriesEntry.values.forEach((value) => { seriesData.push(value.y); bgColors.push(value.barColor); }); this.chartData.push(seriesData); this.chartDatasetOverride.push({ backgroundColor: bgColors, borderColor: "#00000000" }); }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: barChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61f7df52926e9304e2bf8351', ctrl_61f7df52926e9304e2bf8351); app.directive('checkBox', function() { return { scope: { bindingName: "=", bindingParent: "=", onChange: "&", allowInteraction: "=?" }, controller: ctrl_61fc2c0336d8370c1661d424, template: ` `, bindToController: true};}); function ctrl_61fc2c0336d8370c1661d424($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: checkBox failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_61fc2c0336d8370c1661d424', ctrl_61fc2c0336d8370c1661d424); app.directive('printerSettingsEntry', function() { return { scope: { bindingName: "=?", bindingParent: "=?", printerBindingName: "=?", printerBindingParent: "=?", allowInteraction: "=?" }, controller: ctrl_620ba02ddb5db0052c779b0d, template: `
    {{settingName}}
    `, bindToController: true};}); function ctrl_620ba02ddb5db0052c779b0d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || {}; this.cupsDriverData = {}; this.rawBindings = {}; this.selections = {}; this.cupsSizingConstant = 0.283; this.paperSizes = []; this.formatLabels = function(_label) { var paperSize = $scope.directiveScope.paperSizes.find((ps) => { return ps.cups_tags.includes(_label); }); if (paperSize) { return { label: paperSize.name, icon: $scope.$root.models.paper_size.icon.link }; } else if (/[w]\d*[h]\d*/.test(_label)) { var comps = _label.split("w")[1].split("h"); var w = Math.round(parseFloat(comps[0]) / $scope.directiveScope.cupsSizingConstant) / 10; var h = Math.round(parseFloat(comps[1]) / $scope.directiveScope.cupsSizingConstant) / 10; return { label: w + "mm X " + h + "mm (WxH) [" + comps[0] + "x" + parseFloat(comps[1]) + "]" }; } else { return { label: _label }; } } this.buildSelections = function() { $scope.directiveScope.selections = {}; Object.keys($scope.directiveScope.cupsDriverData || {}).forEach((settingName) => { $scope.directiveScope.selections[settingName] = {}; Object.keys($scope.directiveScope.cupsDriverData[settingName]).forEach((settingSelection) => { var formatting = $scope.directiveScope.formatLabels(settingSelection); $scope.directiveScope.selections[settingName][settingSelection] = { label: formatting.label + ($scope.directiveScope.cupsDriverData[settingName][settingSelection] ? " (Default)" : ""), icon: formatting.icon, class: $scope.directiveScope.cupsDriverData[settingName][settingSelection] ? "secondary" : "primary" }; }); }); } retrieveRecords($scope, $http, "paper_size", {}, (response) => { $scope.directiveScope.paperSizes = response.records; $scope.directiveScope.buildSelections(); }); } $scope.$watch("directiveScope.printerBindingParent[directiveScope.printerBindingName]", () => { //Printer has changed, update the available selections if ($scope.directiveScope.printerBindingParent && $scope.directiveScope.printerBindingName && $scope.directiveScope.printerBindingParent[$scope.directiveScope.printerBindingName]) { retrieveRecord($scope, $http, "cmdb_printer", { query: { _id: $scope.directiveScope.printerBindingParent[$scope.directiveScope.printerBindingName] }}, (printer) => { $scope.directiveScope.cupsDriverData = printer.cups_driver_data; $scope.directiveScope.buildSelections(); }); } else { $scope.directiveScope.cupsDriverData = null; $scope.directiveScope.buildSelections(); } }); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printerSettingsEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_620ba02ddb5db0052c779b0d', ctrl_620ba02ddb5db0052c779b0d); app.directive('multipleReferenceCheckboxSelection', function() { return { scope: { refModel: "=", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", selections: "=?", limit: "=?", sort: "=?" }, controller: ctrl_6213881852a51a0cc9e0e091, template: `
    {{selection[$root.models[directiveScope.refModel].display_field]}}
     All  `, bindToController: true};}); function ctrl_6213881852a51a0cc9e0e091($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; $scope.directiveScope = this; this.selections = []; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.selectionsReady = false; this.refQualifier = this.refQualifier || {}; this.updateBinding = function() { if (!$scope.directiveScope.updatingSelections && $scope.directiveScope.selectionsReady) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.selections.filter((s) => { return s._checked; }).map((s) => { return s._id; }); $scope.directiveScope.updatingBinding = false; } } this.updateSelections = function() { if (!$scope.directiveScope.updatingBinding && $scope.directiveScope.selectionsReady) { $scope.directiveScope.updatingSelections = true; $scope.directiveScope.selections.forEach((s) => { s._checked = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].includes(s._id); }); $scope.directiveScope.updatingSelections = false; } } this.updateSelectionRecords = function(){ $scope.directiveScope.selectionsReady = false; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: $scope.directiveScope.refQualifier, limit: $scope.directiveScope.limit, sort: $scope.directiveScope.sort }, (response) => { $scope.directiveScope.selections = response.records; $scope.directiveScope.selectionsReady = true; $scope.directiveScope.updateSelections(); }); }; this.selectAll = function() { if (confirm("Are you sure you want to select all applicable " + $scope.$root.models[$scope.directiveScope.refModel].plural_name + " records?")) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = []; $scope.directiveScope.selections.forEach((s) => { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push(s._id); }); } } this.clear = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = []; } }; $scope.$watch("directiveScope.selections", () => { //Watch selections and update binding using [selections]._checked; if ($scope.directiveScope.selections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Now update the binding $scope.directiveScope.updateBinding(); } }, true); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Watch binding and update selection values if ($scope.directiveScope.selections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Binding modified $scope.directiveScope.updateSelections(); } }, true); $scope.$watch("directiveScope.refQualifier", () => { $scope.directiveScope.updateSelectionRecords(); });; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleReferenceCheckboxSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6213881852a51a0cc9e0e091', ctrl_6213881852a51a0cc9e0e091); app.directive('shippingPackagesEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", lineQuery: "=?", courierRecord: "=?", serviceType: "=?", showTracking: "=?", /* hazmatAvailable: "=?", totalPackages: "=?", totalWeight: "=?", totalValue: "=?", totalUnits: "=?", defaultLabelPrinter: "=?", defaultDocumentPrinter: "=?"*/ }, controller: ctrl_624b15bf4b89d37846f72cbc, template: `
    Shipment Lines
    Shipment Line Item Number Description Category Price List Unit Price Comments Total Qty. Qty. Packed Qty. to Pack Packing Options
    {{line.shipment_number}} {{line.line_number}} {{line.item_number}} {{line.item_description}} {{line.category}} {{line.price_list}} {{line.shipment_unit_price | currency}} {{line.quantity_shipped}} {{directiveScope.getQuantityPacked(line)}} {{line.quantity_shipped - directiveScope.getQuantityPacked(line)}}  Packed




    Packages
    # Type Courier Type Height
    IN
    Length
    IN
    Width
    IN
    Weight
    LBS
    Value
    USD
    Packed Items Sig. Required State Progress Location Tracking Number Shipping Label Return Label DoDG
    {{$index + 1}} {{package.height}} {{package.length}} {{package.width}} {{directiveScope.allowInteraction ? "" : package.weight}} {{package.value | currency}}
    {{a = directiveScope.getItemRecord(itemId); a.number + ": " + a.description}}
    {{quantity}} from {{directiveScope.getLineRecord(lineId).shipment_number}} line {{directiveScope.getLineRecord(lineId).line_number}}
    N/A
    {{package.tracking_number}}
    `, bindToController: true};}); function ctrl_624b15bf4b89d37846f72cbc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.availableLines = []; this.packingSelections = {}; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; this.containerQuery = null; $scope.$watch("directiveScope.courierRecord", () => { $scope.directiveScope.updateContainerQuery(); }); $scope.$watch("directiveScope.serviceType", () => { $scope.directiveScope.updateContainerQuery(); }); $scope.$watch("directiveScope.lineQuery", () => { $scope.directiveScope.updateAvailableLines(); }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.rebuildPackages(); }, true); this.updateContainerQuery = function() { if ($scope.directiveScope.courierRecord && $scope.directiveScope.serviceType) { //Only allow containers with courier/serviceType container map $scope.directiveScope.containerQuery = { }; var key = "courier_package_types." + $scope.directiveScope.courierRecord._id + "." + $scope.directiveScope.serviceType; $scope.directiveScope.containerQuery[key] = { $ne: null }; } else { //Insufficient info to query for containers $scope.directiveScope.containerQuery = null; } } this.onPackSelection = function(_selection, _scope) { var sourceLine = _scope.bindingParent; var targetPackage = null; if (_selection == "new") { //Add new package targetPackage = $scope.directiveScope.addNewPackage(); } else { //Add to existing package targetPackage = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][parseInt(_selection)]; } //Get number to pack var toPack = prompt("How many of the " + sourceLine.quantity_shipped + " items would you like to pack?", sourceLine.quantity_shipped); if (toPack && !isNaN(parseInt(toPack))) { //Insert to line item entry $scope.directiveScope.addItemsToPackage(targetPackage, sourceLine, parseInt(toPack)); } }; this.updateAvailableLines = function() { $scope.directiveScope.busy = true; $scope.directiveScope.availableLines = []; if (!$scope.directiveScope.lineQuery || Object.keys($scope.directiveScope.lineQuery).length == 0) { //Bad query } else { retrieveRecords($scope, $http, "virtual_sage_shipment_line", { query: { $and: [ { line_type: "item" }, $scope.directiveScope.lineQuery] }, sort: { shipment_number: "desc" } }, (lineResponse) => { $scope.directiveScope.availableLines = lineResponse.records; //Retrieve the item number info for all lines retrieveRecords($scope, $http, "virtual_sage_item", { query: { number: { $in: $scope.directiveScope.availableLines.map((l) => { return l.item_number }) }}, }, (itemResponse) => { $scope.directiveScope.availableLines.forEach((l) => { //Bind item record l.item_record = itemResponse.records.find((i) => { return i.number == l.item_number; }); }); //Build selections $scope.directiveScope.updatePackingSelections(); $scope.directiveScope.busy = false; }); }); } } this.rebuildPackages = function() { if (!$scope.directiveScope.rebuildingPackages) { $scope.directiveScope.rebuildingPackages = true; $scope.directiveScope.busy = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].forEach((package) => { var updates = { type: package.container_record ? (package.container_record.courier_package_types[$scope.directiveScope.courierRecord._id] || {})[$scope.directiveScope.serviceType] : null, length: package.container_record ? package.container_record.length : 0, height: package.container_record ? package.container_record.height : 0, width: package.container_record ? package.container_record.width : 0, value: 0, description: "" }; Object.keys(package.contained_items).forEach((itemId) => { var itemRecord = $scope.directiveScope.getItemRecord(itemId); //All items in a package should be from the same COO and have the same Hazmat levels var sourceLines = package.contained_items[itemId].source_lines; var itemTotalCount = Object.values(sourceLines).sum(); updates.description += (itemTotalCount + " x " + itemRecord.number + "\r\n"); //Get the first line with this item var firstLineRecord = $scope.directiveScope.getLineRecord(Object.keys(sourceLines)[0]); //TODO, will need to make this work with > 1 material in the future var material = itemRecord.materials[0] || {}; Object.assign(package.contained_items[itemId], { unit_value: firstLineRecord.shipment_unit_price, country_of_origin: itemRecord.optional_fields.COUNTRYORIGN, description: (itemRecord.number + ": " + itemRecord.description), //Set material info hts_number: material.shipping_hts_number || itemRecord.optional_fields.HTSUS, hazard_class: material.shipping_hazard_class, unna_number: material.shipping_unna_number, proper_name: material.shipping_proper_name, regulation_level: material.shipping_regulation_level, material: material._id }); Object.keys(package.contained_items[itemId].source_lines).forEach((lineId) => { var lineRecord = $scope.directiveScope.getLineRecord(lineId); updates.value += package.contained_items[itemId].source_lines[lineId] * lineRecord.shipment_unit_price; }); }); Object.assign(package, updates); }); $scope.directiveScope.updatePackingSelections(); $scope.directiveScope.busy = false; $scope.directiveScope.rebuildingPackages = false; } } this.updatePackingSelections = function() { $scope.directiveScope.availableLines.forEach((l) => { var selections = null; if (l.quantity_shipped - $scope.directiveScope.getQuantityPacked(l) > 0) { //Still items to pack selections = { new: { label: "New Package", class: "success", icon: "/media/add_icon.png" } }; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].forEach((package, i) => { selections[i] = { label: "Package #" + (i + 1), class: "primary", icon: "/media/shipping_package.png" } }); } l.packingSelections = selections; }); } this.getQuantityPacked = function(_line) { var packed = 0; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].forEach((package) => { if (_line.item_record && package.contained_items[_line.item_record._id] && package.contained_items[_line.item_record._id].source_lines) { //This line's item is packed, is it from _line? packed += (package.contained_items[_line.item_record._id].source_lines || {})[_line._id] || 0; } }); return packed; } this.removePackage = function(_package) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((p) => { return p != _package; }); $scope.directiveScope.updatePackingSelections(); } this.removeItemsFromPackage = function(_package, _line) { delete _package.contained_items[_line.item_record._id].source_lines[_line._id]; //If this was the last line in the package, remove the whole item if (Object.keys(_package.contained_items[_line.item_record._id].source_lines).length == 0) { delete _package.contained_items[_line.item_record._id]; } $scope.directiveScope.updatePackingSelections(); } this.addItemsToPackage = function(_package, _line, _count) { _package.contained_items[_line.item_record._id] = _package.contained_items[_line.item_record._id] || { source_lines: {} }; _package.contained_items[_line.item_record._id].source_lines[_line._id] = _count; $scope.directiveScope.updatePackingSelections(); }; this.addNewPackage = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push({ width: 0, length: 0, height: 0, weight: 0, description: null, signature_required: "none", type: null, contained_items: {} }); return $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].last(); }; this.getItemRecord = function(_id) { var line = $scope.directiveScope.availableLines.find((l) => { return l.item_record._id == _id; }); return line ? line.item_record : null; } this.getLineRecord = function(_id) { return $scope.directiveScope.availableLines.find((l) => { return l._id == _id; }); } this.p = null; this.updateAvailableLines(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shippingPackagesEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_624b15bf4b89d37846f72cbc', ctrl_624b15bf4b89d37846f72cbc); app.directive('shipmentLineCommentEditor', function() { return { scope: { shipmentLineRecord: "=?" }, controller: ctrl_624c85437c1a850bb761139b, template: `✎ Edit   {{directiveScope.getOnlyComments().length}} Comments  |  {{directiveScope.getOnlyInstructions().length}} Instructions
    Comments
    {{comment.value}}
    Instructions
    {{instruction.value}}
    Text will be automatically split into seperate comments by size
    `, bindToController: true};}); function ctrl_624c85437c1a850bb761139b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.getOnlyComments = function() { return $scope.directiveScope.shipmentLineRecord.comments.filter((c) => { return c.comment_type == "comment"; }); }; this.getOnlyInstructions = function() { return $scope.directiveScope.shipmentLineRecord.comments.filter((c) => { return c.comment_type == "instruction"; }); }; this.maxCommentLength = 80; this.editModal = { busy: false, newCommentText: "", newCommentType: "comment", newCommentSelections: { comment: { class: "primary", label: "Comment" }, instruction: { class: "success", label: "Instruction" } }, addComments: function() { $scope.directiveScope.editModal.busy = true; //Get ALL comments for this WHOLE shipment (unique on shipment scope) retrieveRecords($scope, $http, "virtual_sage_shipment_line_comment", { query: { shipment_unique: $scope.directiveScope.shipmentLineRecord.shipment_unique }}, (response) => { //Get next comment number $scope.directiveScope.editModal.nextCommentNumber = Math.max(0, ...response.records.map((comment) => { return comment.comment_number; })) + 1; addComment(() => { retrieveRecord($scope, $http, "virtual_sage_shipment_line", { query: { _id: $scope.directiveScope.shipmentLineRecord._id }}, (updatedLineRecord) => { if (updatedLineRecord) { $scope.directiveScope.shipmentLineRecord.comments = updatedLineRecord.comments; } $scope.directiveScope.editModal.busy = false; }); }); }); function addComment(_then) { if ($scope.directiveScope.editModal.newCommentText.length > 0) { //Split the raw text up by line returns (and maximum comment length) var nextNewline = $scope.directiveScope.editModal.newCommentText.indexOf("\n"); var endIndex = Math.min($scope.directiveScope.maxCommentLength, (nextNewline == -1 ? 9999999 : nextNewline)); var commentText = $scope.directiveScope.editModal.newCommentText.substring(0, endIndex); $scope.directiveScope.editModal.newCommentText = $scope.directiveScope.editModal.newCommentText.substring(endIndex + 1); insertRecord($scope, $http, "virtual_sage_shipment_line_comment", { value: commentText, comment_type: $scope.directiveScope.editModal.newCommentType, comment_number: $scope.directiveScope.editModal.nextCommentNumber, shipment_unique: $scope.directiveScope.shipmentLineRecord.shipment_unique, shipment_line_number: $scope.directiveScope.shipmentLineRecord.line_number }, (result) => { if (result.success) { $scope.directiveScope.editModal.nextCommentNumber++; addComment(_then); } else { _then(); } }); } else { if (_then) { _then(); } } } } } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shipmentLineCommentEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_624c85437c1a850bb761139b', ctrl_624c85437c1a850bb761139b); app.directive('diagramEditor', function() { return { scope: { bindingName: "=?", bindingParent: "=?", imageBindingName: "=?", //Image file data will be written here template: "=?", allowInteraction: "=?" } , controller: ctrl_624de032795b0e18da834740, template: ``, bindToController: true};}); function ctrl_624de032795b0e18da834740($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.template = `ddHBDoMgDADQr+GO4hLuzm2XnTzsTKQDErQGWXT7+mnAOeJ2Al5bSgphZTudnej1FSVYklM5EXYkeZ5xTudlkWeUghZBlDMy2ga1eUHEWKgeRsKQJHpE602fYoNdB41PTDiHY5p2R5t27YWCHdSNsHu9Gel1UH6gm1/AKL12zmiMtGJNjjBoIXH8IlYRVjpEH3btVIJdprfOJdSd/kQ/D3PQ+R8F82a7ez4kX8SqNw==`; this.bindingUpdated = function() { if (!$scope.directiveScope.updating && $scope.directiveScope.ready) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.updating = true; $scope.directiveScope.loadXml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } else { $scope.directiveScope.loadXml($scope.directiveScope.template); } } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", $scope.directiveScope.bindingUpdated); this.editorUpdated = function(_xml) { if (!$scope.directiveScope.updating && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.updating = true; $scope.directiveScope.renderImage(); $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _xml; safeApply($scope); $scope.directiveScope.updating = false; } } this.renderImage = function() { $scope.directiveScope.editor.contentWindow.postMessage(JSON.stringify({ action: "export", format: "png" }), '*'); } this.loadXml = function(_xml) { $scope.directiveScope.editor.contentWindow.postMessage(JSON.stringify({ action: 'load', autosave: true, xml: _xml }), '*'); } this.onMessageFromEditor = function(_data) { if (_data.event == "init") { $scope.directiveScope.ready = true; $scope.directiveScope.bindingUpdated(); } else if (_data.event == "autosave") { $scope.directiveScope.editorUpdated(_data.xml); } else if (_data.event == "load") { $scope.directiveScope.updating = false; } else if (_data.event == "export" && $scope.directiveScope.bindingParent && $scope.directiveScope.imageBindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.imageBindingName] = { name: "diagram", extension: "png", data: _data.data.split("data:image/png;base64,")[1], size: _data.data.length } } } waitForElement(this.id, (iframe) => { $scope.directiveScope.editor = iframe; window.addEventListener('message', function(_message) { if (_message && _message.origin == "https://embed.diagrams.net") { var o; try { o = JSON.parse(_message.data) } catch (e) {} if (!o) { o = {}; o[_message.data] = true; } $scope.directiveScope.onMessageFromEditor(o); } }); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: diagramEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_624de032795b0e18da834740', ctrl_624de032795b0e18da834740); app.directive('calendar', function() { return { scope: { bindingParent: "=?", bindingName: "=?", month: "=?", //Date object showStartTimes: "=?", showToday: "=?", customDayDisplay: "=?", customDayHtml: "=?", customEntryDisplay: "=?", customEntryHtml: "=?", customHeaderDisplay: "=?", customHeaderHtml: "=?", onEntryDrop: "=?", firstDate: "=?", //For reference only lastDate: "=?" //For reference only }, transclude: false, controller: ctrl_62617cfe967a3e37fc0e30c8, template: `

    {{directiveScope.month | date: 'MMMM'}} {{directiveScope.month | date: 'y'}}

    Sunday
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    {{day.date | date: (day.inMonth ? '' : 'MMM ') + 'd'}} Today
    {{entry.start | date:'shortTime'}} - {{entry.title}}
    `, bindToController: true};}); function ctrl_62617cfe967a3e37fc0e30c8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.month = this.month || (new Date()); this.showStartTimes = this.showStartTimes || true; this.showToday = this.showToday || true; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; this.display = []; this.onDrop = function(_dropScope, _dragScope) { //Low level if ($scope.directiveScope.onEntryDrop) { $scope.directiveScope.onEntryDrop(_dropScope.dropData, _dragScope.dragData); } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.updateDisplay(); }, true); this.updateDisplay = function() { var display = [[]]; var today = new Date(); //Get first day of month var firstDayOfMonth = new Date($scope.directiveScope.month.getFullYear(), $scope.directiveScope.month.getMonth()); //Get first day of display calendar var paddingDays = firstDayOfMonth.getDay(); $scope.directiveScope.firstDate = new Date(firstDayOfMonth); $scope.directiveScope.firstDate.setDate($scope.directiveScope.firstDate.getDate() - (paddingDays + 1)); //Build display for (var date = new Date($scope.directiveScope.firstDate); date.setDate(date.getDate() + 1);) { display[display.length - 1].push({ date: new Date(date), inMonth: date.getMonth() == firstDayOfMonth.getMonth(), isToday: date.getFullYear() == today.getFullYear() && date.getMonth() == today.getMonth() && date.getDate() == today.getDate(), entriesStarting: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((entry) => { return entry.start.sameDateAs(date); }) }); $scope.directiveScope.lastDate = date; //Done? if (date.getMonth() > firstDayOfMonth.getMonth() && date.getDay() == 6) { break; } //Add next week to display if (date.getDay() == 6) { display.push([]); } } console.log(display); $scope.directiveScope.display = display; } this.updateDisplay(); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: calendar failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62617cfe967a3e37fc0e30c8', ctrl_62617cfe967a3e37fc0e30c8); app.directive('drop', function() { return { scope: { onDrop: "=?", allowDropMethod: "=?", dropData: "=?", hideWhenInactive: "=?" }, transclude: true, controller: ctrl_6279c43f0f600a03860259d4, template: `
    `, bindToController: true};}); function ctrl_6279c43f0f600a03860259d4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.__ISDROP__ = true; this.hideWhenInactive = this.hideWhenInactive || false; this.displayClass = ""; this.readyToDrop = false; this.isDragging = false; this.forceUpdate = function() { $scope.directiveScope.readyToDrop = $scope.directiveScope.readyToDrop && $scope.$root.dragScope; safeApply($scope); } $rootScope.$on('dragStart', () => { $scope.directiveScope.isDragging = true; $scope.directiveScope.forceUpdate(); }); $rootScope.$on('dragEnd', () => { $scope.directiveScope.isDragging = false; $scope.directiveScope.forceUpdate(); }); } findDeepestDropScope = function(_startScope) { if (_startScope.directiveScope && _startScope.directiveScope.__ISDROP__) { return _startScope; } else if(_startScope.$parent) { return findDeepestDropScope(_startScope.$parent); } else { return null; } } onDragLeave = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); dropScope.directiveScope.readyToDrop = false; dropScope.directiveScope.forceUpdate(); } onDragover = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); if (dropScope && dropScope.directiveScope && dropScope.$root.dragScope && dropScope.directiveScope.allowDropMethod && dropScope.directiveScope.allowDropMethod(dropScope.directiveScope.dropData, dropScope.$root.dragScope.dragData)) { _event.preventDefault(); dropScope.directiveScope.readyToDrop = true; } else { dropScope.directiveScope.readyToDrop = false; } dropScope.directiveScope.forceUpdate(); } onDrop = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); if (dropScope && dropScope.directiveScope && dropScope.$root.dragScope && dropScope.directiveScope.onDrop) { dropScope.directiveScope.onDrop(dropScope.directiveScope.dropData, dropScope.$root.dragScope.dragData); } dropScope.directiveScope.readyToDrop = false; dropScope.directiveScope.forceUpdate(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drop failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6279c43f0f600a03860259d4', ctrl_6279c43f0f600a03860259d4); app.directive('drag', function() { return { scope: { allowDrag: "=?", dragData: "=?" }, transclude: true, controller: ctrl_6279c5300f600a03860259d5, template: `
    `, bindToController: true};}); function ctrl_6279c5300f600a03860259d5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowDrag = this.allowDrag || true; } onDragStart = function(_event) { if ($scope.directiveScope.allowDrag) { var scope = getScopeFromHTMLElement(_event.target); scope.$root.dragScope = scope.directiveScope; $rootScope.$emit('dragStart'); } } onDragEnd = function(_event) { var scope = getScopeFromHTMLElement(_event.target); scope.$root.dragScope = null; $rootScope.$emit('dragEnd'); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drag failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6279c5300f600a03860259d5', ctrl_6279c5300f600a03860259d5); app.directive('tab', function() { return { scope: { tabId: "=" }, transclude: true, controller: ctrl_627a5289cb98444249f56631, template: `
    `, bindToController: true};}); function ctrl_627a5289cb98444249f56631($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.containerScope = $scope.$parent.$parent.directiveScope; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: tab failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_627a5289cb98444249f56631', ctrl_627a5289cb98444249f56631); app.directive('objectRelationshipEditorEntry', function() { return { scope: { entry: "=?", entryHtml: "
    `, bindToController: true};}); function ctrl_627dec5cb21f83037b0279f8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.depth = this.depth || 0; $scope.directiveScope = this; this.selectedEntry = null; this.updateSelectedEntry = function(_entry) { $scope.directiveScope.selectedEntry = _entry; if ($scope.directiveScope.onSelectedEntryChange) { $scope.directiveScope.onSelectedEntryChange(_entry); } } this.allowDropMethod = function(_destinationEntry, _sourceEntry) { //Destination must not be a child of the source if (_destinationEntry.data._id == _sourceEntry.data._id) { return false; } return true; } /* this.allTasks = this.allTasks || []; this.showDropZones = false; this.dropZones = []; this.allowDropMethod = function(_dropData, _dragData) { //Check for cyclic relation return _dropData._id != _dragData._id; }; this.childTasks = $scope.directiveScope.allTasks.filter((t) => { return t.parent_development_task == $scope.directiveScope.task._id; }); this.onDrop = function(_dropData, _dragData) { if (_dropData._type == "development_task") { if ($scope.directiveScope.onMoveToTask) { $scope.directiveScope.onMoveToTask(_dropData, _dragData); } } else if (_dropData._type == "change") { //Change parent change if ($scope.directiveScope.onMoveToChange) { $scope.directiveScope.onMoveToChange(_dropData, _dragData); } } } */ }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectRelationshipEditorEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_627dec5cb21f83037b0279f8', ctrl_627dec5cb21f83037b0279f8); app.directive('objectRelationshipEditor', function() { return { scope: { entries: "=?", entryHtml: "
    `, bindToController: true};}); function ctrl_627eb2b02d44080b37136918($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.selectedEntry = null; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectRelationshipEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_627eb2b02d44080b37136918', ctrl_627eb2b02d44080b37136918); app.directive('dynamicArrayEditor', function() { return { scope: { bindingParent: "=?", bindingName: "=?", newEntryHtml: "=?", existingEntryHtml: "=?", newEntryTemplate: "=?", allowNewEntry: "=?", allowEntryRemoval: "=?", allowReorder: "=?" }, transclude: false, controller: ctrl_6281a43b1116d517d49bb2fd, template: ` New...

    `, bindToController: true};}); function ctrl_6281a43b1116d517d49bb2fd($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.newEntryExpanded = false; this.allowReorder = this.allowReorder == null ? true : this.allowReorder; this.allowNewEntry = this.allowNewEntry == null ? true : this.allowNewEntry; this.allowEntryRemoval = this.allowEntryRemoval == null ? true : this.allowEntryRemoval; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; this.newEntry = cloneObject(this.newEntryTemplate); this.commitNewEntry = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push(cloneObject($scope.directiveScope.newEntry)); Object.assign($scope.directiveScope.newEntry, cloneObject($scope.directiveScope.newEntryTemplate)); } this.removeEntry = function(_index) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].splice(_index, 1) } this.reorderEntry = function(_index, _direction) { var entry = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_index]; $scope.directiveScope.removeEntry(_index); $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = [ ...$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].slice(0, _index + (_direction ? -1 : 1)), entry, ...$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].slice(_index + (_direction ? -1 : 1)) ]; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicArrayEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6281a43b1116d517d49bb2fd', ctrl_6281a43b1116d517d49bb2fd); app.directive('multipleCheckboxSelection', function() { return { scope: { bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", selections: "=?", allowNull: "=?" }, controller: ctrl_6281aa031116d517d49bb2ff, template: `
    `, bindToController: true};}); function ctrl_6281aa031116d517d49bb2ff($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; $scope.directiveScope = this; this.displaySelections = null; this.allowNull = this.allowNull == null ? true : this.allowNull; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.updateBinding = function() { if (!$scope.directiveScope.updatingDisplaySelections) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = Object.keys($scope.directiveScope.displaySelections).filter((s) => { return $scope.directiveScope.displaySelections[s]._checked; }).map((v) => { return v == "null" ? null : v; }); $scope.directiveScope.updatingBinding = false; } } this.updateDisplaySelections = function() { if (!$scope.directiveScope.updatingBinding) { $scope.directiveScope.updatingDisplaySelections = true; $scope.directiveScope.displaySelections = $scope.directiveScope.displaySelections || {}; if ($scope.directiveScope.allowNull) { $scope.directiveScope.displaySelections.null = $scope.directiveScope.displaySelections.null || {}; Object.assign($scope.directiveScope.displaySelections.null, { label: "(None)", class: "danger", //icon: "/media/crossout_icon.png" }); } //Update selection values with _checked Object.keys($scope.directiveScope.displaySelections).forEach((s) => { $scope.directiveScope.displaySelections[s]._checked = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].includes(s == "null" ? null : s); }); $scope.directiveScope.updatingDisplaySelections = false; } } this.canSelectAll = function() { return ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []).length != Object.keys(($scope.directiveScope.displaySelections || {})).length; } this.selectAll = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = Object.keys($scope.directiveScope.displaySelections); } this.canClear = function() { return ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []).length > 0; } this.clear = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = []; } }; $scope.$watch("directiveScope.selections", (_old, _new) => { // if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.updatingDisplaySelections = true; $scope.directiveScope.displaySelections = $scope.directiveScope.displaySelections || {}; //Break binding (avoid metadata writeback) var oldKeys = Object.keys($scope.directiveScope.displaySelections); var newKeys = Object.keys($scope.directiveScope.selections || {}); newKeys.forEach((k) => { $scope.directiveScope.displaySelections[k] = $scope.directiveScope.displaySelections[k] || {}; Object.assign($scope.directiveScope.displaySelections[k], $scope.directiveScope.selections[k]); }); //Remove keys that no longer exist in selections oldKeys.filter((k) => { return !newKeys.includes(k); }).forEach((k) => { delete $scope.directiveScope.displaySelections[k]; }); $scope.directiveScope.updatingDisplaySelections = false; $scope.directiveScope.updateDisplaySelections(); // } }); $scope.$watch("directiveScope.displaySelections", (_old, _new) => { //Watch selections and update binding using [selections]._checked; if ($scope.directiveScope.displaySelections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Now update the binding $scope.directiveScope.updateBinding(); } }, true); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Watch binding and update selection values if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []; //Binding modified $scope.directiveScope.updateDisplaySelections(); } }, true); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleCheckboxSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6281aa031116d517d49bb2ff', ctrl_6281aa031116d517d49bb2ff); app.directive('treeView', function() { return { scope: { nodes: "=?", selectedNodes: "=?", selectionMode: "=?", selectNode: "=?", onSelection: "=?", onExpand: "=?" }, transclude: false, controller: ctrl_6286e239a7dd8803adf0247d, template: ``, bindToController: true};}); function ctrl_6286e239a7dd8803adf0247d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.searchBinding = ""; this.searchFilter = ""; this.selectedNodes = this.selectedNodes || {}; this.selectionMode = this.selectionMode || "single"; this.searchSeleleted = function(_selection) { } this.selectNode = this.selectNode || (function(_id, _node) { $scope.directiveScope.setSelections($scope.directiveScope.nodes, this.selectionMode == "single" ? [_node.selected && _node.selectable ? null : _id] : ( this.selectionMode == "multiple" ? [...Object.keys($scope.directiveScope.selectedNodes), _id].filter((sid) => { return _node.selectable && (sid != _id || !_node.selected); }) : [] ) ); $scope.directiveScope.selectedNodes = $scope.directiveScope.getSelectedNodes($scope.directiveScope.nodes); if ($scope.directiveScope.onSelection) { $scope.directiveScope.onSelection($scope.directiveScope.selectedNodes); } }); this.setSelections = function(_nodes, _selectedIds) { Object.keys(_nodes || {}).forEach((id) => { var node = _nodes[id]; node.selected = _selectedIds.includes(id); $scope.directiveScope.setSelections(node.nodes, _selectedIds) }); safeApply($scope); } this.getSelectedNodes = function(_nodes) { var selected = {}; Object.keys(_nodes || {}).forEach((id) => { var node = _nodes[id]; if (node.selected) { selected[id] = node; } Object.assign(selected, $scope.directiveScope.getSelectedNodes(node.nodes)); }); return selected; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: treeView failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6286e239a7dd8803adf0247d', ctrl_6286e239a7dd8803adf0247d); app.directive('treeNode', function() { return { scope: { data: "=?", nodeId: "=?", visible: "=?", selected: "=?", label: "=?", labelClass: "=?", icon: "=?", subIcon: "=?", expanded: "=?", allowExpand: "=?", showBorder: "=?", nodes: "=?", selected: "=?", selectionMode: "=?", selectNode: "=?", //Method in the tree-view selectable: "=?", contextSelections: "=?", population: "=?", allowDropMethod: "=?", populate: "=?", allowCheck: "=?", checked: "=?", onExpand: "=?" }, transclude: false, controller: ctrl_62870193cafe730fb190e008, template: `
    `, bindToController: true};}); function ctrl_62870193cafe730fb190e008($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.selectable = this.selectable == null ? true : this.selectable; this.allowExpand = this.allowExpand == null ? true : this.allowExpand; this.visible = this.visible == null ? true : this.visible; this.nodesExist = function() { return Object.keys($scope.directiveScope.nodes ?? {}).length > 0; } this.populate = function() { if ($scope.directiveScope.population) { $scope.directiveScope.population($scope.directiveScope); } } this.onArrowClick = function() { if (!$scope.directiveScope.expanded && Object.keys($scope.directiveScope.nodes || {}).length == 0) { $scope.directiveScope.populate(); } $scope.directiveScope.expanded = !$scope.directiveScope.expanded; if ($scope.directiveScope.onExpand && $scope.directiveScope.expanded) { $scope.directiveScope.onExpand($scope.directiveScope); } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: treeNode failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62870193cafe730fb190e008', ctrl_62870193cafe730fb190e008); app.directive('nodeNavigator', function() { return { scope: { nodes: "=?" }, transclude: false, controller: ctrl_6287a350964fed13fa578da6, template: `
    `, bindToController: true};}); function ctrl_6287a350964fed13fa578da6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.getSelectedContentHtml = function() { var selectedId = Object.keys($scope.directiveScope.selectedNodes)[0]; return $scope.directiveScope.selectedNodes && Object.keys($scope.directiveScope.selectedNodes).length == 1 ? $scope.directiveScope.selectedNodes[Object.keys($scope.directiveScope.selectedNodes)[0]].data.contentHtml : null; } /* this.selectedId = null; this.selectedModel = null; this.onSelection = function(_selectedNodes) { var ids = Object.keys(_selectedNodes || {}); $scope.directiveScope.updatingFormBindings = true; if (ids.length == 1) { $scope.directiveScope.selectedModel = _selectedNodes[ids[0]].data._type; $timeout(() => { $scope.directiveScope.selectedId = ids[0]; $scope.directiveScope.updatingFormBindings = false; }, 100); } else { $scope.directiveScope.selectedId = null; $scope.directiveScope.selectedModel = null; } } */ }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nodeNavigator failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6287a350964fed13fa578da6', ctrl_6287a350964fed13fa578da6); app.directive('liveTimeDifference', function() { return { scope: { value: "=?" }, controller: ctrl_628b9adc6654132d4f7b79b0, template: `{{directiveScope.days}} Days {{("00" + directiveScope.hours).slice(-2)}} Hr {{("00" + directiveScope.minutes).slice(-2)}} Min {{("00" + directiveScope.seconds).slice(-2)}} Sec `, bindToController: true};}); function ctrl_628b9adc6654132d4f7b79b0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; setInterval(() => { $scope.directiveScope.diff = ( $scope.directiveScope.value - new Date())/ 1000; $scope.directiveScope.days = 0; $scope.directiveScope.hours = 0; $scope.directiveScope.minutes = 0; $scope.directiveScope.seconds = 0; while($scope.directiveScope.diff > 86400) { $scope.directiveScope.days++; $scope.directiveScope.diff-=86400; } while($scope.directiveScope.diff > 3600) { $scope.directiveScope.hours++; $scope.directiveScope.diff-=3600; } while($scope.directiveScope.diff > 60) { $scope.directiveScope.minutes++; $scope.directiveScope.diff-=60; } while($scope.directiveScope.diff > 1) { $scope.directiveScope.seconds++; $scope.directiveScope.diff-=1; } $rootScope.$digest(); //Force update }, 1000); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: liveTimeDifference failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_628b9adc6654132d4f7b79b0', ctrl_628b9adc6654132d4f7b79b0); app.directive('downloadData', function() { return { scope: { bindingParent: "=?", bindingName: "=?", label: "=?", icon: "=?", fileName: "=?", fileExtension: "=?" }, controller: ctrl_629faee4f6cd87145fb1eb5f, template: `
    `, bindToController: true};}); function ctrl_629faee4f6cd87145fb1eb5f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.fileName = this.fileName || "download"; this.fileExtension = this.fileExtension || "txt"; this.label = this.label || "Download"; this.linkHtml = ""; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.linkHtml = ''; }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: downloadData failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_629faee4f6cd87145fb1eb5f', ctrl_629faee4f6cd87145fb1eb5f); app.directive('electricalConnectionBussesDisplay', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_62afd61b2d490d46a236595a, template: `
    {{directiveScope.formatBus(bus)}}
    `, bindToController: true};}); function ctrl_62afd61b2d490d46a236595a($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.processConnector = function() { retrieveRecord($scope, $http, "connector_type", { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].connector } }, (connector) => { $scope.directiveScope.connector = connector; }); } this.processConnector(); this.fanWidth = 50; this.getActiveBusses = function() { return Object.keys($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]).filter((b) => { var def = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][b]; return def && (def.wire_primary_color || b.wire_secondary_color || def.conductor_color || def.pin != null); }); } this.wiresDefined = function() { return $scope.directiveScope.getActiveBusses().some((b) => { var def = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][b]; return def.wire_primary_color || def.wire_secondary_color || def.conductor_color; }); } this.getAngle = function(_bus) { var activeBusses = $scope.directiveScope.getActiveBusses(); var index = activeBusses.indexOf(_bus); var angle = ($scope.directiveScope.fanWidth * -0.5) + (($scope.directiveScope.fanWidth / (activeBusses.length - 1)) * (index)); return angle; } this.getLabelTop = function(_index) { var activeBusses = $scope.directiveScope.getActiveBusses(); return _index * (110 / (activeBusses.length - 1)); } this.formatBus = function(_bus) { return ( ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_bus].pin ? ("PIN " + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_bus].pin) : ( ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_bus].wire_primary_color ?? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_bus].conductor_color ?? { }).name ) ) + ": " + _bus.replace("_", "") ).toUpperCase(); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionBussesDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62afd61b2d490d46a236595a', ctrl_62afd61b2d490d46a236595a); app.directive('diagramDisplay', function() { return { scope: { bindingName: "=?", bindingParent: "=?" } , controller: ctrl_62ba93cb09cbf53cfe7b9d73, template: ``, bindToController: true};}); function ctrl_62ba93cb09cbf53cfe7b9d73($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: diagramDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62ba93cb09cbf53cfe7b9d73', ctrl_62ba93cb09cbf53cfe7b9d73); app.directive('dynamicSearchPanel', function() { return { scope: { definition: "=?", term: "=?", limit: "=?" }, controller: ctrl_62c7acfaa09587149baddff5, template: `
    Search Term

    `, bindToController: true};}); function ctrl_62c7acfaa09587149baddff5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.limit = this.limit || 25; this.performSearch = function() { $scope.directiveScope.query = { definition: $scope.directiveScope.definition, term: $scope.directiveScope.term }; } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicSearchPanel failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62c7acfaa09587149baddff5', ctrl_62c7acfaa09587149baddff5); app.directive('modelRelationMap', function() { return { scope: { modelName: "=?", displayDependants: "=?", displayDependencies: "=?" }, controller: ctrl_62cc34678ab13a318d4b48d7, template: `
    Models Referencing this Model
    {{$root.models[dependant.model].singular_name}} {{dependant.field}}
    {{$root.models[directiveScope.modelName].singular_name}}
    Models Referenced by this Model
    {{$root.models[dependencies.model].singular_name}} {{dependencies.field}}
    `, bindToController: true};}); function ctrl_62cc34678ab13a318d4b48d7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.displayDependants = true; this.displayDependencies = true; this.dependencies = []; this.dependants = []; this.build = function() { this.dependencies = []; this.dependants = []; if (!$scope.directiveScope.modelName) { return; } //Find dependencies Object.keys($scope.$root.models[$scope.directiveScope.modelName].fields).forEach((fieldName) => { var field = $scope.$root.models[$scope.directiveScope.modelName].fields[fieldName]; if (fieldName != "_id" && field.type == "reference" && field.reference_model) { $scope.directiveScope.dependencies.push({ field: fieldName, model: field.ref }); } }); //Find dependants Object.keys($scope.$root.models).forEach((modelName) => { var model = $scope.$root.models[modelName]; Object.keys(model.fields).forEach((fieldName) => { var field = model.fields[fieldName]; if (fieldName != "_id" && field.type == "reference" && field.ref == $scope.directiveScope.modelName) { $scope.directiveScope.dependants.push({ field: fieldName, model: modelName }); } }); }); }; this.build(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelRelationMap failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_62cc34678ab13a318d4b48d7', ctrl_62cc34678ab13a318d4b48d7); app.directive('physicalNetworkMap', function() { return { scope: { nicQuery: "=?", ciModels: "=?" }, controller: ctrl_633280ba49fdea059c8e4b48, template: ` `, bindToController: true};}); function ctrl_633280ba49fdea059c8e4b48($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.relationModal = {}; this.relations = []; this.nics = []; this.nicQuery = this.nicQuery || {}; this.options = { height: "100%", edges:{ smooth: false }, layout: { improvedLayout: true, hierarchical: false }, physics: { solver: "repulsion", stabalization: { enabled: true, iterations: 100000 }, repulsion: { springConstant: 0.05, springLength: 300, nodeDistance: 1000, centralGravity: 2, //damping }, maxVelocity: 100, minVelocity: 3 } }; this.onRelationSelection = function(_data) { if (_data.nodes.length == 0) { var relation = $scope.directiveScope.relations.find((r) => { return r.id == _data.edges[0]; }); $scope.directiveScope.relationModal.relation = relation; safeApply($scope); $scope.directiveScope.relationModal.show(); } }; this.buildRelationTitleHeader = function(_to, _from) { return `
    ` + _from.name + `
    ->
    ` + _to.name + `
    ` }; this.buildRelationTitle = function(_to, _from) { return `
    ` + _from.name + `` + (_from.internal_name ? (` (` + _from.internal_name + `)`) : ``) + `
    ->
    ` + _to.name + `` + (_to.internal_name ? (` (` + _to.internal_name + `)`) : ``) + `
    `; }; this.update = function() { retrieveRecords($scope, $http, "cmdb_nic", { query: { $and: [ { active: true, connected_to: { $ne: null }, parent: { $ne: null } }, $scope.directiveScope.nicQuery ] }, populate: ["parent", { path: "connected_to", populate: "parent" }] }, (response) => { var nodes = []; $scope.directiveScope.relations = []; $scope.directiveScope.nics = response.records.filter((n) => { return n.parent && n.parent.active && ($scope.directiveScope.ciModels ? $scope.directiveScope.ciModels.includes(n.parent._type) : true) }); $scope.directiveScope.nics.forEach((nic) => { if (!nodes.some((n) => { return n.id == nic.parent._id; })) { //Add CI node nodes.push({ id: nic.parent._id, label: nic.parent.name, font: { // color: "#eeeeee" }, shadow: { enabled: true }, image: nic.parent.icon ? nic.parent.icon.link : $scope.$root.models[(nic.parent._type || "cmdb_ci")].icon.link, }); } //Add relations for NICs connected_to (nic.connected_to || []).forEach((connectedNic) => { if (!$scope.directiveScope.relations.some((r) => { return (nic.parent && r.to == nic.parent._id && connectedNic.parent && r.from == connectedNic.parent._id); })) { //Check for existing relation between these CIs (skip existing reverse connections) var existing = $scope.directiveScope.relations.find((r) => { return r.from == nic.parent._id && r.to == connectedNic.parent._id; }); if (existing) { existing.width++; existing.label = existing.width.toString(); existing.title += $scope.directiveScope.buildRelationTitle(connectedNic, nic); } else if (connectedNic.parent) { //Add relation between this NICs parent and the connectedNic's parent $scope.directiveScope.relations.push({ from: nic.parent._id, to: connectedNic.parent._id, width: 1, label: nic.name + " -> " + connectedNic.name, title: $scope.directiveScope.buildRelationTitleHeader(connectedNic.parent, nic.parent) + `
    ` + $scope.directiveScope.buildRelationTitle(connectedNic, nic), arrows: { to: { enabled: ["hybrid", "downlink"].includes(connectedNic.role) }, from: { enabled: ["hybrid", "downlink"].includes(nic.role) }, middle: { enabled: true, src: (nic.adapter_type ? ($scope.$root.models.cmdb_nic.fields.adapter_type.selections[nic.adapter_type] ?? {}).icon : $scope.$root.models.cmdb_nic.icon.link), type: "image" } } }); } } }); }); $scope.directiveScope.nodes = nodes.filter((n) => { return $scope.directiveScope.relations.some((r) => { return r.to == n.id || r.from == n.id; }); }); }); }; this.update(); $scope.$watch("directiveScope.nicQuery", (_new, _old) => { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.update(); } }); $scope.$watch("directiveScope.ciModels", (_new, _old) => { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.update(); } }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: physicalNetworkMap failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_633280ba49fdea059c8e4b48', ctrl_633280ba49fdea059c8e4b48); app.directive('shipmentTrackingNumber', function() { return { scope: { bindingParent: "=?", bindingName: "=?", courier: "=?" }, controller: ctrl_633330674122f713fa712fc4, template: `{{directiveScope.bindingParent[directiveScope.bindingName]}} {{directiveScope.trackingUrl ? '' : (directiveScope.bindingParent[directiveScope.bindingName])}}`, bindToController: true};}); function ctrl_633330674122f713fa712fc4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.getIdFromRecord = function(_value) { return _value == null || typeof(_value) == "string" ? _value : _value._id; } this.updateCourierLink = function() { if ($scope.directiveScope.courier) { retrieveRecord($scope, $http, "courier", { query: { _id: $scope.directiveScope.getIdFromRecord($scope.directiveScope.courier) }}, (courier) => { $scope.directiveScope.trackingUrl = courier.tracking_url; }); } else { $scope.directiveScope.trackingUrl = null; } } $scope.$watch("[directiveScope.bindingParent, directiveScope.bindingName, directiveScope.courier]", () => { $scope.directiveScope.updateCourierLink() }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shipmentTrackingNumber failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_633330674122f713fa712fc4', ctrl_633330674122f713fa712fc4); app.directive('webLinkSelectionModal', function() { return { scope: { bindingParent: "=?", bindingName: "=?", record: "=?", modelName: "=?", show: "=?" }, controller: ctrl_6334a6ea2c43372a57deea74, template: `

    `, bindToController: true};}); function ctrl_6334a6ea2c43372a57deea74($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.show = function() { $scope.directiveScope.linkSelectionModal.show(); } this.getCurrentRecordFiles = function() { var files = []; var modelDef = $scope.$root.models[$scope.directiveScope.modelName]; Object.keys(modelDef.fields).forEach((f) => { if (modelDef.fields[f].type == "file") { if (modelDef.fields[f].array) { ($scope.directiveScope.record[f] || []).forEach((file) => { var toPush = cloneObject(file); toPush.source = f; files.push(toPush); }); } else if ($scope.directiveScope.record[f]) { var toPush = cloneObject($scope.directiveScope.record[f]); toPush.source = f; files.push(toPush); } } }); return files; }; this.linkSelectionModal = { currentRecordFiles: $scope.directiveScope.getCurrentRecordFiles(), set linkBinding(_value) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = (typeof(_value) == "object" ? (_value.path) : _value); }, tabs: { url: { label: "URL" }, currentRecord: { label: "From Current Record" }, webResource: { label: "Web Resource", icon: $scope.$root.models.web_resource.icon.link } }, currentTab: "url" }; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: webLinkSelectionModal failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6334a6ea2c43372a57deea74', ctrl_6334a6ea2c43372a57deea74); app.directive('drawer', function() { return { scope: { drawerId: "=" }, transclude: true, controller: ctrl_633bb07bea92056dbd25be9d, template: `
    `, bindToController: true};}); function ctrl_633bb07bea92056dbd25be9d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.containerScope = $scope.$parent.$parent.directiveScope; this.getCardBorders = function() { var index = Object.keys($scope.containerScope.drawers).indexOf($scope.directiveScope.drawerId); return "0px"//return index == 0 ? "6px 6px 0px 0px" : (index == Object.keys($scope.containerScope.drawers).length - 1 ? "0px 0px 6px 6px" : "0px 0px 0px 0px"); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drawer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_633bb07bea92056dbd25be9d', ctrl_633bb07bea92056dbd25be9d); app.directive('drawerContainer', function() { return { scope: { drawers: "=?", currentDrawer: "=?", dynamic: "=?" //True: will populate tabs with their respective 'html' property, otherwise use the static transclusion }, transclude: true, controller: ctrl_633bb084ea92056dbd25be9e, template: `
    `, bindToController: true};}); function ctrl_633bb084ea92056dbd25be9e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.drawers = this.drawers || {}; this.unique = createUniqueTag(); $scope.directiveScope = this; this.dynamic = this.dynamic || false; $scope.$watch("directiveScope.currentDrawer", () => { }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drawerContainer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_633bb084ea92056dbd25be9e', ctrl_633bb084ea92056dbd25be9e); app.directive('buttonGroupSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", values: "=", onChange: "=?", placeholder: "=?", allowNull: "=?", size: "=?", horizontal: "=?" }, controller: ctrl_634e1f0ca88c284dac1c4d0b, template: ``, bindToController: true};}); function ctrl_634e1f0ca88c284dac1c4d0b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.size = this.size == null ? "sm" : this.size; this.getBorderRadius = function(_index) { var selectionCount = Object.keys($scope.directiveScope.values).length; if (_index == 0) { if (selectionCount > 1) { return "border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important"; } else { return ""; } } else if (_index == selectionCount - 1) { if (selectionCount > 0) { return "border-top-left-radius: 0px !important; border-bottom-left-radius: 0px !important"; } else { return ""; } } else { return "border-radius: 0 !important"; } } this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.select = function(_key) { $scope.directiveScope.selecting = true; if (_key == null || $scope.directiveScope.values[_key].selectable != false) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key, $scope.directiveScope); } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: buttonGroupSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_634e1f0ca88c284dac1c4d0b', ctrl_634e1f0ca88c284dac1c4d0b); app.directive('instanceDeploymentConfiguration', function() { return { scope: { remoteInstance: "=?" } , controller: ctrl_635699c17e7fde0436dd3c69, template: `
    Segment Description Installed
    Remotely
    Installed
    Locally
    Pull
    Update to Apply
    Push
    Update to Apply
    Active for {{configData.name}}
    {{segmentData.name}}
    Configuration


    Instances will be compared assuming the {{directiveScope.push ? 'LOCAL' : 'REMOTE'}} instance is the desired state.








    Details
    Segment Model Record Field Local Remote
    {{directiveScope.delta.segmentDeltas[matrixEntry.segment].modelDeltas[matrixEntry.model].recordDeltas[matrixEntry.record].fieldDeltas[matrixEntry.field].local.value}}
    {{directiveScope.delta.segmentDeltas[matrixEntry.segment].modelDeltas[matrixEntry.model].recordDeltas[matrixEntry.record].fieldDeltas[matrixEntry.field].remote.value}}
    `, bindToController: true};}); function ctrl_635699c17e7fde0436dd3c69($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.parseDateDifference = parseDateDifference; this.actions = { excepted: { label: "Excepted", icon: "/media/restrict_icon.png", class: "secondary" }, insert: { label: "Insert", icon: "/media/add_icon.png", class: "success" }, delete: { label: "Delete", icon: "/media/crossout_icon.png", class: "danger" }, update: { label: "Update", icon: "/media/external_icon.png", class: "primary" }, }; this.toObjectBy = function(_array, _field) { var output = {}; _array.forEach((i) => { output[i[_field]] = i; }); return output; }; this.updateConfigs = function() { retrieveRecords($scope, $http, "config", {}, (response) => { $scope.directiveScope.configs = $scope.directiveScope.toObjectBy(response.records, "_id"); }); } this.updateConfigs(); this.updateSegments = function() { $scope.directiveScope.remoteSegments = $scope.directiveScope.toObjectBy($scope.directiveScope.remoteInstance.remote_segments, "_id"); $scope.directiveScope.allSegments = {}; Object.assign($scope.directiveScope.allSegments, $scope.directiveScope.remoteSegments); retrieveRecords($scope, $http, "segment", {}, (segmentResponse) => { $scope.directiveScope.localSegments = $scope.directiveScope.toObjectBy(segmentResponse.records, "_id"); Object.assign($scope.directiveScope.allSegments, $scope.directiveScope.localSegments); }); } this.updateSegments(); this.toggleDeployDefault = function(_type, _id) { if ($scope.directiveScope.remoteInstance[_type + "_segments"].includes(_id)) { $scope.directiveScope.remoteInstance[_type + "_segments"] = $scope.directiveScope.remoteInstance[_type + "_segments"].filter((s) => { return s != _id; }); } else { $scope.directiveScope.remoteInstance[_type + "_segments"] = [...$scope.directiveScope.remoteInstance[_type + "_segments"], _id];; } safeApply($scope); }; this.toggleConfig = function(_configId, _segmentId) { var state = $scope.directiveScope.configs[_configId].active_segments.includes(_segmentId); if (confirm("Are you sure you want to " + (state ? 'DISABLE' : 'ENABLE') + " this segment on the LOCAL instance?")) { if (state) { //Disable updateRecord($scope, $http, "config", _configId, { $pull: { active_segments: _segmentId }}, () => { $scope.directiveScope.updateConfigs(); }); } else { //Enable updateRecord($scope, $http, "config", _configId, { $push: { active_segments: _segmentId }}, () => { $scope.directiveScope.updateConfigs(); }); } safeApply($scope); } }; this.toggleLocalInstall = function(_segmentId) { var state = !!$scope.directiveScope.localSegments[_segmentId]; if (confirm("Are you sure you want to " + (state ? 'REMOVE this segment from' : 'INSTALL this segment on') + " the LOCAL instance?")) { if (state) { //Remove locally deleteRecord($scope, $http, "segment", _segmentId, () => { $scope.directiveScope.updateSegments(); }); } else { //Install locally insertRecord($scope, $http, "segment", $scope.directiveScope.remoteSegments[_segmentId], () => { $scope.directiveScope.updateSegments(); }); } safeApply($scope); } } this.segments = $scope.directiveScope.remoteInstance[($scope.directiveScope.push ? 'push' : 'pull') + '_segments']; this.delta = {}; this.nodes = {}; this.checkDefault = true; this.push = true; this.selectedNodes = null; this.state = null; this.currentTab = "tool"; this.tabs = { matrix: { label: "Matrix" }, tool: { label: "Deployment Tool" } }; this.actionMap = { update: { label: "Update", class: "warning" }, insert: { label: "Insert", class: "success" }, delete: { label: "Delete", class: "danger" }, excepted: { label: "Excepted", class: "secondary" }, "null": { label: "Synchronized", class: "primary" } }; this.normalizeEncoding = function(_string) { try { var d = atob(_string); return d.length > 0 ? d : _string; } catch (e) { return _string; } } this.selectAll = function(_state, _rootNodes) { _state = _state == null ? true : _state; _rootNodes = _rootNodes == null ? $scope.directiveScope.nodes : _rootNodes; Object.values(_rootNodes).forEach((node) => { node.checked = _state; if (node.nodes) { $scope.directiveScope.selectAll(_state, node.nodes); } }); safeApply($scope); } $scope.$watch("directiveScope.push", () => { $scope.directiveScope.segments = $scope.directiveScope.remoteInstance[($scope.directiveScope.push ? 'push' : 'pull') + '_segments']; }); this.buildCommit = function() { var segmentDeltas = {}; Object.values($scope.directiveScope.nodes).forEach((segmentNode) => { if (segmentNode.checked) { segmentDeltas[segmentNode.segmentId] = { action: segmentNode.data.action, models: {} }; if (segmentNode.nodes.modelDeltas) { Object.values(segmentNode.nodes.modelDeltas.nodes).forEach((modelNode) => { if (modelNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName] = { action: modelNode.data.action, records: {} }; if (modelNode.nodes.recordDeltas) { Object.values(modelNode.nodes.recordDeltas.nodes).forEach((recordNode) => { if (recordNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName].records[recordNode.recordId] = { action: recordNode.data.action, fields: [] }; if (recordNode.nodes.fieldDeltas) { Object.values(recordNode.nodes.fieldDeltas.nodes).forEach((fieldNode) => { if (fieldNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName].records[recordNode.recordId].fields.push(fieldNode.fieldName); } }); } } }); } } }); } } }); return segmentDeltas; } this.commitDeltas = function() { if (confirm("You are about to " + ($scope.directiveScope.push ? "PUSH modifications to" : "PULL modifications from") + " the remote instance, are you sure?")) { $scope.directiveScope.state = "committing"; executeTask($scope, $http, "6437561df8ee6f03ce2ca326", { parameters: { instance: $scope.directiveScope.remoteInstance._id, push: $scope.directiveScope.push, commit: $scope.directiveScope.buildCommit() } }, () => {}, (taskExecution) => { $scope.directiveScope.retrieveNewDelta(); }); } } this.excepted = function(_model, _record, _field) { return $scope.directiveScope.remoteInstance.exceptions.some((entry) => { return ($scope.directiveScope.push ? entry.push : entry.pull) && entry.model == _model && entry.record == _record && entry.field == _field }); } this.toggleException = function(_model, _record, _field) { $scope.directiveScope.remoteInstance.exceptions = $scope.directiveScope.remoteInstance.exceptions || []; if ($scope.directiveScope.excepted(_model, _record, _field)) { //Remove $scope.directiveScope.remoteInstance.exceptions = $scope.directiveScope.remoteInstance.exceptions.filter((exception) => { return !(exception.model == _model && exception.record == _record && exception.field == _field); }); } else { //Add $scope.directiveScope.remoteInstance.exceptions.push({ push: $scope.directiveScope.push, pull: !$scope.directiveScope.push, model: _model, record: _record, field: _field }); console.log($scope.directiveScope.remoteInstance.exceptions); } } this.processDelta = function() { $scope.directiveScope.deltaMatrix = []; Object.keys($scope.directiveScope.delta.segmentDeltas).forEach((segmentId) => { var segmentDelta = $scope.directiveScope.delta.segmentDeltas[segmentId]; if (Object.keys(segmentDelta.modelDeltas).length > 0) { Object.keys(segmentDelta.modelDeltas).forEach((modelName) => { var modelDelta = segmentDelta.modelDeltas[modelName]; if (Object.keys(modelDelta.recordDeltas).length > 0) { Object.keys(modelDelta.recordDeltas).forEach((recordId) => { var recordDelta = modelDelta.recordDeltas[recordId]; if (Object.keys(recordDelta.fieldDeltas).length > 0) { Object.keys(recordDelta.fieldDeltas).forEach((fieldName) => { var fieldDelta = recordDelta.fieldDeltas[fieldName]; $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName, record: recordId, field: fieldName }); }); } else { //Just add record delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName, record: recordId }); } }); } else { //Just add model delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName }); } }); } else { //Just add segment delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId }); } }); } this.retrieveLastDelta = function() { retrieveRecord($scope, $http, "task_execution", { query: { task: "64375611f8ee6f03ce2ca2fa", state: "succeeded" }, sort: { ended: "desc" } }, (execution) => { $scope.directiveScope.delta = JSON.parse(execution.result); postProcessJSON($scope.directiveScope.delta); $scope.directiveScope.processDelta(); }); } this.retrieveNewDelta = function() { $scope.directiveScope.state = "retrieving"; executeTask($scope, $http, "64375611f8ee6f03ce2ca2fa", { parameters: { instance: $scope.directiveScope.remoteInstance._id, push: $scope.directiveScope.push, segments: $scope.directiveScope.segments, exceptions: JSON.stringify($scope.directiveScope.remoteInstance[($scope.directiveScope.push ? "push" : "pull") + "_exceptions"]) } }, () => {}, (taskExecution) => { $scope.directiveScope.delta = JSON.parse(taskExecution.result); postProcessJSON($scope.directiveScope.delta); $scope.directiveScope.processDelta(); $scope.directiveScope.state = null; }); } this.retrieveLastDelta(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: instanceDeploymentConfiguration failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_635699c17e7fde0436dd3c69', ctrl_635699c17e7fde0436dd3c69); app.directive('thermometerLogChart', function() { return { scope: { thermometerIds: "=?" } , controller: ctrl_6362a0709fe83b1140fa1704, template: ` `, bindToController: true};}); function ctrl_6362a0709fe83b1140fa1704($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.thermometers = this.thermometers == null ? [] : this.thermometers; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: thermometerLogChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6362a0709fe83b1140fa1704', ctrl_6362a0709fe83b1140fa1704); app.directive('modalWysiwygHtmlEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_63631f41dc9d8919fa4a919f, template: ` None   {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_63631f41dc9d8919fa4a919f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalWysiwygHtmlEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63631f41dc9d8919fa4a919f', ctrl_63631f41dc9d8919fa4a919f); app.directive('modalJsonEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_637e1d05c14b310801d5ee38, template: ` None   {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_637e1d05c14b310801d5ee38($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.pretty = function(_json) { return typeof(_json) == "string" ? _json : JSON.stringify(_json, null, 2); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalJsonEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_637e1d05c14b310801d5ee38', ctrl_637e1d05c14b310801d5ee38); app.directive('scannerInput', function() { return { scope: { bindingParent: "=?", bindingName: "=?", onInput: "=?", allowManualEntry: "=?", showScannedValue: "=?", placeholder: "=?", inactivePlaceholder: "=?", active: "=?" }, controller: ctrl_6389578e63048972e16e4838, template: `
    `, bindToController: true};}); function ctrl_6389578e63048972e16e4838($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.placeholder = this.placeholder == null ? "Scan a barcode..." : this.placeholder; this.inactivePlaceholder = this.inactivePlaceholder == null ? "" : this.inactivePlaceholder; this.allowManualEntry = this.allowManualEntry == null ? true : this.allowManualEntry; this.showScannedValue = this.showScannedValue == null ? true : this.showScannedValue; this.active = this.active == undefined ? true : this.active; this.buffer = ""; this.lastKeypress; this.maxDelay = 100; $(document).keypress(function(_event) { if (!$scope.directiveScope.active) { return; } $scope.directiveScope.lastKeypress = new Date(); if (_event.keyCode == 13) { if ($scope.directiveScope.buffer.length > 0) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.buffer.replace("\r","").replace("\n",""); $scope.directiveScope.buffer = ""; $scope.directiveScope.flash = true; setTimeout(() => { $scope.directiveScope.flash = false; safeApply($scope); }, 500); safeApply($scope); } if ($scope.directiveScope.onInput) { $scope.directiveScope.onInput($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } else if (!_event.ctrlKey) { if (_event.keyCode > 31 && _event.keyCode < 127) { $scope.directiveScope.buffer += _event.key; } } }); setInterval(() => { if ($scope.directiveScope.buffer.length > 0 && (new Date()) - $scope.directiveScope.lastKeypress > $scope.directiveScope.maxDelay) { $scope.directiveScope.buffer = ""; } }, $scope.directiveScope.maxDelay); }; this.$onDestroy = function() { //If the directive is destroyed (ng-if eval to false) kill the event handler $(document).off("keypress"); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: scannerInput failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6389578e63048972e16e4838', ctrl_6389578e63048972e16e4838); app.directive('workflowStageEntrySelection', function() { return { scope: { allowInteraction: "=?", bindingParent: "=?", bindingName: "=?", workflow: "=?" }, controller: ctrl_6392d7cb6f93ff190acd48bf, template: ` `, bindToController: true};}); function ctrl_6392d7cb6f93ff190acd48bf($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.selections = {}; this.updateSelections = function() { var wfQuery = null; if (!$scope.directiveScope.workflow) { //No workflow supplied if ($scope.directiveScope.allowInteraction) { //We're in entry mode, workflow must be supplied to continue $scope.directiveScope.selections = null; return; } else { //Display mode, find workflow from binding value wfQuery = { stages: { $elemMatch: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }}}; } } else { //Workflow supplied wfQuery = { _id: $scope.directiveScope.workflow }; } $scope.directiveScope.loading = true; retrieveRecord($scope, $http, "production_workflow", { query: wfQuery, populate: { path: "stages", populate: "stage" } }, (workflow) => { workflow = workflow || { stages: []}; var newSelections = {}; workflow.stages.forEach((stageEntry) => { newSelections[stageEntry._id] = { label: stageEntry.stage.title, icon: stageEntry.stage.icon.link } }); $scope.directiveScope.selections = newSelections; $scope.directiveScope.loading = false; }); } this.updateSelections(); $scope.$watch("directiveScope.workflow", (_new, _old) => { if (_new != _old) { $scope.directiveScope.updateSelections(); } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: workflowStageEntrySelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6392d7cb6f93ff190acd48bf', ctrl_6392d7cb6f93ff190acd48bf); app.directive('sidepaneFilterList', function() { return { scope: { modelName: "=?", listSort: "=?", enforcedQuery: "=?", listLayout: "=?" } , controller: ctrl_63b780bcb96068189d850b49, template: `
    Filter Reset
    {{$root.models[directiveScope.modelName].fields[fieldName].display_name || fieldName}}
    `, bindToController: true};}); function ctrl_63b780bcb96068189d850b49($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.query = {}; this.filterFields = []; this.filterValues = {}; this.updateQuery = function() { var newQuery = {}; Object.keys($scope.directiveScope.filterValues).forEach((f) => { var filterValue = $scope.directiveScope.filterValues[f]; var fieldModel = $scope.$root.models[$scope.directiveScope.modelName].fields[f]; if (fieldModel.selections) { newQuery[f] = { $in: filterValue }; } else if (["enumerator", "string"].includes(fieldModel.type)) { if (filterValue) { newQuery[f] = { $regex: (".*" + filterValue + ".*"), $options: "i" }; } } else { newQuery[f] = filterValue; } }); $scope.directiveScope.query = $scope.directiveScope.enforcedQuery ? { $and: [$scope.directiveScope.enforcedQuery, newQuery] } : newQuery; } this.buildFilterFields = function() { $scope.directiveScope.filterValues = {}; $scope.directiveScope.filterFields = Object.keys($scope.$root.models[$scope.directiveScope.modelName].fields).filter((f) => { var fieldModel = $scope.$root.models[$scope.directiveScope.modelName].fields[f]; if (!fieldModel.queryable) { return false; } else if (fieldModel.selections) { $scope.directiveScope.filterValues[f] = Object.keys(fieldModel.selections); $scope.directiveScope.filterValues[f].push(null); return true; } else if (["enumerator", "string"].includes(fieldModel.type)) { return true; } return false; }).sort((a) => { return $scope.$root.models[$scope.directiveScope.modelName].fields[a].selections ? 1 : -1; }); }; this.buildFilterFields(); $scope.$watch("directiveScope.filterValues", () => { $scope.directiveScope.updateQuery(); }, true); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: sidepaneFilterList failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63b780bcb96068189d850b49', ctrl_63b780bcb96068189d850b49); app.directive('recordPieChart', function() { return { scope: { modelName: "=?", query: "=?", aggregationField: "=?", title: "=?", refDisplayField: "=?", reloadRate: "=?" }, controller: ctrl_63bfb8b1f2378c03cf4711b4, template: `
    {{directiveScope.title}}
     Loading... `, bindToController: true};}); function ctrl_63bfb8b1f2378c03cf4711b4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.slices = {}; this.updating = false; this.update = function() { $scope.directiveScope.updating = true; retrieveRecords($scope, $http, $scope.directiveScope.modelName, { query: $scope.directiveScope.query, select: [$scope.directiveScope.aggregationField] }, (response) => { var fieldConfig = $scope.$root.models[$scope.directiveScope.modelName].fields[$scope.directiveScope.aggregationField]; var newSlices = {}; var groups = groupByProperty(response.records, $scope.directiveScope.aggregationField); if (fieldConfig.type == "reference") { var refDisplayField = $scope.directiveScope.refDisplayField || $scope.$root.models[fieldConfig.ref].display_field; retrieveRecords($scope, $http, fieldConfig.ref, { query: { _id: { $in: Object.keys(groups).filter((v) => { return v && v!= "undefined"; }) }}, select: [refDisplayField] }, (refResponse) => { Object.keys(groups).sort((a, b) => { return groups[a].length < groups[b].length ? 1 : -1; }).forEach((v) => { var label = (((refResponse.records.find((r) => { return r._id == v; }) || {})[refDisplayField]) || v) + " (" + groups[v].length + ")"; newSlices[label] = groups[v].length; }); $scope.directiveScope.slices = newSlices; $scope.directiveScope.updating = false; }); } else { Object.keys(groups).sort((a, b) => { return groups[a].length < groups[b].length ? 1 : -1; }).forEach((v) => { var label = (fieldConfig.selections ? ((fieldConfig.selections[v] || {}).label || v) : v) + " (" + groups[v].length + ")"; newSlices[label] = groups[v].length; }); $scope.directiveScope.slices = newSlices; $scope.directiveScope.updating = false; } //Retrigger if requested if ($scope.directiveScope.reloadRate > 500) { setTimeout(() => { $scope.directiveScope.update(); }, $scope.directiveScope.reloadRate); } }); } this.update(); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: recordPieChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63bfb8b1f2378c03cf4711b4', ctrl_63bfb8b1f2378c03cf4711b4); app.directive('modalAddressEntry', function() { return { scope: { title: "=?", subtext: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", validateMethod: "=?", //should return an object { field_name: "error", ...} formatMethod: "=?" //should modify the values directly } , controller: ctrl_63c21069f34e1719ad34bd31, template: ` {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_63c21069f34e1719ad34bd31($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalAddressEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63c21069f34e1719ad34bd31', ctrl_63c21069f34e1719ad34bd31); app.directive('singleLineTextInput', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", applyOnChange: "=?", applyOnEnter: "=?", }, controller: ctrl_63c4a4fbf3b28225025ea76b, template: ``, bindToController: true};}); function ctrl_63c4a4fbf3b28225025ea76b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.tempBinding = ""; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.applyOnChange = this.applyOnChange == null ? true : this.applyOnChange; this.keydown = function($event) { if ($event.code.endsWith("Enter") && $scope.directiveScope.applyOnEnter) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.tempBinding; } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if (!$scope.directiveScope.updatingUi) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.updatingBinding = false; } }); $scope.$watch("directiveScope.tempBinding", () => { if (!$scope.directiveScope.updatingBinding) { $scope.directiveScope.updatingUi = true; $scope.directiveScope.updatingUi = false; } }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleLineTextInput failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63c4a4fbf3b28225025ea76b', ctrl_63c4a4fbf3b28225025ea76b); app.directive('taskExecutionLogDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?", displayDebug: "=?" }, transclude: false, controller: ctrl_63cff6c96fb17603866a7d19, template: `
    Level Timestamp Message
    {{entry.timestamp | date:'M/d/yy, h:mm:ss a'}} {{entry.message}}
    `, bindToController: true};}); function ctrl_63cff6c96fb17603866a7d19($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayDebug = this.displayDebug == null ? true : this.displayDebug; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: taskExecutionLogDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63cff6c96fb17603866a7d19', ctrl_63cff6c96fb17603866a7d19); app.directive('pressureTestChart', function() { return { scope: { item: "=", bindingParent: "=?", bindingName: "=?" }, controller: ctrl_63d0993231d96011f8d055d1, template: `
    `, bindToController: true};}); function ctrl_63d0993231d96011f8d055d1($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.itemRecord = { accuracy: 0 }; retrieveRecord($scope, $http, "virtual_sage_item", { query: { _id: this.item }}, (itemRecord) => { this.itemRecord = itemRecord; }); //Configure watch $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); $scope.$watch('directiveScope.itemRecord', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); }; this.process = function() { this.seriesConfig = { upper: { label: "Upper Threshold", fillColor: "#347aeb22", fill: true, fillMode: "end", lineColor: "#00000000" }, lower: { label: "Lower Threshold", fillColor: "#347aeb22", fill: true, fillMode: "start", lineColor: "#00000000" } }; this.seriesData = { }; ((this.bindingParent || {})[this.bindingName] || []).forEach((unitResults) => { //Add result unit series this.seriesConfig[unitResults.unit] = { label: "Unit " + unitResults.unit, lineColor: unitResults.pass ? "#00aa0099" : "#aa000099" }; //Add result points unitResults.points.forEach((point) => { if (!this.seriesData[point.pressure]) { this.seriesData[point.pressure] = { upper: { value: (point.expected_output + (this.itemRecord.accuracy * (this.itemRecord.output_max - this.itemRecord.output_min))).toFixed(3), pointColor: "#00000000" }, lower: { value: (point.expected_output - (this.itemRecord.accuracy * (this.itemRecord.output_max - this.itemRecord.output_min))).toFixed(3), pointColor: "#00000000" } } } if (!this.seriesData[point.pressure][unitResults.unit]) { this.seriesData[point.pressure][unitResults.unit] = { value: point.output.toFixed(3), pointColor: point.pass ? "#00aa0099" : "#aa000099" } } }); }); } this.outputValid = function(_pressure, _output) { return Math.abs(_output / ((this.m * _pressure) + this.b)) < 1 + this.itemRecord.accuracy; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pressureTestChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63d0993231d96011f8d055d1', ctrl_63d0993231d96011f8d055d1); app.directive('locationVisualization', function() { return { scope: { zoom: "=?", location: "=?", scaleFactor: "=?", isChild: "=?", maxDepth: "=?", contentFunction: "=?", classFunction: "=?", selectionFunction: "=?", vertical: "=?" } , controller: ctrl_63d9231f9f678303a34364e4, template: `
    {{directiveScope.location.name}}
    `, bindToController: true};}); function ctrl_63d9231f9f678303a34364e4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = "location_" + createUniqueTag(); this.maxDepth = this.maxDepth == null ? 99999 : this.maxDepth; this.containedLocations = []; this.scaleFactor; this.selectionQueue = []; Object.defineProperty(this, "dynamicScaleFactor", { get: function() { if ($scope.directiveScope.isChild) { //Use supplied scale factor return $scope.directiveScope.scaleFactor; } else { var maxWidth = $("#" + $scope.directiveScope.unique).parent().parent().width(); var newFactor = maxWidth / $scope.directiveScope.location.width; return newFactor; } } }); Object.defineProperty(this, "dynamicClass", { get: function() { if ($scope.directiveScope.classFunction) { var c = $scope.directiveScope.classFunction($scope.directiveScope.location); return "hover-border-theme text-dark table-" + c + " border-" + c; } else { return "rounded bg-white text-dark"; } } }); this.update(); }; this.getTitleOffset = function() { var left = 5; for(var location of $scope.directiveScope.containedLocations.sort((a, b) => { return a > b ? -1 : 1; })) { if (location.relative_location_top < 50 && left > location.relative_location_left - 100 && left < location.relative_location_left + location.width) { left = 5 + location.relative_location_left + location.width; } } return left * $scope.directiveScope.dynamicScaleFactor; } this.getFontSize = function() { return $scope.directiveScope.location ? Math.min(1.25, Math.max(0.25, ($scope.directiveScope.location.width / 100) * $scope.directiveScope.dynamicScaleFactor)) : 0 } this.onSelect = function(_location, _event) { console.log(_event.target.innerText); $scope.directiveScope.selectionFunction(_location); _event.stopPropagation(); safeApply($scope); } this.update = function() { if ($scope.directiveScope.location) { console.log($scope.directiveScope.location); retrieveRecords($scope, $http, "location", { query: { location: $scope.directiveScope.location._id, /* length: { $gt: 0 }, width: { $gt: 0 }, relative_location_left: { $lte: $scope.directiveScope.location.width }, relative_location_top: { $lte: $scope.directiveScope.location[$scope.directiveScope.vertical ? 'height' : 'length'] } */ } }, (response) => { $scope.directiveScope.containedLocations = response.records; }); } } $scope.$watch("directiveScope.location", (_new, _old) => { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.update(); } }); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: locationVisualization failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63d9231f9f678303a34364e4', ctrl_63d9231f9f678303a34364e4); app.directive('productionWorkflowGlobalLookup', function() { return { scope: { searchTerm: "=?" }, controller: ctrl_63e4958bf2697f01d1b5ba8f, template: `
    Please wait...
    No results found for {{directiveScope.searchTerm}}
    Multiple Results
    `, bindToController: true};}); function ctrl_63e4958bf2697f01d1b5ba8f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.busy = false; this.results = []; this.onCompletion = function() { $scope.directiveScope.busy = false; }; this.layouts = { production_workflow_instance: "639186970fb8210d1caa2eb7" }; this.update = function() { $scope.directiveScope.busy = true; $scope.directiveScope.results = []; if (/\M\O\d{8}$/.test($scope.directiveScope.searchTerm)) { //PWFI or MO retrieveRecord($scope, $http, "production_workflow_instance", { query: { number: $scope.directiveScope.searchTerm }}, (pwfi) => { if (pwfi) { pwfi._type = "production_workflow_instance"; $scope.directiveScope.results = [pwfi]; $scope.directiveScope.onCompletion(); return; } //No PWFI found, check for MO retrieveRecord($scope, $http, "virtual_sage_manufacturing_order", { query: { manufacturing_order_number: $scope.directiveScope.searchTerm }}, (mo) => { if (mo) { $scope.directiveScope.results = [mo]; } $scope.directiveScope.onCompletion(); return; }); }); } else if (/\d{4}\.\d{5}\.\d{6,7}(?:\.\d{2,3})?$/.test($scope.directiveScope.searchTerm)) { //Product code retrieveRecord($scope, $http, "virtual_sage_item", { query: { number: $scope.directiveScope.searchTerm }}, (item) => { if (item) { $scope.directiveScope.results = [item]; } $scope.directiveScope.onCompletion(); return; }); } else if (/[\C\Q]\d{6}$/.test($scope.directiveScope.searchTerm)) { //Order/Quote number retrieveRecord($scope, $http, "virtual_sage_order", { query: { order_number: $scope.directiveScope.searchTerm }}, (order) => { if (order) { $scope.directiveScope.results = [order]; } $scope.directiveScope.onCompletion(); return; }); } else if (/[\C\Q]\d{6}\-\d{1,}$/.test($scope.directiveScope.searchTerm)) { //Order/Quote number line var s = $scope.directiveScope.searchTerm.split("-"); retrieveRecord($scope, $http, "virtual_sage_order_line", { query: { order_number: s[0], line_number: s[1] }}, (orderLine) => { if (orderLine) { $scope.directiveScope.results = [orderLine]; } $scope.directiveScope.onCompletion(); return; }); } else if (/\M\O\d{8}-\d{1,}$/.test($scope.directiveScope.searchTerm)) { //PWFU number retrieveRecord($scope, $http, "production_workflow_unit", { query: { number: $scope.directiveScope.searchTerm }}, (unit) => { if (unit) { unit._type = "production_workflow_unit"; $scope.directiveScope.results = [unit]; } $scope.directiveScope.onCompletion(); return; }); } else if (/\I\N\d{6}$/.test($scope.directiveScope.searchTerm)) { //Invoice number retrieveRecord($scope, $http, "virtual_sage_invoice", { query: { invoice_number: $scope.directiveScope.searchTerm }}, (invoice) => { if (invoice) { $scope.directiveScope.results = [invoice]; } $scope.directiveScope.onCompletion(); return; }); } else if (/\S\H\d{6}$/.test($scope.directiveScope.searchTerm)) { //Shipment number retrieveRecord($scope, $http, "virtual_sage_shipment", { query: { shipment_number: $scope.directiveScope.searchTerm }}, (shipment) => { if (shipment) { $scope.directiveScope.results = [shipment]; } $scope.directiveScope.onCompletion(); return; }); } else { //Try serial unit serial directiveScope retrieveRecord($scope, $http, "production_workflow_unit", { query: { serial_number: $scope.directiveScope.searchTerm }}, (unit) => { if (unit) { unit._type = "production_workflow_unit"; $scope.directiveScope.results = [unit]; } $scope.directiveScope.onCompletion(); return; }); } } $scope.$watch("directiveScope.searchTerm", (_new, _old) => { if ($scope.directiveScope.results.length == 0 || _old != _new) { $scope.directiveScope.update(); } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionWorkflowGlobalLookup failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63e4958bf2697f01d1b5ba8f', ctrl_63e4958bf2697f01d1b5ba8f); app.directive('sageItemDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, transclude: false, controller: ctrl_63f95dcd0d74b603c9b55fca, template: `
    {{directiveScope.displayRecord.number}}
    {{directiveScope.displayRecord.description}}
    {{directiveScope.displayRecord.accuracy * 100}}% {{directiveScope.displayRecord.series}} {{directiveScope.displayRecord.drawing}}
    {{directiveScope.displayRecord.pressure_min}}{{directiveScope.displayRecord.pressure_max}} {{directiveScope.displayRecord.pressure_type_data.value}}
    {{directiveScope.displayRecord.output_min}}{{directiveScope.displayRecord.output_max}} {{directiveScope.displayRecord.output_unit_symbol}} Ratio. {{modeTitle}}
    {{directiveScope.displayRecord.termination_cable_type ? (directiveScope.displayRecord.cable_feet + "\' of " + directiveScope.displayRecord.termination_cable_type) : ""}} {{directiveScope.displayRecord.termination_connector_type ? directiveScope.displayRecord.termination_connector_type : ""}}
    {{directiveScope.displayRecord.optional_data.value}}
    `, bindToController: true};}); function ctrl_63f95dcd0d74b603c9b55fca($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.displayRecord = null; this.digitalModes = { rs485: "RS-485", i2c: "I²C", sdi12: "SDI-12" }; this.updateDisplayRecord = function() { $scope.directiveScope.loading = true; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { var bindingValue = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; if (typeof(bindingValue) == "object") { $scope.directiveScope.displayRecord = bindingValue; $scope.directiveScope.loading = false; } else { var query = /([a-z]|\d){24}/.test(bindingValue) ? { _id: bindingValue } : { number: bindingValue }; retrieveRecord($scope, $http, "virtual_sage_item", { query: query }, (item) => { $scope.directiveScope.displayRecord = item; $scope.directiveScope.loading = false; }); } } else { $scope.directiveScope.displayRecord = null; $scope.directiveScope.loading = false; } } this.updateDisplayRecord(); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { if (_new != _old) { $scope.directiveScope.updateDisplayRecord(); } }); } /* */; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: sageItemDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63f95dcd0d74b603c9b55fca', ctrl_63f95dcd0d74b603c9b55fca); app.directive('commonDisplay', function() { return { scope: { text: "=?", textClass: "=?", subText: "=?", subTextClass: "=?", icon: "=?", subIcon: "=?", allowInteraction: "=?", spinnerIcon: "=?", spinnerSubIcon: "=?", progress: "=?", progressClass: "=?", iconLocation: "=?", subTextBelow: "=?", iconCircle: "=?", iconSize: "=?", allowWrap: "=?" }, controller: ctrl_63fed76c9af6563cf8cbf827, template: `
    {{directiveScope.text}}
    {{directiveScope.subText}}
    {{directiveScope.text}}
    {{directiveScope.subText}}
    `, bindToController: true};}); function ctrl_63fed76c9af6563cf8cbf827($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; this.allowWrap = this.allowWrap == null ? true : this.allowWrap; this.iconLocation = this.iconLocation == null ? "left" : this.iconLocation; this.subTextBelow = this.subTextBelow == null ? true : this.subTextBelow; this.subTextClass = this.subTextClass == null ? "secondary" : this.subTextClass; this.iconSize = this.iconSize == null ? 1.1 : this.iconSize; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: commonDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_63fed76c9af6563cf8cbf827', ctrl_63fed76c9af6563cf8cbf827); app.directive('qrButton', function() { return { scope: { displayClass: "=?", label: "=?", subLabel: "=?", qr: "=?", allowInteraction: "=?", onClick: "=?", icon: "=?", subIcon: "=?" } , controller: ctrl_640b448549f10c03c4870afb, template: `
    `, bindToController: true};}); function ctrl_640b448549f10c03c4870afb($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayClass = this.displayClass == null ? "primary" : this.displayClass; this.label = this.label == null ? "" : this.label; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: qrButton failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_640b448549f10c03c4870afb', ctrl_640b448549f10c03c4870afb); app.directive('recordModal', function() { return { scope: { refModel: "=", allowEdit: "=?", bindingName: "=", bindingParent: "=", layout: "=?", directiveRef: "=" }, controller: ctrl_641b126048d89f256385bb07, template: ` `, bindToController: true};}); function ctrl_641b126048d89f256385bb07($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; this.unique = createUniqueTag(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: recordModal failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_641b126048d89f256385bb07', ctrl_641b126048d89f256385bb07); app.directive('productionWorkflowProgress', function() { return { scope: { expanded: "=?", workflow: "=?", //Only required if pwfi not provided workflowInstance: "=?" //Only required if reporting progress }, controller: ctrl_64278355fa9bc870dbf76953, template: `


    Click to collapse...
    `, bindToController: true};}); function ctrl_64278355fa9bc870dbf76953($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.expanded = !!this.expanded; this.expand = function() { $scope.directiveScope.expanded = !$scope.directiveScope.expanded; } this.reload = function() { if ($scope.directiveScope.workflowInstance) { //PWFI provided, load it retrieveRecord($scope, $http, "production_workflow_instance", { query: { _id: $scope.directiveScope.workflowInstance }, populate: { path: "workflow", populate: { path: "stages", populate: ["stage"] } } }, (pwfi) => { $scope.directiveScope.workflowRecord = pwfi.workflow; $scope.directiveScope.workflowInstanceRecord = pwfi }); } else if ($scope.directiveScope.workflow) { //PWFI not provided, but workflow is retrieveRecord($scope, $http, "production_workflow", { query: { _id: $scope.directiveScope.workflow }, populate: { path: "stages", populate: ["stage"] } }, (workflow) => { $scope.directiveScope.workflowRecord = workflow; $scope.directiveScope.workflowInstanceRecord = null }); } else { //No params provided $scope.directiveScope.workflowRecord = null; $scope.directiveScope.workflowInstanceRecord = null } } this.reload(); this.getStageEntryDisplay = function(_entry) { if ($scope.directiveScope.workflowInstanceRecord) { if ($scope.directiveScope.workflowInstanceRecord.suggested_stage_entry) { //Calculate based on PWFI's suggestStage (all before are assumed complete) for(var entry of $scope.directiveScope.workflowInstanceRecord.workflow.stages) { if (entry._id == $scope.directiveScope.workflowInstanceRecord.suggested_stage_entry) { //At the suggested stage, not complete return { class: "warning", icon: "/media/hourglass_icon.png" } } else if (entry._id == _entry._id) { return { class: "success", icon: "/media/checkmark_icon.png" } } } } else { //No suggested stage for this PWFSI return { class: "success", icon: "/media/checkmark_icon.png" } } } else { //No PWFI provided, check for rules on this stage return { class: (_entry.rules || []).length == 0 ? null : 'primary', icon: (_entry.rules || []).length == 0 ? null : '/media/info_icon.png' } } } $scope.$watch("[directiveScope.workflow, directiveScope.workflowInstance]", (_new, _old) => { if (_new != _old) { $scope.directiveScope.reload(); } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionWorkflowProgress failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_64278355fa9bc870dbf76953', ctrl_64278355fa9bc870dbf76953); app.directive('segmentOperationalStateDetailsDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?", hideOk: "=?" } , controller: ctrl_643a48e741f8b63c4b6e0a92, template: `
    `, bindToController: true};}); function ctrl_643a48e741f8b63c4b6e0a92($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: segmentOperationalStateDetailsDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_643a48e741f8b63c4b6e0a92', ctrl_643a48e741f8b63c4b6e0a92); app.directive('productionWorkflowUnitsControl', function() { return { scope: { units: "=?", unit: "=?", stageEntry: "=?", stageInstances: "=?", workstation: "=?" }, controller: ctrl_6452b30d98c9780f98c4a678, template: `
    # Serial Progress

    {{unit.index + 1}}

    {{unit.serial_number || 'None'}}
    `, bindToController: true};}); function ctrl_6452b30d98c9780f98c4a678($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.units = this.units == null ? [] : this.units; this.stageInstances = this.stageInstances == null ? [] : this.stageInstances; this.ready = true; this.toggleSelection = function(_unit) { if ($scope.directiveScope.ready && $scope.directiveScope.unitCanBeSelected(_unit)) { $scope.directiveScope.manualChange = true; _unit.selected = !_unit.selected; } }; this.getUnit = function(_unitId) { return $scope.directiveScope.units.find((unit) => { return unit._id == _unitId; }); } this.getSelectedUnits = function() { return $scope.directiveScope.units.filter((unit) => { return unit.selected; }); } this.unitCanBeSelected = function(_unit) { var currentUnitStageInstance = $scope.directiveScope.findCurrentUnitStageInstance(_unit); return currentUnitStageInstance ? ( ($scope.directiveScope.stageEntry.stage.in_progress_unit_selection || currentUnitStageInstance.state != "in_progress") && ($scope.directiveScope.stageEntry.stage.complete_unit_selection || currentUnitStageInstance.state != "complete") && ($scope.directiveScope.stageEntry.stage.scrapped_unit_selection || !_unit.scrapped) ) : true; } this.findCurrentUnitStageInstance = function(_unit) { var t = $scope.directiveScope.stageInstances.find((stageInstance) => { return stageInstance.unit == _unit._id; }); return t; } this.canSelectNextPending = function() { return !!$scope.directiveScope.units.find((unit) => { var unitStateInstance = $scope.directiveScope.findCurrentUnitStageInstance(unit); return unitStateInstance && unitStateInstance.state == "pending"; }); } this.scrollToElement = function(_id) { var container = document.getElementById($scope.directiveScope.unique + "_container"); var scrollTo = document.getElementById(_id); container.scrollTop = scrollTo.offsetTop; }; this.selectNextPending = function() { $scope.directiveScope.clearSelections(); var toSelect = $scope.directiveScope.units.find((unit) => { var unitStateInstance = $scope.directiveScope.findCurrentUnitStageInstance(unit); return $scope.directiveScope.unitCanBeSelected(unit) && unitStateInstance && unitStateInstance.state == "pending"; }); if (toSelect) { toSelect.selected = true; } } this.canSelectAllPending = function() { return $scope.directiveScope.stageEntry && $scope.directiveScope.stageEntry.stage.unit_selection_mode == 'multiple' && $scope.directiveScope.units.some((unit) => { var unitStateInstance = $scope.directiveScope.findCurrentUnitStageInstance(unit); return unitStateInstance && unitStateInstance.state == "pending"; }); } this.selectAllPending = function() { $scope.directiveScope.units.forEach((unit) => { var unitStateInstance = $scope.directiveScope.findCurrentUnitStageInstance(unit); unit.selected = unitStateInstance && unitStateInstance.state == "pending" ? $scope.directiveScope.unitCanBeSelected(unit) : false; }); } this.selectAll = function() { $scope.directiveScope.units.forEach((unit) => { unit.selected = $scope.directiveScope.unitCanBeSelected(unit); }); } this.clearSelections = function() { $scope.directiveScope.units.forEach((unit) => { unit.selected = false; }); } }; $scope.$watch("directiveScope.config", (_new, _old) => { if ($scope.directiveScope.manualChange) { $scope.directiveScope.manualChange = false; return; } ((_new || {}).units || []).filter((unit) => { return unit.selected; }).map((unit) => { return unit; }).forEach((selection) => { $scope.directiveScope.scrollToElement($scope.directiveScope.unique + "_" + selection); }); }, true); $scope.$watch("directiveScope.stageInstances", () => { //Apply conditions for(var unit of $scope.directiveScope.units) { var wasSelected = unit.selected; unit.selected = unit.selected && $scope.directiveScope.unitCanBeSelected(unit); if (!unit.selected && wasSelected && $scope.directiveScope.stageEntry.stage.select_next_unit_when_complete) { //Unit was unselected, select next $scope.directiveScope.selectNextPending(); } } }); $scope.$watch("directiveScope.units", (_new, _old) => { var multipleSelections = (_new || []).filter((u) => { return u.selected; }).length > 1; if (multipleSelections && $scope.directiveScope.stageEntry.stage.unit_selection_mode == "single") { //Single selection mode, find newest selection var latestSelection = _new.filter((nu) => { return nu.selected && !_old.find((ou) => { return ou.selected && ou._id == nu._id; }); }).reverse()[0]; var fixed = $scope.directiveScope.units.map((u) => { u.selected = u._id == latestSelection._id; return u; }); $scope.directiveScope.units = fixed; } }, true); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionWorkflowUnitsControl failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6452b30d98c9780f98c4a678', ctrl_6452b30d98c9780f98c4a678); app.directive('compoundMaterialComponentEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_6454736bc79e9a3155e76b04, template: `
    {{component.proportion * 100}}%
    `, bindToController: true};}); function ctrl_6454736bc79e9a3155e76b04($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: compoundMaterialComponentEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6454736bc79e9a3155e76b04', ctrl_6454736bc79e9a3155e76b04); app.directive('compoundMaterialCuringEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_6455d0e79760e73b822f6a49, template: `
    {{directiveScope.getFormattedTime(cureConfig.seconds_working)}} Working
    {{directiveScope.getFormattedTime(cureConfig.seconds_full)}} Full
    @ {{cureConfig.temperature}}°C
    `, bindToController: true};}); function ctrl_6455d0e79760e73b822f6a49($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.buildTemplate = function(_new) { return `
    Temp. °C
    Working Cure
    Full Cure
    `; }; this.newEntryHtml = this.buildTemplate(true); this.existingEntryHtml = this.buildTemplate(); this.newEntryTemplate = { temperature: 0, seconds_working: 0, seconds_full: 0 }; this.getFormattedTime = function(_seconds) { return getFormattedTime(_seconds * 1000); } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: compoundMaterialCuringEntry failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6455d0e79760e73b822f6a49', ctrl_6455d0e79760e73b822f6a49); app.directive('taskExecutionDetails', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_64583181cdf68a3eeccaee10, template: `
    `, bindToController: true};}); function ctrl_64583181cdf68a3eeccaee10($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.taskExecution = null; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: taskExecutionDetails failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_64583181cdf68a3eeccaee10', ctrl_64583181cdf68a3eeccaee10); app.directive('workflowProgressMatrix', function() { return { scope: { bindingParent: "=?", bindingName: "=?", scrollParentId: "=?" }, controller: ctrl_645d7c83e6664c03eb80bbfb, template: `
    Unit ({{directiveScope.workflowInstance.units_required}})
    `, bindToController: true};}); function ctrl_645d7c83e6664c03eb80bbfb($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.workflowUnits = []; this.workflowStageInstances = {}; this.workflowInstance = null; this.unique = createUniqueTag(); this.scrollToNextIncompleteUnit = function(_stageEntryId) { var unitIndex; var unitFound = !!$scope.directiveScope.workflowUnits.find((unit, i) => { unitIndex = i; return !unit.scrapped && $scope.directiveScope.workflowStageInstances[unit._id][_stageEntryId].state != "complete"; }); if (unitFound) { scrollToElement("unit_" + (unitIndex > 0 ? $scope.directiveScope.workflowUnits[unitIndex - 1]._id : "top"), $scope.directiveScope.scrollParentId, true); } } this.update = function() { if ($scope.directiveScope.loading) { return; } var pwfiId = $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] : null; $scope.directiveScope.workflowUnits = []; $scope.directiveScope.workflowStageInstances = {}; $scope.directiveScope.workflowInstance = null; if (!pwfiId) { return; } $scope.directiveScope.loading = true; //Get workflow instance retrieveRecord($scope, $http, "production_workflow_instance", { query: { _id: pwfiId }, populate: { path: "workflow", populate: [{ path: "stages", populate: "stage" }] } }, (pwfi) => { $scope.directiveScope.workflowInstance = pwfi; if (!pwfi) { return; } retrieveRecords($scope, $http, "production_workflow_unit", { query: { workflow_instance: pwfiId }, sort: { index: "asc" }, }, (pwfuResponse) => { $scope.directiveScope.workflowUnits = pwfuResponse.records; retrieveRecords($scope, $http, "production_workflow_stage_instance", { query: { unit: { $in: $scope.directiveScope.workflowUnits.map((u) => { return u._id; }) } }, select: ["_id", "unit", "workflow_stage_entry", "state"] }, (pwfsiResponse) => { //Group PWFIs by unit id and then workflow_stage_entry id $scope.directiveScope.workflowStageInstances = groupByProperty(pwfsiResponse.records, "unit"); Object.keys($scope.directiveScope.workflowStageInstances).forEach((unitId) => { $scope.directiveScope.workflowStageInstances[unitId] = arrayToObjectBy($scope.directiveScope.workflowStageInstances[unitId], "workflow_stage_entry"); }); //Calculate stats $scope.directiveScope.workflowInstance.workflow.stages.forEach((stageEntry) => { stageEntry.unitsComplete = pwfsiResponse.records.filter((pwfsi) => { return pwfsi.workflow_stage_entry == stageEntry._id && pwfsi.state == "complete"; }).length; stageEntry.unitsInProgress = pwfsiResponse.records.filter((pwfsi) => { return pwfsi.workflow_stage_entry == stageEntry._id && pwfsi.state == "in_progress"; }).length; }); $scope.directiveScope.loading = false; }); }); }); } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.update(); }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: workflowProgressMatrix failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_645d7c83e6664c03eb80bbfb', ctrl_645d7c83e6664c03eb80bbfb); app.directive('shelfRackVisualization', function() { return { scope: { bindingParent: "=?", bindingName: "=?", shelfHtml: "=?", shelfJs: "=?" }, controller: ctrl_64937fe25158c82d95336f18, template: `
    {{shelf.name}}
    `, bindToController: true};}); function ctrl_64937fe25158c82d95336f18($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; retrieveRecord($scope, $http, "shelf_rack", { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } }, (shelfRack) => { retrieveRecords($scope, $http, "shelf", { query: { location: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } }, (response) => { $scope.directiveScope.shelfRack = shelfRack; $scope.directiveScope.verticalShelfIndexes = groupByProperty(response.records, "parent_vertical_index"); Object.keys($scope.directiveScope.verticalShelfIndexes).forEach((shelf) => { $scope.directiveScope.verticalShelfIndexes[shelf] = arrayToObjectBy($scope.directiveScope.verticalShelfIndexes[shelf], "parent_horizontal_index") }); waitForElement("shelfVisualization", (shelfRack) => { $scope.directiveScope.displayWidth = shelfRack.offsetWidth; $scope.directiveScope.verticalScale = $scope.directiveScope.displayWidth / $scope.directiveScope.shelfRack.length; safeApply($scope); }); }); }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shelfRackVisualization failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_64937fe25158c82d95336f18', ctrl_64937fe25158c82d95336f18); app.directive('productionShelfRackVisualization', function() { return { scope: { bindingParent: "=?", bindingName: "=?", highlightedOrderNumbers: "=?" }, controller: ctrl_6493af9f5158c82d953525ed, template: ` `, bindToController: true};}); function ctrl_6493af9f5158c82d953525ed($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.shelfHtml = btoa(`
    {{orderNumber}}-{{lineNumber}} {{orderStats.customer}}
    {{orderLineStats.units.length}} {{orderLineStats.itemNumber}}
    {{orderLineStats.itemDescription.split("/")[0]}}
    `); this.shelfJs = ` //Get all units at this shelf retrieveRecords($scope, $http, "production_workflow_unit", { query: { location: $scope.$parent.shelf } }, (unitResponse) => { $scope.units = unitResponse.records; //Get all PWFIs retrieveRecords($scope, $http, "production_workflow_instance", { query: { _id: { $in: $scope.units.map((pwfu) => { return pwfu.workflow_instance; }).distinct() }}, populate: ["order_lines", "sibling_order_lines"] }, (pwfiResponse) => { $scope.orders = {}; pwfiResponse.records.forEach((pwfi) => { pwfi.order_lines.forEach((orderLine) => { $scope.orders[orderLine.order_number] = $scope.orders[orderLine.order_number] || { customer: orderLine.customer, class: (($scope.$parent.$parent.$parent.$parent.$parent.directiveScope.highlightedOrderNumbers || []).includes(orderLine.order_number) ? "border-primary table-primary" : "bg-light"), lines: {} }; $scope.orders[orderLine.order_number].lines[orderLine.line_number] = { units: $scope.units.filter((pwfu) => { return pwfu.workflow_instance == pwfi._id; }), itemNumber: orderLine.item_number, itemDescription: orderLine.item_description, completion: orderLine.production_completion }; }) }); }); }); `; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionShelfRackVisualization failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6493af9f5158c82d953525ed', ctrl_6493af9f5158c82d953525ed); app.directive('productionUnitsStateDisplay', function() { return { scope: { unitQuery: "=?", groupBy: "=?" }, controller: ctrl_6496007feb54ad04281d0e06, template: `
    {{units.length}}
    at
    `, bindToController: true};}); function ctrl_6496007feb54ad04281d0e06($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.groupBy = this.groupBy == null ? "suggested_stage_entry" : this.groupBy; this.update = function() { retrieveRecords($scope, $http, "production_workflow_unit", { query: ($scope.directiveScope.unitQuery || { _id: null }), select: ["suggested_stage_entry", "location"] }, (response) => { $scope.directiveScope.groupedUnits = groupByProperty(response.records, $scope.directiveScope.groupBy); Object.keys($scope.directiveScope.groupedUnits).forEach((groupValue) => { $scope.directiveScope.groupedUnits[groupValue] = groupByProperty($scope.directiveScope.groupedUnits[groupValue], "location"); }); }); } this.update(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionUnitsStateDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6496007feb54ad04281d0e06', ctrl_6496007feb54ad04281d0e06); app.directive('orderLinesProductionDisplay', function() { return { scope: { orderLineQuery: "=?", highlightedLines: "=?" }, controller: ctrl_6498c08d220ed71f46c15443, template: `
    Line Req. Prod. Item
    {{orderLine.original_quantity || 0}} {{(orderLine.original_quantity || 0) - (orderLine.quantity_ordered || 0)}} {{orderLine.item_number}}
    {{orderLine.item_description}}
    ... - - {{orderLines.length - 1}} More...
    `, bindToController: true};}); function ctrl_6498c08d220ed71f46c15443($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.expandCollapse = function() { $scope.directiveScope.expanded = !$scope.directiveScope.expanded; } this.update = function() { console.log($scope.directiveScope.orderLineQuery); retrieveRecords($scope, $http, "virtual_sage_order_line", { query: ($scope.directiveScope.orderLineQuery || { _id: null }), // select: ["suggested_stage_entry", "location"], sort: { line_number: "asc" } }, (response) => { $scope.directiveScope.orders = groupByProperty(response.records, "order_number"); }); } this.update(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: orderLinesProductionDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6498c08d220ed71f46c15443', ctrl_6498c08d220ed71f46c15443); app.directive('normalizedSageOrderLineNumber', function() { return { scope: { lineNumber: "=?", orderNumber: "=?" }, controller: ctrl_6498c34c220ed71f46c191c1, template: ` {{directiveScope.normalizedLine}}`, bindToController: true};}); function ctrl_6498c34c220ed71f46c191c1($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.directiveScope.normalizedLine = $scope.directiveScope.lineNumber; retrieveRecords($scope, $http, "virtual_sage_order_line", { query: { order_number: $scope.directiveScope.orderNumber, line_number: { $lt: $scope.directiveScope.lineNumber } }, sort: { line_number: "asc" }, select: ["line_number"] }, (response) => { $scope.directiveScope.normalizedLine = (response.total_count + 1); $scope.directiveScope.normalized = true; }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: normalizedSageOrderLineNumber failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6498c34c220ed71f46c191c1', ctrl_6498c34c220ed71f46c191c1); app.directive('productionUnitLaserVariablePreview', function() { return { scope: { bindingParent: "=", bindingName: "=", template: "=?" }, transclude: false, controller: ctrl_64c954ec9f2c144e8a5cbdee, template: `
    {{variableName}} {{variableValue}}
    `, bindToController: true};}); function ctrl_64c954ec9f2c144e8a5cbdee($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.reload = function() { if (!$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || !$scope.directiveScope.template) { $scope.directiveScope.variables = {}; return; } $http.get( "/api/pwf/laserTemplateVariables/" + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] + ($scope.directiveScope.template ? ("?template=" + $scope.directiveScope.template) : ""), { withCredentials: true }).then(function(json) { $scope.directiveScope.variables = {}; Object.keys(json.data).forEach((k) => { if (json.data[k]) { $scope.directiveScope.variables[k] = json.data[k]; } }); }); } $scope.$watch("[directiveScope.bindingParent[directiveScope.bindingName], directiveScope.template]", () => { console.log("WATCH"); $scope.directiveScope.reload(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionUnitLaserVariablePreview failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_64c954ec9f2c144e8a5cbdee', ctrl_64c954ec9f2c144e8a5cbdee); app.directive('modalPrintTemplate', function() { return { scope: { modalRef: "=?", modelName: "=?", renderData: "=?", template: "=?", query: "=?" } , controller: ctrl_651a316452dc0b2fd22333ad, template: `
    Template
    Mode
    Printer
    Format
    Optional Render Data


    `, bindToController: true};}); function ctrl_651a316452dc0b2fd22333ad($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.renderData = this.renderData == null ? {} : this.renderData; this.modalRef = { mode: false, templateQuery: (() => { var q = { $or: [{ compatible_models: $scope.directiveScope.modelName }] }; try { if ($scope.$root.models[$scope.directiveScope.modelName].parent) { q.$or.push({ compatible_models: $scope.$root.models[$scope.directiveScope.modelName].parent }); } } catch (e) {} return q; })(), renderFormat: "pdf", renderFormats: { pdf: { label: "PDF" }, png: { label: "PNG" } }, printer: null, printerSettings: {}, ready: function() { return $scope.directiveScope.template && (!$scope.directiveScope.modalRef.mode || $scope.directiveScope.modalRef.printer); }, go: function() { if ($scope.directiveScope.modalRef.mode) { //Print var data = $scope.directiveScope.renderData || {}; data.modelName = $scope.directiveScope.modelName; data.modelQuery = $scope.directiveScope.query; renderTemplateToPrinter( $scope, $http, $scope.directiveScope.template, $scope.directiveScope.modalRef.printer, data, false, $scope.directiveScope.modalRef.printerSettings ); } else { //Render $scope.directiveScope.modalRef.displayRender = true; } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalPrintTemplate failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_651a316452dc0b2fd22333ad', ctrl_651a316452dc0b2fd22333ad); app.directive('executeTaskButton', function() { return { scope: { label: "=?", executingLabel: "=?", task: "=?", parameters: "=?", buttonClass: "=?", icon: "=?", confirm: "=?", executionContext: "=?" /* 'user' will check for executions only by the current user 'any' will check for any executions null will not check for existing executions */ } , controller: ctrl_6558592005109b3abbdff778, template: ``, bindToController: true};}); function ctrl_6558592005109b3abbdff778($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.refreshInterval = 10000; this.activeStates = ["initializing", "initialized", "executing"]; this.updateExecutionState = function(_newExecution, _then) { var query = null; if (_newExecution) { // New explicit execution supplied query = { _id: _newExecution._id }; } else if ($scope.directiveScope.taskExecution) { // Execution is already known query = { _id: $scope.directiveScope.taskExecution._id }; } else if (!$scope.directiveScope.executionContext) { // Execution unknown query = null; } else if ($scope.directiveScope.executionContext == "any") { // Retrieve the latest executing execution query = { task: $scope.directiveScope.task, state: { $in: $scope.directiveScope.activeStates }, parameters: $scope.directiveScope.parameters }; } else if ($scope.directiveScope.executionContext == "user") { // Retrieve the latest executing execution (by the current user) query = { task: $scope.directiveScope.task, created_by: $scope.$root.currentUser._id, state: { $in: $scope.directiveScope.activeStates }, parameters: $scope.directiveScope.parameters }; } // Do we have an execution to check for? if (query) { // Yes, retrieve retrieveRecord($scope, $http, "task_execution", { query: query, sort: { created_at: "desc" } }, (execution) => { if (execution) { // Execution found, new? if ($scope.directiveScope.taskExecution) { // Execution not new, state change? if (execution.state == "succeeded" && $scope.directiveScope.activeStates.includes($scope.directiveScope.taskExecution.state)) { // Was running, now succeeded, slow down refresh interval $scope.directiveScope.refreshInterval = 10000; $scope.$root.$emit('showAlert', "Task completed successfully
    " + (execution.result ?? "") + "", "success"); } else if (execution.state == "failed" && $scope.directiveScope.activeStates.includes($scope.directiveScope.taskExecution.state)) { // Was running, now failed, slow down refresh interval $scope.directiveScope.refreshInterval = 10000; $scope.$root.$emit('showAlert', "Task failed to completed
    " + (execution.result ?? "") + "", "danger"); } else if (execution.state == "cancelled" && $scope.directiveScope.activeStates.includes($scope.directiveScope.taskExecution.state)) { // Was running, now failed, slow down refresh interval $scope.directiveScope.refreshInterval = 10000; $scope.$root.$emit('showAlert', "Task was cancelled", "warning"); } } else { // Execution is new, set interval to update more frequently $scope.directiveScope.refreshInterval = 1000; } // Store latest execution $scope.directiveScope.taskExecution = execution; $scope.directiveScope.ready = true; } else { // No execution found, try again later $scope.directiveScope.ready = true; } if (_then) { _then(); } // Set refresh timeout if ($scope.directiveScope.refreshInterval) { setTimeout(() => { $scope.directiveScope.updateExecutionState(); }, $scope.directiveScope.refreshInterval); } }); } else { // No query, set refresh timeout $scope.directiveScope.ready = true; if ($scope.directiveScope.refreshInterval) { setTimeout(() => { $scope.directiveScope.updateExecutionState(); }, $scope.directiveScope.refreshInterval); } if (_then) { _then(); } } } this.updateExecutionState(); this.execute = function() { if ($scope.directiveScope.confirm) { if (!confirm("Are you sure you want to execute the task?")) { return; } } // Double check execution state $scope.ready = false; safeApply($scope); $scope.directiveScope.updateExecutionState(null, () => { if (!$scope.directiveScope.taskExecution || !$scope.directiveScope.activeStates.includes($scope.directiveScope.taskExecution.state)) { executeTask($scope, $http, $scope.directiveScope.task, { parameters: $scope.directiveScope.parameters }, (started) => { $scope.directiveScope.updateExecutionState(started); }); } }); }; }; this.$onDestroy = function() { $scope.directiveScope.refreshInterval = null; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: executeTaskButton failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6558592005109b3abbdff778', ctrl_6558592005109b3abbdff778); app.directive('neuralOrganism', function() { return { scope: { cellHeight: "=?", cellWidth: "=?", cellSize: "=?", minChangeReset: "=?", aliveClass: "=?", speed: "=?" }, controller: ctrl_659b397ad2c4df0424b455bd, template: `
    `, bindToController: true};}); function ctrl_659b397ad2c4df0424b455bd($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.results = []; $scope.directiveScope = this; this.result = { iterations: 0 }; this.cellHeight = this.cellHeight == null ? 25 : this.cellHeight ; this.cellWidth = this.cellWidth == null ? 25 : this.cellWidth; this.cellSize = this.cellSize == null ? 1 : this.cellSize; this.minChangeReset = this.minChangeReset == null ? 10 : this.minChangeReset; this.aliveClass = this.aliveClass == null ? "theme" : this.aliveClass; this.speed = this.speed == null ? 1 : this.speed; this.reset = function() { $scope.directiveScope.result = { iterations: 0 }; $scope.directiveScope.cells = []; for(var y = 0; y < $scope.directiveScope.cellHeight; y++) { $scope.directiveScope.cells.push([]); for(var x = 0; x < $scope.directiveScope.cellWidth; x++) { $scope.directiveScope.cells[y].push(Math.random() * 0.4); } } } this.reset(); this.process = function() { $scope.directiveScope.result.iterations++; var changes = []; for(var y = 0; y < $scope.directiveScope.cellHeight; y++) { for(var x = 0; x < $scope.directiveScope.cellWidth; x++) { //Calculate new state var newState = $scope.directiveScope.processFloat(y, x); if (newState != null) { changes.push({ y: y, x: x, state: newState }); } } } $scope.changes = changes.length; if (changes.length <= $scope.directiveScope.minChangeReset) { $scope.directiveScope.results.push($scope.directiveScope.result); $scope.directiveScope.reset(); } changes.forEach((change) => { $scope.directiveScope.cells[change.y][change.x] = change.state; }); safeApply($scope); setTimeout(() => { $scope.directiveScope.process(); }, $scope.directiveScope.speed) } this.processStandard = function(_y, _x) { var neighbors = 0; var state = $scope.directiveScope.cells[_y][_x]; for(var yo = -1; yo < 2; yo++) { for(var xo = -1; xo < 2; xo++) { if (_y + yo > $scope.directiveScope.cellHeight - 1 || _y + yo < 0 || _x + xo > $scope.directiveScope.cellWidth - 1 || _x + xo < 0 || (yo == 0 && xo == 0) ) { continue; } neighbors += $scope.directiveScope.cells[_y + yo][_x + xo]; } } var newState = state ? (neighbors < 2 ? 0 : (neighbors > 3 ? 0 : 1)) : (neighbors == 3 ? 1 : 0); return newState != state ? newState : null; }; this.processFloat = function(_y, _x) { var state = $scope.directiveScope.cells[_y][_x]; state = limit(state - 0.01); var neighbors = 0; var neighborTotal = 0; for(var yo = -1; yo < 2; yo++) { for(var xo = -1; xo < 2; xo++) { if (_y + yo > $scope.directiveScope.cellHeight - 1 || _y + yo < 0 || _x + xo > $scope.directiveScope.cellWidth - 1 || _x + xo < 0 || (yo == 0 && xo == 0) ) { continue; } neighbors++; neighborTotal += $scope.directiveScope.cells[_y + yo][_x + xo]; } } var neighborAverage = neighborTotal / neighbors; var newLow = limit(-0.1 + state); var newHigh = limit( 0.1 + state); var newState = state > 0.01 ? //Alive, will it starve? //Alive, will it be outcompeted? (neighborAverage < 0.25 ? newLow : (neighborAverage > 0.375 ? newLow : newHigh)) : //Dead, can neighbors mate? (neighborAverage > 0.24 && neighborAverage < 0.5 ? newHigh : newLow); return newState != state ? newState : null; } this.process(); }; function limit(_float) { return Math.min(1, Math.max(0, _float)); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: neuralOrganism failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_659b397ad2c4df0424b455bd', ctrl_659b397ad2c4df0424b455bd); app.directive('microsoftLogin', function() { return { scope: { scopeUri: "=?", forceLogin: "=?", bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_65ab5ff5d07fe27bc059c104, template: `ms login`, bindToController: true};}); function ctrl_65ab5ff5d07fe27bc059c104($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; console.log("U: " + this.unique); this.scopeUri = this.scopeUri == null ? "https://analysis.windows.net/powerbi/api/.default" : this.scopeUri; this.forceLogin = this.forceLogin == null ? true : this.forceLogin; this.login = function () { var loginUrl = "https://login.microsoftonline.com/b8225e48-a909-4896-87fe-1d3c32c7d1aa" + '/oauth2/authorize?client_id=0fbc3693-c3f1-40f3-8dcb-5060cc949d6c' + '&redirect_uri=' + "https://kim.kelleramerica.com:44400" + '&response_type=token' + ($scope.directiveScope.forceLogin ? "&prompt=login" : "") + "&resource=0fbc3693-c3f1-40f3-8dcb-5060cc949d6c" + '&scope=' + encodeURIComponent(this.scopeUri) + '&nonce=' + this.unique; $scope.directiveScope.loginWindow = window.open(loginUrl, 'newwindow','width=500,height=700'); setInterval(() => { console.log($scope.directiveScope.loginWindow.location.href); }, 1000); }; this.login(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: microsoftLogin failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_65ab5ff5d07fe27bc059c104', ctrl_65ab5ff5d07fe27bc059c104); app.directive('multipleArticleSelection', function() { return { scope: { bindingName: "=", bindingParent: "=" }, controller: ctrl_65e73747cad0473647afec70, template: ` `, bindToController: true};}); function ctrl_65e73747cad0473647afec70($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.showArticle = function(_articleId) { $scope.directiveScope.articleModal.articleId = _articleId; $scope.directiveScope.articleModal.show(); } this.articleModal = { }; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleArticleSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_65e73747cad0473647afec70', ctrl_65e73747cad0473647afec70); app.directive('diffDisplay', function() { return { scope: { subjectBindingParent: "=?", subjectBindingName: "=?", comparisonBindingParent: "=?", comparisonBindingName: "=?" } , controller: ctrl_65f4a33d5f4f6b2fd5bcc331, template: ` `, bindToController: true};}); function ctrl_65f4a33d5f4f6b2fd5bcc331($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.dmp = new diff_match_patch(); this.process = function() { $scope.directiveScope.diffs = $scope.directiveScope.dmp.diff_main( ($scope.directiveScope.comparisonBindingParent[$scope.directiveScope.comparisonBindingName] ?? ""), ($scope.directiveScope.subjectBindingParent[$scope.directiveScope.subjectBindingName] ?? "") ); $scope.directiveScope.dmp.diff_cleanupSemantic($scope.directiveScope.diffs); $scope.directiveScope.diffHtml = btoa(`` + $scope.directiveScope.diffs.map((diff) => { var mode = diff["0"]; var c = mode == -1 ? `class="table-danger" style="text-decoration: line-through;"` : ( mode == 1 ? `class="table-success"` : `` ); return `` + diff["1"].split("<").join("<").split(">").join(">") + ``; }).join("") + ``); } this.process(); $scope.$watch("directiveScope.comparisonBindingParent[directiveScope.comparisonBindingName]", (_new, _old) => { if (_new != _old) { $scope.directiveScope.process(); } }); $scope.$watch("directiveScope.subjectBindingParent[directiveScope.subjectBindingName]", (_new, _old) => { if (_new != _old) { $scope.directiveScope.process(); } }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: diffDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_65f4a33d5f4f6b2fd5bcc331', ctrl_65f4a33d5f4f6b2fd5bcc331); app.directive('instanceDeltaFieldDisplay', function() { return { scope: { localBindingParent: "=?", localBindingName: "=?", remoteBindingParent: "=?", remoteBindingName: "=?", displayMode: "=?", modelName: "=?", fieldName: "=?", fieldModel: "=?", remoteInstance: "=?" } , controller: ctrl_65f264cbb16ae93c0c092eb0, template: `
    b64
    `, bindToController: true};}); function ctrl_65f264cbb16ae93c0c092eb0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.localInstanceName = $scope.$root.kimConfig.title; this.remoteInstanceName = (this.remoteInstance ?? { name: "Remote Instance" }).name; this.subjectValue = this.displayMode == "push" ? this.localBindingParent[this.localBindingName] : this.remoteBindingParent[this.remoteBindingName]; this.comparisonValue = this.displayMode == "push" ? this.remoteBindingParent[this.remoteBindingName] : this.localBindingParent[this.localBindingName]; this.subjectArray = Array.isArray(this.subjectValue ); this.subjectObject = !this.subjectArray && this.subjectValue && typeof(this.subjectValue ) == "object"; this.comparisonArray = Array.isArray(this.comparisonValue); this.comparisonObject = !this.comparisonArray && this.comparisonValue && typeof(this.comparisonValue) == "object"; this.diffView = false; this.base64View = true; this.swapBase64 = function() { if ($scope.directiveScope.base64View) { //Already in base64 (by default), decode $scope.directiveScope.subjectValue = atob($scope.directiveScope.subjectValue); $scope.directiveScope.comparisonValue = atob($scope.directiveScope.comparisonValue); } else { $scope.directiveScope.subjectValue = btoa($scope.directiveScope.subjectValue); $scope.directiveScope.comparisonValue = btoa($scope.directiveScope.comparisonValue); } $scope.directiveScope.base64View = !$scope.directiveScope.base64View; }; this.allObjectKeys = [ ...(this.subjectObject ? Object.keys(this.subjectValue) : []), ...(this.comparisonObject ? Object.keys(this.comparisonValue) : []) ].distinct(); this.maxArrayLength = Math.max(this.subjectArray ? this.subjectValue.length : 0, this.comparisonArray ? this.comparisonValue.length : 0); this.virtualArrayRange = []; for(var i = 0; i < this.maxArrayLength; i++) { this.virtualArrayRange.push(i); } this.control = this.fieldModel ? $scope.$root.controls[this.fieldModel.selections ? "6023e2298989745e0939f791" : $scope.$root.kimConfig["default_singular_" + this.fieldModel.type + "_read_control" ]] : null; this.compareValues = function(_a, _b) { //Simple check if (_a == _b) { return true; } //Either null? if (_a == null || _b == null) { return false; } //Different types? if (typeof(_a) != typeof(_b)) { return false; } //Same type, neither is null if (Array.isArray(_a)) { if (_a.length != _b.length) { return false; } return _a.every((v, i) => { return this.compareValues(_a[i], _b[i]); }); } else if (typeof(_a) == "object") { var allKeys = [...Object.keys(_a), ...Object.keys(_b)].distinct(); return allKeys.every((v) => { return this.compareValues(_a[v], _b[v]); }); } else { return false; }; } this.inArray = typeof(this.fieldName) == "number"; this.copyToClipboard = function(_text) { navigator.clipboard.writeText(typeof(_text) == "object" ? JSON.stringify(_text, null, 2) : _text); $scope.$root.$emit("showAlert", "Value copied to clipboard", "primary"); } this.valuesEqual = this.compareValues(this.subjectValue, this.comparisonValue); this.displayClass = this.valuesEqual ? { bg: "light", fg: "dark", icon: "/media/checkmark_icon.png" } : ( this.compareValues(this.subjectValue, null) && !this.compareValues(this.comparisonValue, null) ? { bg: "danger", fg: "light", icon: "/media/crossout_icon.png" } : ( !this.compareValues(this.subjectValue, null) && this.compareValues(this.comparisonValue, null) ? { bg: "success", fg: "light", icon: "/media/add_icon.png" } : { bg: "warning", fg: "dark", icon: "/media/edit_icon.png" } ) ); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: instanceDeltaFieldDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_65f264cbb16ae93c0c092eb0', ctrl_65f264cbb16ae93c0c092eb0); app.directive('twoPaneLayout', function() { return { scope: { smallPaneLocation: "=?", smallPaneSize: "=?", //Bootstrap "col-" value smallPaneVisible: "=?", smallPaneScroll: "=?", largePaneVisible: "=?", largePaneScroll: "=?", }, transclude: { smallPane: "smallPane", largePane: "largePane", }, controller: ctrl_65ea2e3175fc905edb31ee85, template: `
    `, bindToController: true};}); function ctrl_65ea2e3175fc905edb31ee85($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.smallPaneSize = this.smallPaneSize ?? "auto"; this.smallPaneLocation = this.smallPaneLocation ?? "left"; this.smallPaneVisible = this.smallPaneVisible == null ? true : this.smallPaneVisible; this.smallPaneScroll = this.smallPaneScroll == null ? "hidden" : this.smallPaneScroll; this.largePaneVisible = this.largePaneVisible == null ? true : this.largePaneVisible; this.largePaneScroll = this.largePaneScroll == null ? "hidden" : this.largePaneScroll; this.smallPaneId = createUniqueTag(); this.getSmallPaneHeight = function() { var el = document.getElementById($scope.directiveScope.smallPaneId); return (el ?? {}).offsetHeight ?? 0 } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: twoPaneLayout failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_65ea2e3175fc905edb31ee85', ctrl_65ea2e3175fc905edb31ee85); app.directive('regexEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?" }, transclude: false, controller: ctrl_6602fcfc432a1960c31dd73f, template: `
    `, bindToController: true};}); function ctrl_6602fcfc432a1960c31dd73f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.guiMode = true; this.components = []; this.processing = false; this.supportedClauses = { litteral: { match: null }, wildcard: { match: "\\.\\*" }, anyOf: { match: "\\(.*?\\)" } } this.processUIChange = function() { } this.processBindingChange = function() { var components = []; var binding = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; var extractionRegex = new RegExp(Object.keys($scope.directiveScope.supportedClauses).map((c) => { var clause = $scope.directiveScope.supportedClauses[c]; return "(?<" + c + ">" + clause.match + ")"; }).join("|"), "g"); var extractedComponents = [...binding.matchAll(extractionRegex)]; console.log(extractedComponents); return ""; } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { if (!$scope.directiveScope.processing) { $scope.directiveScope.processing = true; $scope.directiveScope.processBindingChange(); $scope.directiveScope.processing = false; } }); $scope.$watch("directiveScope.components", (_new, _old) => { if (!$scope.directiveScope.processing) { $scope.directiveScope.processing = true; $scope.directiveScope.processUIChange(); $scope.directiveScope.processing = false; } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: regexEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6602fcfc432a1960c31dd73f', ctrl_6602fcfc432a1960c31dd73f); app.directive('simpleArrayEditor', function() { return { scope: { bindingParent: "=?", bindingName: "=?", template: "=?", inputType: "=?", allowInteraction: "=?" } , controller: ctrl_66a834c7f2e1e7040aec4e5c, template: `
    `, bindToController: true};}); function ctrl_66a834c7f2e1e7040aec4e5c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.type = this.type == null ? "text" : this.type; this.tempEntry = null; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: simpleArrayEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66a834c7f2e1e7040aec4e5c', ctrl_66a834c7f2e1e7040aec4e5c); app.directive('modelFilterPane', function() { return { scope: { modelName: "=?", query: "=?" }, controller: ctrl_66390436910d3c12766aab7c, template: `
    Filter


    `, bindToController: true};}); function ctrl_66390436910d3c12766aab7c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.editQuery = {}; this.getControl = function(_field) { var fieldDef = $scope.$root.models[$scope.directiveScope.modelName].fields[_field]; var control = getDefaultControls($scope, $scope.directiveScope.modelName, _field)[(fieldDef.array ? "plural" : "singular") + "_write"]; return control; } this.applyQuery = function() { var q = {}; Object.keys($scope.directiveScope.editQuery).forEach((f) => { if (!Array.isArray($scope.directiveScope.editQuery[f]) || $scope.directiveScope.editQuery[f].length > 0) { q[f] = $scope.directiveScope.editQuery[f]; } }); $scope.directiveScope.query = q; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFilterPane failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66390436910d3c12766aab7c', ctrl_66390436910d3c12766aab7c); app.directive('filterList', function() { return { scope: { modelName: "=?", baseQuery: "=?" }, controller: ctrl_6639036d910d3c12766aa4a0, template: `
    `, bindToController: true};}); function ctrl_6639036d910d3c12766aa4a0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.query = {}; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: filterList failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6639036d910d3c12766aa4a0', ctrl_6639036d910d3c12766aa4a0); app.directive('queryEditor', function() { return { scope: { child: "=?", fieldDef: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_66a56fd7f2e1e7040aec12de, template: `
    `, bindToController: true};}); function ctrl_66a56fd7f2e1e7040aec12de($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] ?? {} this.getPropertyNames = function() { return Object.keys($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] ?? {}).sort((a, b) => { return a > b && a.startsWith("$") && !b.startsWith("$") ? -1 : 1 }); } this.remove = function() { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; safeApply($scope); } this.booleanSelections = { all: { and: { label: "All Of", icon: "/media/checkmark_icon.png", class: "success" }, or: { label: "Any Of", icon: "/media/wait_icon.png", class: "warning" }, nor: { label: "None Of", icon: "/media/restrict_icon.png", class: "danger" } }, availableCache: {}, get available() { var newCache = {}; Object.keys($scope.directiveScope.booleanSelections.all).forEach((f) => { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]["$" + f] == null) { newCache[f] = cloneObject($scope.directiveScope.booleanSelections.all[f]); } }); if (JSON.stringify(newCache) != JSON.stringify($scope.directiveScope.booleanSelections.availableCache)) { $scope.directiveScope.booleanSelections.availableCache = newCache; } return $scope.directiveScope.booleanSelections.availableCache; }, get anyAvailable() { return Object.keys($scope.directiveScope.booleanSelections.available).length > 0; } }; this.onNewFieldSelection = function(_field) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][_field] = null; $scope.directiveScope.newFieldSelection = null; } this.onNewBooleanSelection = function(_boolean) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]["$" + _boolean] = [{}]; $scope.directiveScope.newBooleanSelection = null; } this.fieldSelections = { availableCache: {}, get available() { var newCache = {}; Object.keys($scope.directiveScope.fieldDef.fields).sort().forEach((f) => { var field = $scope.directiveScope.fieldDef.fields[f]; if (field && field.queryable && !["query", "file"].includes(field.type) && !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].hasOwnProperty(f)) { newCache[f] = { label: (f == "_id" ? $scope.directiveScope.fieldDef.singular_name : (field.display_name ?? f.toTitleCase())), class: (f == "_id" ? "primary" : ""), icon: field.type == "reference" ? (($scope.$root.models[field.ref] ?? {}).icon ?? {}).link : (field.type == "enumerator" ? $scope.$root.models.enumerator.icon.link : ("/media/icons/" + field.type + ".png")) }; } }); if (JSON.stringify(newCache) != JSON.stringify($scope.directiveScope.fieldSelections.availableCache)) { $scope.directiveScope.fieldSelections.availableCache = newCache; } return $scope.directiveScope.fieldSelections.availableCache; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66a56fd7f2e1e7040aec12de', ctrl_66a56fd7f2e1e7040aec12de); app.directive('queryBoolean', function() { return { scope: { fieldDef: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_66a57114f2e1e7040aec15f0, template: `
    `, bindToController: true};}); function ctrl_66a57114f2e1e7040aec15f0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.labels = { $and: { label: "All Of", class: "success", icon: "/media/checkmark_icon.png" }, $or: { label: "Any Of", class: "warning", icon: "/media/wait_icon.png" }, $nor: { label: "None Of", class: "danger", icon: "/media/restrict_icon.png" } } this.addClause = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push({}); } this.remove = function() { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { //Watch for changes to the contained query objects, remove any nulls (removed) if (!$scope.directiveScope.processingBinding && JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.processingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((ae) => { return ae != null; }); $scope.directiveScope.processingBinding = false; } }, true); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryBoolean failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66a57114f2e1e7040aec15f0', ctrl_66a57114f2e1e7040aec15f0); app.directive('queryField', function() { return { scope: { fieldDef: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_66a5727af2e1e7040aec161b, template: `
    {{directiveScope.inverted() ? 'Is Not' : 'Is'}}
    `, bindToController: true};}); function ctrl_66a5727af2e1e7040aec161b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.invert = function() { if (!$scope.directiveScope.allowInteraction) { return; } if ($scope.directiveScope.inverted()) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$not; } else { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = { $not: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } } } this.addClause = function() { if ($scope.directiveScope.inverted()) { if ($scope.directiveScope.simpleComparator()) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$not = {}; } $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$not.$tbd = null } else { if ($scope.directiveScope.simpleComparator()) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = {}; } $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$tbd = null } } this.inverted = function() { return ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] ?? {}).$not != null; } this.simpleComparator = function() { var v = $scope.directiveScope.inverted() ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$not : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; return v == null || (typeof(v) != "object") || v.getFullYear; } this.getFieldClauseNames = function() { return Object.keys( $scope.directiveScope.inverted() ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].$not : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] ).filter((f) => { return f != "$options"; }); } $scope.$watchCollection("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { //Watch for changes to the clause, if the clause is empty, remove it var currentClause = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; if (currentClause && typeof(currentClause) == "object" && currentClause.getFullYear == null && Object.keys(currentClause).length == 0) { console.log("REMOVING"); delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } }, true); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryField failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66a5727af2e1e7040aec161b', ctrl_66a5727af2e1e7040aec161b); app.directive('queryClause', function() { return { scope: { fieldDef: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_66a6dd11f2e1e7040aec1bea, template: `
    `, bindToController: true};}); function ctrl_66a6dd11f2e1e7040aec1bea($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); postProcessJSON(this.bindingParent); this.remove = function() { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } this.isArrayField = function(_fieldName) { return ["$and", "$or", "$nor"].includes(_fieldName); } this.selectionsDefined = function() { return Object.keys($scope.directiveScope.fieldDef.selections ?? {}).length > 0; } this.regexOptions = { caseInsensitive: true } this.regexOptionsUpdating = false; $scope.$watch("directiveScope.bindingParent", (_new, _old) => { postProcessJSON($scope.directiveScope.bindingParent); if (!$scope.directiveScope.regexOptionsUpdating && ($scope.directiveScope.bindingParent ?? {}).$regex != null) { //In a $regex clause, decode $options $scope.directiveScope.regexOptionsUpdating = true; $scope.directiveScope.regexOptions = { caseInsensitive: ($scope.directiveScope.bindingParent.$options ?? "").includes("i") }; $scope.directiveScope.regexOptionsUpdating = false; } }, true); $scope.$watch("directiveScope.regexOptions", (_new, _old) => { if (!$scope.directiveScope.regexOptionsUpdating && ($scope.directiveScope.bindingParent ?? {}).$regex != null) { //In a $regex clause, encode $options $scope.directiveScope.regexOptionsUpdating = true; $scope.directiveScope.bindingParent.$options = ( $scope.directiveScope.regexOptions.caseInsensitive ? "i": "" ); $scope.directiveScope.regexOptionsUpdating = false; } }, true); this.defaults = { string: "", number: 0, boolean: false, datetime: null, reference: null, enumerator: "", dynamic_object: {}, structured_object: {}, } this.comparators = { all: { tbd: { label: "Select comparator...", class: "secondary", selectable: false }, eq: { label: (this.fieldDef.array ? "Includes" : "Equal To"), class: "success" }, ne: { label: (this.fieldDef.array ? "Excludes" : "Not Equal To"), class: "danger" }, gt: { label: (this.fieldDef.type == "datetime" ? "After": "Greater Than"), class: "primary", compatibleTypes: ["number", "datetime"] }, gte: { label: (this.fieldDef.type == "datetime" ? "At or After": "Equal/Greater Than"), class: "primary", compatibleTypes: ["number", "datetime"] }, lt: { label: (this.fieldDef.type == "datetime" ? "Before": "Less Than"), class: "warning", compatibleTypes: ["number", "datetime"] }, lte: { label: (this.fieldDef.type == "datetime" ? "At or Before": "Equal/Less Than"), class: "warning", compatibleTypes: ["number", "datetime"] }, in: { label: (this.fieldDef.array ? "Includes All Of" : "One Of"), class: "success", compatibleTypes: ["number", "string", "reference", "enumerator"], arraySelection: true }, nin: { label: (this.fieldDef.array ? "Excludes All Of" : "Not One Of"), class: "danger", compatibleTypes: ["number", "string", "reference", "enumerator"], arraySelection: true }, regex: { label: "Matching", class: "info", compatibleTypes: ["string", "enumerator"] } }, availableCache: {}, get available() { var newCache = {}; Object.keys($scope.directiveScope.comparators.all).forEach((c) => { var comparator = $scope.directiveScope.comparators.all[c]; if (c != "tbd" && (!comparator.compatibleTypes || comparator.compatibleTypes.includes($scope.directiveScope.fieldDef.type))) { newCache[c] = cloneObject($scope.directiveScope.comparators.all[c]); newCache[c].selectable = !Object.keys($scope.directiveScope.bindingParent).includes("$" + c); } }); if (JSON.stringify(newCache) != JSON.stringify($scope.directiveScope.comparators.availableCache)) { $scope.directiveScope.comparators.availableCache = newCache; } return $scope.directiveScope.comparators.availableCache; } } $scope.$watch("directiveScope.bindingName", (_new, _old) => { $scope.directiveScope.comparator = Object.keys($scope.directiveScope.comparators.all).includes(_new.replace("$", "")) ? _new.replace("$", "") : "eq"; //Apply defaults if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] == null) { //Null value, check for correct default if ($scope.directiveScope.bindingName.startsWith("$") && $scope.directiveScope.comparators.all[$scope.directiveScope.bindingName].arraySelection) { //Array selection, always [] $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = []; } else { //Singular selection $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.defaults[$scope.directiveScope.fieldDef.type]; } } }); $scope.$watch("directiveScope.comparator", (_new, _old) => { if (_new == _old) { return; } var oldClause = cloneObject($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); //Convert between array/singular comparators var oldIsArray = $scope.directiveScope.comparators.all[_old].arraySelection; var newIsArray = $scope.directiveScope.comparators.all[_new].arraySelection; if (oldIsArray != newIsArray) { if (oldIsArray) { //Convert from array to singular oldClause = oldClause.length > 0 ? oldClause[0] : null; } else { //Convert from singular to array oldClause = oldClause == null || oldClause.toString().trim().length == 0 ? [] : [oldClause]; } } if (_old != "eq") { //Was previously a complex comparator, what is it now? if (_new == "eq") { //Now a simple equivalence comparator, directly assign comparison value to binding $scope.directiveScope.bindingParent = oldClause; } else { //Still a complex comparator, update to new comparator object (clears metadata) delete $scope.directiveScope.bindingParent["$" + _old] ; $scope.directiveScope.bindingParent["$" + _new] = oldClause; } } else { //Was previously a simple equivalence comparator, what is it now? if (_new == "eq") { //Still a simple equivalence comparator //$scope.directiveScope.bindingParent = oldClause; } else { //Now a complex comparator $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = {}; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]["$" + _new] = oldClause; } } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryClause failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_66a6dd11f2e1e7040aec1bea', ctrl_66a6dd11f2e1e7040aec1bea); app.directive('nodeRecordBrowser', function() { return { scope: { model: "=", id: "=", relationsTo: "=?", options: "=?" }, controller: ctrl_6728ec5558f294071f7dc972, template: ` `, bindToController: true};}); function ctrl_6728ec5558f294071f7dc972($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.records = {}; this.nodes = []; this.relations = []; this.options = this.options != null ? this.options : { height: "1000px", width: "100%", edges:{ smooth: false }, physics: true, layout: { hierarchical: { enabled: true, nodeSpacing: 250, levelSeparation: 500, direction: "LR", sortMethod: "directed" } } }; console.log("TEST"); this.onNodeSelection = function(_args) { $scope.directiveScope.populateRelations(_args.nodes[0]); } this.addRecordNode = function(_model, _record, _level) { if ($scope.directiveScope.nodes.some((n) => { return n.id == _model + ":" + _record._id; })) { return; } _level = _level ?? 0; $scope.directiveScope.records[_record._id] = _record; $scope.directiveScope.nodes.push({ label: "[" + $scope.$root.models[_model].singular_name + "]\r\n" + _record[$scope.$root.models[_model].display_field] + " " + _level, id: _model + ":" + _record._id, image: (_record.icon ?? $scope.$root.models[_model].icon).link, level: _level }); } retrieveRecord($scope, $http, $scope.directiveScope.model, { query: { _id: $scope.directiveScope.id } }, (record) => { $scope.directiveScope.addRecordNode($scope.directiveScope.model, record); this.populateRelations($scope.directiveScope.model + ":" + record._id); }); this.populateRelations = function(_nodeId) { var model = _nodeId.split(":")[0]; var id = _nodeId.split(":")[1]; var record = $scope.directiveScope.records[id]; var level = $scope.directiveScope.nodes.find((n) => { return n.id == _nodeId; }).level; // if ($scope.directiveScope.relationsTo) { //Relations to this record Object.keys($scope.$root.models).forEach((relatedModelName) => { Object.keys($scope.$root.models[relatedModelName].fields).forEach((relatedModelFieldName) => { var relatedField = $scope.$root.models[relatedModelName].fields[relatedModelFieldName]; if (relatedModelFieldName == "_id" || relatedField.type != "reference" || relatedField.ref != model || !relatedField.queryable || $scope.$root.globalFields[relatedModelFieldName]) { return; } var q = {}; q[relatedModelFieldName] = id; retrieveRecords($scope, $http, relatedModelName, { query: q, limit: 10 }, (response) => { response.records.forEach((relatedRecord) => { if (relatedRecord._id == id) { return; } $scope.directiveScope.addRecordNode(relatedModelName, relatedRecord, level - 1); if ($scope.directiveScope.relations.some((r) => { return r.from == _nodeId && r.to == relatedModelName + ":" + relatedRecord._id; })) { return; } $scope.directiveScope.relations.push({ from: _nodeId, to: relatedModelName + ":" + relatedRecord._id, label: relatedModelFieldName, arrows: { to: { enabled: false }, from: { enabled: true } } }); }); }); }); }); // } else { //Relations from this record Object.keys($scope.$root.models[model].fields).forEach((fieldName) => { var field = $scope.$root.models[model].fields[fieldName]; if (fieldName == "_id" || field.type != "reference" || $scope.$root.globalFields[fieldName]) { return; } var referencedIds = (Array.isArray(record[fieldName]) ? record[fieldName] : [record[fieldName]]).filter((i) => { return !!i; }); if (referencedIds.length == 0) { return; } retrieveRecords($scope, $http, field.ref, { query: { _id: { $in: referencedIds }}, limit: 10 }, (response) => { response.records.forEach((relatedRecord) => { $scope.directiveScope.addRecordNode(field.ref, relatedRecord, level + 1 ); if ($scope.directiveScope.relations.some((r) => { return r.from == _nodeId && r.to == field.ref + ":" + relatedRecord._id; })) { return; } $scope.directiveScope.relations.push({ from: _nodeId, to: field.ref + ":" + relatedRecord._id, label: fieldName, arrows: { to: { enabled: true }, from: { enabled: false } } }); }); }); }); //} } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nodeRecordBrowser failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6728ec5558f294071f7dc972', ctrl_6728ec5558f294071f7dc972); app.directive('productionCapacityChart', function() { return { scope: { capacityData: "=?", onSelection: "=?" }, controller: ctrl_675848279af99f39ee60210e, template: `
     
     
    Max. {{directiveScope.capacityData.max_concurrent_units | number}}
    Avg. {{directiveScope.capacityData.mean_concurrent_units | number}}
    Min. {{directiveScope.capacityData.min_concurrent_units | number}}
    {{directiveScope.latestDate | date}} {{directiveScope.earliestDate | date}}
     
     
     
    `, bindToController: true};}); function ctrl_675848279af99f39ee60210e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.concurrencyMax = 300; this.periodHeight = 300; this.groupByProperty = groupByProperty; this.getSlotLeftOffset = function(_date) { return ((_date.getTime() - $scope.directiveScope.earliestDate.getTime()) / ($scope.directiveScope.latestDate.getTime() - $scope.directiveScope.earliestDate.getTime())) * 100 } this.getSlotUnitWidth = function(_unit) { return $scope.directiveScope.getSlotLeftOffset(_unit.completed_at ?? new Date(Math.max($scope.directiveScope.capacityData.now.getTime(), _unit.expected_completion.getTime()))) - $scope.directiveScope.getSlotLeftOffset(_unit.started_at) } $scope.$watch("directiveScope.capacityData", (_new, _old) => { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.earliestDate = $scope.directiveScope.capacityData.earliest_date; $scope.directiveScope.latestDate = $scope.directiveScope.capacityData.latest_date; $scope.directiveScope.concurrencyMax = $scope.directiveScope.capacityData.max_concurrent_units * 1.25; $scope.directiveScope.periodDays = []; for(var day = $scope.directiveScope.earliestDate.getTime(); day <= $scope.directiveScope.latestDate; day += $scope.directiveScope.capacityData.period) { $scope.directiveScope.periodDays.push(new Date(day)); } for(var period of $scope.directiveScope.capacityData.periods) { period.unitsByWorkflow = $scope.directiveScope.groupByProperty(period.units, 'workflow'); } } }); retrieveRecords($scope, $http, "production_workflow", {}, (workflowResponse) => { $scope.directiveScope.workflows = arrayToObjectBy(workflowResponse.records, "_id"); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productionCapacityChart failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_675848279af99f39ee60210e', ctrl_675848279af99f39ee60210e); app.directive('copyToClipboard', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_675afa9ad01fe92c95b5282c, template: ` `, bindToController: true};}); function ctrl_675afa9ad01fe92c95b5282c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.copiedDisplay = null; this.canCopy = function() { return !$scope.directiveScope.copiedDisplay && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } this.updateClipboard = function() { navigator.clipboard.writeText(typeof($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) == "object" ? JSON.stringify($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName], null, 2) : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); $scope.directiveScope.copiedDisplay = true; safeApply($scope); setTimeout(() => { $scope.directiveScope.copiedDisplay = null; safeApply($scope); }, 500); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: copyToClipboard failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_675afa9ad01fe92c95b5282c', ctrl_675afa9ad01fe92c95b5282c); app.directive('numericInput', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_67771ff057c139382be0691e, template: ``, bindToController: true};}); function ctrl_67771ff057c139382be0691e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: numericInput failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67771ff057c139382be0691e', ctrl_67771ff057c139382be0691e); app.directive('matrixDisplay', function() { return { scope: { buffer: "=?" }, controller: ctrl_6768c4163e1fbb03ffeb5c4b, template: `
    `, bindToController: true};}); function ctrl_6768c4163e1fbb03ffeb5c4b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.buffer = this.buffer == null ? [] : this.buffer ; $scope.directiveScope = this; var o = 0; this.change = function() { var n = []; for(var r = 0; r < 25; r++) { n.push([]); for(var c = 0; c < 25; c++) { n[n.length - 1].push(Math.sin(o * (c/r))); } } $scope.directiveScope.buffer = n; safeApply($scope); o = o > 100 ? 0 : o + 0.1; setTimeout(() => { $scope.directiveScope.change(); }, 10); } this.change(); this.getSpectrumRgb = function(_value, _min, _max) { var p = _value / (_max - _min); return { b: 255 * Math.sin(p * 9), g: 255 * Math.sin(p * 5), r: 255 * Math.sin(p * 2), } } this.getRowStyle = function(_index) { return ` position: absolute; top: ` + ((_index / $scope.directiveScope.buffer.length) * 100) + `%; left: 0px; width: 100%; height: ` + (100 / $scope.directiveScope.buffer.length) + `%;`; } this.getCellStyle = function(_index, _row, _cell) { var rgb = $scope.directiveScope.getSpectrumRgb(_cell, 0, 1); return ` position: absolute; top: 0%; left: ` + ((_index / _row.length) * 100) + `%;; width: ` + (100 / _row.length) + `%; height: 100%; background-color: rgb(` + rgb.r + `, ` + rgb.g + `, ` + rgb.b + `) !important`; } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: matrixDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6768c4163e1fbb03ffeb5c4b', ctrl_6768c4163e1fbb03ffeb5c4b); app.directive('objectJsonDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_67a7071e56a60645e39d04a9, template: `
    `, bindToController: true};}); function ctrl_67a7071e56a60645e39d04a9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new ,_old) => { $scope.directiveScope.jsonHtml = btoa(formatJsonToHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName])); }, true); $scope.directiveScope.jsonHtml = btoa(formatJsonToHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName])); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectJsonDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67a7071e56a60645e39d04a9', ctrl_67a7071e56a60645e39d04a9); app.directive('approvalRequestApproverInterface', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?" }, controller: ctrl_67ad4e279f4edc51b3787945, template: `
    Approver State Time Note
    {{approvalState.timestamp ? approvalState.timestamp : '-' | date:'short' }} {{approvalState.note}}
    `, bindToController: true};}); function ctrl_67ad4e279f4edc51b3787945($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.showOptions = function(_approvalState) { // Record must be pending AND approvalState must be current identity return $scope.directiveScope.allowInteraction && _approvalState.identity == $scope.$root.currentUser._id && ($scope.directiveScope.bindingParent.allow_approval_change || _approvalState.state == "pending"); } this.cast = function(_action) { for(var approval of $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { if (approval.identity == $scope.$root.currentUser._id) { approval.state = _action == null ? "pending" : (_action ? "approved" : "rejected"); approval.timestamp = new Date(); } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: approvalRequestApproverInterface failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67ad4e279f4edc51b3787945', ctrl_67ad4e279f4edc51b3787945); app.directive('locationMapExplorer', function() { return { scope: { location: "=?", maxDepth: "=?", contentFunction: "=?", classFunction: "=?", selectionFunction: "=?", vertical: "=?" } , controller: ctrl_67b7c4d1c0b4f00403fc58c7, template: `
    {{directiveScope.selectedLocation}}
    `, bindToController: true};}); function ctrl_67b7c4d1c0b4f00403fc58c7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.query = {}; this.selectedLocation = this.location ? this.location._id : null; this.selectionFunction = function(_location) { $scope.directiveScope.selectedLocation = null; setTimeout(() => { $scope.directiveScope.selectedLocation = (_location ?? {})._id; }, 100); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: locationMapExplorer failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67b7c4d1c0b4f00403fc58c7', ctrl_67b7c4d1c0b4f00403fc58c7); app.directive('physicalNetworkConnectionEditor', function() { return { scope: { selected: "=?", // Which type/ci is selected hideUnselected: "=?", // Should unselected/related CIs be hidden? autoZoom: "=?", showControls: "=?", showDivision: "=?", showBorders: "=?", hideDisconnectedNics: "=?", hideDisconnectedCis: "=?", showImages: "=?" }, controller: ctrl_67b9011dff0d4a03ffe613f5, template: `
    Options
    Hide Unselected
    Hide Disconnected NICs
    Hide Disconnected CIs
    Show Images
    Auto-Zoom
    Zoom

    Depth Spacing
    CI Spacing

    Reload on Change

    Power Only
    Connection Types


    CI Types

    External Internal

    `, bindToController: true};}); function ctrl_67b9011dff0d4a03ffe613f5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.hideDisconnectedNics = this.hideDisconnectedNics == null ? false : this.hideDisconnectedNics; this.hideDisconnectedCis = this.hideDisconnectedCis == null ? false : this.hideDisconnectedCis; this.showControls = this.showControls == null ? true : this.showControls; this.autoZoom = this.autoZoom == null ? true : this.autoZoom; this.hideUnselected = this.hideUnselected == null ? true : this.hideUnselected; this.showDivision = this.showDivision == null ? true : this.showDivision; this.showBorders = this.showBorders == null ? true : this.showBorders; //this.ciTypes this.connectionTypes = this.connectionTypes == null ? Object.keys($scope.$root.models.cmdb_nic.fields.adapter_type.selections) : this.connectionTypes; this.unique = createUniqueTag(); this.connectingFrom = false; this.zoom = 0.75; this.depthSpacing = 400; this.ciSpacing = 200; this.previewRecordModal = {}; this.connectToModal = {}; this.disconnectFromModal = {}; this.articleModal = {}; this.ciFields = ["_id", "model_number", "context_icon", "name", "_type", "network_depth", "icon", "context_icon", "network_depth_index", "state"]; this.ciPopulate = { path: "model_number", populate: ["front_image", "back_image"] }; this.nicFields = ["_id", "name", "_type", "power_role", "adapter_type", "role", "parent", "connected_to", "internal_name"]; this.loadingMessage = ""; this.styleMap = { default: { color: "black", width: 1 }, ethernet: { color: "SlateBlue", width: 1 }, wifi: { color: "DarkTurquoise", dash: [2, 5], width: 1 }, pots: { color: "red" }, bluetooth: { color: "blue", dash: [1, 1], width: 1 }, coax: { color: "gray", width: 1 }, fiber: { color: "Goldenrod", width: 1 }, virtual: { color: "skyblue", dash: [10, 3], width: 1 }, cellular: { color: "blue", dash: [10, 5], width: 1 }, composite: { color: "yellow", }, power: { color: "orange" }, rs_232: { color: "purple" }, rs_485: { color: "purple" }, sdi_12: { color: "purple" }, i2c: { color: "purple" }, vpn_ipsec: { color: "DarkSlateBlue", dash: [10, 3], width: 1 }, vpn_ssl: { color: "DarkMagenta", dash: [10, 3], width: 1 } }; this.print = function() { var mywindow = window.open('', 'PRINT', 'height=400,width=600'); mywindow.document.write('' + document.title + ''); mywindow.document.write(''); mywindow.document.write($scope.directiveScope.uniqueContainerElement.outerHTML); mywindow.document.write(''); mywindow.print(); } this.ciContextSelections = { article: { label: "Article", icon: "/media/info_icon.png", onClick: function(_event) { $scope.directiveScope.articleModal.id = _event.target._id; $scope.directiveScope.articleModal.show(() => { $scope.directiveScope.articleModal.id = null; }); } }, edit: { label: "Edit CI", icon: "/media/edit_icon.png", onClick: function(_event) { $scope.directiveScope.previewRecordModal.type = "cmdb_ci"; $scope.directiveScope.previewRecordModal.tab = null; $scope.directiveScope.previewRecordModal.layout = "6329291c22a06724456468dd"; $scope.directiveScope.previewRecordModal.id = _event.target._id; $scope.directiveScope.previewRecordModal.show(() => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: $scope.directiveScope.previewRecordModal.id }, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (updatedCi) => { $scope.directiveScope.previewRecordModal.id = null; $scope.directiveScope.cisById[_event.target._id] = updatedCi; $scope.directiveScope.processCisById(); }); }); } }, viewImages: { label: "View Images", icon: "/media/observe_icon.png", onClick: function(_event) { $scope.directiveScope.previewRecordModal.type = "cmdb_ci"; $scope.directiveScope.previewRecordModal.tab = "Images"; $scope.directiveScope.previewRecordModal.layout = "6329291c22a06724456468dd"; $scope.directiveScope.previewRecordModal.id = _event.target._id; $scope.directiveScope.previewRecordModal.show(() => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: $scope.directiveScope.previewRecordModal.id }, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (updatedCi) => { $scope.directiveScope.previewRecordModal.id = null; $scope.directiveScope.cisById[_event.target._id] = updatedCi; $scope.directiveScope.processCisById(); }); }); } }, moveToTop: { label: "Move to Top", class: "primary font-weight-bold", icon: "/media/up_arrow_icon.png", onClick: function(_event) { var firstIndex = $scope.directiveScope.cisByDepth[_event.target.network_depth][0].network_depth_index ?? 0; updateRecord($scope, $http, "cmdb_ci", _event.target._id, { network_depth_index: firstIndex - 0.01 }, () => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: _event.target._id }, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (updatedCi) => { $scope.directiveScope.cisById[_event.target._id] = updatedCi; $scope.directiveScope.processCisById(); }); }); } }, moveUp: { label: "Move Up", icon: "/media/up_arrow_icon.png", onClick: function(_event) { var updates = {}; var i = 1; for(var depthCi of $scope.directiveScope.cisByDepth[_event.target.network_depth]) { var newNdi = (depthCi._id == _event.target._id ? i - 1.5 : i); if (depthCi.network_depth_index != newNdi) { updates[depthCi._id] = { network_depth_index: newNdi }; } i++; } updateRecords($scope, $http, "cmdb_ci", updates, () => { retrieveRecords($scope, $http, "cmdb_ci", { query: { _id: { $in: Object.keys(updates) }}, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (response) => { response.records.forEach((updatedCi) => { $scope.directiveScope.cisById[updatedCi._id] = updatedCi; }); $scope.directiveScope.processCisById(); }) }); } }, moveLeft: { label: "Move Left", icon: "/media/left_arrow_icon.png", onClick: function(_event) { updateRecord($scope, $http, "cmdb_ci", _event.target._id, { network_depth: _event.target.network_depth - 1 }, () => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: _event.target._id }, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (updatedCi) => { $scope.directiveScope.cisById[updatedCi._id] = updatedCi; $scope.directiveScope.processCisById(); }) }); } }, moveRight: { label: "Move Right", icon: "/media/right_arrow_icon.png", onClick: function(_event) { updateRecord($scope, $http, "cmdb_ci", _event.target._id, { network_depth: _event.target.network_depth + 1 }, () => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: _event.target._id }, select: $scope.directiveScope.ciFields }, (updatedCi) => { $scope.directiveScope.cisById[updatedCi._id] = updatedCi; $scope.directiveScope.processCisById(); }) }); } }, moveDown: { label: "Move Down", icon: "/media/down_arrow_icon.png", onClick: function(_event) { var updates = {}; var i = 1; for(var depthCi of $scope.directiveScope.cisByDepth[_event.target.network_depth]) { var newNdi = (depthCi._id == _event.target._id ? i + 1.5 : i); if (depthCi.network_depth_index != newNdi) { updates[depthCi._id] = { network_depth_index: newNdi }; } i++; } updateRecords($scope, $http, "cmdb_ci", updates, () => { retrieveRecords($scope, $http, "cmdb_ci", { query: { _id: { $in: Object.keys(updates) }}, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (response) => { response.records.forEach((updatedCi) => { $scope.directiveScope.cisById[updatedCi._id] = updatedCi; }); $scope.directiveScope.processCisById(); }) }); } }, moveToBottom: { label: "Move to Bottom", class: "primary font-weight-bold", icon: "/media/down_arrow_icon.png", onClick: function(_event) { var lastIndex = $scope.directiveScope.cisByDepth[_event.target.network_depth][$scope.directiveScope.cisByDepth[_event.target.network_depth].length - 1].network_depth_index ?? 0; updateRecord($scope, $http, "cmdb_ci", _event.target._id, { network_depth_index: lastIndex + 0.01 }, () => { retrieveRecord($scope, $http, "cmdb_ci", { query: { _id: _event.target._id }, select: $scope.directiveScope.ciFields, populate: $scope.directiveScope.ciPopulate }, (updatedCi) => { $scope.directiveScope.cisById[_event.target._id] = updatedCi; $scope.directiveScope.processCisById(); }); }); } }, addNic: { label: "Add NIC", icon: "/media/add_icon.png", onClick: function(_event) { insertRecord($scope, $http, "cmdb_nic", { parent: _event.target._id, name: "New NIC", active: true, mac: "Unknown" }, (result) => { retrieveRecords($scope, $http, "cmdb_nic", { query: { parent: _event.target._id }, select: $scope.directiveScope.nicFields }, (response) => { response.records.forEach((updatedNic) => { $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; }); $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } }, disconnectAll: { label: "Disconnect All", class: "danger", icon: "/media/restrict_icon.png" } }; this.nicContextSelections = { edit: { label: "Edit NIC", icon: "/media/edit_icon.png", onClick: function(_event) { $scope.directiveScope.previewRecordModal.type = "cmdb_nic"; $scope.directiveScope.previewRecordModal.layout = null; $scope.directiveScope.previewRecordModal.id = _event.target._id; $scope.directiveScope.previewRecordModal.show(() => { retrieveRecord($scope, $http, "cmdb_nic", { query: { _id: $scope.directiveScope.previewRecordModal.id }, select: $scope.directiveScope.nicFields }, (updatedNic) => { $scope.directiveScope.previewRecordModal.id = null; $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } }, connectTo: { label: "Connect To...", icon: "/media/right_arrow_icon.png", onClick: function(_event) { $scope.directiveScope.connectToModal.from = _event.target._id; $scope.directiveScope.connectToModal.to = null; $scope.directiveScope.connectToModal.show(() => { if ($scope.directiveScope.connectToModal.to) { updateRecord($scope, $http, "cmdb_nic", $scope.directiveScope.connectToModal.from, { $push: { connected_to: $scope.directiveScope.connectToModal.to._id } }, () => { // Done, reset and update retrieveRecords($scope, $http, "cmdb_nic", { query: { _id: { $in: [ $scope.directiveScope.connectToModal.from, $scope.directiveScope.connectToModal.to ]}}, select: $scope.directiveScope.nicFields }, (response) => { response.records.forEach((updatedNic) => { $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; }); $scope.directiveScope.connectToModal.from = null; $scope.directiveScope.connectToModal.to = null; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } else { // No NIC selected, reset $scope.directiveScope.connectToModal.from = null; $scope.directiveScope.connectToModal.to = null; } }); } }, connectMap: { label: "Connect on Map", icon: "/media/icons/structured_object.png", onClick: function(_event) { $scope.directiveScope.connectingFrom = _event.target._id; $scope.$root.$emit("showAlert", "Select the NIC to connect to...", "warning"); } }, disconnectFrom: { label: "Disconnect From...", icon: "/media/restrict_icon.png", onClick: function(_event) { $scope.directiveScope.disconnectFromModal.from = _event.target._id; $scope.directiveScope.disconnectFromModal.to = null; $scope.directiveScope.disconnectFromModal.show(() => { if ($scope.directiveScope.disconnectFromModal.to) { updateRecord($scope, $http, "cmdb_nic", $scope.directiveScope.disconnectFromModal.from, { $pull: { connected_to: $scope.directiveScope.disconnectFromModal.to._id } }, () => { // Done, reset and update retrieveRecords($scope, $http, "cmdb_nic", { query: { _id: { $in: [ $scope.directiveScope.disconnectFromModal.from, $scope.directiveScope.disconnectFromModal.to._id ]}}, select: $scope.directiveScope.nicFields }, (response) => { response.records.forEach((updatedNic) => { $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; }); $scope.directiveScope.disconnectFromModal.from = null; $scope.directiveScope.disconnectFromModal.to = null; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } else { // No NIC selected, reset $scope.directiveScope.disconnectFromModal.from = null; $scope.directiveScope.disconnectFromModal.to = null; } }); } }, changeToUplink: { label: "Make Uplink (Source)", class: "primary", icon: "/media/edit_icon.png", onClick: function(_event) { updateRecord($scope, $http, "cmdb_nic", _event.target._id, { role: "uplink" }, () => { retrieveRecord($scope, $http, "cmdb_nic", { query: { _id: _event.target._id }, select: $scope.directiveScope.nicFields }, (updatedNic) => { $scope.directiveScope.nicsById[_event.target._id] = updatedNic; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } }, changeToDownlink: { label: "Make Downlink (Sink)", class: "info", icon: "/media/edit_icon.png", onClick: function(_event) { updateRecord($scope, $http, "cmdb_nic", _event.target._id, { role: "downlink" }, () => { retrieveRecord($scope, $http, "cmdb_nic", { query: { _id: _event.target._id }, select: $scope.directiveScope.nicFields }, (updatedNic) => { $scope.directiveScope.nicsById[_event.target._id] = updatedNic; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } }, changeToHybrid: { label: "Make Hybrid", class: "success", icon: "/media/edit_icon.png", onClick: function(_event) { updateRecord($scope, $http, "cmdb_nic", _event.target._id, { role: "hybrid" }, () => { retrieveRecord($scope, $http, "cmdb_nic", { query: { _id: _event.target._id }, select: $scope.directiveScope.nicFields }, (updatedNic) => { $scope.directiveScope.nicsById[_event.target._id] = updatedNic; $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); }); }); } }, disconnectMap: { label: "Disconnect on Map", icon: "/media/icons/structured_object.png", onClick: function(_event) { $scope.directiveScope.disconnectingFrom = _event.target._id; $scope.$root.$emit("showAlert", "Select the NIC to disconnect...", "warning"); } }, removeNic: { label: "Remove NIC", class: "danger", icon: "/media/crossout_icon.png", onClick: function(_event) { deleteRecord($scope, $http, "cmdb_nic", _event.target._id, () => { $scope.$root.$emit("showAlert", "NICs removed", "success"); $scope.directiveScope.update(); }); } } }; $scope.$watch("directiveScope.hideUnselected", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { //$scope.directiveScope.zoomToWidth(); } }, 1); }); $scope.$watch("directiveScope.hideDisconnectedNics", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { //$scope.directiveScope.zoomToWidth(); } }, 1); }); $scope.$watch("directiveScope.hideDisconnectedCis", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { //$scope.directiveScope.zoomToWidth(); } }, 1); }); $scope.$watch("directiveScope.showImages", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { //$scope.directiveScope.zoomToWidth(); } }, 1); }); $scope.$watch("directiveScope.zoom", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); $scope.$watch("directiveScope.depthSpacing", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); $scope.$watch("directiveScope.ciSpacing", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); $scope.$watch("directiveScope.powerOnly", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); $scope.$watch("directiveScope.connectionTypes", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); $scope.$watch("directiveScope.ciTypes", () => { setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); }, 1); }); this.select = function(_type, _id) { if (_type == null && _id == null) { // Clear $scope.directiveScope.selected = null; setTimeout(() => { safeApply($scope); if ($scope.directiveScope.autoZoom) { $scope.directiveScope.zoomToWidth(); } $scope.directiveScope.drawConnections(); }, 1); } else if (_type == "cmdb_nic" && $scope.directiveScope.connectingFrom && $scope.directiveScope.connectingFrom != _id) { // Trying to connect updateRecord($scope, $http, "cmdb_nic", $scope.directiveScope.connectingFrom, { $push: { connected_to: _id } }, () => { retrieveRecords($scope, $http, "cmdb_nic", { query: { _id: { $in: [ $scope.directiveScope.connectingFrom, _id ]}}, select: $scope.directiveScope.nicFields }, (response) => { response.records.forEach((updatedNic) => { $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; }); $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); $scope.$root.$emit("showAlert", "NICs connected", "success"); $scope.directiveScope.connectingFrom = null; }); }); } else if (_type == "cmdb_nic" && $scope.directiveScope.disconnectingFrom && $scope.directiveScope.disconnectingFrom != _id) { // Trying to connect updateRecord($scope, $http, "cmdb_nic", $scope.directiveScope.disconnectingFrom, { $pull: { connected_to: _id } }, () => { retrieveRecords($scope, $http, "cmdb_nic", { query: { _id: { $in: [ $scope.directiveScope.disconnectingFrom, _id ]}}, select: $scope.directiveScope.nicFields }, (response) => { response.records.forEach((updatedNic) => { $scope.directiveScope.nicsById[updatedNic._id] = updatedNic; }); $scope.directiveScope.processNicsById(); $scope.directiveScope.processCisById(); $scope.$root.$emit("showAlert", "NICs disconnected", "success"); $scope.directiveScope.disconnectingFrom = null; }); }); } else { // Clear if already set to same id $scope.directiveScope.selected = ($scope.directiveScope.selected ?? {}).id == _id ? null : { type: _type, id: _id, }; setTimeout(() => { safeApply($scope); if ($scope.directiveScope.autoZoom) { $scope.directiveScope.zoomToWidth(); } $scope.directiveScope.drawConnections(); }, 1); } } this.zoomToWidth = function() { var rect = $scope.directiveScope.uniqueElement.getBoundingClientRect(); var visibleDepths = $scope.directiveScope.ciDepths.filter((depth) => { return document.getElementById("depth_" + depth).getBoundingClientRect().width > 2; }).length; $scope.directiveScope.zoom = (rect.width / (visibleDepths * ($scope.directiveScope.depthSpacing + 300))); setTimeout(() => { $scope.directiveScope.uniqueElement.scrollTo({ left: 0, top: 0 }); }, 1); } this.resetZoom = function() { $scope.directiveScope.zoom = 0.75; setTimeout(() => { safeApply($scope); $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { $scope.directiveScope.zoomToWidth(); } }, 1); } this.ciVisible = function(_ci) { // Hide if not in visible types if (!$scope.directiveScope.ciTypes.includes(_ci._type ?? "cmdb_ci")) { return false; } // Hide if something else is selected if ( $scope.directiveScope.hideUnselected && $scope.directiveScope.selected && $scope.directiveScope.selected.id != _ci._id && !(_ci.nics ?? []).some((nic) => { return $scope.directiveScope.selected.id == nic._id || (nic.connected_to ?? []).some((connectedNicId) => { var connectedNic = $scope.directiveScope.nicsById[connectedNicId]; return connectedNic && ($scope.directiveScope.selected.id == connectedNic._id || $scope.directiveScope.selected.id == connectedNic.parent); }) }) ) { return false; } // Hide if has no NICs if ($scope.directiveScope.hideDisconnectedCis && (_ci.nics ?? []).filter((nic) => { return $scope.directiveScope.connectionTypes.includes(nic.adapter_type); }).length == 0) { return false; } // Hide if no NICS connected to anything if ($scope.directiveScope.hideDisconnectedCis && !(_ci.nics ?? []).some((nic) => { return (nic.connected_to ?? []).length > 0; })) { return false; } // Show return true; } // Wait for visible before first load this.waitForFirstView = function() { if ($scope.directiveScope.unique && elementIsVisible($scope.directiveScope.unique)) { this.update(); } else { setTimeout(() => { $scope.directiveScope.waitForFirstView(); }, 500); } } this.waitForFirstView(); // Init event listeners window.onresize = () => { if ($scope.directiveScope.autoZoom) { $scope.directiveScope.zoomToWidth(); } }; window.addEventListener("beforeprint", () => { $scope.directiveScope.zoomToWidth(); }); waitForElement($scope.directiveScope.unique + "_svgCanvas", (element) => { $scope.directiveScope.svgCanvas = element; }); waitForElement($scope.directiveScope.unique + "_container", (element) => { $scope.directiveScope.uniqueContainerElement = element; }); waitForElement(this.unique, (element) => { $scope.directiveScope.uniqueElement = element; element.addEventListener("wheel", (event) => { if (event.ctrlKey && event.deltaY != 0) { $scope.directiveScope.zoom -= (event.deltaY / 1000); $scope.directiveScope.zoom = Math.max(0.01, Math.min(2, $scope.directiveScope.zoom)); safeApply($scope); $scope.directiveScope.drawConnections(); event.preventDefault(); } }, { passive: false }); element.addEventListener("scroll", (event) => { $scope.directiveScope.drawConnections(true); }); }); this.getPointDistance = function(_a, _b) { const dx = _b.clientX - _a.clientX; const dy = _b.clientY - _a.clientY; return Math.sqrt(dx * dx + dy * dy); } this.processNicsById = function() { $scope.directiveScope.nicsByParent = groupByProperty(Object.values($scope.directiveScope.nicsById), "parent"); } this.processCisById = function() { $scope.directiveScope.previousScrollLeft = $scope.directiveScope.uniqueElement.scrollLeft; $scope.directiveScope.previousScrollTop = $scope.directiveScope.uniqueElement.scrollTop; // Add NICs to CIs Object.values($scope.directiveScope.cisById).forEach((ci) => { ci.network_depth_index = ci.network_depth_index ?? 1; ci.nics = $scope.directiveScope.nicsByParent[ci._id] ?? []; ci.network_depth = ci.network_depth ?? 100; }); // Group CIs by depth $scope.directiveScope.cisByDepth = groupByProperty(Object.values($scope.directiveScope.cisById), "network_depth"); // Create ordered depths $scope.directiveScope.ciDepths = Object.keys($scope.directiveScope.cisByDepth).sort((a, b) => { return parseFloat(a) > parseFloat(b) ? 1 : -1; }); // Re-order each depth array by index $scope.directiveScope.reorderDepthIndexes(); $scope.directiveScope.updating = false; setTimeout(() => { $scope.directiveScope.uniqueElement.scrollLeft = $scope.directiveScope.previousScrollLeft; $scope.directiveScope.uniqueElement.scrollTop = $scope.directiveScope.previousScrollTop; $scope.directiveScope.drawConnections(); if ($scope.directiveScope.autoZoom) { $scope.directiveScope.zoomToWidth(); } }, 1); } this.update = function() { $scope.directiveScope.loadingIcon = $scope.$root.models.cmdb_nic.icon.link; $scope.directiveScope.loadingMessage = "Retrieving NICs"; $scope.directiveScope.updating = true; // First, retrieve all NICs retrieveRecords($scope, $http, "cmdb_nic", { query: { parent: { $ne: null } }, select: $scope.directiveScope.nicFields }, (nicResponse) => { $scope.directiveScope.nicsById = arrayToObjectBy(nicResponse.records, "_id"); $scope.directiveScope.processNicsById(); // Now retrieve all parent CIs $scope.directiveScope.loadingIcon = $scope.$root.models.cmdb_ci.icon.link; $scope.directiveScope.loadingMessage = "Retrieving CIs"; retrieveRecords($scope, $http, "cmdb_ci", { query: { active: true, _id: { $in: Object.values($scope.directiveScope.nicsById).map((nic) => { return nic.parent; }) } }, populate: $scope.directiveScope.ciPopulate, select: $scope.directiveScope.ciFields }, (ciResponse) => { $scope.directiveScope.ciTypeSelections = {}; ciResponse.records.map((ci) => { return ci._type ?? "cmdb_ci"; }).distinct().forEach((type) => { $scope.directiveScope.ciTypeSelections[type] = { label: $scope.$root.models[type].plural_name, icon: $scope.$root.models[type].icon.link }; }); $scope.directiveScope.ciTypes = $scope.directiveScope.ciTypes == null ? Object.keys($scope.directiveScope.ciTypeSelections) : $scope.directiveScope.ciTypes; $scope.directiveScope.cisById = arrayToObjectBy(ciResponse.records, "_id"); $scope.directiveScope.processCisById(); }); }); } this.reorderDepthIndexes = function() { Object.keys($scope.directiveScope.cisByDepth).reverse().forEach((d) => { $scope.directiveScope.cisByDepth[d] = $scope.directiveScope.cisByDepth[d].sort((cia, cib) => { return cia.network_depth_index > cib.network_depth_index ? 1 : -1; }); }); } this.drawConnections = function(_skipRender) { var drawn = []; if ($scope.directiveScope.uniqueElement) { if (!_skipRender) { var uniqueRect = $scope.directiveScope.uniqueElement.getBoundingClientRect(); var backgroundColor = window.getComputedStyle($scope.directiveScope.uniqueElement.parentElement.parentElement).backgroundColor; $scope.directiveScope.svgCanvas.innerHTML = ""; for(var depth of Object.keys($scope.directiveScope.cisByDepth)) { for(var ci of $scope.directiveScope.cisByDepth[depth]) { if (!$scope.directiveScope.ciVisible(ci)) { continue; } for(var nic of ci.nics) { var nicElement = document.getElementById("nic_" + nic._id); for(var connectedNicId of nic.connected_to ?? []) { // Skip if already drawn inversely if (drawn.includes(connectedNicId + nic._id)) { continue; } drawn.push(nic._id + connectedNicId); // Get connected NIC var connectedNic = $scope.directiveScope.nicsById[connectedNicId]; // Skip if connected NIC is not found if (!connectedNic) { continue; } // Skip if powerOnly and neither nic has a power_role if ($scope.directiveScope.powerOnly && !nic.power_role && !connectedNic.power_role) { continue; } // Skip if not in connectionTypes if (!$scope.directiveScope.connectionTypes.includes(nic.adapter_type) && !$scope.directiveScope.connectionTypes.includes(connectedNic.adapter_type)) { continue; } // Get connected CI var connectedCi = $scope.directiveScope.cisById[connectedNic.parent]; var connectedNicElement = document.getElementById("nic_" + connectedNicId); if (nicElement && connectedNicElement) { var nicElementRect = nicElement.getBoundingClientRect(); var connectedNicElementRect = connectedNicElement.getBoundingClientRect(); if ((nicElementRect.x == 0 && nicElementRect.y == 0) || (connectedNicElementRect.x == 0 && connectedNicElementRect.y == 0)) { continue; } var opacity = $scope.directiveScope.selected ? ( [ci._id, nic._id, connectedNic._id, connectedCi._id].includes($scope.directiveScope.selected.id) ? 1 : 0.1 ) : 1; // Build main line points + element var mainLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline"); var style = $scope.directiveScope.styleMap[nic.adapter_type] ?? $scope.directiveScope.styleMap.default; mainLine.setAttribute("stroke", style.color); mainLine.setAttribute("stroke-dasharray", style.dash); mainLine.setAttribute("stroke-opacity", opacity); mainLine.setAttribute("stroke-width", style.width); mainLine.setAttribute("stroke-linejoin", "round"); mainLine.setAttribute("fill", "none"); if (ci.network_depth <= connectedCi.network_depth) { var startRect = nicElementRect; var endRect = connectedNicElementRect; } else { var startRect = connectedNicElementRect; var endRect = nicElementRect; } var sameDepth = ci.network_depth == connectedCi.network_depth; var startPoint = [ $scope.directiveScope.uniqueElement.scrollLeft + ((startRect.x - uniqueRect.x) + startRect.width), $scope.directiveScope.uniqueElement.scrollTop + ((startRect.y - uniqueRect.y) + (startRect.height / 2)) ]; var startExtPoint = [ $scope.directiveScope.uniqueElement.scrollLeft + ((startRect.x - uniqueRect.x) + startRect.width + (50 * $scope.directiveScope.zoom)), $scope.directiveScope.uniqueElement.scrollTop + ((startRect.y - uniqueRect.y) + (startRect.height / 2)) ]; var endExtPoint = [ $scope.directiveScope.uniqueElement.scrollLeft + ((endRect.x - uniqueRect.x) + (sameDepth ? endRect.width + (50* $scope.directiveScope.zoom) : (-50* $scope.directiveScope.zoom))), $scope.directiveScope.uniqueElement.scrollTop + ((endRect.y - uniqueRect.y) + (endRect.height / 2)) ]; var endPoint = [ $scope.directiveScope.uniqueElement.scrollLeft + ((endRect.x - uniqueRect.x) + ((sameDepth ? endRect.width : 0))), $scope.directiveScope.uniqueElement.scrollTop + ((endRect.y - uniqueRect.y) + (endRect.height / 2)) ]; mainLine.setAttribute("points", [startPoint, startExtPoint, endExtPoint, endPoint].map((p) => { return p.join(" "); }).join(" ")); var backgroundLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline"); backgroundLine.setAttribute("stroke", backgroundColor); backgroundLine.setAttribute("stroke-opacity", 1); backgroundLine.setAttribute("stroke-width", 7); backgroundLine.setAttribute("stroke-linejoin", "round"); backgroundLine.setAttribute("fill", "none"); backgroundLine.setAttribute("points", [startPoint, startExtPoint, endExtPoint, endPoint].map((p) => { return p.join(" "); }).join(" ")); $scope.directiveScope.svgCanvas.appendChild(backgroundLine); // Power role on either of these NICs? if (nic.power_role || connectedNic.power_role) { // Yes, create and append line below original line var powerLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline"); powerLine.setAttribute("stroke", "gold"); powerLine.setAttribute("stroke-opacity", opacity * 0.5); powerLine.setAttribute("stroke-width", 3); powerLine.setAttribute("stroke-linejoin", "round"); powerLine.setAttribute("fill", "none"); powerLine.setAttribute("points", [startPoint, startExtPoint, endExtPoint, endPoint].map((p) => { return p.join(" "); }).join(" ")); $scope.directiveScope.svgCanvas.appendChild(powerLine); } // Add main line to SVG $scope.directiveScope.svgCanvas.appendChild(mainLine); } } } } } } $scope.directiveScope.uniqueElement.style.backgroundRepeat = "no-repeat" $scope.directiveScope.uniqueElement.style.backgroundSize = "auto auto"; $scope.directiveScope.uniqueElement.style.backgroundPosition = (-1 * $scope.directiveScope.uniqueElement.scrollLeft) + "px " + (-1 * $scope.directiveScope.uniqueElement.scrollTop) + "px"; $scope.directiveScope.uniqueElement.style.backgroundImage = `url("` + encodeSVG(` ` + $scope.directiveScope.svgCanvas.innerHTML + ` `) + `")`; } } } function encodeSVG(svg) { return 'data:image/svg+xml,' + encodeURIComponent(svg) .replaceAll("#", "%23") .replaceAll("<", "%3C") .replaceAll(">", "%3E") .replaceAll("\"", "%22") .replaceAll(" ", "%20") .replaceAll("'", "%27"); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: physicalNetworkConnectionEditor failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67b9011dff0d4a03ffe613f5', ctrl_67b9011dff0d4a03ffe613f5); app.directive('dynamicTimeDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?", displayMode: "=?", // date, time, datetime, delta subDisplayMode: "=?", // date, time, datetime, delta diffMode: "=?", // now, field diffField: "=?", dateFormat: "=?", timeFormat: "=?", diffFormat: "=?", diffRounded: "=?", diffPastLabel: "=?", // label to display when diff is before value diffPastLabelClass: "=?", // class to use when diff is before diffPastLabelPrefix: "=?", // true, false : affix or prefix label to before diff diffFutureLabel: "=?", // label to display when diff is after value diffFutureLabelClass: "=?", // class to use when diff is after diffFutureLabelPrefix: "=?", // true, false : affix or prefix label to after diff }, controller: ctrl_67c0ede650482b7a0fcaed94, template: ` `, bindToController: true};}); function ctrl_67c0ede650482b7a0fcaed94($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.update(); }); this.formatDate = function(_date) { //date.toLocaleString('en-US', { year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }) var format = {}; var locale = "en-US"; if ($scope.directiveScope.dateFormat == "y") { format.year = "numeric"; } else if ($scope.directiveScope.dateFormat == "my") { format.year = "numeric"; format.month = "numeric"; } else if ($scope.directiveScope.dateFormat == "dmy") { format.year = "numeric"; format.month = "numeric"; format.day = "numeric"; locale = "en-GB"; } else if ($scope.directiveScope.dateFormat == "mdy") { format.year = "numeric"; format.month = "numeric"; format.day = "numeric"; } else if ($scope.directiveScope.dateFormat == "mNdy") { format.year = "numeric"; format.month = "short"; format.day = "numeric"; } return _date ? _date.toLocaleDateString(locale, format) : ""; } this.formatTime = function(_time) { var format = {}; var locale = "en-US"; if ($scope.directiveScope.timeFormat == "hm") { format.hour = "numeric"; format.minute = "numeric"; format.hour12 = true; } else if ($scope.directiveScope.timeFormat == "hms") { format.hour = "numeric"; format.minute = "numeric"; format.second = "numeric"; format.hour12 = true; } else if ($scope.directiveScope.timeFormat == "h24m") { format.hour = "numeric"; format.minute = "numeric"; format.hour12 = false; } else if ($scope.directiveScope.timeFormat == "h24ms") { format.hour = "numeric"; format.minute = "numeric"; format.second = "numeric"; format.hour12 = false; } return _time ? _time.toLocaleTimeString(locale, format) : ""; } this.formatDiff = function(_diff) { var comps = parseDateDifference(_diff); var past = _diff > 0; var diff = ""; // Add past/future labels if ($scope.directiveScope.diffPastLabelPrefix && past) { // Add "past" label to beginning diff += $scope.directiveScope.diffPastLabel + " "; var labelClass = $scope.directiveScope.diffPastLabelClass; } else if ($scope.directiveScope.diffFutureLabelPrefix && !past) { // Add "future" label to beginning diff += $scope.directiveScope.diffFutureLabel + " "; var labelClass = $scope.directiveScope.diffFutureLabelClass; } if (!$scope.directiveScope.diffFormat) { } else if ($scope.directiveScope.diffFormat == "s") { var d = _diff / 1000; diff += ($scope.directiveScope.diffRounded ? Math.round(d) : d) + " sec" } else if ($scope.directiveScope.diffFormat == "m") { var d = (_diff / (1000 * 60)); diff += ($scope.directiveScope.diffRounded ? Math.round(d) : d) + " min" } else if ($scope.directiveScope.diffFormat == "h") { var d = (_diff / (1000 * 60 * 60)); diff += ($scope.directiveScope.diffRounded ? Math.round(d) : d) + " hr" } else if ($scope.directiveScope.diffFormat == "d") { var d = (_diff / (1000 * 60 * 60 * 24)); diff += ($scope.directiveScope.diffRounded ? Math.round(d) : d) + " dy" } else if ($scope.directiveScope.diffFormat == "hm") { diff += ((comps.days * 24) + comps.hours) + " hr " + comps.minutes + " min "; } else if ($scope.directiveScope.diffFormat == "hms") { diff += ((comps.days * 24) + comps.hours) + " hr " + comps.minutes + " min " + comps.seconds + " sec"; } else if ($scope.directiveScope.diffFormat == "dh") { diff += (comps.days + " dy " + comps.hours + " hr"); } else if ($scope.directiveScope.diffFormat == "dhm") { diff += (comps.days + " dy " + comps.hours + " hr " + comps.minutes + " min"); } // Add past/future labels if (!$scope.directiveScope.diffPastLabelPrefix && past) { // Add "past" label to beginning diff += " " + $scope.directiveScope.diffPastLabel; var labelClass = $scope.directiveScope.diffPastLabelClass; } else if (!$scope.directiveScope.diffFutureLabelPrefix && !past) { // Add "future" label to beginning diff += " " + $scope.directiveScope.diffFutureLabel; var labelClass = $scope.directiveScope.diffFutureLabelClass; } return { text: diff, class: labelClass }; } this.update = function() { var val = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; // Calc diff value if ($scope.directiveScope.diffMode == "now") { var diff = (new Date()) - val; } else if ($scope.directiveScope.diffMode == "field") { var diff = $scope.directiveScope.bindingParent[$scope.directiveScope.diffField] - val; } // Calc display text if ($scope.directiveScope.displayMode == "date") { $scope.directiveScope.text = $scope.directiveScope.formatDate(val); } else if ($scope.directiveScope.displayMode == "time") { $scope.directiveScope.text = $scope.directiveScope.formatTime(val); } else if ($scope.directiveScope.displayMode == "datetime") { $scope.directiveScope.text = $scope.directiveScope.formatTime(val) + " " + $scope.directiveScope.formatDate(val); } else if ($scope.directiveScope.displayMode == "diff") { var diff = $scope.directiveScope.formatDiff(diff); $scope.directiveScope.text = diff.text; $scope.directiveScope.textClass = diff.class; } else { $scope.directiveScope.text = null; $scope.directiveScope.textClass = null; } // Calc display sub text if ($scope.directiveScope.subDisplayMode == "date") { $scope.directiveScope.subText = $scope.directiveScope.formatDate(val); } else if ($scope.directiveScope.subDisplayMode == "time") { $scope.directiveScope.subText = $scope.directiveScope.formatTime(val); } else if ($scope.directiveScope.subDisplayMode == "datetime") { $scope.directiveScope.subText = $scope.directiveScope.formatTime(val) + " " + $scope.directiveScope.formatDate(val); } else if ($scope.directiveScope.subDisplayMode == "diff") { var diff = $scope.directiveScope.formatDiff(diff); $scope.directiveScope.subText = diff.text; $scope.directiveScope.subTextClass = diff.class; } else { $scope.directiveScope.subText = null; $scope.directiveScope.subTextClass = null; } } this.update(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicTimeDisplay failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67c0ede650482b7a0fcaed94', ctrl_67c0ede650482b7a0fcaed94); app.directive('slider', function() { return { scope: { bindingParent: "=?", bindingName: "=?", min: "=?", max: "=?", step: "=?", allowInteraction: "=?" }, controller: ctrl_67c1e4ea50482b7a0fd655d5, template: `
    `, bindToController: true};}); function ctrl_67c1e4ea50482b7a0fd655d5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.unique = createUniqueTag(); waitForElement(this.unique, (element) => { $scope.directiveScope.sliderElement = element; element.addEventListener("input", (event) => { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = parseFloat(event.target.value); safeApply($scope); }); }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { $scope.directiveScope.sliderElement.value = _new; }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: slider failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_67c1e4ea50482b7a0fd655d5', ctrl_67c1e4ea50482b7a0fd655d5); app.directive('intervalSelection', function() { return { scope: { allowInteraction: "=?", bindingParent: "=?", bindingName: "=?" }, controller: ctrl_6841e17d7eb1e2274b83d9e3, template: `
    {{directiveScope.display | number}}
    `, bindToController: true};}); function ctrl_6841e17d7eb1e2274b83d9e3($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.updating = false; this.allowInteraction = this.allowInteraction == null ? true: this.allowInteraction; this.unitSelections = { ms: { label: "Milliseconds", class: "info", max: 1000, multiplier: 1 }, s: { label: "Seconds", class: "primary", max: 60000, multiplier: 1000 }, m: { label: "Minutes", class: "success", max: 3600000, multiplier: 60000 }, h: { label: "Hours", class: "warning", max: 86400000, multiplier: 3600000 }, d: { label: "Days", class: "danger", max: 99999999999999999999999, multiplier: 86400000 } }; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { $scope.directiveScope.processBindingChange(); }); this.processBindingChange = function() { if ($scope.directiveScope.updating) { return; } $scope.directiveScope.updating = true; var bindingValue = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; if (bindingValue == null) { // Binding is not initialized, set unit to ms and leave alone $scope.directiveScope.display = null; $scope.directiveScope.unit = "ms"; } else { for(var u of Object.keys($scope.directiveScope.unitSelections)) { var unit = $scope.directiveScope.unitSelections[u]; if (bindingValue < unit.max) { $scope.directiveScope.unit = u; $scope.directiveScope.display = bindingValue / unit.multiplier; break; } } } setTimeout(() => { $scope.directiveScope.updating = false; }, 1); } $scope.$watch("[directiveScope.display, directiveScope.unit]", (_new, _old) => { $scope.directiveScope.processUIChange(); }); this.processUIChange = function() { if ($scope.directiveScope.updating) { return; } $scope.directiveScope.updating = true; if ($scope.directiveScope.display == null) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; } else { var unit = $scope.directiveScope.unitSelections[$scope.directiveScope.unit]; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.display * unit.multiplier; } setTimeout(() => { $scope.directiveScope.updating = false; }, 1); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: intervalSelection failed to initialize: " + e + "\r\nSee next message for exception details"); console.log(e); } }); } app.controller('ctrl_6841e17d7eb1e2274b83d9e3', ctrl_6841e17d7eb1e2274b83d9e3);