dominikriemer commented on code in PR #1441:
URL: https://github.com/apache/streampipes/pull/1441#discussion_r1145369758


##########
ui/src/app/connect/dialog/start-all-adapters/start-all-adapters-dialog.component.ts:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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 { Component, Input, OnInit } from '@angular/core';
+import { DialogRef } from '@streampipes/shared-ui';
+import {
+    AdapterDescriptionUnion,
+    AdapterService,
+} from '@streampipes/platform-services';
+
+@Component({
+    selector: 'sp-start-all-adapters-dialog',
+    templateUrl: './start-all-adapters-dialog.component.html',
+    styleUrls: ['./start-all-adapters-dialog.component.scss'],
+})
+export class StartAllAdaptersDialogComponent implements OnInit {
+    @Input()
+    adapters: AdapterDescriptionUnion[];
+
+    adaptersToModify: AdapterDescriptionUnion[];
+    installationStatus: any;
+    installationFinished: boolean;
+    page: string;
+    nextButton: string;
+    installationRunning: boolean;

Review Comment:
   same here



##########
ui/src/app/connect/dialog/start-all-adapters/start-all-adapters-dialog.component.ts:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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 { Component, Input, OnInit } from '@angular/core';
+import { DialogRef } from '@streampipes/shared-ui';
+import {
+    AdapterDescriptionUnion,
+    AdapterService,
+} from '@streampipes/platform-services';
+
+@Component({
+    selector: 'sp-start-all-adapters-dialog',
+    templateUrl: './start-all-adapters-dialog.component.html',
+    styleUrls: ['./start-all-adapters-dialog.component.scss'],
+})
+export class StartAllAdaptersDialogComponent implements OnInit {
+    @Input()
+    adapters: AdapterDescriptionUnion[];
+
+    adaptersToModify: AdapterDescriptionUnion[];
+    installationStatus: any;
+    installationFinished: boolean;

Review Comment:
   Is there a reason these variables are named `installation` although they are 
referring to starting/stopping adapters?



##########
ui/src/app/connect/dialog/start-all-adapters/start-all-adapters-dialog.component.ts:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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 { Component, Input, OnInit } from '@angular/core';
+import { DialogRef } from '@streampipes/shared-ui';
+import {
+    AdapterDescriptionUnion,
+    AdapterService,
+} from '@streampipes/platform-services';
+
+@Component({
+    selector: 'sp-start-all-adapters-dialog',
+    templateUrl: './start-all-adapters-dialog.component.html',
+    styleUrls: ['./start-all-adapters-dialog.component.scss'],
+})
+export class StartAllAdaptersDialogComponent implements OnInit {
+    @Input()
+    adapters: AdapterDescriptionUnion[];
+
+    adaptersToModify: AdapterDescriptionUnion[];
+    installationStatus: any;
+    installationFinished: boolean;
+    page: string;
+    nextButton: string;
+    installationRunning: boolean;
+
+    @Input()
+    action: boolean;
+
+    constructor(
+        private dialogRef: DialogRef<StartAllAdaptersDialogComponent>,
+        private adapterService: AdapterService,
+    ) {
+        this.adaptersToModify = [];
+        this.installationStatus = [];
+        this.installationFinished = false;
+        this.page = 'preview';
+        this.nextButton = 'Next';
+        this.installationRunning = false;
+    }
+
+    ngOnInit() {
+        this.getAdaptersToModify();
+        if (this.adaptersToModify.length === 0) {
+            this.nextButton = 'Close';
+            this.page = 'installation';
+        }
+    }
+
+    close(refreshAdapters: boolean) {
+        this.dialogRef.close(refreshAdapters);
+    }
+
+    next() {
+        if (this.page === 'installation') {
+            this.close(true);
+        } else {
+            this.page = 'installation';
+            this.initiateInstallation(this.adaptersToModify[0], 0);
+        }
+    }
+
+    getAdaptersToModify() {
+        this.adapters.forEach(adapter => {
+            this.adaptersToModify.push(adapter);
+        });
+    }
+
+    initiateInstallation(adapter: AdapterDescriptionUnion, index) {
+        this.installationRunning = true;
+        this.installationStatus.push({
+            name: adapter.name,
+            id: index,
+            status: 'waiting',
+        });
+        if (this.action) {
+            this.startAdapter(adapter, index);
+        } else {
+            this.stopAdapter(adapter, index);
+        }
+    }
+
+    startAdapter(adapter: AdapterDescriptionUnion, index) {
+        this.adapterService
+            .startAdapter(adapter)
+            .subscribe(data => {
+                this.installationStatus[index].status = data.success
+                    ? 'success'
+                    : 'error';
+            })
+            .add(() => {
+                if (index < this.adaptersToModify.length - 1) {
+                    index++;
+                    this.initiateInstallation(
+                        this.adaptersToModify[index],
+                        index,
+                    );
+                } else {
+                    this.nextButton = 'Close';
+                    this.installationRunning = false;
+                }
+            });
+    }
+
+    stopAdapter(adapter: AdapterDescriptionUnion, index) {

Review Comment:
   Can we simplify both methods as they are very similar?
   E.g., can we introduce a method which takes the observable and the 
nextButton string as an argument and performs the operation?



##########
ui/src/app/connect/dialog/start-all-adapters/start-all-adapters-dialog.component.ts:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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 { Component, Input, OnInit } from '@angular/core';
+import { DialogRef } from '@streampipes/shared-ui';
+import {
+    AdapterDescriptionUnion,
+    AdapterService,
+} from '@streampipes/platform-services';
+
+@Component({
+    selector: 'sp-start-all-adapters-dialog',
+    templateUrl: './start-all-adapters-dialog.component.html',
+    styleUrls: ['./start-all-adapters-dialog.component.scss'],
+})
+export class StartAllAdaptersDialogComponent implements OnInit {
+    @Input()
+    adapters: AdapterDescriptionUnion[];
+
+    adaptersToModify: AdapterDescriptionUnion[];
+    installationStatus: any;
+    installationFinished: boolean;
+    page: string;
+    nextButton: string;
+    installationRunning: boolean;
+
+    @Input()
+    action: boolean;
+
+    constructor(
+        private dialogRef: DialogRef<StartAllAdaptersDialogComponent>,
+        private adapterService: AdapterService,
+    ) {
+        this.adaptersToModify = [];
+        this.installationStatus = [];
+        this.installationFinished = false;
+        this.page = 'preview';
+        this.nextButton = 'Next';
+        this.installationRunning = false;
+    }
+
+    ngOnInit() {
+        this.getAdaptersToModify();
+        if (this.adaptersToModify.length === 0) {
+            this.nextButton = 'Close';
+            this.page = 'installation';
+        }
+    }
+
+    close(refreshAdapters: boolean) {
+        this.dialogRef.close(refreshAdapters);
+    }
+
+    next() {
+        if (this.page === 'installation') {
+            this.close(true);
+        } else {
+            this.page = 'installation';
+            this.initiateInstallation(this.adaptersToModify[0], 0);
+        }
+    }
+
+    getAdaptersToModify() {
+        this.adapters.forEach(adapter => {
+            this.adaptersToModify.push(adapter);

Review Comment:
   Why do we need the `adaptersToModify` array even though always all adapters 
are added to the array?
   Do we need to check for the current status to make sure that the request is 
not executed for already started/stopped adapters?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to