Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…dd_deployables_link
  • Loading branch information
dalehille committed Mar 3, 2020
2 parents a6b2185 + abb9e1f commit b232031
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 142 deletions.
2 changes: 1 addition & 1 deletion imports/api/deployables/channels/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { requireOrgAccess } from '/imports/api/org/utils.js';
import { updateDeployablesCountStat } from '../../stat/utils.js';
import { logUserAction } from '../../userLog/utils.js';

import uuid from 'uuid/v4';
import { v4 as uuid } from 'uuid';

// https://docs.meteor.com/api/check.html
const NonEmptyString = Match.Where((x) => {
Expand Down
2 changes: 1 addition & 1 deletion imports/api/deployables/subscriptions/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { check, Match } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { Subscriptions } from './subscriptions.js';
import { requireOrgAccess } from '/imports/api/org/utils.js';
import uuid from 'uuid/v4';
import { v4 as uuid } from 'uuid';
import { pub } from '/imports/api/lib/pubsub';
import { logUserAction } from '../../userLog/utils.js';

Expand Down
2 changes: 1 addition & 1 deletion imports/api/org/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import _ from 'lodash';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import uuid from 'uuid';
import { v4 as uuid } from 'uuid';
import { Orgs } from './orgs.js';
import ghe from '../lib/ghe.js';
import bitbucket from '../lib/bitbucket.js';
Expand Down
15 changes: 0 additions & 15 deletions imports/api/resource/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,12 @@

import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { Orgs } from '../org/orgs.js';
import { Resources } from './resources.js';
import { tokenCrypt } from '/imports/both/utils.js';
import { requireOrgAccess } from '/imports/api/org/utils.js';
import moment from 'moment';
import _ from 'lodash';

Meteor.methods({
getResourceData(clusterId, resourceName){
check( clusterId, String );
check( resourceName, String );
var resource = Resources.findOne({ cluster_id: clusterId, selfLink: resourceName });
if(!resource){
return null;
}
var org = Orgs.findOne({ _id: resource.org_id });
if(!org){
throw new Meteor.Error(`couldnt find org id "${resource.org_id}" from resource._id "${resource._id}"`);
}
return tokenCrypt.decrypt(resource.data, org.orgKeys[0]);
},
async getActiveDepsPerService(orgId){
requireOrgAccess(orgId);
var out = await Resources.rawCollection().aggregate( [
Expand Down
12 changes: 0 additions & 12 deletions imports/both/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import _ from 'lodash';
import CryptoJS from 'crypto-js';

exports.sanitizeRegexStr = (str) => {
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
Expand Down Expand Up @@ -134,14 +133,3 @@ exports.buildSearchForResourcesName = (orgId, searchStr = '', fromTime, toTime,
};
return search;
};

export const tokenCrypt = {
encrypt: (str, token)=>{
var out = CryptoJS.AES.encrypt(str, token).toString();
return out;
},
decrypt: (str, token)=>{
var out = CryptoJS.AES.decrypt(str, token).toString(CryptoJS.enc.Utf8);
return out;
},
};
27 changes: 27 additions & 0 deletions imports/ui/components/noClusters/component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
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.
-->

<template name="noClusters">
<div class="card">
<div class="card-header cardHeader d-flex no-block">
<h5 class="text-muted my-0">No data</h5>
</div>
<div class="card-body p-1">
<div class="m-3">No clusters were found in Razee. Go to the <i class="fa fa-cog m-1 text-muted"></i> settings menu to add a cluster.
</div>
</div>
</div>
</template>
17 changes: 17 additions & 0 deletions imports/ui/components/noClusters/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* 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';
18 changes: 6 additions & 12 deletions imports/ui/layouts/body/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@
{{#if currentUser}}
{{> nav}}
<div class="container-fluid px-0">
{{> breadcrumbs }}
{{#if hasRazeeData}}
{{> Template.dynamic template=main}}
{{#if skipClusterCheck}}
{{> Template.dynamic template=main}}
{{else if hasClusters}}
{{> breadcrumbs }}
{{> Template.dynamic template=main}}
{{else}}
<div class="card">
<div class="card-header cardHeader d-flex no-block">
<h5 class="text-muted my-0">No data</h5>
</div>
<div class="card-body p-1">
<div class="m-3">No clusters were found in Razee. Go to the <i class="fa fa-cog m-1 text-muted"></i> settings menu to add a cluster.
</div>
</div>
</div>
{{> noClusters }}
{{/if}}
</div>
{{> footer}}
Expand Down
17 changes: 15 additions & 2 deletions imports/ui/layouts/body/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import './body.html';
import './footer.html';
import '../../pages/login';
import '../../components/addCluster';
import '../../components/noClusters';

import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
Expand Down Expand Up @@ -49,8 +50,11 @@ 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');
const orgId = Session.get('currentOrgId');
if(orgId) {
this.subscribe('clusters.org', orgId);
}
this.subscribe('orgIdByName', orgName);
Meteor.call('hasOrgs', function(err, result) {
hasOrgsDefined.set(result);
Expand Down Expand Up @@ -81,7 +85,16 @@ Template.Base_layout.helpers({
currentOrgName(){
return Session.get('currentOrgName');
},
hasRazeeData () {
skipClusterCheck() {
// Don't show the 'noClusters' template on these routes
const route = currentRoute.get();
if(route === 'root' || route === 'org' || route === 'profile') {
return true;
} else {
return false;
}
},
hasClusters () {
const clusters = Clusters.find({ org_id: Session.get('currentOrgId')}).count();
return (clusters > 0) ? true : false;
}
Expand Down
Loading

0 comments on commit b232031

Please sign in to comment.