Skip to content

Commit

Permalink
migrate to new version 1018
Browse files Browse the repository at this point in the history
  • Loading branch information
sagIoTPower committed Mar 28, 2024
1 parent d98e0ca commit d9da5c1
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 27 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/check-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check push requests

on:
workflow_dispatch:
push:
# Sequence of patterns matched against refs/tags
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- '*'

permissions:
contents: write
issues: write
pull-requests: write

jobs:
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4

- name: Check spelling
uses: crate-ci/typos@master
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Cumulocity widget plugin

This is the Cumulocity data capture widget. For a set of configured datapoint measurements can be manually created.
The configuration page allows to select the data points and if audit information about the user should be added to the measurements.
This is a Cumulocity widget for data capturing. For a set of configured data points measurements can be manually created.
The configuration page allows to select the data points and if audit information about the user should be added to the audit log.

<p align="center">
<img src="assets/widget-datacapture-pr.png" style="width: 70%;" />
</p>
<br/>

----------
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
Binary file modified assets/widget-datacapture-pr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "cumulocity-datacapture-widget",
"version": "0.0.3",
"version": "0.0.4",
"description": "Cumulocity widget to capture measturements manually.",
"repository": {
"type": "git",
"url": "git@github.com:SoftwareAG/cumulocity-datacapture-widget.git"
},
"scripts": {
"start": "c8ycli server",
"start:cockpit": "npm start -- --shell cockpit",
"start:cockpit": "npm start -- --shell cockpit-twin",
"build": "c8ycli build",
"build:ci": "npm run build -- --ci",
"deploy": "c8ycli deploy",
Expand Down Expand Up @@ -76,7 +76,11 @@
{
"from": "README.md",
"to": "README.md"
}
},
{
"from": "../assets/widget-datacapture-pr.png",
"to": "assets/widget-datacapture-pr.png"
}
],
"remotes": {
"sag-ps-pkg-widget-datacapture": [
Expand Down
3 changes: 3 additions & 0 deletions widget/widget-datacapture.component.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.text {
transform: scaleX(-1);
font-size: 3em;
}
.p-t-18 {
padding-top: 18px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h4 class="card-title">{{ "Enter values for datapoints" | translate }}</h4>
</div>

<div class="card-block">
<table class="table table-condensed table-striped">
<table class="table table-striped">
<thead>
<tr>
<th>{{ "ID" | translate }}</th>
Expand All @@ -19,9 +19,9 @@ <h4 class="card-title">{{ "Enter values for datapoints" | translate }}</h4>
<tbody>
<tr *ngFor="let d of config.datapoints; let i = index">
<!-- <form> -->
<td>{{d.__target.id}}</td>
<td>{{d.__target.name}}</td>
<td>{{d.label}}</td>
<td class="p-t-18">{{d.__target.id}}</td>
<td class="p-t-18">{{d.__target.name}}</td>
<td class="p-t-18">{{d.label}}</td>
<td>
<input
class="form-control"
Expand Down
32 changes: 15 additions & 17 deletions widget/widget-datacapture.component.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { Component, Input, OnInit } from "@angular/core";
import {

IMeasurementCreate,
IUser,
InventoryService,
MeasurementService,
} from "@c8y/client";
import { IMeasurementCreate, IUser, MeasurementService } from "@c8y/client";
import { BehaviorSubject } from "rxjs";
import { AlertService, AppStateService } from "@c8y/ngx-components";

@Component({
selector: "c8y-widget-datacapture",
templateUrl: "widget-datacapture.html",
styleUrls: [
"./widget-datacapture.component.css"],
templateUrl: "widget-datacapture.component.html",
styleUrls: ["./widget-datacapture.component.css"],
})
export class DataCaptureWidgetComponent implements OnInit {
@Input() config;
Expand All @@ -23,7 +16,6 @@ export class DataCaptureWidgetComponent implements OnInit {
user: string;

constructor(
private inventory: InventoryService,
private measurement: MeasurementService,
private alert: AlertService,
private app: AppStateService
Expand All @@ -36,6 +28,10 @@ export class DataCaptureWidgetComponent implements OnInit {
//console.log("User", u);
this.user = u.userName;
});
for (let index = 0; index < this.config["datapoints"].length; index++) {
this.dates.push(new Date());
// this.values.push(0);
}
}

async onSubmit(index: number) {
Expand All @@ -46,13 +42,15 @@ export class DataCaptureWidgetComponent implements OnInit {
this.dates,
this.config.datapoints[index]
);
const time = this.dates[index]?this.dates[index] : new Date().toISOString();
const time = this.dates[index]
? this.dates[index]
: new Date().toISOString();
const m: Partial<IMeasurementCreate> = {
source :{
id:this.config.datapoints[index].__target.id,
source: {
id: this.config.datapoints[index].__target.id,
},
type : this.config.datapoints[index].fragment,
time: time
type: this.config.datapoints[index].fragment,
time: time,
};
if (this.config.addAudit) {
m.user = this.user;
Expand All @@ -73,7 +71,7 @@ export class DataCaptureWidgetComponent implements OnInit {
}
*/
console.log("New entry:", m);
const {res, data} = await this.measurement.create(m);
const { res, data } = await this.measurement.create(m);
this.alert.success(`New measurement: ${data.id}`);
}
}
2 changes: 1 addition & 1 deletion widget/widget-datacapture.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { TranslateModule } from "@ngx-translate/core";
providers: [
BsDatepickerConfig,
hookComponent({
id: "angular.widget.plugin",
id: "datacapture.widget",
label: gettext("Data capture widget"),
description: gettext("Widget added data capture"),
component: DataCaptureWidgetComponent,
Expand Down

0 comments on commit d9da5c1

Please sign in to comment.