Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Commit

Permalink
Fixed dash-list bug
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshcmu committed Jan 18, 2017
1 parent e974db7 commit 1ecb75c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
19 changes: 9 additions & 10 deletions src/local/dashlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var dashListFile = 'conf/dash-list.json';

function DashList() {
this.dashlistConf = require('nconf');
this.dashlistConf.add('dashlist.conf', {type: 'file', file: dashListFile});
}


Expand All @@ -34,7 +33,7 @@ DashList.prototype.createList = function(commands) {
var self = this;
var listName = commands[0];
self.createIfNotExists(false);
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
if (!self.dashlistConf.get('dashlists')) {
self.dashlistConf.set('dashlists', []);
self.saveDashListConf(false);
Expand All @@ -55,7 +54,7 @@ DashList.prototype.addDashboard = function(commands) {
var self = this;
var listName = commands[0];
var dashboardName = commands[1];
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -72,7 +71,7 @@ DashList.prototype.removeDashboard = function(commands) {
var self = this;
var listName = commands[0];
var dashboardName = commands[1];
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -89,7 +88,7 @@ DashList.prototype.removeDashboard = function(commands) {
DashList.prototype.showList = function(commands) {
var self = this;
var listName = commands[0];
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -103,7 +102,7 @@ DashList.prototype.showList = function(commands) {
DashList.prototype.clearList = function(commands) {
var self = this;
var listName = commands[0];
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -119,7 +118,7 @@ DashList.prototype.clearList = function(commands) {
DashList.prototype.deleteList = function(commands) {
var self = this;
var listName = commands[0];
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -134,7 +133,7 @@ DashList.prototype.deleteList = function(commands) {

DashList.prototype.getList = function(listName) {
var self = this;
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
var listIndex = getListIndex(listName, lists);
if (listIndex === -1) {
Expand All @@ -154,7 +153,7 @@ function getListIndex(listName, lists) {

DashList.prototype.getListNames = function() {
var self = this;
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
var lists = self.dashlistConf.get('dashlists');
if (lists && lists.length > 0) {
return _.map(lists, function (list) {
Expand All @@ -169,7 +168,7 @@ DashList.prototype.getListNames = function() {
// Save dashlist config
DashList.prototype.saveDashListConf = function(showOutput) {
var self = this;
self.dashlistConf.use('dashlist.conf');
self.dashlistConf.use('file', {file: dashListFile});
self.dashlistConf.save(function (err) {
if (err) {
if (showOutput) {
Expand Down
4 changes: 2 additions & 2 deletions src/remote/s3services.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ var _ = require('lodash');
//Create the s3 bucket and required directories
function S3(conf, comps) {
this.params = {};
if (conf.s3 && conf.s3.bucket_name) {
if (conf && conf.s3 && conf.s3.bucket_name) {
this.params.Bucket = conf.s3.bucket_name;
}
if (conf.s3 && conf.s3.path) {
if (conf && conf.s3 && conf.s3.path) {
this.params.Key = conf.s3.path;
}
this.components = comps;
Expand Down
9 changes: 4 additions & 5 deletions src/util/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var confFile = 'conf/wizzy.json';
// Constructor
function Config() {
this.conf = require('nconf');
this.conf.add('wizzy.conf', {type: 'file', file: confFile});
}

// Initialize wizzy configuration
Expand Down Expand Up @@ -78,7 +77,7 @@ Config.prototype.checkConfigPrereq = function(showOutput) {
Config.prototype.addProperty = function(key, value) {
var self = this;
self.checkConfigPrereq();
self.conf.use('wizzy.conf');
self.conf.use('file', {file: confFile});
if (_.includes(configs, key)) {
self.conf.set(key, value);
self.saveConfig(true);
Expand All @@ -92,22 +91,22 @@ Config.prototype.addProperty = function(key, value) {
Config.prototype.showProperty = function(config) {
var self = this;
self.checkConfigPrereq();
self.conf.use('wizzy.conf');
self.conf.use('file', {file: confFile});
logger.showOutput(logger.stringify(self.conf.get(config)));
};

// Gets a config property from wizzy configuration file
Config.prototype.getProperty = function(config) {
var self = this;
self.checkConfigPrereq();
self.conf.use('wizzy.conf');
self.conf.use('file', {file: confFile});
return(self.conf.get(config));
};

// Save wizzy config file
Config.prototype.saveConfig = function(showOutput) {
var self = this;
self.conf.use('wizzy.conf');
self.conf.use('file', {file: confFile});
self.conf.save(function (err) {
if (err) {
if (showOutput) {
Expand Down

0 comments on commit 1ecb75c

Please sign in to comment.