|
@@ -19,14 +19,23 @@
|
|
var App = require('app');
|
|
var App = require('app');
|
|
|
|
|
|
App.MainServiceController = Em.ArrayController.extend({
|
|
App.MainServiceController = Em.ArrayController.extend({
|
|
- name:'mainServiceController',
|
|
|
|
- content: function(){
|
|
|
|
- if(!App.router.get('clusterController.isLoaded')){
|
|
|
|
|
|
+
|
|
|
|
+ name: 'mainServiceController',
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @type {Ember.Object[]}
|
|
|
|
+ */
|
|
|
|
+ content: function () {
|
|
|
|
+ if (!App.router.get('clusterController.isLoaded')) {
|
|
return [];
|
|
return [];
|
|
}
|
|
}
|
|
return App.Service.find();
|
|
return App.Service.find();
|
|
}.property('App.router.clusterController.isLoaded').volatile(),
|
|
}.property('App.router.clusterController.isLoaded').volatile(),
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Current cluster
|
|
|
|
+ * @type {Ember.Object}
|
|
|
|
+ */
|
|
cluster: function () {
|
|
cluster: function () {
|
|
if (!App.router.get('clusterController.isLoaded')) {
|
|
if (!App.router.get('clusterController.isLoaded')) {
|
|
return null;
|
|
return null;
|
|
@@ -34,66 +43,99 @@ App.MainServiceController = Em.ArrayController.extend({
|
|
return App.Cluster.find().objectAt(0);
|
|
return App.Cluster.find().objectAt(0);
|
|
}.property('App.router.clusterController.isLoaded'),
|
|
}.property('App.router.clusterController.isLoaded'),
|
|
|
|
|
|
- isAllServicesInstalled: function() {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Check if all services are installed
|
|
|
|
+ * true - all installed, false - not all
|
|
|
|
+ * @type {bool}
|
|
|
|
+ */
|
|
|
|
+ isAllServicesInstalled: function () {
|
|
if (!this.get('content.content')) return false;
|
|
if (!this.get('content.content')) return false;
|
|
-
|
|
|
|
var availableServices = App.StackService.find().mapProperty('serviceName');
|
|
var availableServices = App.StackService.find().mapProperty('serviceName');
|
|
- if (!App.supports.hue) {
|
|
|
|
|
|
+ if (!App.get('supports.hue')) {
|
|
availableServices = availableServices.without('HUE');
|
|
availableServices = availableServices.without('HUE');
|
|
}
|
|
}
|
|
return this.get('content.content').length == availableServices.length;
|
|
return this.get('content.content').length == availableServices.length;
|
|
}.property('content.content.@each', 'content.content.length'),
|
|
}.property('content.content.@each', 'content.content.length'),
|
|
|
|
|
|
- isStartAllDisabled: function(){
|
|
|
|
- if(this.get('isStartStopAllClicked') == true) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Should "Start All"-button be disabled
|
|
|
|
+ * @type {bool}
|
|
|
|
+ */
|
|
|
|
+ isStartAllDisabled: function () {
|
|
|
|
+ if (this.get('isStartStopAllClicked') == true) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- var stoppedServices = this.get('content').filter(function(_service){
|
|
|
|
|
|
+ var stoppedServices = this.get('content').filter(function (_service) {
|
|
return (_service.get('healthStatus') === 'red' && !App.get('services.clientOnly').contains(_service.get('serviceName')));
|
|
return (_service.get('healthStatus') === 'red' && !App.get('services.clientOnly').contains(_service.get('serviceName')));
|
|
});
|
|
});
|
|
return (stoppedServices.length === 0); // all green status
|
|
return (stoppedServices.length === 0); // all green status
|
|
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
|
|
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
|
|
- isStopAllDisabled: function(){
|
|
|
|
- if(this.get('isStartStopAllClicked') == true) {
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Should "Stop All"-button be disabled
|
|
|
|
+ * @type {bool}
|
|
|
|
+ */
|
|
|
|
+ isStopAllDisabled: function () {
|
|
|
|
+ if (this.get('isStartStopAllClicked') == true) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- var startedServiceLength = this.get('content').filterProperty('healthStatus','green').length;
|
|
|
|
|
|
+ var startedServiceLength = this.get('content').filterProperty('healthStatus', 'green').length;
|
|
return (startedServiceLength === 0);
|
|
return (startedServiceLength === 0);
|
|
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
|
|
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
|
|
- isStartStopAllClicked: function(){
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @type {bool}
|
|
|
|
+ */
|
|
|
|
+ isStartStopAllClicked: function () {
|
|
return (App.router.get('backgroundOperationsController').get('allOperationsCount') !== 0);
|
|
return (App.router.get('backgroundOperationsController').get('allOperationsCount') !== 0);
|
|
}.property('App.router.backgroundOperationsController.allOperationsCount'),
|
|
}.property('App.router.backgroundOperationsController.allOperationsCount'),
|
|
|
|
|
|
/**
|
|
/**
|
|
- * callback for <code>start all service</code> button
|
|
|
|
|
|
+ * Callback for <code>start all service</code> button
|
|
|
|
+ * @return {App.ModalPopup|null}
|
|
|
|
+ * @method startAllService
|
|
*/
|
|
*/
|
|
- startAllService: function(event){
|
|
|
|
- if ($(event.target).hasClass('disabled') || $(event.target.parentElement).hasClass('disabled')) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- var self = this;
|
|
|
|
- App.showConfirmationFeedBackPopup(function(query) {
|
|
|
|
- self.allServicesCall('STARTED', query);
|
|
|
|
- });
|
|
|
|
|
|
+ startAllService: function (event) {
|
|
|
|
+ return this.startStopAllService(event, 'STARTED');
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Callback for <code>stop all service</code> button
|
|
|
|
+ * @return {App.ModalPopup|null}
|
|
|
|
+ * @method stopAllService
|
|
|
|
+ */
|
|
|
|
+ stopAllService: function (event) {
|
|
|
|
+ return this.startStopAllService(event, 'INSTALLED');
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * callback for <code>stop all service</code> button
|
|
|
|
|
|
+ * Common method for "start-all", "stop-all" calls
|
|
|
|
+ * @param {object} event
|
|
|
|
+ * @param {string} state 'STARTED|INSTALLED'
|
|
|
|
+ * @returns {App.ModalPopup|null}
|
|
|
|
+ * @method startStopAllService
|
|
*/
|
|
*/
|
|
- stopAllService: function(event){
|
|
|
|
|
|
+ startStopAllService: function(event, state) {
|
|
if ($(event.target).hasClass('disabled') || $(event.target.parentElement).hasClass('disabled')) {
|
|
if ($(event.target).hasClass('disabled') || $(event.target.parentElement).hasClass('disabled')) {
|
|
- return;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
var self = this;
|
|
var self = this;
|
|
- App.showConfirmationFeedBackPopup(function(query) {
|
|
|
|
- self.allServicesCall('INSTALLED', query);
|
|
|
|
|
|
+ return App.showConfirmationFeedBackPopup(function (query) {
|
|
|
|
+ self.allServicesCall(state, query);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- allServicesCall: function(state, query) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Do request to server for "start|stop" all services
|
|
|
|
+ * @param {string} state "STARTED|INSTALLED"
|
|
|
|
+ * @param {object} query
|
|
|
|
+ * @method allServicesCall
|
|
|
|
+ * @return {$.ajax}
|
|
|
|
+ */
|
|
|
|
+ allServicesCall: function (state, query) {
|
|
var context = (state == 'INSTALLED') ? App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES :
|
|
var context = (state == 'INSTALLED') ? App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES :
|
|
- App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES
|
|
|
|
- App.ajax.send({
|
|
|
|
|
|
+ App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES;
|
|
|
|
+ return App.ajax.send({
|
|
name: 'common.services.update',
|
|
name: 'common.services.update',
|
|
sender: this,
|
|
sender: this,
|
|
data: {
|
|
data: {
|
|
@@ -108,12 +150,15 @@ App.MainServiceController = Em.ArrayController.extend({
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- allServicesCallSuccessCallback: function(data, xhr, params) {
|
|
|
|
- console.log("TRACE: Start/Stop all service -> In success function for the start/stop all Service call");
|
|
|
|
- console.log("TRACE: Start/Stop all service -> value of the received data is: " + data);
|
|
|
|
- var requestId = data.Requests.id;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Success-callback for all-services request
|
|
|
|
+ * @param {object} data
|
|
|
|
+ * @param {object} xhr
|
|
|
|
+ * @param {object} params
|
|
|
|
+ * @method allServicesCallSuccessCallback
|
|
|
|
+ */
|
|
|
|
+ allServicesCallSuccessCallback: function (data, xhr, params) {
|
|
params.query.set('status', 'SUCCESS');
|
|
params.query.set('status', 'SUCCESS');
|
|
- console.log('requestId is: ' + requestId);
|
|
|
|
|
|
|
|
// load data (if we need to show this background operations popup) from persist
|
|
// load data (if we need to show this background operations popup) from persist
|
|
App.router.get('applicationController').dataLoading().done(function (initValue) {
|
|
App.router.get('applicationController').dataLoading().done(function (initValue) {
|
|
@@ -122,12 +167,25 @@ App.MainServiceController = Em.ArrayController.extend({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- allServicesCallErrorCallback: function(request, ajaxOptions, error, opt, params) {
|
|
|
|
- console.log("ERROR");
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Error-callback for all-services request
|
|
|
|
+ * @param {object} request
|
|
|
|
+ * @param {object} ajaxOptions
|
|
|
|
+ * @param {string} error
|
|
|
|
+ * @param {object} opt
|
|
|
|
+ * @param {object} params
|
|
|
|
+ * @method allServicesCallErrorCallback
|
|
|
|
+ */
|
|
|
|
+ allServicesCallErrorCallback: function (request, ajaxOptions, error, opt, params) {
|
|
params.query.set('status', 'FAIL');
|
|
params.query.set('status', 'FAIL');
|
|
},
|
|
},
|
|
|
|
|
|
- gotoAddService: function() {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * "Add-service"-click handler
|
|
|
|
+ * @method gotoAddService
|
|
|
|
+ */
|
|
|
|
+ gotoAddService: function () {
|
|
if (this.get('isAllServicesInstalled')) {
|
|
if (this.get('isAllServicesInstalled')) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|