Skip to content

Commit

Permalink
Merge pull request #744 from SCADA-LTS/feature_m/#727_Add_sleep_statu…
Browse files Browse the repository at this point in the history
…s_for_HttpRetriver_and_reactivation_of_datasource

#727 added sleep httpRetriver datasource
  • Loading branch information
grzesiekb authored Nov 8, 2018
2 parents 663a082 + 7347060 commit 16980e4
Show file tree
Hide file tree
Showing 33 changed files with 853 additions and 85 deletions.
176 changes: 176 additions & 0 deletions ScadaLTS-UI-1/src/components/form/SleepAndReactivationDS.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<template>
<div class="container move-top format_font">
<div class="panel panel-default col-ld-4, col-md-4, col-sm-6">
<div class="panel-body">
<div>
<btn-group aria-describedby="sleepHelp" style="display: inline">
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_STOP" v-model="reactivation">Stop</btn>
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_SLEEP" v-model="reactivation">Sleep</btn>
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_NONE" v-model="reactivation">None</btn>
</btn-group>
<small id="sleepHelp" class="form-text text-muted" style="margin:10px">It will disable the datasource
when the attempted connections fail and try reconnect according to the reactivity configuration</small>
</div>
<div v-if="reactivation=='sleep'" style="padding:0px; margin:30px" >
<table>
<tr>
<td>
<input v-model="reactivationValue" type="number" min="1" max="31" class="form-control number-width" style="display: inline"/>
</td>
<td>
<btn-group style="display: inline">
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_TIME_MIN" v-model="reactivationTimeType">Minute</btn>
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_TIME_HOUR" v-model="reactivationTimeType">Hour</btn>
<btn input-type="radio" :input-value="STR_REACTIVATION_TYPE_TIME_DAY" v-model="reactivationTimeType">Day</btn>
</btn-group>

</td>
</tr>
</table>
<div>
<p>time to next attempt to enable data source: {{timeToNextTryEnableDs | infoTime}}</p>
</div>
</div>
</div>
</div>
</div>
</template>

<script>
import axios from 'axios';
/**
* @author grzegorz.bylica@gmail.com
*
* Associated with class in java ReactivationDs.java
*/
export default {
data() {
return {
STR_REACTIVATION_TYPE_TIME_MIN: "min",
STR_REACTIVATION_TYPE_TIME_HOUR: "hour",
STR_REACTIVATION_TYPE_TIME_DAY: "day",
INT_REACTIVATION_TYPE_TIME_MIN: 0,
INT_REACTIVATION_TYPE_TIME_HOUR: 1,
INT_REACTIVATION_TYPE_TIME_DAY: 2,
STR_REACTIVATION_TYPE_NONE: "none",
STR_REACTIVATION_TYPE_SLEEP: "sleep",
STR_REACTIVATION_TYPE_STOP: "stop",
TIME_REFRESH: 1000,
//
reactivation: this.defaultReactivation(),
reactivationTimeType: this.defaultTimeType(),
reactivationTimeValue: this.defaultValue(),
idDs:0,
timeToNextTryEnableDs: 0
};
},
methods: {
defaultReactivation() {
return this.STR_REACTIVATION_TYPE_NONE
},
defaultTimeType() {
return this.STR_REACTIVATION_TYPE_TIME_MIN
},
defaultValue() {
return 1
},
checkWhenNextTryEnableDs() {
const apiCheckReactivation = `./api/check-reactivation/${this.idDs}`;
axios.get(apiCheckReactivation).then(response => {
this.timeToNextTryEnableDs = response.data;
}).catch(error => {
console.log(error);
});
}
},
created() {
// get from variable to communicate between old ui and new
if (editDSNewUI.reactivation.sleep) {
this.reactivation = this.STR_REACTIVATION_TYPE_SLEEP;
} else if (editDSNewUI.stop) {
this.reactivation = this.STR_REACTIVATION_TYPE_STOP;
} else {
this.reactivation = this.STR_REACTIVATION_TYPE_NONE;
}
if (editDSNewUI.reactivation.type == this.INT_REACTIVATION_TYPE_TIME_MIN) {
this.reactivationTimeType = this.STR_REACTIVATION_TYPE_TIME_MIN
} else if (editDSNewUI.reactivation.type == this.INT_REACTIVATION_TYPE_TIME_HOUR) {
this.reactivationTimeType = this.STR_REACTIVATION_TYPE_TIME_HOUR
} else if (editDSNewUI.reactivation.type == this.INT_REACTIVATION_TYPE_TIME_DAY) {
this.reactivationTimeType = this.STR_REACTIVATION_TYPE_TIME_DAY
}
this.reactivationValue = editDSNewUI.reactivation.value;
this.idDs = editDSNewUI.id;
setInterval(
function() {
this.checkWhenNextTryEnableDs();
}.bind(this),
this.TIME_REFRESH
);
},
watch: {
reactivationType() {
if (this.reactivationTimeType == this.STR_REACTIVATION_TYPE_TIME_MIN) {
editDSNewUI.reactivation.type = this.INT_REACTIVATION_TYPE_TIME_MIN
} else if (this.reactivationType == this.STR_REACTIVATION_TYPE_TIME_HOUR) {
editDSNewUI.reactivation.type = this.INT_REACTIVATION_TYPE_TIME_HOUR;
} else if (this.reactivationType == this.STR_REACTIVATION_TYPE_TIME_DAY) {
editDSNewUI.reactivation.type = this.INT_REACTIVATION_TYPE_TIME_DAY;
}
},
reactivation() {
if (this.reactivation == this.STR_REACTIVATION_TYPE_SLEEP) {
editDSNewUI.stop = false;
editDSNewUI.reactivation.sleep = true;
} else if (this.reactivation == this.STR_REACTIVATION_TYPE_STOP) {
editDSNewUI.stop = true;
editDSNewUI.reactivation.sleep = false;
} else {
editDSNewUI.stop = false;
editDSNewUI.reactivation.sleep = false;
}
},
reactivationValue() {
editDSNewUI.reactivation.value = this.reactivationValue;
}
},
filters: {
infoTime: function (date) {
var seconds = parseInt(date/1000);
var days = Math.floor(seconds / (3600*24));
seconds -= days*3600*24;
var hrs = Math.floor(seconds / 3600);
seconds -= hrs*3600;
var mnts = Math.floor(seconds / 60);
seconds -= mnts*60;
return days+" days, "+hrs+" Hrs, "+mnts+" Minutes, "+seconds+" Seconds";
}
},
};
</script>

<style scoped>
.number-width {
width:70px;
}
.move-top {
top:-170px;
}
.format_font {
font-size:12px
}
</style>
5 changes: 4 additions & 1 deletion ScadaLTS-UI-1/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Test from './components/Test'
import IsAlive from './components/IsAlive'
import ExportImportPointHierarchy from './components/ExportImportPointHierarchy'
import SimpleComponentSVG from './components/SimpleComponentSVG'

import SleepAndReactivationDS from './components/form/SleepAndReactivationDS'
import router from './router'
import VJsoneditor from 'vue-jsoneditor';
import Vuetify from 'vuetify';
Expand Down Expand Up @@ -52,7 +54,8 @@ new Vue({
el: '#app',
components: {
"simple-component-svg": SimpleComponentSVG,
"export-import-ph": ExportImportPointHierarchy
"export-import-ph": ExportImportPointHierarchy,
"sleep-reactivation-ds": SleepAndReactivationDS,
}
})

4 changes: 4 additions & 0 deletions WebContent/WEB-INF/classes/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,10 @@ ds.state.importChangeEnableStateDs=During the import, the on/off status of DataS
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
ds.state.startSleep=Data source has been started after sleeped



6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3165,4 +3165,8 @@ ds.state.apiChangeEnableStateDs=\ With the use of the API, the on/off status of
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3090,4 +3090,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
4 changes: 4 additions & 0 deletions WebContent/WEB-INF/classes/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2912,3 +2912,7 @@ ds.state.importChangeEnableStateDs=During the import, the on/off status of DataS
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3166,4 +3166,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3176,4 +3176,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2716,4 +2716,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3078,4 +3078,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
4 changes: 4 additions & 0 deletions WebContent/WEB-INF/classes/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3157,3 +3157,7 @@ ds.state.importChangeEnableStateDs=During the import, the on/off status of DataS
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3127,4 +3127,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
6 changes: 5 additions & 1 deletion WebContent/WEB-INF/classes/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2030,4 +2030,8 @@ ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of Da
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
dsList.statusDescribe=Status description
event.reactivation.sleep=Data source has been sleeped
event.ds.describe={1}
ds.state.startSleep=Data source has been started after sleeped
ds.state.sleep=Data source has been sleeped after several attempted connections had failed
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/jsp/dataSourceEdit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
rowCreator: function(options) {
var tr = document.createElement("tr");
tr.mangoId = "p"+ options.rowData.id;
tr.className = "row"+ (options.rowIndex % 2 == 0 ? "" : "Alt");
tr.className = ""+ (options.rowIndex % 2 == 0 ? "" : "rowAlt");
return tr;
},
cellCreator: function(options) {
Expand Down
Loading

0 comments on commit 16980e4

Please sign in to comment.