diff --git a/html/nuDashboard.html b/html/nuDashboard.html index 13c689d..ce940aa 100644 --- a/html/nuDashboard.html +++ b/html/nuDashboard.html @@ -6,9 +6,9 @@ width: 18px; } - +
- +
@@ -33,7 +33,7 @@

PrimoExplorer {{$ctrl.version}}

- + {{component}} @@ -73,13 +73,14 @@

{{$ctrl.selectedComponentName}}

-
css({{$ctrl.selectedComponentElement.cssPath}})
+
- - {{key}} + + {{property.key}}: + {{property.value}}
diff --git a/js/custom.js b/js/custom.js index b2c6169..7b52cbf 100644 --- a/js/custom.js +++ b/js/custom.js @@ -277,14 +277,15 @@ var Component = function () { value: function ctrl() { var scope = this.scope(); if (scope) { + var scopeChild = scope.$$childTail; if (Object.keys(scope).includes('$ctrl')) { return scope.$ctrl; } else if (Object.keys(scope).includes('ctrl')) { return scope.ctrl; - } else if (scope.$$childTail && Object.keys(scope.$$childTail).includes('$ctrl')) { - return scope.$$childTail.$ctrl; - } else if (scope.$$childTail && Object.keys(scope.$$childTail).includes('ctrl')) { - return scope.$$childTail.ctrl; + } else if (scopeChild && Object.keys(scopeChild).includes('$ctrl')) { + return scopeChild.$ctrl; + } else if (scopeChild && Object.keys(scopeChild).includes('ctrl')) { + return scopeChild.ctrl; } else { console.error('No $ctrl defined'); } @@ -594,6 +595,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -606,6 +609,7 @@ var Ui = function () { //vmUi.active = false; vmUi._injectDOMElement(); vmUi.module = vmUi._createModule(); + angular.bootstrap(document.querySelector('#explorerUi'), ['explorerUi']); vmUi.scope = angular.element(document.querySelector('#explorerUi')).scope(); } @@ -614,7 +618,7 @@ var Ui = function () { key: '_createModule', value: function _createModule() { var vmUi = this; - return angular.module("explorerUi", ['ngMaterial']).component("explorerUi", { + return angular.module("explorerUi", ['ngMaterial', 'angularLoad']).component("explorerUi", { templateUrl: 'nuDashboard.html', controller: ['$http', '$scope', function ($http, $scope) { var ctrl = this; @@ -647,10 +651,12 @@ var Ui = function () { ctrl.selectedComponentElementIdx = index; ctrl.selectedComponentElementCount = ctrl.selectedComponent.length; ctrl.selectedComponentElement = ctrl.selectedComponent[index]; + ctrl.selectedComponentElementProperties = ctrl.selectedComponentElementCtrlKeys(); } else { ctrl.selectedComponentElementIdx = 0; ctrl.selectedComponentElementCount = 0; ctrl.selectedComponentElement = null; + ctrl.selectedComponentElementProperties = []; } }; @@ -667,16 +673,102 @@ var Ui = function () { ctrl.refreshComponents(); }; - ctrl.selectedComponentElementCtrlKeys = function () { + ctrl.rselectedComponentElementCtrlKeys = function () { if (ctrl.selectedComponentElement) { - var keys = ctrl.selectedComponentElement.ctrl(); - if (keys) { - return Object.keys(keys); + var selectedCtrl = ctrl.selectedComponentElement.ctrl(); + if (selectedCtrl) { + return Object.keys(selectedCtrl); //.map((d) => {return {key: d, value:'', type:''}}); } } return []; }; + ctrl.selectedComponentElementCtrlKeys = function () { + var sce = []; + if (ctrl.selectedComponentElement) { + var selectedCtrl = ctrl.selectedComponentElement.ctrl(); + if (selectedCtrl) { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = Object.keys(selectedCtrl)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + if (selectedCtrl.hasOwnProperty(key)) { + switch (_typeof(selectedCtrl[key])) { + case 'string': + sce.push({ + key: key, + value: '"' + selectedCtrl[key] + '"', + type: 'string' + }); + break; + case 'boolean': + sce.push({ + key: key, + value: '' + selectedCtrl[key], + type: 'boolean' + }); + break; + case 'number': + sce.push({ + key: key, + value: '' + selectedCtrl[key], + type: 'number' + }); + break; + case 'undefined': + sce.push({ + key: key, + value: "Undefined", + type: 'undefined' + }); + break; + case 'null': + sce.push({ + key: key, + value: "Null", + type: 'null' + }); + break; + default: + try { + sce.push({ + key: key, + value: '' + selectedCtrl[key].constructor.name, + type: _typeof(selectedCtrl[key]) + }); + } catch (e) { + sce.push({ + key: key, + value: '' + _typeof(selectedCtrl[key]), + type: _typeof(selectedCtrl[key]) + }); + } + } + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + } + } + return sce; + }; + ctrl.selectedComponentElementPrev = function () { if (ctrl.selectedComponentElementIdx > 0) { ctrl.selectedComponentElementIdx -= 1; @@ -740,7 +832,7 @@ var Ui = function () { }).config(function ($mdIconProvider) { $mdIconProvider.iconSet('primo-ui', 'img/svg/svg-primo-ui.svg', 18); }).run(function ($templateCache) { - $templateCache.put('nuDashboard.html', '\n\n
\n \n
\n \n
\n

PrimoExplorer {{$ctrl.version}}

\n \n \n \n
\n
\n
\n\n
\n
\n
\n
\n Reload\n \n \n \n \n
\n
\n \n \n \n {{component}}\n \n \n \n \n
\n\n
\n
\n \n
\n\n \n \n \n\n

{{$ctrl.selectedComponentName}}

\n\n \n \n \n \n \n \n
\n
\n
\n
\n \n \n \n
\n
{{$ctrl.selectedComponentElementIdx+1}}/{{$ctrl.selectedComponentElementCount}}
\n
\n \n \n \n
\n
\n
css({{$ctrl.selectedComponentElement.cssPath}})
\n
\n
\n
\n \n \n {{key}}\n \n \n
\n
\n
\n
\n
\n
\n'); + $templateCache.put('nuDashboard.html', '\n\n
\n \n
\n \n
\n

PrimoExplorer {{$ctrl.version}}

\n \n \n \n
\n
\n
\n\n
\n
\n
\n
\n Reload\n \n \n \n \n
\n
\n \n \n \n {{component}}\n \n \n \n \n
\n\n
\n
\n \n
\n\n \n \n \n\n

{{$ctrl.selectedComponentName}}

\n\n \n \n \n \n \n \n
\n
\n
\n
\n \n \n \n
\n
{{$ctrl.selectedComponentElementIdx+1}}/{{$ctrl.selectedComponentElementCount}}
\n
\n \n \n \n
\n
\n \n
\n
\n
\n \n \n {{property.key}}:\n {{property.value}}\n \n \n
\n
\n
\n
\n
\n
\n'); }); } }, { diff --git a/js/custom.module.js b/js/custom.module.js index 53ba0be..0d3eb53 100644 --- a/js/custom.module.js +++ b/js/custom.module.js @@ -1 +1 @@ -var app = angular.module('viewCustom', []); +//var app = angular.module('viewCustom', []); diff --git a/js/primo/explore/components.js b/js/primo/explore/components.js index 8c7b821..4c9fef8 100644 --- a/js/primo/explore/components.js +++ b/js/primo/explore/components.js @@ -30,14 +30,15 @@ class Component { ctrl(){ let scope = this.scope(); if (scope) { + let scopeChild = scope.$$childTail; if (Object.keys(scope).includes('$ctrl')) { return scope.$ctrl } else if(Object.keys(scope).includes('ctrl')) { return scope.ctrl - } else if (scope.$$childTail && Object.keys(scope.$$childTail).includes('$ctrl')){ - return scope.$$childTail.$ctrl; - } else if (scope.$$childTail && Object.keys(scope.$$childTail).includes('ctrl')){ - return scope.$$childTail.ctrl; + } else if (scopeChild && Object.keys(scopeChild).includes('$ctrl')){ + return scopeChild.$ctrl; + } else if (scopeChild && Object.keys(scopeChild).includes('ctrl')){ + return scopeChild.ctrl; } else { console.error('No $ctrl defined'); } diff --git a/js/primo/explore/ui.js b/js/primo/explore/ui.js index 8e23742..ca0f5b2 100644 --- a/js/primo/explore/ui.js +++ b/js/primo/explore/ui.js @@ -1,166 +1,235 @@ -export default class Ui{ - constructor(){ +export default class Ui { + constructor() { let vmUi = this; //vmUi.active = false; vmUi._injectDOMElement(); vmUi.module = vmUi._createModule(); + angular.bootstrap(document.querySelector('#explorerUi'), ['explorerUi']); vmUi.scope = angular.element(document.querySelector('#explorerUi')).scope(); } - _createModule(){ + _createModule() { let vmUi = this; - return angular.module("explorerUi", ['ngMaterial']) - .component("explorerUi",{ - templateUrl: 'nuDashboard.html', - controller:['$http', '$scope', function($http, $scope){ - let ctrl = this; - ctrl.version = Primo.version || ''; - ctrl.selectedTab = 0; - ctrl.selectedComponent = null; - ctrl.componentFilter = ''; - ctrl.selectedComponentName = ''; - ctrl.selectedComponentDetailShow = false; - ctrl.selectedComponentElementIdx = 0; - ctrl.selectedComponentElementCount = 0; - ctrl.selectedComponentElement = null; - - ctrl.components = ''; - - ctrl.loadComponent = function(name){ - let c = Primo.explore.components.get(name); - if (c && c.length > 0) { - ctrl.selectedComponent = c; - ctrl.selectedComponentName = name; - ctrl.loadComponentElement(0); - ctrl.selectedComponentDetailShow = true; - } else { - ctrl.selectedComponent = null; - } - - } - - ctrl.loadComponentElement = function(index){ - if (ctrl.selectedComponent) { - ctrl.selectedComponentElementIdx = index; - ctrl.selectedComponentElementCount = ctrl.selectedComponent.length; - ctrl.selectedComponentElement = ctrl.selectedComponent[index]; - } else { - ctrl.selectedComponentElementIdx = 0; - ctrl.selectedComponentElementCount = 0; - ctrl.selectedComponentElement = null; - } - - } - - ctrl.refreshComponents = function(){ - ctrl.components = Primo.explore.components.keys(); - } - - ctrl.isActive = function(){ - return vmUi.active; - } - - ctrl.toggle = function() { - vmUi.toggle(); - ctrl.refreshComponents(); - } - - ctrl.selectedComponentElementCtrlKeys = function(){ - if (ctrl.selectedComponentElement) { - let keys = ctrl.selectedComponentElement.ctrl(); - if (keys) { - return Object.keys(keys); - } - } - return []; - } - - ctrl.selectedComponentElementPrev = function(){ - if (ctrl.selectedComponentElementIdx > 0){ - ctrl.selectedComponentElementIdx -= 1; - ctrl.loadComponentElement(ctrl.selectedComponentElementIdx); - } - } - - ctrl.selectedComponentElementNext = function(){ - if (ctrl.selectedComponentElementIdx < ctrl.selectedComponentElementCount-1){ - ctrl.selectedComponentElementIdx += 1; - ctrl.loadComponentElement(ctrl.selectedComponentElementIdx); - } - } - - ctrl.blink = function() { - if (ctrl.selectedComponentElement) { - console.log(`blinking ${ctrl.selectedComponentName}[${ctrl.selectedComponentElementIdx }]`); - ctrl.selectedComponentElement.blink(); - } - } - - ctrl.pushToConsole = function() { - if (ctrl.selectedComponentElement) { - let varName = ctrl.selectedComponentName.split('-').map((m, i) => { - m = m.trim(); - return i == 0 ? m : m[0].toUpperCase() + m.substr(1) - }).join(''); - - setTimeout(`eval("var ${varName}=(Primo.explore.components.get('${ctrl.selectedComponentName}'))[${ctrl.selectedComponentElementIdx }];console.log('access variable through -> ${varName}');")`, 0); - } - } - - ctrl.headerMove = function(event) { - event.stopPropagation(); - event.preventDefault(); - - let header = document.querySelector('#explorerUiContainer'); - - let originalTop = parseInt(window.getComputedStyle(header).top); - let mouseDownY = event.clientY; - - let originalLeft = parseInt(window.getComputedStyle(header).left); - let mouseDownX = event.clientX; - - let dragHeader = function(event) { - header.style.top = originalTop + event.clientY - mouseDownY + "px"; - header.style.left = originalLeft + event.clientX - mouseDownX + "px"; - event.stopPropagation(); - } - - let dropHeader = function(event) { - header.removeEventListener('mousemove', dragHeader, true); - header.removeEventListener('mouseup', dropHeader, true); - event.stopPropagation(); - } - - header.addEventListener('mouseup', dropHeader, true); - header.addEventListener('mousemove', dragHeader, true); - } - }] - }).config(function($mdIconProvider){ - $mdIconProvider.iconSet('primo-ui', 'img/svg/svg-primo-ui.svg', 18); - }).run(function($templateCache) {$templateCache.put('nuDashboard.html','\n\n
\n \n
\n \n
\n

PrimoExplorer {{$ctrl.version}}

\n \n \n \n
\n
\n
\n\n
\n
\n
\n
\n Reload\n \n \n \n \n
\n
\n \n \n \n {{component}}\n \n \n \n \n
\n\n
\n
\n \n
\n\n \n \n \n\n

{{$ctrl.selectedComponentName}}

\n\n \n \n \n \n \n \n
\n
\n
\n
\n \n \n \n
\n
{{$ctrl.selectedComponentElementIdx+1}}/{{$ctrl.selectedComponentElementCount}}
\n
\n \n \n \n
\n
\n
css({{$ctrl.selectedComponentElement.cssPath}})
\n
\n
\n
\n \n \n {{key}}\n \n \n
\n
\n
\n
\n
\n
\n');}); + return angular.module("explorerUi", ['ngMaterial', 'angularLoad']) + .component("explorerUi", { + templateUrl: 'nuDashboard.html', + controller: ['$http', '$scope', function($http, $scope) { + let ctrl = this; + ctrl.version = Primo.version || ''; + ctrl.selectedTab = 0; + ctrl.selectedComponent = null; + ctrl.componentFilter = ''; + ctrl.selectedComponentName = ''; + ctrl.selectedComponentDetailShow = false; + ctrl.selectedComponentElementIdx = 0; + ctrl.selectedComponentElementCount = 0; + ctrl.selectedComponentElement = null; + + ctrl.components = ''; + + ctrl.loadComponent = function(name) { + let c = Primo.explore.components.get(name); + if (c && c.length > 0) { + ctrl.selectedComponent = c; + ctrl.selectedComponentName = name; + ctrl.loadComponentElement(0); + ctrl.selectedComponentDetailShow = true; + } else { + ctrl.selectedComponent = null; + } + } + + ctrl.loadComponentElement = function(index) { + if (ctrl.selectedComponent) { + ctrl.selectedComponentElementIdx = index; + ctrl.selectedComponentElementCount = ctrl.selectedComponent.length; + ctrl.selectedComponentElement = ctrl.selectedComponent[index]; + ctrl.selectedComponentElementProperties = ctrl.selectedComponentElementCtrlKeys(); + } else { + ctrl.selectedComponentElementIdx = 0; + ctrl.selectedComponentElementCount = 0; + ctrl.selectedComponentElement = null; + ctrl.selectedComponentElementProperties = []; + } + + } + + ctrl.refreshComponents = function() { + ctrl.components = Primo.explore.components.keys(); + } + + ctrl.isActive = function() { + return vmUi.active; + } + + ctrl.toggle = function() { + vmUi.toggle(); + ctrl.refreshComponents(); + } + + ctrl.rselectedComponentElementCtrlKeys = function() { + if (ctrl.selectedComponentElement) { + let selectedCtrl = ctrl.selectedComponentElement.ctrl(); + if (selectedCtrl) { + return Object.keys(selectedCtrl);//.map((d) => {return {key: d, value:'', type:''}}); + } + } + return []; + }; + + ctrl.selectedComponentElementCtrlKeys = function() { + let sce = []; + if (ctrl.selectedComponentElement) { + let selectedCtrl = ctrl.selectedComponentElement.ctrl(); + if (selectedCtrl) { + for (let key of Object.keys(selectedCtrl)) { + if (selectedCtrl.hasOwnProperty(key)) { + switch (typeof(selectedCtrl[key])) { + case 'string': + sce.push({ + key: key, + value: `"${selectedCtrl[key]}"`, + type: 'string' + }); + break; + case 'boolean': + sce.push({ + key: key, + value: `${selectedCtrl[key]}`, + type: 'boolean' + }); + break; + case 'number': + sce.push({ + key: key, + value: `${selectedCtrl[key]}`, + type: 'number' + }); + break; + case 'undefined': + sce.push({ + key: key, + value: "Undefined", + type: 'undefined' + }); + break; + case 'null': + sce.push({ + key: key, + value: "Null", + type: 'null' + }); + break; + default: + try { + sce.push({ + key: key, + value: `${selectedCtrl[key].constructor.name}`, + type: typeof(selectedCtrl[key]) + }); + } catch (e) { + sce.push({ + key: key, + value: `${typeof(selectedCtrl[key])}`, + type: typeof(selectedCtrl[key]) + }); + } + } + } + } + } + } + return sce; + } + + ctrl.selectedComponentElementPrev = function() { + if (ctrl.selectedComponentElementIdx > 0) { + ctrl.selectedComponentElementIdx -= 1; + ctrl.loadComponentElement(ctrl.selectedComponentElementIdx); + } + } + + ctrl.selectedComponentElementNext = function() { + if (ctrl.selectedComponentElementIdx < ctrl.selectedComponentElementCount - 1) { + ctrl.selectedComponentElementIdx += 1; + ctrl.loadComponentElement(ctrl.selectedComponentElementIdx); + } + } + + ctrl.blink = function() { + if (ctrl.selectedComponentElement) { + console.log(`blinking ${ctrl.selectedComponentName}[${ctrl.selectedComponentElementIdx }]`); + ctrl.selectedComponentElement.blink(); + } + } + + ctrl.pushToConsole = function() { + if (ctrl.selectedComponentElement) { + let varName = ctrl.selectedComponentName.split('-').map((m, i) => { + m = m.trim(); + return i == 0 ? m : m[0].toUpperCase() + m.substr(1) + }).join(''); + + setTimeout(`eval("var ${varName}=(Primo.explore.components.get('${ctrl.selectedComponentName}'))[${ctrl.selectedComponentElementIdx }];console.log('access variable through -> ${varName}');")`, 0); + } + } + + ctrl.headerMove = function(event) { + event.stopPropagation(); + event.preventDefault(); + + let header = document.querySelector('#explorerUiContainer'); + + let originalTop = parseInt(window.getComputedStyle(header).top); + let mouseDownY = event.clientY; + + let originalLeft = parseInt(window.getComputedStyle(header).left); + let mouseDownX = event.clientX; + + let dragHeader = function(event) { + header.style.top = originalTop + event.clientY - mouseDownY + "px"; + header.style.left = originalLeft + event.clientX - mouseDownX + "px"; + event.stopPropagation(); + } + + let dropHeader = function(event) { + header.removeEventListener('mousemove', dragHeader, true); + header.removeEventListener('mouseup', dropHeader, true); + event.stopPropagation(); + } + + header.addEventListener('mouseup', dropHeader, true); + header.addEventListener('mousemove', dragHeader, true); + } + }] + }).config(function($mdIconProvider) { + $mdIconProvider.iconSet('primo-ui', 'img/svg/svg-primo-ui.svg', 18); + }).run(function($templateCache) {$templateCache.put('nuDashboard.html','\n\n
\n \n
\n \n
\n

PrimoExplorer {{$ctrl.version}}

\n \n \n \n
\n
\n
\n\n
\n
\n
\n
\n Reload\n \n \n \n \n
\n
\n \n \n \n {{component}}\n \n \n \n \n
\n\n
\n
\n \n
\n\n \n \n \n\n

{{$ctrl.selectedComponentName}}

\n\n \n \n \n \n \n \n
\n
\n
\n
\n \n \n \n
\n
{{$ctrl.selectedComponentElementIdx+1}}/{{$ctrl.selectedComponentElementCount}}
\n
\n \n \n \n
\n
\n \n
\n
\n
\n \n \n {{property.key}}:\n {{property.value}}\n \n \n
\n
\n
\n
\n
\n
\n');}); + + } _injectDOMElement() { let div = document.createElement('div'); - div.setAttribute('id','explorerUi'); + div.setAttribute('id', 'explorerUi'); div.innerHTML = ""; //document.querySelector('primo-explore').appendChild(div); document.body.appendChild(div); } - show(){ + show() { this.active = true; //this.scope.$apply(); } - hide(){ + hide() { this.active = false; //this.scope.$apply(); } - toggle(){ + toggle() { this.active = !this.active; //this.scope.$apply(); }