You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/26 09:08:45 UTC

[GitHub] [inlong] leezng opened a new pull request, #6295: [INLONG-6273][Dashboard] Ability to load plugins asynchronously

leezng opened a new pull request, #6295:
URL: https://github.com/apache/inlong/pull/6295

   Complete the Group and Consume tasks in #6273


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #6295: [INLONG-6273][Dashboard] Ability to load plugins asynchronously

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6295:
URL: https://github.com/apache/inlong/pull/6295#discussion_r1006353056


##########
inlong-dashboard/src/metas/DataWithBackend.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { ColumnType } from 'antd/es/table';
+import type { FieldItemType } from '@/metas/common';
+import { isDevelopEnv } from '@/utils';
+import { DataStatic } from './DataStatic';
+
+interface PositionObjectType extends Record<string, unknown> {
+  position: ['before' | 'after', string];
+}
+
+function sortListPosition(list: PositionObjectType[], primaryPositionKey = 'name') {
+  const output: Record<string, unknown>[] = [];
+  const notFoundPosMap: Record<string, PositionObjectType> = {};
+  const _list = [...list];
+  let loopCount = 0;
+  while (_list.length) {
+    loopCount++;
+    if (loopCount > 500) {
+      console.error(
+        '[Apache InLong Error] The number of loops of the sorting algorithm array has reached the maximum limit, please check or adjust the configuration.',
+      );
+      break;
+    }
+    const listItem = _list.shift();
+    if (!listItem) continue;
+    if (listItem.position) {
+      const [positionType, positionName] = listItem.position;
+      const index = output.findIndex(item => item[primaryPositionKey] === positionName);
+      if (index !== -1) {
+        output.splice(positionType === 'before' ? index : index + 1, 0, listItem);
+      } else {
+        notFoundPosMap[positionName] = listItem;
+      }
+    } else {
+      output.push(listItem);
+    }
+    const currentItemName = listItem[primaryPositionKey] as string;
+    if (notFoundPosMap[currentItemName]) {
+      _list.push(notFoundPosMap[currentItemName]);
+      delete notFoundPosMap[currentItemName];
+    }
+  }
+
+  const notFoundPosList = Object.keys(notFoundPosMap).map(name => notFoundPosMap[name]);
+  return output.concat(notFoundPosList);
+}
+
+export abstract class DataWithBackend extends DataStatic {
+  static FieldList: FieldItemType[] = [];
+  static ColumnList: ColumnType<Record<string, any>>[] = [];
+
+  static FormField(config: FieldItemType): PropertyDecorator {
+    return (target: any, propertyKey: string) => {
+      const { I18nMap, FieldList } = target.constructor;
+      const newFieldList = [...FieldList];
+
+      if (isDevelopEnv()) {
+        // Hot refresh of the development env will have old data
+        const existIndex = newFieldList.findIndex(item => item.name === propertyKey);
+        if (existIndex !== -1) {
+          newFieldList.splice(existIndex, 1);
+        }
+      }
+
+      newFieldList.push({
+        ...config,
+        name: propertyKey,
+        label: I18nMap[propertyKey],
+      });
+
+      // console.log('--', target.constructor, target.constructor.timer);

Review Comment:
   Does this need?



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] leezng commented on a diff in pull request #6295: [INLONG-6273][Dashboard] Ability to load plugins asynchronously

Posted by GitBox <gi...@apache.org>.
leezng commented on code in PR #6295:
URL: https://github.com/apache/inlong/pull/6295#discussion_r1006354857


##########
inlong-dashboard/src/metas/DataWithBackend.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { ColumnType } from 'antd/es/table';
+import type { FieldItemType } from '@/metas/common';
+import { isDevelopEnv } from '@/utils';
+import { DataStatic } from './DataStatic';
+
+interface PositionObjectType extends Record<string, unknown> {
+  position: ['before' | 'after', string];
+}
+
+function sortListPosition(list: PositionObjectType[], primaryPositionKey = 'name') {
+  const output: Record<string, unknown>[] = [];
+  const notFoundPosMap: Record<string, PositionObjectType> = {};
+  const _list = [...list];
+  let loopCount = 0;
+  while (_list.length) {
+    loopCount++;
+    if (loopCount > 500) {
+      console.error(
+        '[Apache InLong Error] The number of loops of the sorting algorithm array has reached the maximum limit, please check or adjust the configuration.',
+      );
+      break;
+    }
+    const listItem = _list.shift();
+    if (!listItem) continue;
+    if (listItem.position) {
+      const [positionType, positionName] = listItem.position;
+      const index = output.findIndex(item => item[primaryPositionKey] === positionName);
+      if (index !== -1) {
+        output.splice(positionType === 'before' ? index : index + 1, 0, listItem);
+      } else {
+        notFoundPosMap[positionName] = listItem;
+      }
+    } else {
+      output.push(listItem);
+    }
+    const currentItemName = listItem[primaryPositionKey] as string;
+    if (notFoundPosMap[currentItemName]) {
+      _list.push(notFoundPosMap[currentItemName]);
+      delete notFoundPosMap[currentItemName];
+    }
+  }
+
+  const notFoundPosList = Object.keys(notFoundPosMap).map(name => notFoundPosMap[name]);
+  return output.concat(notFoundPosList);
+}
+
+export abstract class DataWithBackend extends DataStatic {
+  static FieldList: FieldItemType[] = [];
+  static ColumnList: ColumnType<Record<string, any>>[] = [];
+
+  static FormField(config: FieldItemType): PropertyDecorator {
+    return (target: any, propertyKey: string) => {
+      const { I18nMap, FieldList } = target.constructor;
+      const newFieldList = [...FieldList];
+
+      if (isDevelopEnv()) {
+        // Hot refresh of the development env will have old data
+        const existIndex = newFieldList.findIndex(item => item.name === propertyKey);
+        if (existIndex !== -1) {
+          newFieldList.splice(existIndex, 1);
+        }
+      }
+
+      newFieldList.push({
+        ...config,
+        name: propertyKey,
+        label: I18nMap[propertyKey],
+      });
+
+      // console.log('--', target.constructor, target.constructor.timer);

Review Comment:
   Reserved for now, this will be dealt with on my next PR.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang merged pull request #6295: [INLONG-6273][Dashboard] Ability to load plugins asynchronously

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #6295:
URL: https://github.com/apache/inlong/pull/6295


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org