Skip to content

Commit

Permalink
incorporate PR comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-c8y committed Mar 27, 2024
1 parent 489c50b commit f0627e2
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 50 deletions.
58 changes: 29 additions & 29 deletions asset-properties-widget/common/asset-property-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const defaultProperty = [
type: 'string',
active: true,
isEditable: true,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: { properties: { id: { type: 'string', label: 'ID' } } },
Expand All @@ -17,7 +17,7 @@ export const defaultProperty = [
type: 'string',
active: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -28,7 +28,7 @@ export const defaultProperty = [
type: 'string',
active: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -38,7 +38,7 @@ export const defaultProperty = [
label: 'Owner',
type: 'string',
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -48,7 +48,7 @@ export const defaultProperty = [
label: 'Last updated',
type: 'string',
isEditable: false,
isExistingProperty: true
isStandardProperty: true
}
];

Expand All @@ -69,7 +69,7 @@ export const computedPropertiesBaseObject = [
config: { type: '' },
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -87,7 +87,7 @@ export const computedPropertiesBaseObject = [
config: { type: '' },
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -105,7 +105,7 @@ export const computedPropertiesBaseObject = [
config: { type: '' },
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -123,7 +123,7 @@ export const computedPropertiesBaseObject = [
config: { type: '' },
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -140,7 +140,7 @@ export const computedPropertiesBaseObject = [
config: { dp: [], isValid: null, resultTypes: 1 },
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -156,7 +156,7 @@ export const computedPropertiesBaseObject = [
type: 'number',
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -172,7 +172,7 @@ export const computedPropertiesBaseObject = [
type: 'number',
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -189,7 +189,7 @@ export const computedPropertiesBaseObject = [
type: 'string',
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -205,7 +205,7 @@ export const computedPropertiesBaseObject = [
type: 'string',
computed: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
}
];

Expand All @@ -214,7 +214,7 @@ export const devicePropertiesBaseObject = [
label: 'Active alarms status',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_ActiveAlarmsStatus',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -248,7 +248,7 @@ export const devicePropertiesBaseObject = [
label: 'Address',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Address',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -290,7 +290,7 @@ export const devicePropertiesBaseObject = [
label: 'Agent',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Agent',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -324,7 +324,7 @@ export const devicePropertiesBaseObject = [
label: 'Availability',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Availability',
c8y_JsonSchema: {
properties: {
Expand All @@ -351,7 +351,7 @@ export const devicePropertiesBaseObject = [
label: 'Connection',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Connection',
c8y_JsonSchema: {
properties: {
Expand All @@ -373,7 +373,7 @@ export const devicePropertiesBaseObject = [
label: 'Communication mode',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_CommunicationMode',
c8y_JsonSchema: {
properties: {
Expand All @@ -395,7 +395,7 @@ export const devicePropertiesBaseObject = [
label: 'Firmware',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Firmware',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -429,7 +429,7 @@ export const devicePropertiesBaseObject = [
label: 'Hardware',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Hardware',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -459,7 +459,7 @@ export const devicePropertiesBaseObject = [
label: 'LPWAN device',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_LpwanDevice',
c8y_JsonSchema: {
properties: {
Expand All @@ -481,7 +481,7 @@ export const devicePropertiesBaseObject = [
label: 'Mobile',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Mobile',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -577,7 +577,7 @@ export const devicePropertiesBaseObject = [
label: 'Notes',
type: 'string',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
c8y_JsonSchema: {
properties: {
c8y_Notes: {
Expand All @@ -594,7 +594,7 @@ export const devicePropertiesBaseObject = [
label: 'Position',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Position',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -624,7 +624,7 @@ export const devicePropertiesBaseObject = [
label: 'Required availability',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_RequiredAvailability',
c8y_JsonSchema: {
properties: {
Expand All @@ -650,7 +650,7 @@ export const devicePropertiesBaseObject = [
label: 'Software',
type: 'object',
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Software',
c8y_JsonSchema: {
properties: {
Expand Down Expand Up @@ -680,7 +680,7 @@ export const devicePropertiesBaseObject = [
label: 'Network',
type: 'object',
isEditable: true,
isExistingProperty: true,
isStandardProperty: true,
name: 'c8y_Network',
c8y_JsonSchema: {
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('AssetPropertiesConfigComponent', () => {
type: 'string',
active: true,
isEditable: true,
isExistingProperty: true
isStandardProperty: true
},
{
c8y_JsonSchema: {
Expand All @@ -33,7 +33,7 @@ describe('AssetPropertiesConfigComponent', () => {
type: 'string',
active: true,
isEditable: false,
isExistingProperty: true
isStandardProperty: true
}
];
asset = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ describe('AssetPropertiesViewComponent', () => {
config: { id: '8005633676046595', type: 'test' },
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand All @@ -484,7 +484,7 @@ describe('AssetPropertiesViewComponent', () => {
config: { id: '8005633676046596', type: 'test' },
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand All @@ -503,7 +503,7 @@ describe('AssetPropertiesViewComponent', () => {
config: { id: '8005633676046597', type: 'test' },
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand All @@ -522,7 +522,7 @@ describe('AssetPropertiesViewComponent', () => {
config: { id: '8005633676046598', type: 'test' },
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand Down Expand Up @@ -558,7 +558,7 @@ describe('AssetPropertiesViewComponent', () => {
},
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand All @@ -576,7 +576,7 @@ describe('AssetPropertiesViewComponent', () => {
type: 'string',
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
},
{
Expand All @@ -593,7 +593,7 @@ describe('AssetPropertiesViewComponent', () => {
type: 'string',
computed: true,
isEditable: false,
isExistingProperty: true,
isStandardProperty: true,
active: true
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class AssetPropertiesViewComponent implements OnInit {
@Input() config: any;
computedPropertyObject: ComputedPropertyObject;
isLoading = true;
dateTimeWithTimeZone = 'yyyy-MM-ddThh:mm:ssZZZZZ';

constructor(
protected inventoryService: InventoryService,
Expand All @@ -52,7 +53,7 @@ export class AssetPropertiesViewComponent implements OnInit {
);
this.properties = this.config.properties.filter(property => {
if (
property.isExistingProperty ||
property.isStandardProperty ||
(this.customProperties.length != 0 &&
this.customProperties.find(prop => prop.id === property.id)) ||
this.validateComplexProperty(property)
Expand Down Expand Up @@ -117,7 +118,7 @@ export class AssetPropertiesViewComponent implements OnInit {
Math.max(
...Array.from(dateSet).map(dateString => new Date(dateString).getTime())
),
'yyyy-MM-ddThh:mm:ssZZZZZ'
this.dateTimeWithTimeZone
);
this.computedPropertyObject = {
...this.computedPropertyObject,
Expand All @@ -143,11 +144,12 @@ export class AssetPropertiesViewComponent implements OnInit {
}

async getAlarmCount(device: IManagedObject, property: IManagedObject, dateFrom: string) {
// By incrementing the dateTo parameter by 1 day, this code aims to mitigate timezone-related inconsistencies.
const filters = {
dateFrom: dateFrom,
dateTo: this.datePipe.transform(
new Date().setDate(new Date().getDate() + 1),
'yyyy-MM-ddThh:mm:ssZZZZZ'
this.dateTimeWithTimeZone
),
source: device.id,
pageSize: 2000,
Expand All @@ -173,11 +175,12 @@ export class AssetPropertiesViewComponent implements OnInit {
}

async getEventCount(device: IManagedObject, property: IManagedObject, dateFrom: string) {
// By incrementing the dateTo parameter by 1 day, this code aims to mitigate timezone-related inconsistencies.
const filters = {
dateFrom: dateFrom,
dateTo: this.datePipe.transform(
new Date().setDate(new Date().getDate() + 1),
'yyyy-MM-ddThh:mm:ssZZZZZ'
this.dateTimeWithTimeZone
),
source: device.id,
pageSize: 2000,
Expand Down
Loading

0 comments on commit f0627e2

Please sign in to comment.