Skip to content

Commit

Permalink
Merge pull request #1458 from SCADA-LTS/feature/#1447_logging_type_se…
Browse files Browse the repository at this point in the history
…ttings

Feature/#1447 logging type settings
  • Loading branch information
SoftQ authored Dec 29, 2020
2 parents 29b3f62 + 20eb4b3 commit 5943716
Show file tree
Hide file tree
Showing 16 changed files with 495 additions and 93 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ branches:
only:
- "/^develop.*$/"
- "/^master.*$/"
- "/^feature/#1447.*$/"
- "/^release/2.4.0.*$/"
- "/^feature/#1464.*$/"
- "/^feature/#1438.*$/"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,6 @@
context('Create Datasource', () => {

function createVirtualDataSource(name) {
cy.visit('data_sources.shtm');
cy.get("#dataSourceTypes").select('Virtual Data Source').should('have.value', '1');
cy.get('img.ptr[src="images/icon_ds_add.png"]').first().click();
cy.get('.smallTitle').should('contain', 'Virtual data source properties')
cy.get('#dataSourceName').type(name)
cy.get('#updatePeriods').type("{backspace}1").should('have.value', '1');
cy.get('img.ptr[src="images/save.png"]').first().click();
cy.get('#dataSourceMessage').should('contain', 'Data source has been saved')
// cy.debug('DataSource created!')
}
import {createVirtualDataSource, addVirtualDataPoint, login} from '../../utils/utils';

/**
*
* @param {*} name DataPoint name
* @param {*} type [Multistate = 2| Numeric = 3]
*/
function addVirtualDataPoint(name, type) {
cy.get('img.ptr[src="images/icon_comp_add.png"]').click();
cy.get('input#name').type(name)
cy.get('input#settable').click()
cy.get('select#dataTypeId').select(type)
if (type === '3') {
cy.wait(500)
cy.get('select#changeTypeId').select('Random')
cy.get('#divCH6').children().first().next().find('input').type("{backspace}20")
cy.get('#divCH6').children().first().next().next().find('input').type("2")
} else if (type === '2') {
cy.get('select#changeTypeId').select('8')
cy.get('input#randomMultistate').type("1")
for (let x = 1; x <= 5; x = x + 1) {
cy.get('img.ptr[src="images/add.png"]').click()
}
cy.get('select#randomMultistateChange.startValue').select('1')
}
cy.get('img.ptr#pointSaveImg').click()
cy.get('#pointMessage').should('contain', 'Point details saved')
// cy.debug(`DataPoint ${name} created!`)
}

function login(username, password) {
cy.visit('/login.htm')
cy.get('input#username').type(username)
cy.get('input#password').type(password)
cy.get('.login-button > input').click()
}
context('Create Datasource', () => {

before(() => {
login("admin", "admin")
Expand All @@ -58,7 +13,7 @@ context('Create Datasource', () => {
cy.visit('/data_sources.shtm')
createVirtualDataSource(`Test-${new Date().toISOString()}`)
for (let i = 0; i < count; i = i + 1) {
addVirtualDataPoint(`0${i}-Test`, '3')
addVirtualDataPoint(`0${i}-Test`, 'Numeric')
}
cy.get('#pointsList').children().should('have.length', count)
cy.get('img.ptr#enableAllImg').click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { Context } = require("ag-grid-community");
import {createVirtualDataSource, addVirtualDataPoint} from '../../utils/utils';

context('Test System Settings Vue.JS page', () => {

Expand Down Expand Up @@ -60,4 +61,59 @@ context('Test System Settings Vue.JS page', () => {
})
})

})

context('Test System Settings Components functionality', () => {

beforeEach(() => {
cy.clearCookies()
cy.visit('/login.htm')
cy.get('input#username').type("admin").should('have.value', 'admin')
cy.get('input#password').type("admin").should('have.value', 'admin')
cy.get('.login-button > input').click()
cy.location('pathname').should('include', 'watch_list')
})

describe("Test Default Logging Type Setting", () => {

beforeEach(() => {
cy.visit('app.shtm#/system-settings')
})

it("Should be visible", () => {
cy.get('#default-logging-type-setting').should('be.visible');
cy.get('#default-logging-type-setting > .align-items-center > .col-xs-12').should('contain', 'Default Data Point logging type');
})

it("Save do not log value", () => {
let name = `Test_SystemSettings-${new Date().getTime()}`;
name = name.substring(0,30);
cy.get('.col-xs-12 > .form-control').select("Do not log");
cy.get('.floated-right').click();
cy.get('.btn-success').click();

createVirtualDataSource(name);
addVirtualDataPoint(`DP_${name}`, "Numeric")

cy.get(':nth-child(5) > img[src="images/icon_comp_edit.png"]').click();
cy.get('select#loggingType option[selected="selected"]').should('contain', 'Do not log');

})

it("Save do not log value", () => {
let name = `Test_SystemSettings2-${new Date().getTime()}`;
name = name.substring(0,30);
cy.get('.col-xs-12 > .form-control').select("When point value changes");
cy.get('.floated-right').click();
cy.get('.btn-success').click();

createVirtualDataSource(name);
addVirtualDataPoint(`DP_${name}`, "Numeric")

cy.get(':nth-child(5) > img[src="images/icon_comp_edit.png"]').click();
cy.get('select#loggingType option[selected="selected"]').should('contain', 'When point value changes');

})

})
})
46 changes: 46 additions & 0 deletions scadalts-ui/cypress/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export function createVirtualDataSource(name) {
cy.visit('data_sources.shtm');
cy.get("#dataSourceTypes").select('Virtual Data Source').should('have.value', '1');
cy.get('img.ptr[src="images/icon_ds_add.png"]').first().click();
cy.get('.smallTitle').should('contain', 'Virtual data source properties')
cy.get('#dataSourceName').type(name)
cy.get('#updatePeriods').type("{backspace}1").should('have.value', '1');
cy.get('img.ptr[src="images/save.png"]').first().click();
cy.get('#dataSourceMessage').should('contain', 'Data source has been saved')
// cy.debug('DataSource created!')
}

/**
*
* @param {*} name DataPoint name
* @param {*} type [Multistate = 2| Numeric = 3]
*/
export function addVirtualDataPoint(name, type) {
cy.get('img.ptr[src="images/icon_comp_add.png"]').click();
cy.get('input#name').type(name)
cy.get('input#settable').click()
cy.get('select#dataTypeId').select(type)
if (type === 'Numeric') {
cy.wait(500)
cy.get('select#changeTypeId').select('Random')
cy.get('#divCH6').children().first().next().find('input').type("{backspace}20")
cy.get('#divCH6').children().first().next().next().find('input').type("2")
} else if (type === 'Multistate') {
cy.get('select#changeTypeId').select('8')
cy.get('input#randomMultistate').type("1")
for (let x = 1; x <= 5; x = x + 1) {
cy.get('img.ptr[src="images/add.png"]').click()
}
cy.get('select#randomMultistateChange.startValue').select('1')
}
cy.get('img.ptr#pointSaveImg').click()
cy.get('#pointMessage').should('contain', 'Point details saved')
// cy.debug(`DataPoint ${name} created!`)
}

export function login(username, password) {
cy.visit('/login.htm')
cy.get('input#username').type(username)
cy.get('input#password').type(password)
cy.get('.login-button > input').click()
}
19 changes: 19 additions & 0 deletions scadalts-ui/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Scada-LTS User Interface
## Vue.js subproject for Views and Components

## Description

User Interface subproject to display ScadaLTS content.

## Usage

- To start a developmnent server type inside this directory: `npm run-script serve`
- To run unit test type: `npm run-script test:unit`
- To run E2E cypress tests type: `npm run-script test:e2e`
- To run Cypress testing framework type: `npm run-script cypress`

## Creators
Developers from Scada-LTS project:
- @grzesiekb
- @radek2s

10 changes: 9 additions & 1 deletion scadalts-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"systemsettings.scadaconf.doNotCreateEventsForEmailError": "Do not create Events for email error",
"systemsettings.scadaconf.httpRetriverSleepCheckToReactivationWhenStart": "HTTP Retriver - sleep check to reactivation when start",
"systemsettings.scadaconf.httpRetriverDoNotAllowEnableReactivation": "HTTP Retriver - do not allow to enable reactivation",
"systemsettings.loggingtype.title": "Default Data Point logging type",
"systemsettings.loggingtype.value": "Logging type:",
"systemsettings.notification.fail": "Something went wrong!",
"systemsettings.notification.purgedata": "Successfully cleared data!",
"systemsettings.notification.send.email": "Email has been sent to ",
Expand All @@ -142,6 +144,7 @@
"systemsettings.notification.save.systemevent": "System Event Types settings saved!",
"systemsettings.notification.save.auditevent": "Audit Event Types settings saved!",
"systemsettings.notification.save.database": "Database changed!",
"systemsettings.notification.save.logging": "Default logging type saved!",
"systemsettings.alert.purgedata.title": "Purge data?",
"systemsettings.alert.purgedata": "This operation will permanently delete datapoint history content. Continue?",
"systemsettings.tooltip.derbydatabase": "Derby database is unavailable in this ScadaLTS version!",
Expand Down Expand Up @@ -181,5 +184,10 @@
"timeperiod.days": "day(s)",
"timeperiod.weeks": "week(s)",
"timeperiod.months": "month(s)",
"timeperiod.years": "year(s)"
"timeperiod.years": "year(s)",
"pointEdit.logging.type.change": "When point value changes",
"pointEdit.logging.type.all": "All data",
"pointEdit.logging.type.never": "Do not log",
"pointEdit.logging.type.interval": "Interval",
"pointEdit.logging.type.tsChange": "When point timestamp changes"
}
35 changes: 34 additions & 1 deletion scadalts-ui/src/store/systemSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const storeSystemSettings = {
miscSettings: undefined,
systemStartupTime: undefined,
schemaVersion: undefined,
scadaConfig: undefined
scadaConfig: undefined,
defaultLoggingType: undefined,
},
mutations: {
setDatabaseType(state, databaseType) {
Expand Down Expand Up @@ -54,6 +55,9 @@ const storeSystemSettings = {
},
setScadaConfig(state, scadaConfig) {
state.scadaConfig = scadaConfig;
},
setDefaultLoggingType(state, defaultLoggingType) {
state.defaultLoggingType = defaultLoggingType;
}
},
actions: {
Expand Down Expand Up @@ -350,6 +354,35 @@ const storeSystemSettings = {
})
})
},
saveDefaultLoggingType(context) {
return new Promise((resolve, reject) => {
axios.post(`${context.state.systemSettingsApiUrl}/saveDefaultLoggingType/${context.state.defaultLoggingType}`,
{ timeout: 5000, useCredentials: true, credentials: 'same-origin' }).then(response => {
if (response.status === 200) {
resolve(true)
} else {
reject(false)
}
}).catch(err => {
reject(err)
})
})
},
getDefaultLoggingType(context) {
return new Promise((resolve, reject) => {
axios.get(`${context.state.systemSettingsApiUrl}/getDefaultLoggingType`, context.state.requestOptions).then(response => {
if (response.status === 200) {
console.debug(response.data);
context.commit('setDefaultLoggingType', response.data.defaultLoggingType)
resolve(response.data.defaultLoggingType)
}
reject(false)
}).catch(err => {
console.error(err);
reject(false)
})
})
},
configurationEqual(ctx, objects) {
return new Promise((resolve, reject) => {
const keys1 = Object.keys(objects.object1);
Expand Down
Loading

0 comments on commit 5943716

Please sign in to comment.