Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EUWE] Pull in the real power_state column off of service #382

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions client/app/services/poweroperations.service.js
Expand Up @@ -24,58 +24,58 @@
};

function powerOperationUnknownState(item) {
return item.powerState === "" && item.powerStatus === "";
return item.power_state === "" && item.options.power_status === "";
}

function powerOperationInProgressState(item) {
return (item.powerState !== "timeout" && item.powerStatus === "starting")
|| (item.powerState !== "timeout" && item.powerStatus === "stopping")
|| (item.powerState !== "timeout" && item.powerStatus === "suspending");
return (item.power_state !== "timeout" && item.options.power_status === "starting")
|| (item.power_state !== "timeout" && item.options.power_status === "stopping")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

|| (item.power_state !== "timeout" && item.options.power_status === "suspending");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

}

function powerOperationOnState(item) {
return item.powerState === "on" && item.powerStatus === "start_complete";
return item.power_state === "on" && item.options.power_status === "start_complete";
}

function powerOperationOffState(item) {
return item.powerState === "off" && item.powerStatus === "stop_complete";
return item.power_state === "off" && item.options.power_status === "stop_complete";
}

function powerOperationSuspendState(item) {
return item.powerState === "off" && item.powerStatus === "suspend_complete";
return item.power_state === "off" && item.options.power_status === "suspend_complete";
}

function powerOperationTimeoutState(item) {
return item.powerState === "timeout";
return item.power_state === "timeout";
}

function powerOperationStartTimeoutState(item) {
return item.powerState === "timeout" && item.powerStatus === "starting";
return item.power_state === "timeout" && item.options.power_status === "starting";
}

function powerOperationStopTimeoutState(item) {
return item.powerState === "timeout" && item.powerStatus === "stopping";
return item.power_state === "timeout" && item.options.power_status === "stopping";
}

function powerOperationSuspendTimeoutState(item) {
return item.powerState === "timeout" && item.powerStatus === "suspending";
return item.power_state === "timeout" && item.options.power_status === "suspending";
}

function startService(item) {
item.powerState = '';
item.powerStatus = 'starting';
item.power_state = '';
item.options.power_status = 'starting';
powerOperation('start', item);
}

function stopService(item) {
item.powerState = '';
item.powerStatus = 'stopping';
item.power_state = '';
item.options.power_status = 'stopping';
powerOperation('stop', item);
}

function suspendService(item) {
item.powerState = '';
item.powerStatus = 'suspending';
item.power_state = '';
item.options.power_status = 'suspending';
powerOperation('suspend', item);
}

Expand Down
17 changes: 7 additions & 10 deletions client/app/states/services/details/details.html
Expand Up @@ -132,16 +132,13 @@ <h4>{{ ::vm.service.long_description || vm.service.description }}</h4>
<div class="form-group">
<label class="control-label col-sm-4" translate>Power State</label>
<div class="col-sm-8">
<i class="fa fa-circle" style="font-size:15px;color:#1dc58e;" ng-if="vm.service.powerState === 'on' && vm.service.powerStatus === 'start_complete'" tooltip="{{'Power State: On'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-circle" style="font-size:15px;color:#cc151d;" ng-if="vm.service.powerState === 'off' && vm.service.powerStatus === 'stop_complete'" tooltip="{{'Power State: Off'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-circle" style="font-size:15px;color:orangered;" ng-if="vm.service.powerState === 'off' && vm.service.powerStatus === 'suspend_complete'" tooltip="{{'Power State: Suspended'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:#1dc58e;" ng-if="vm.service.powerState !== 'timeout' && vm.service.powerStatus === 'starting'" tooltip="{{'Power State: Starting...'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:#cc151d;" ng-if="vm.service.powerState !== 'timeout' && vm.service.powerStatus === 'stopping'" tooltip="{{'Power State: Stopping...'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:orangered;" ng-if="vm.service.powerState !== 'timeout' && vm.service.powerStatus === 'suspending'" tooltip="{{'Power State: Suspending...'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-adjust" style="font-size:15px;color:#1dc58e;" ng-if="vm.service.powerState === 'timeout' && vm.service.powerStatus === 'starting'" tooltip="{{'Power State: Start operation timed out'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-adjust" style="font-size:15px;color:#cc151d;" ng-if="vm.service.powerState === 'timeout' && vm.service.powerStatus === 'stopping'" tooltip="{{'Power State: Stop operation timed out'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-adjust" style="font-size:15px;color:orangered;" ng-if="vm.service.powerState === 'timeout' && vm.service.powerStatus === 'suspending'" tooltip="{{'Power State: Suspend operation timed out'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-question-circle" style="font-size:15px;color:#3397db;" ng-if="vm.service.powerState === '' && vm.service.powerStatus === ''" tooltip="{{'Power State: Unknown'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-circle" style="font-size:15px;color:#1dc58e;" ng-if="vm.service.power_state === 'on' && vm.service.options.power_status === 'start_complete'" tooltip="{{'Power State: On'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-circle" style="font-size:15px;color:#cc151d;" ng-if="vm.service.power_state === 'off' && vm.service.options.power_status === 'stop_complete'" tooltip="{{'Power State: Off'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-circle" style="font-size:15px;color:orangered;" ng-if="vm.service.power_state === 'off' && vm.service.options.power_status === 'suspend_complete'" tooltip="{{'Power State: Suspended'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-question-circle" style="font-size:15px;color:#3397db;" ng-if="vm.service.power_state === '' && vm.service.options.power_status === ''" tooltip="{{'Power State: Unknown'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:#1dc58e;" ng-if="vm.service.power_state !== 'timeout' && vm.service.options.power_status === 'starting'" tooltip="{{'Power State: Starting...'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:#cc151d;" ng-if="vm.service.power_state !== 'timeout' && vm.service.options.power_status === 'stopping'" tooltip="{{'Power State: Stopping...'|translate}}" tooltip-placement="bottom"></i>
<i class="fa fa-spinner fa-pulse" style="font-size:15px;color:orangered;" ng-if="vm.service.power_state !== 'timeout' && vm.service.options.power_status === 'suspending'" tooltip="{{'Power State: Suspending...'|translate}}" tooltip-placement="bottom"></i>
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions client/app/states/services/details/details.state.js
Expand Up @@ -42,6 +42,7 @@
'provision_dialog',
'service_template',
'chargeback_report',
'power_state',
];
var options = {
attributes: requestAttributes,
Expand Down Expand Up @@ -107,9 +108,6 @@
vm.ownershipServiceModal = ownershipServiceModal;
vm.reconfigureService = reconfigureService;

vm.service.powerState = angular.isDefined(vm.service.options.power_state) ? vm.service.options.power_state : "";
vm.service.powerStatus = angular.isDefined(vm.service.options.power_status) ? vm.service.options.power_status : "";

vm.startService = PowerOperations.startService;
vm.stopService = PowerOperations.stopService;
vm.suspendService = PowerOperations.suspendService;
Expand Down
37 changes: 19 additions & 18 deletions tests/services-details.state.spec.js
Expand Up @@ -21,24 +21,24 @@ describe('Dashboard', function() {

PowerOperations = {
powerOperationOnState: function (item) {
return item.powerState === "on" && item.powerStatus === "start_complete";
return item.power_state === "on" && item.options.power_status === "start_complete";
},
powerOperationUnknownState: function (item) {
return item.powerState === "" && item.powerStatus === "";
return item.power_state === "" && item.options.power_status === "";
},
powerOperationInProgressState: function (item) {
return (item.powerState !== "timeout" && item.powerStatus === "starting")
|| (item.powerState !== "timeout" && item.powerStatus === "stopping")
|| (item.powerState !== "timeout" && item.powerStatus === "suspending");
return (item.power_state !== "timeout" && item.options.power_status === "starting")
|| (item.power_state !== "timeout" && item.options.power_status === "stopping")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

|| (item.power_state !== "timeout" && item.options.power_status === "suspending");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

},
powerOperationOffState: function (item) {
return item.powerState === "off" && item.powerStatus === "stop_complete";
return item.power_state === "off" && item.options.power_status === "stop_complete";
},
powerOperationSuspendState: function (item) {
return item.powerState === "off" && item.powerStatus === "suspend_complete";
return item.power_state === "off" && item.options.power_status === "suspend_complete";
},
powerOperationTimeoutState: function (item) {
return item.powerState === "timeout";
return item.power_state === "timeout";
},
};
});
Expand All @@ -62,8 +62,8 @@ describe('Dashboard', function() {
var controller;

var service = {
power_state: "",
options: {
power_state: "timeout",
power_status: "starting"
},
chargeback_report: {
Expand All @@ -82,13 +82,13 @@ describe('Dashboard', function() {
});
});

describe('service detail contains power state in "timeout" and power status in "starting', function() {
describe('service detail contains power state in "off" and power status in "stop_complete"', function() {
var controller;

var service = {
power_state: "off",
options: {
power_state: "timeout",
power_status: "starting"
power_status: "stop_complete"
},
chargeback_report: {
results: []
Expand All @@ -101,24 +101,25 @@ describe('Dashboard', function() {
controller = $controller($state.get('services.details').controller, {service: service, $state: state, Chargeback: Chargeback});
});

it('enables the "Start" button when power state is "timeout" and power status is "starting', function() {
expect(controller.enableStartButton(controller.service)).to.eq(true);
it('disables the "Stop" button when power state is "OFF"', function() {
expect(controller.checkDisabled('stop', controller.service)).to.eq(true);
});

it('disables the "Stop" button when power state is "timeout" and power status is "starting', function() {
expect(controller.checkDisabled('stop', controller.service)).to.eq(false);
it('enables the "Start" button when power state is "OFF"', function() {
expect(controller.enableStartButton(controller.service)).to.eq(true);
});

it('disables the "Suspend" button when power state is "timeout" and power status is "starting', function() {
it('enables the "Suspend" button when power state is "OFF"', function() {
expect(controller.checkDisabled('suspend', controller.service)).to.eq(false);
});

});

describe('service detail contains power state in "on" and power status in "start_complete', function() {
var controller;
var service = {
power_state: "on",
options: {
power_state: "on",
power_status: "start_complete"
},
chargeback_report: {
Expand Down
61 changes: 33 additions & 28 deletions tests/services-list.state.spec.js
Expand Up @@ -42,17 +42,20 @@ describe('Dashboard', function() {
});
});

describe('service list contains power state in "timeout" and power status in "starting', function() {
describe('service list contains power state in "" and power status in "starting', function() {
var controller;
var services = {
name: 'services',
count: 1,
subcount: 1,
resources: [
{options: {
power_state: "timeout",
power_status: "starting"
}}
{
power_state: "",
options: {
power_state: "",
power_status: "starting"
}
}
]
};

Expand All @@ -71,19 +74,19 @@ describe('Dashboard', function() {
});

it('sets the powerState value on the Service', function() {
expect(serviceItem.powerState).to.eq('timeout');
expect(serviceItem.power_state).to.eq('');
});

it('sets the powerStatus value on the Service', function() {
expect(serviceItem.powerStatus).to.eq('starting');
expect(serviceItem.options.power_status).to.eq('starting');
});

it('does not hide the kebab menu when "Start" operation times out', function() {
expect(controller.hideMenuForItemFn(serviceItem)).to.eq(false);
it('does hide the kebab menu when "Start" operation is unknown', function() {
expect(controller.hideMenuForItemFn(serviceItem)).to.eq(true);
});

it('Shows the "Start" button when "Start" operation times out', function() {
expect(controller.enableButtonForItemFn({}, serviceItem)).to.eq(true);
it('Disables the "Start" button when "Start" operation is "starting"', function() {
expect(controller.enableButtonForItemFn("undefined", serviceItem)).to.eq(false);
});

it('displays "Stop" button when action is "stop"', function() {
Expand All @@ -106,10 +109,12 @@ describe('Dashboard', function() {
count: 1,
subcount: 1,
resources: [
{options: {
{
power_state: "on",
power_status: "start_complete"
}}
options: {
power_status: "start_complete"
}
}
]
};

Expand All @@ -121,25 +126,25 @@ describe('Dashboard', function() {
};

var PowerOperations = {
powerOperationOnState: function (item) {
return item.powerState === "on" && item.powerStatus === "start_complete";
powerOperationOnState: function(item) {
return item.power_state === "on" && item.options.power_status === "start_complete";
},
powerOperationUnknownState: function (item) {
return item.powerState === "" && item.powerStatus === "";
powerOperationUnknownState: function(item) {
return item.power_state === "" && item.options.power_status === "";
},
powerOperationInProgressState: function (item) {
return (item.powerState !== "timeout" && item.powerStatus === "starting")
|| (item.powerState !== "timeout" && item.powerStatus === "stopping")
|| (item.powerState !== "timeout" && item.powerStatus === "suspending");
powerOperationInProgressState: function(item) {
return (item.power_state !== "timeout" && item.options.power_status === "starting")
|| (item.power_state !== "timeout" && item.options.power_status === "stopping")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

|| (item.power_state !== "timeout" && item.options.power_status === "suspending");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad line breaking before '||'.

},
powerOperationOffState: function (item) {
return item.powerState === "off" && item.powerStatus === "stop_complete";
powerOperationOffState: function(item) {
return item.power_state === "off" && item.options.power_status === "stop_complete";
},
powerOperationSuspendState: function (item) {
return item.powerState === "off" && item.powerStatus === "suspend_complete";
powerOperationSuspendState: function(item) {
return item.power_state === "off" && item.options.power_status === "suspend_complete";
},
powerOperationTimeoutState: function (item) {
return item.powerState === "timeout";
powerOperationTimeoutState: function(item) {
return item.power_state === "timeout";
},
};

Expand Down