IGNITE-7147 Web Console: Added "Number of connected clusters" component.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/67625336 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/67625336 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/67625336 Branch: refs/heads/ignite-zk-ce Commit: 67625336b72ce3bd175a3de6895e2ced93a0b442 Parents: 7b7fb8c Author: Dmitriy Shabalin <dmitri...@gmail.com> Authored: Tue Dec 12 11:41:04 2017 +0700 Committer: Alexey Kuznetsov <akuznet...@apache.org> Committed: Tue Dec 12 11:41:04 2017 +0700 ---------------------------------------------------------------------- modules/web-console/frontend/app/app.js | 2 + .../components/connected-clusters/controller.js | 36 ++++++++++++++++++ .../app/components/connected-clusters/index.js | 29 ++++++++++++++ .../components/connected-clusters/style.scss | 40 ++++++++++++++++++++ .../components/connected-clusters/template.pug | 18 +++++++++ .../components/web-console-header/component.js | 11 ++++++ .../components/web-console-header/template.pug | 2 + .../public/images/icons/connectedClusters.svg | 1 + .../frontend/public/images/icons/index.js | 1 + 9 files changed, 140 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index dde6aa9..5a27ea2 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -129,6 +129,7 @@ import protectFromBsSelectRender from './components/protect-from-bs-select-rende import uiGridHovering from './components/ui-grid-hovering'; import listEditable from './components/list-editable'; import clusterSelector from './components/cluster-selector'; +import connectedClusters from './components/connected-clusters'; import igniteServices from './services'; @@ -207,6 +208,7 @@ angular.module('ignite-console', [ AngularStrapSelect.name, listEditable.name, clusterSelector.name, + connectedClusters.name, // Ignite modules. IgniteModules.name ]) http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/connected-clusters/controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/connected-clusters/controller.js b/modules/web-console/frontend/app/components/connected-clusters/controller.js new file mode 100644 index 0000000..377948e --- /dev/null +++ b/modules/web-console/frontend/app/components/connected-clusters/controller.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class { + static $inject = ['AgentManager']; + + constructor(agentMgr) { + Object.assign(this, { agentMgr }); + + this.connectedClusters = 0; + } + + $onInit() { + this.connectedClusters$ = this.agentMgr.connectionSbj + .do(({ clusters }) => this.connectedClusters = clusters.length) + .subscribe(); + } + + $onDestroy() { + this.connectedClusters$.unsubscribe(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/connected-clusters/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/connected-clusters/index.js b/modules/web-console/frontend/app/components/connected-clusters/index.js new file mode 100644 index 0000000..fd8dd11 --- /dev/null +++ b/modules/web-console/frontend/app/components/connected-clusters/index.js @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import angular from 'angular'; + +import './style.scss'; +import template from './template.pug'; +import controller from './controller'; + +export default angular + .module('ignite-console.connected-clusters', []) + .component('connectedClusters', { + template, + controller + }); http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/connected-clusters/style.scss ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/connected-clusters/style.scss b/modules/web-console/frontend/app/components/connected-clusters/style.scss new file mode 100644 index 0000000..b8af8d6 --- /dev/null +++ b/modules/web-console/frontend/app/components/connected-clusters/style.scss @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +connected-clusters { + @import "./../../../public/stylesheets/variables.scss"; + + position: absolute; + top: 0; + right: 0; + + display: flex; + align-items: center; + padding: 3px 10px; + + color: white; + font-size: 12px; + line-height: 12px; + + background-color: $text-color; + + border-radius: 0 0 4px 4px; + + [ignite-icon] { + margin-right: 6px; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/connected-clusters/template.pug ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/connected-clusters/template.pug b/modules/web-console/frontend/app/components/connected-clusters/template.pug new file mode 100644 index 0000000..8a77084 --- /dev/null +++ b/modules/web-console/frontend/app/components/connected-clusters/template.pug @@ -0,0 +1,18 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +svg(ignite-icon='connectedClusters') + | Connected clusters: {{ $ctrl.connectedClusters }} http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/web-console-header/component.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/web-console-header/component.js b/modules/web-console/frontend/app/components/web-console-header/component.js index 66f09e9..fbdbcfc 100644 --- a/modules/web-console/frontend/app/components/web-console-header/component.js +++ b/modules/web-console/frontend/app/components/web-console-header/component.js @@ -29,6 +29,10 @@ export default { 'base.settings' ]; + static connectedClustersUnvisibleStates = [ + '403', '404' + ]; + constructor($rootScope, $scope, $state, branding, UserNotifications) { Object.assign(this, {$rootScope, $scope, $state, branding, UserNotifications}); } @@ -38,10 +42,17 @@ export default { this.constructor.webAgentDownloadVisibleStates.some((state) => this.$state.includes(state)); } + setConnectedClustersVisible() { + this.isConnectedClustersVisible = + !this.constructor.connectedClustersUnvisibleStates.some((state) => this.$state.includes(state)); + } + $onInit() { this.setWebAgentDownloadVisible(); + this.setConnectedClustersVisible(); this.$scope.$on('$stateChangeSuccess', () => this.setWebAgentDownloadVisible()); + this.$scope.$on('$stateChangeSuccess', () => this.setConnectedClustersVisible()); } }, transclude: { http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/app/components/web-console-header/template.pug ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/web-console-header/template.pug b/modules/web-console/frontend/app/components/web-console-header/template.pug index 23fc81e..41586b7 100644 --- a/modules/web-console/frontend/app/components/web-console-header/template.pug +++ b/modules/web-console/frontend/app/components/web-console-header/template.pug @@ -24,6 +24,8 @@ | You are now in #[b Demo Mode]. #[a(ng-click='closeDemo();') Close Demo?] .wch-content.container + connected-clusters(ng-if='$ctrl.$rootScope.user && !$ctrl.$rootScope.IgniteDemoMode && $ctrl.isConnectedClustersVisible') + a(ui-sref='signin') img.wch-logo(ng-src='{{::$ctrl.branding.headerLogo}}') http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/public/images/icons/connectedClusters.svg ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/public/images/icons/connectedClusters.svg b/modules/web-console/frontend/public/images/icons/connectedClusters.svg new file mode 100644 index 0000000..f405317 --- /dev/null +++ b/modules/web-console/frontend/public/images/icons/connectedClusters.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 13"><g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M6 0h4v4H6zm0 9h4v4H6zm6 0h4v4h-4zM0 9h4v4H0z"/><path stroke="currentColor" stroke-linecap="square" d="M8 4v2l6.125.04v3.365"/><path stroke="currentColor" stroke-linecap="square" d="M8.125 4v5.405V6L2 6.04v3.365"/></g></svg> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/67625336/modules/web-console/frontend/public/images/icons/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/public/images/icons/index.js b/modules/web-console/frontend/public/images/icons/index.js index d802805..5ca6307 100644 --- a/modules/web-console/frontend/public/images/icons/index.js +++ b/modules/web-console/frontend/public/images/icons/index.js @@ -26,3 +26,4 @@ export search from './search.svg'; export refresh from './refresh.svg'; export sort from './sort.svg'; export info from './info.svg'; +export connectedClusters from './connectedClusters.svg';