diff --git a/imports/startup/client/index.js b/imports/startup/client/index.js index 4da60d13..d8e9c19e 100644 --- a/imports/startup/client/index.js +++ b/imports/startup/client/index.js @@ -403,4 +403,8 @@ Template.registerHelper('getClusterNameById', (clusterId) => { return cluster.metadata.name || clusterId; }); +Template.registerHelper('org', () => { + return Orgs.findOne({ name: FlowRouter.getParam('baseOrgName') }); +}); + import './routes.js'; diff --git a/imports/ui/components/addCluster/component.html b/imports/ui/components/addCluster/component.html new file mode 100644 index 00000000..8bd1a700 --- /dev/null +++ b/imports/ui/components/addCluster/component.html @@ -0,0 +1,27 @@ + diff --git a/imports/ui/components/addCluster/index.js b/imports/ui/components/addCluster/index.js new file mode 100644 index 00000000..1629cceb --- /dev/null +++ b/imports/ui/components/addCluster/index.js @@ -0,0 +1,26 @@ +/** +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import './component.html'; + +import { Template } from 'meteor/templating'; +import Clipboard from 'clipboard'; + +Template.addCluster.onRendered( () => { + new Clipboard('.copy-button', { + container: document.getElementById('add-cluster-modal') + }); +}); diff --git a/imports/ui/layouts/body/body.html b/imports/ui/layouts/body/body.html index e0ff9052..9c724ffa 100644 --- a/imports/ui/layouts/body/body.html +++ b/imports/ui/layouts/body/body.html @@ -22,7 +22,19 @@ {{> nav}}
{{> breadcrumbs }} - {{> Template.dynamic template=main}} + {{#if hasRazeeData}} + {{> Template.dynamic template=main}} + {{else}} +
+
+
No data
+
+
+
No clusters were found in Razee. Go to the settings menu to add a cluster. +
+
+
+ {{/if}}
{{> footer}} {{else}} diff --git a/imports/ui/layouts/body/body.js b/imports/ui/layouts/body/body.js index 72052d1d..7d40d44a 100644 --- a/imports/ui/layouts/body/body.js +++ b/imports/ui/layouts/body/body.js @@ -19,6 +19,8 @@ import './nav.html'; import './body.html'; import './footer.html'; import '../../pages/login'; +import '../../components/addCluster'; + import { Meteor } from 'meteor/meteor'; import { Session } from 'meteor/session'; import { FlowRouter } from 'meteor/kadira:flow-router'; @@ -27,6 +29,7 @@ import { Tracker } from 'meteor/tracker'; import _ from 'lodash'; import { Template } from 'meteor/templating'; import { Stats } from '/imports/api/stat/stats.js'; +import { Clusters } from '/imports/api/cluster/clusters/clusters'; import { Breadcrumb } from 'meteor/ahref:flow-router-breadcrumb'; import { hasOrgsDefined } from '../../../startup/client'; @@ -46,9 +49,9 @@ Template.Base_layout.helpers({ Template.Base_layout.onRendered(function() { this.autorun(()=>{ this.subscribe('userData'); + this.subscribe('clusters.org', Session.get('currentOrgId')); var orgName = Session.get('currentOrgName'); this.subscribe('orgIdByName', orgName); - Meteor.call('hasOrgs', function(err, result) { hasOrgsDefined.set(result); }); @@ -78,6 +81,11 @@ Template.Base_layout.helpers({ currentOrgName(){ return Session.get('currentOrgName'); }, + hasRazeeData () { + const clusters = Clusters.find({ org_id: Session.get('currentOrgId')}).count(); + return (clusters > 0) ? true : false; + } + }); Template.nav.helpers({ @@ -128,9 +136,38 @@ Template.nav.events({ }, 'click a' () { $('.navbar-collapse').collapse('hide'); + }, + 'click .navbar' () { + $('#js-settingsDropdown').popover('dispose'); + }, + 'click .js-add-cluster'(e){ + e.preventDefault(); + const $modal = $('.js-add-cluster-modal'); + $modal.modal('show'); + return false; } }); +Template.nav.onRendered(function() { + let statsSubscription = this.subscribe('resourceStats', Session.get('currentOrgId')); + Tracker.autorun(()=> { + if(statsSubscription.ready()) { + const numberOfClusters = (_.get(Stats.findOne({org_id:Session.get('currentOrgId')}), 'clusterCount') || 0).toLocaleString(); + if(numberOfClusters === '0') { + const options = { + container: '.js-settings', + placement: 'bottom', + trigger: 'focus' + }; + $('#js-settingsDropdown').popover(options); + $('#js-settingsDropdown').popover('show'); + } else { + $('#js-settingsDropdown').popover('dispose'); + } + } + }); +}); + Template.nav.onCreated(function() { this.autorun(() => { Meteor.call('reloadUserOrgList'); @@ -141,7 +178,6 @@ Template.nav.onCreated(function() { hasOrgsDefined.set(false); } if(Session.get('currentOrgId')) { - this.subscribe('resourceStats', Session.get('currentOrgId')); Meteor.call('updateResourceStats', Session.get('currentOrgId')); } this.subscribe('userData'); diff --git a/imports/ui/layouts/body/nav.html b/imports/ui/layouts/body/nav.html index aec9e935..d3671f1d 100644 --- a/imports/ui/layouts/body/nav.html +++ b/imports/ui/layouts/body/nav.html @@ -55,7 +55,24 @@ {{/if}} -