You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/02/12 14:59:39 UTC
[incubator-streampipes] branch dev updated: STREAMPIPES-58:
Refactor and extend live dashboard Add service to check for semantic type
and format dates in table
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 921ed50 STREAMPIPES-58: Refactor and extend live dashboard Add service to check for semantic type and format dates in table
921ed50 is described below
commit 921ed5049827a08976c0c21f0308029adbde7d6b
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Feb 12 15:58:29 2020 +0100
STREAMPIPES-58: Refactor and extend live dashboard
Add service to check for semantic type and format dates in table
---
.../semantic-type/semantic-type-utils.service.ts | 36 ++++++++++++++++++++++
.../widgets/table/table-widget.component.ts | 9 +++++-
ui/src/app/dashboard-v2/dashboard.module.ts | 2 ++
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts b/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
new file mode 100644
index 0000000..7bcf5c6
--- /dev/null
+++ b/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import {Injectable} from '@angular/core';
+
+@Injectable()
+export class SemanticTypeUtilsService {
+
+ private IMAGE_TYPE: string = 'http://schema.org/DateTime';
+
+ constructor() {
+ }
+
+ public getValue(inputValue, semanticType) {
+ if (semanticType === this.IMAGE_TYPE) {
+ return new Date(inputValue).toLocaleString() ;
+ } else {
+ return inputValue;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ui/src/app/dashboard-v2/components/widgets/table/table-widget.component.ts b/ui/src/app/dashboard-v2/components/widgets/table/table-widget.component.ts
index e4f392c..78d9300 100644
--- a/ui/src/app/dashboard-v2/components/widgets/table/table-widget.component.ts
+++ b/ui/src/app/dashboard-v2/components/widgets/table/table-widget.component.ts
@@ -4,6 +4,7 @@ import {RxStompService} from "@stomp/ng2-stompjs";
import {StaticPropertyExtractor} from "../../../sdk/extractor/static-property-extractor";
import {MatTableDataSource} from "@angular/material/table";
import {TableConfig} from "./table-config";
+import {SemanticTypeUtilsService} from "../../../../core-services/semantic-type/semantic-type-utils.service";
@Component({
selector: 'table-widget',
@@ -17,13 +18,18 @@ export class TableWidgetComponent extends BaseStreamPipesWidget implements OnIni
displayedColumns: String[] = [];
dataSource = new MatTableDataSource();
+ semanticTypes: { [key: string]: string; } = {};
- constructor(rxStompService: RxStompService) {
+ constructor(rxStompService: RxStompService, private semanticTypeUtils: SemanticTypeUtilsService) {
super(rxStompService);
}
ngOnInit(): void {
super.ngOnInit();
+
+ this.widgetConfig.dashboardWidgetDataConfig.schema.eventProperties.forEach((key, index) => {
+ this.semanticTypes[key.runtimeName] = key.domainProperty
+ });
}
ngOnDestroy(): void {
@@ -46,6 +52,7 @@ export class TableWidgetComponent extends BaseStreamPipesWidget implements OnIni
createTableObject(event: any) {
let object = {};
this.selectedProperties.forEach((key, index) => {
+ event[key] = this.semanticTypeUtils.getValue(event[key], this.semanticTypes[key]);
object[key] = event[key];
});
return object;
diff --git a/ui/src/app/dashboard-v2/dashboard.module.ts b/ui/src/app/dashboard-v2/dashboard.module.ts
index fb5374d..c66a309 100644
--- a/ui/src/app/dashboard-v2/dashboard.module.ts
+++ b/ui/src/app/dashboard-v2/dashboard.module.ts
@@ -28,6 +28,7 @@ import {ResizeService} from "./services/resize.service";
import {TableWidgetComponent} from "./components/widgets/table/table-widget.component";
import {CdkTableModule} from "@angular/cdk/table";
import {RefreshDashboardService} from "./services/refresh-dashboard.service";
+import {SemanticTypeUtilsService} from '../core-services/semantic-type/semantic-type-utils.service';
const dashboardWidgets = [
@@ -68,6 +69,7 @@ const dashboardWidgets = [
DashboardService,
ResizeService,
RefreshDashboardService,
+ SemanticTypeUtilsService,
{
provide: 'RestApi',
useFactory: ($injector: any) => $injector.get('RestApi'),