Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature migration 1018 #3

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Cumulocity widget plugin
# Cumulocity data capture widget

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.
27,716 changes: 2,257 additions & 25,459 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 11 additions & 7 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-debug",
"start:cockpit": "npm start -- --shell cockpit-twin",
"build": "c8ycli build",
"build:ci": "npm run build -- --ci",
"deploy": "c8ycli deploy",
Expand All @@ -28,9 +28,9 @@
"@angular/platform-browser-dynamic": "14.0.6",
"@angular/router": "14.0.6",
"@angular/upgrade": "14.0.6",
"@c8y/client": "1017.0.267",
"@c8y/ngx-components": "1017.0.267",
"@c8y/style": "1017.0.267",
"@c8y/client": "1018.0.205",
"@c8y/ngx-components": "1018.0.205",
"@c8y/style": "1018.0.205",
"@ngx-formly/core": "^6.1.8",
"@ngx-translate/core": "14.0.0",
"ngx-bootstrap": "9.0.0",
Expand All @@ -43,7 +43,7 @@
"@angular/language-service": "14.0.6",
"@angular/localize": "14.0.6",
"@angular/service-worker": "14.0.6",
"@c8y/cli": "1017.0.267",
"@c8y/cli": "1018.0.205",
"@semantic-release/changelog": "github:semantic-release/changelog",
"@semantic-release/exec": "github:semantic-release/exec",
"@semantic-release/git": "github:semantic-release/git",
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