Skip to content
Snippets Groups Projects
Verified Commit f4fb7959 authored by Alexander-Krause's avatar Alexander-Krause
Browse files

towards fieldings rest definition

parent 3033c373
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,9 @@ import layout from '../templates/components/agent-details';
import { inject as service } from "@ember/service";
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
// Declare globals
/*global $*/
export default Component.extend(AlertifyHandler, {
layout,
......
......@@ -3,6 +3,9 @@ import layout from '../templates/components/procezz-details';
import { inject as service } from "@ember/service";
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
// Declare globals
/*global $*/
export default Component.extend(AlertifyHandler, {
layout,
......@@ -30,7 +33,7 @@ export default Component.extend(AlertifyHandler, {
this._super(...arguments);
// Save the monitoring flag on component setup
// We can therefore use it to show a message for the user
// (handleMessageForUser)
// (showMessageForUser)
const monitoredFlag = this.get('procezz.monitoredFlag');
this.set('monitoredFlag', monitoredFlag);
},
......@@ -45,7 +48,7 @@ export default Component.extend(AlertifyHandler, {
this.get('procezz').save({include: 'agent'}).then(() => {
self.set('showSpinner', false);
self.handleMessageForUser(false);
self.showMessageForUser(self.buildUpdateMessageForUser(true));
})
.catch((errorObject) => {
......@@ -58,7 +61,7 @@ export default Component.extend(AlertifyHandler, {
self.errorHandling(errorObject);
});
} else {
self.handleMessageForUser(false);
self.showMessageForUser(self.buildUpdateMessageForUser(false));
}
},
......@@ -66,17 +69,45 @@ export default Component.extend(AlertifyHandler, {
const self = this;
// this attribute will trigger the agent
// to restart the procezz
this.set('procezz.restart', true);
this.set('procezz.stopped', false);
this.set('showSpinner', true);
this.get('procezz').save({
include: 'agent'
})
.then(() => {
self.set('showSpinner', false);
self.showMessageForUser(self.buildRestartMessageForUser());
})
.catch((errorObject) => {
self.get('procezz').rollbackAttributes();
// closure action from discovery controller
self.errorHandling(errorObject);
});
},
stopProcezz() {
const self = this;
// this attribute will trigger the agent
// to stop the procezz
this.set('procezz.stopped', true);
this.set('procezz.restart', false);
this.set('showSpinner', true);
this.get('procezz').save({
include: 'agent',
adapterOptions: {
pathExtension: 'restart'
}
include: 'agent'
})
.then(() => {
self.set('showSpinner', false);
self.handleMessageForUser(true);
self.showMessageForUser("Procezz was stopped.");
})
.catch((errorObject) => {
self.get('procezz').rollbackAttributes();
......@@ -87,29 +118,42 @@ export default Component.extend(AlertifyHandler, {
}
},
handleMessageForUser(wasRestarted) {
let defaultMessage = "Procezz updated.";
let monitoringMessageForUser = "";
buildRestartMessageForUser() {
const mainMessage = "Procezz restarted.";
let monitoringMessage = "";
if(wasRestarted) {
defaultMessage = "Procezz restarted.";
const monitoredFlag = this.get('procezz').get('monitoredFlag');
const oldMonitoredFlag = this.get('monitoredFlag');
const monitoredFlag = this.get('procezz').get('monitoredFlag');
const oldMonitoredFlag = this.get('monitoredFlag');
if(monitoredFlag !== oldMonitoredFlag && monitoredFlag) {
// was set from off to on
monitoringMessage = "Monitoring was started.";
}
else if(monitoredFlag !== oldMonitoredFlag && !monitoredFlag) {
// was set from on to off
monitoringMessage = "Monitoring was stopped.";
}
if(monitoredFlag !== oldMonitoredFlag && monitoredFlag) {
// was set from off to on
monitoringMessageForUser = "Monitoring was started.";
}
else if(monitoredFlag !== oldMonitoredFlag && !monitoredFlag) {
// was set from on to off
monitoringMessageForUser = "Monitoring was stopped.";
}
return `${mainMessage} ${monitoringMessage}`;
},
buildUpdateMessageForUser(hasDirtyAttributes) {
let mainMessage = "No change detected.";
if(hasDirtyAttributes) {
mainMessage = "Procezz updated.";
}
return mainMessage;
},
showMessageForUser(message) {
this.set('monitoredFlag', this.get('procezz').get('monitoredFlag'));
this.showAlertifyMessageWithDuration(
`${defaultMessage} ${monitoringMessageForUser} Click on <b>Discovery</b> to go back.` ,4);
`${message} Click on <b>Discovery</b> to go back.`, 4);
}
});
......@@ -32,6 +32,9 @@ export default BaseModel.extend({
workingDirectory: attr("string"),
stopped: attr("boolean"),
restart: attr("boolean"),
aopContent: attr("string"),
kiekerConfigContent: attr("string"),
......
......@@ -19,7 +19,7 @@
<td>{{lastDiscoveryTimeAsDate}}</td>
</tr>
<tr>
<td><b>Name</b>{{help-tooltip title="Name attribute has a higher priority than IP:Port in all views. This attribute will also be considered for monitoring. If it's not filled, a monitored node will be named after the IP:Port attribute."}}</td>
<td><b>Name</b>{{help-tooltip title="Name attribute has a higher priority than IP:Port in all views. This attribute will also be considered for monitoring. If not filled, a monitored node will be named after the IP:Port attribute. While a procezz of this agent is monitored, changes to this attribute have no effect. Restart of process is necessary."}}</td>
<td>
{{input class="form-control" value=agent.name}}
</td>
......
......@@ -4,26 +4,26 @@
</div>
{{/if}}
<div class="text-center" style="margin-bottom: 5px;">
<button type="button" class="btn btn-success" {{action "saveAgent"}}>Save</button>
</div>
<div class="panel-group" id="accordion">
<div class="panel-group" id="accordion">
<!-- BEGIN collapse1 -->
<div class="panel panel-default">
<div data-toggle="collapse" data-parent="#accordion" data-target="#collapse1" class="panel-heading darker-accordion-header container-shadow" style="cursor:pointer">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
{{name-selector agent.ip agent.name}} - <b>General Information</b>
</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">
{{agent-details-tables/general-information agent=agent}}
</div>
<!-- BEGIN collapse1 -->
<div class="panel panel-default">
<div data-toggle="collapse" data-parent="#accordion" data-target="#collapse1" class="panel-heading darker-accordion-header container-shadow" style="cursor:pointer">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
{{name-selector agent.ip agent.name}} - <b>General Information</b>
</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">
{{agent-details-tables/general-information agent=agent}}
</div>
</div>
</div>
</div>
<div class="text-center" style="margin-bottom: 5px;">
<button type="button" class="btn btn-success" {{action "saveAgent"}}>Save</button>
</div>
\ No newline at end of file
......@@ -6,6 +6,14 @@
</tr>
</thead>
<tbody>
<tr>
<td><b>Is stopped?</b>{{help-tooltip title="Flag that indicates if the process is stopped."}}</td>
<td>
<div class="well well-sm container-word-wrap" style="margin-bottom: 0px;">
{{procezz.stopped}}
</div>
</td>
</tr>
<tr>
<td><b>Working Directory</b>{{help-tooltip title="Shows the file system directory of the process. Some processes don't contain the absolute path to their execution artifact. Therefore, this attribute might be a hint on how to start a process."}}</td>
<td>
......
......@@ -4,11 +4,6 @@
</div>
{{/if}}
<div style="margin-bottom: 5px;" class="button-box text-center">
<a class="btn btn-info" {{action "saveProcezz"}} role="button">Save</a>
<a class="btn btn-warning" {{action "restartProcezz"}} role="button">Restart</a>
</div>
<div class="panel-group" id="accordion">
<!-- BEGIN collapse1 -->
......@@ -58,4 +53,10 @@
</div>
</div>
</div>
</div>
<div style="margin-bottom: 5px;" class="button-box text-center">
<a class="btn btn-info" {{action "saveProcezz"}} role="button">Save</a>
<a class="btn btn-warning" {{action "restartProcezz"}} role="button">Restart</a>
<a class="btn btn-primary" {{action "stopProcezz"}} role="button">Stop</a>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment