Skip to content

Commit

Permalink
Merge pull request #991 from Tendrl/master
Browse files Browse the repository at this point in the history
Backport fixes from master to release/1.6.3-4
  • Loading branch information
nthomas-redhat authored Jun 15, 2018
2 parents 62cf770 + 1d0ad59 commit 8595fbd
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 133 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# store the current working directory
NAME := tendrl-ui
VERSION := 1.6.3
RELEASE := 3
RELEASE := 4
COMMIT := $(shell git rev-parse HEAD)
SHORTCOMMIT := $(shell echo $(COMMIT) | cut -c1-7)

Expand Down
3 changes: 3 additions & 0 deletions src/commons/stores/cluster-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
temp.hostCount = cluster.nodes.length || 0;
temp.state = cluster.status;
temp.isProfilingEnabled = _getProfileStatus(temp, cluster);
temp.readyState = false;

temp.errors = cluster.errors ? cluster.errors : [];

Expand Down Expand Up @@ -266,6 +267,7 @@
temp.message = "Expansion required";
} else {
temp.message = "Ready to Use";
temp.readyState = true;
}
}
} else if (temp.jobType === "UnmanageCluster") {
Expand All @@ -287,6 +289,7 @@
temp.message = "Expansion required";
} else if (!temp.message) {
temp.message = "Ready to Use";
temp.readyState = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/bricks/host-bricks/host-bricks.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ <h1 class="bold-text">Brick Details</h1>
</div>
</form>
<div class="row toolbar-pf-results">
<div class="col-md-1">
<div class="pull-left">
<h5 ng-if="vm.brickList.length !== 0">{{vm.filteredBrickList.length}}
<ng-pluralize count="vm.filteredBrickList.length" when="{'one': 'Brick',
'other': 'Bricks'}"></ng-pluralize>
</h5>
</div>
<div class="col-md-1" ng-show="vm.stoppedBrickCnt">
<div class="pull-left" ng-show="vm.stoppedBrickCnt">
<span uib-tooltip="Stopped" class="fa ffont fa-stop-circle-o"></span>
<h5>{{vm.stoppedBrickCnt}}</h5>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/modules/bricks/host-bricks/host-bricks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
padding-left: 0;
}

.toolbar-pf-results > span {
display: none;
.toolbar-pf-results {
margin-left: 0;

& > span {
display: none;
}
}

.ffont {
Expand Down
20 changes: 15 additions & 5 deletions src/modules/bricks/volume-bricks/volume-bricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,18 @@
}

function _matchesFilters(item, filters) {
var subVol;
var subVol,
i,
len = filters.length;

filters.forEach(function(filter) {
subVol = _matchesFilter(item, filter);
});
for (i = 0; i < len; i++) {
subVol = _matchesFilter(item, filters[i]);

//if any filter criteria doesn't match, exit from the loop
if (subVol === -9999) {
break;
}
}

return subVol;
}
Expand Down Expand Up @@ -421,12 +428,13 @@
}

function _mantainExpandedState(data) {
var subVolData = JSON.parse(JSON.stringify(vm.subVolumeList)),
var subVolData = JSON.parse(JSON.stringify(vm.filteredBrickList)),
len = subVolData.length,
subVolume,
i;

vm.subVolumeList = data;
vm.filteredBrickList = data;

for (i = 0; i < len; i++) {
subVolume = _isSubVolPresent(subVolData[i]);
Expand All @@ -436,6 +444,8 @@
vm.subVolumeList[subVolume.index].activeTab = subVolume.subVolume.activeTab;
}
}

_filterChange(vm.filters);
}

function _isSubVolPresent(subVolume) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/clusters/cluster-list/cluster-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h5 class="pull-left" ng-show="cluster.isProfilingEnabled !== 'Pending'">{{clust
<h5 class="pull-left" ng-show="cluster.isProfilingEnabled === 'Pending'"><a href="" ng-click="clusterCntrl.goToTaskDetail(cluster)">{{cluster.isProfilingEnabled || "NA"}}</a></h5>
</div>
<div class="list-view-pf-additional-info-item cluster-text" ng-class="{'error-message': (cluster.message === 'Cluster Misconfigured'), 'warning-message': (cluster.message === 'Import Failed' || cluster.message === 'Unmanage Failed')}">
<p uib-tooltip-template="'../modules/clusters/cluster-list/unmanage-cluster-tooltip.html'" tooltip-enable="clusterCntrl.isTooltipEnable(cluster.message)" tooltip-placement="auto">{{cluster.disableExpand ? "Expanding cluster" : cluster.message}}</p>
<p uib-tooltip-html="clusterCntrl.getTemplate(cluster)" tooltip-placement="auto">{{cluster.disableExpand ? "Expanding cluster" : cluster.message}}</p>
<p><a ng-click="clusterCntrl.goToTaskDetail(cluster)" ng-show="clusterCntrl.showViewDetailsLink(cluster)" class="details-link">View Details</a></p>
</div>
</div>
Expand Down
26 changes: 21 additions & 5 deletions src/modules/clusters/cluster-list/cluster-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
vm.getClass = getClass;
vm.expandCluster = expandCluster;
vm.hideExpandBtn = hideExpandBtn;
vm.isTooltipEnable = isTooltipEnable;
vm.goToClusterHost = goToClusterHost;
vm.showViewDetailsLink = showViewDetailsLink;
vm.showDisableLink = showDisableLink;
vm.showEnableLink = showEnableLink;
vm.getTemplate = getTemplate;

vm.filterConfig = {
fields: [{
Expand Down Expand Up @@ -282,7 +282,7 @@

function disableImportBtn(cluster) {
return (cluster.currentStatus === "in_progress" ||
(cluster.jobType === "UnmanageCluster" && cluster.currentStatus === "failed"));
((cluster.jobType === "UnmanageCluster" || cluster.jobType === "ImportCluster") && cluster.currentStatus === "failed"));
}

function showDashboardBtn(cluster) {
Expand All @@ -304,9 +304,6 @@
(cluster.managed === "Yes" && cluster.state !== "expand_pending"));
}

function isTooltipEnable(message) {
return (message !== "Expansion required" && message !== "Expansion Failed" && message !== "Expanding cluster");
}

function getClass(cluster) {
var cls;
Expand Down Expand Up @@ -364,6 +361,25 @@
cluster.isProfilingEnabled === "Unknown";
}

function getTemplate(cluster) {
var tooltip = {
"unmanagecluster": "If unmanage fails, resolve the issue and reinitiate unmanage cluster.",
"importcluster": "If import cluster fails, resolve the issue before performing an unmanage cluster and reinitiate import.",
"expandclusterwithdetectedpeers": "If cluster expansion fails, check if tendrl-ansible was executed successfully and ensure the node agents are correctly configured.",
"ready": "The cluster is successfully imported for viewing monitoring data and metrics."
},
template = "";

if (cluster.currentStatus === "failed") {
template = tooltip[cluster.jobType.toLowerCase()];

} else if (cluster.readyState) {
template = tooltip["ready"];
}

return template;
}

/***Private Functions***/

function _compareFn(item1, item2) {
Expand Down

This file was deleted.

11 changes: 5 additions & 6 deletions src/modules/clusters/import-cluster/import-cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<li>Import Cluster</li>
</ol>
<div ng-show="vm.failedImport" class="alert alert-warning">
<span class="pficon pficon-warning-triangle-o"></span>
Import cluster previously failed with <a ng-click="vm.openImportErrorModal(vm.taskId)" class="alert-link">{{vm.taskId}}</a>. Be sure that all the issues have been corrected and the cluster has been unmanaged before proceeding.
<span class="pficon pficon-warning-triangle-o"></span> Import cluster previously failed with <a ng-click="vm.openImportErrorModal(vm.taskId)" class="alert-link">{{vm.taskId}}</a>. Be sure that all the issues have been corrected and the cluster has been unmanaged before proceeding.
</div>
<div class="alert alert-danger" ng-show="vm.errorMsg.length > 0">
<span class="pficon pficon-error-circle-o"></span>
Expand All @@ -19,7 +18,7 @@ <h1 class="bold-text">Import Cluster</h1>
<label class="col-sm-2 col-md-1" for="clusterName">Cluster Name</label>
<div class="col-sm-4 col-md-3">
<div class="row">
<input class="col-md-12 col-sm-12" type="text" name="clusterName" ng-model="vm.clusterName"/>
<input class="col-md-12 col-sm-12" type="text" name="clusterName" ng-model="vm.clusterName" />
</div>
<div class="row name-validation-msg">Only alphanumeric and underscore characters are allowed.</div>
</div>
Expand Down Expand Up @@ -53,9 +52,9 @@ <h2>Discovered Host(s)</h2>
<!-- /col -->
</div>
<div class="row " ng-show="vm.filteredHostList.length ">
<h3 ng-if="vm.hostList.length !== 0" class="col-sm-12 ">{{vm.filteredHostList.length}}
<ng-pluralize count="vm.filteredHostList.length " when="{ 'one': 'Host', 'other': 'Hosts'} "></ng-pluralize>
Discovered</h3>
<h3 ng-if="vm.hostList.length !== 0" class="col-sm-12 ">{{vm.filteredHostList.length}} of {{vm.hostList.length}} Discovered
- <ng-pluralize count="vm.hostList.length " when="{ 'one': 'Host', 'other': 'Hosts'} "></ng-pluralize>
- </h3>
</div>
<div ng-if="vm.isDataLoading" class="spinner spinner-lg"></div>
<center ng-show="!vm.isDataLoading && vm.filteredHostList.length===0 ">
Expand Down
45 changes: 27 additions & 18 deletions src/modules/clusters/import-cluster/import-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,19 @@
* @memberOf importClusterController
*/
function importCluster() {
var clusterName;

if (vm.clusterName) {
clusterName = vm.clusterName.match(vm.clusterNamePattern);
}

if (clusterName !== null) {
if (_validateFields()) {
clusterStore.importCluster(vm.clusterId, vm.enableProfiling, vm.clusterName)
.then(function(data) {
vm.importIcon = true;
vm.taskInitiated = true;
vm.jobId = data.job_id;
}).catch(function(e){
vm.importIcon = false;
vm.taskInitiated = false;
Notifications.message("danger", "", "Failed to initaite import.");
});
} else {
vm.errorMsg = "Please enter a valid cluster name. Only alphanumeric and underscore characters are allowed."
.then(function(data) {
vm.importIcon = true;
vm.taskInitiated = true;
vm.jobId = data.job_id;
}).catch(function(e) {
vm.importIcon = false;
vm.taskInitiated = false;
Notifications.message("danger", "", "Failed to initaite import.");
});
}

}

/**
Expand All @@ -171,6 +163,23 @@
}
}

/***Private Functions***/

function _validateFields() {
var isValid = true,
clusterName = vm.clusterName && vm.clusterName.match(vm.clusterNamePattern);

if (clusterName === null) {
isValid = false;
vm.errorMsg = "Please enter a valid cluster name. Only alphanumeric and underscore characters are allowed.";
} else if (vm.filters.length) {
isValid = false;
vm.errorMsg = "Review the discovered host list, and ensure there are no filters applied before proceeding with Import.";
}

return isValid;
}

function _setImportDetail() {
vm.clusterObj = clusterStore.getClusterDetails(vm.clusterId);
vm.hostList = vm.clusterObj.hosts;
Expand Down
5 changes: 4 additions & 1 deletion tendrl-ui.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: tendrl-ui
Version: 1.6.3
Release: 3%{?dist}
Release: 4%{?dist}
BuildArch: noarch
Summary: GUI for Tendrl
License: LGPLv2+
Expand Down Expand Up @@ -37,6 +37,9 @@ cp -a ./dist/* $RPM_BUILD_ROOT/%{_localstatedir}/www/tendrl/
%license LICENSE

%changelog
* Fri Jun 15 2018 Neha Gupta <[email protected]> - 1.6.3-4
- Bugfixes (https://github.com/Tendrl/ui/milestone/7)

* Tue May 29 2018 Neha Gupta <[email protected]> - 1.6.3-3
- Bugfixes (https://github.com/Tendrl/ui/milestone/6)

Expand Down
5 changes: 3 additions & 2 deletions test/unit/cluster-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ describe("Unit Component: clusterList", function() {
});

it("Should show tooltip", function() {
var cluster = clusterList.clusters[0];
expect(vm.isTooltipEnable(cluster.message)).to.be.true;
var cluster = clusterList.clusters[1];
cluster.currentStatus = "finished";
expect(vm.getTemplate(cluster)).to.be.equal("The cluster is successfully imported for viewing monitoring data and metrics.");
});

it("Should get an icon class when cluster is unmanaged", function() {
Expand Down
40 changes: 6 additions & 34 deletions test/unit/import-cluster-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Unit Component: importCluster", function() {
var config, utils, importCluster, Notifications, clusterStore;

// Local variables used for testing
var getClusterListDeferred, importClusterDeferred, vm, clock, throttled, intervalSpy, timer, args, element;
var getClusterDeferred, importClusterDeferred, vm, clock, throttled, intervalSpy, timer, args, element;

// Initialize modules
beforeEach(function() {
Expand Down Expand Up @@ -53,12 +53,11 @@ describe("Unit Component: importCluster", function() {
$rootScope.clusterData = importCluster.formattedOutput;
$state.current.name = "import-cluster";
$stateParams.clusterId = importCluster.formattedOutput[0].clusterId;
getClusterListDeferred = $q.defer();
getClusterDeferred = $q.defer();
importClusterDeferred = $q.defer();

sinon.stub($state, "go");
sinon.stub(clusterStore, "getClusterList").returns(getClusterListDeferred.promise);
sinon.stub(clusterStore, "formatClusterData").returns(importCluster.formattedOutput);
sinon.stub(clusterStore, "getCluster").returns(getClusterDeferred.promise);
sinon.stub(clusterStore, "importCluster").returns(importClusterDeferred.promise);

clock = sinon.useFakeTimers();
Expand All @@ -83,40 +82,11 @@ describe("Unit Component: importCluster", function() {
expect(vm.tableColumns).to.deep.equal(importCluster.tableColumns);
});

it("Should call getClusterList if clusterData doens't exit", function() {
vm = $componentController("importCluster", { $scope: $scope });
getClusterListDeferred.resolve(importCluster.clusters);
$rootScope.$digest();

expect($rootScope.clusterData).to.deep.equal(importCluster.formattedOutput);
expect(vm.isDataLoading).to.be.false;
expect(vm.clusterObj).to.deep.equal(importCluster.formattedOutput[0]);
expect(vm.hostList).to.be.equal(importCluster.formattedOutput[0].hosts);
expect(vm.taskId).to.be.equal(importCluster.formattedOutput[0].currentTaskId);
expect(vm.taskStatus).to.be.equal(importCluster.formattedOutput[0].currentStatus);
expect(vm.taskType).to.be.equal(importCluster.formattedOutput[0].jobType);
expect(vm.failedImport).to.be.false;
expect(vm.filteredHostList).to.deep.equal(importCluster.formattedOutput[0].hosts);
});

it("Should not call getClusterList if clusterData exists", function() {
$rootScope.clusterData = importCluster.formattedOutput;
vm = $componentController("importCluster", { $scope: $scope });

expect(vm.isDataLoading).to.be.false;
expect(vm.clusterObj).to.deep.equal(importCluster.formattedOutput[0]);
expect(vm.hostList).to.be.equal(importCluster.formattedOutput[0].hosts);
expect(vm.taskId).to.be.equal(importCluster.formattedOutput[0].currentTaskId);
expect(vm.taskStatus).to.be.equal(importCluster.formattedOutput[0].currentStatus);
expect(vm.taskType).to.be.equal(importCluster.formattedOutput[0].jobType);
expect(vm.failedImport).to.be.false;
expect(vm.filteredHostList).to.deep.equal(importCluster.formattedOutput[0].hosts);
});

describe("Import Cluster workflows", function() {
beforeEach(function() {
vm = $componentController("importCluster", { $scope: $scope });
getClusterListDeferred.resolve(importCluster.clusters);
getClusterDeferred.resolve(importCluster.clusters[0]);
$rootScope.$digest();
});

Expand Down Expand Up @@ -171,6 +141,8 @@ describe("Unit Component: importCluster", function() {
// Tear down
$state.go.restore();
clock.restore();
clusterStore.getCluster.restore();
clusterStore.importCluster.restore();
});

});
Loading

0 comments on commit 8595fbd

Please sign in to comment.