This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch auto-monitor-name
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/auto-monitor-name by this push:
     new 5c26bc384 [improve] auto generate readable random monitor name
5c26bc384 is described below

commit 5c26bc38407d46d787ff295c54acc26cf4923484
Author: tomsun28 <[email protected]>
AuthorDate: Thu Aug 15 21:32:31 2024 +0800

    [improve] auto generate readable random monitor name
    
    Signed-off-by: tomsun28 <[email protected]>
---
 .../monitor/monitor-new/monitor-new.component.ts   |  2 +-
 web-app/src/app/shared/utils/common-util.ts        | 63 ++++++++++++++++++----
 2 files changed, 55 insertions(+), 10 deletions(-)

diff --git 
a/web-app/src/app/routes/monitor/monitor-new/monitor-new.component.ts 
b/web-app/src/app/routes/monitor/monitor-new/monitor-new.component.ts
index c9785d0b9..6f0c7898e 100644
--- a/web-app/src/app/routes/monitor/monitor-new/monitor-new.component.ts
+++ b/web-app/src/app/routes/monitor/monitor-new/monitor-new.component.ts
@@ -156,7 +156,7 @@ export class MonitorNewComponent implements OnInit {
     if (this.monitor.app != 'prometheus') {
       let autoName = `${this.monitor.app.toUpperCase()}_${hostValue}`;
       if (this.monitor.name == undefined || this.monitor.name == '') {
-        this.monitor.name = generateReadableRandomString(6);
+        this.monitor.name = generateReadableRandomString();
       }
     }
   }
diff --git a/web-app/src/app/shared/utils/common-util.ts 
b/web-app/src/app/shared/utils/common-util.ts
index f7cded4cd..7b7ca16bc 100644
--- a/web-app/src/app/shared/utils/common-util.ts
+++ b/web-app/src/app/shared/utils/common-util.ts
@@ -44,7 +44,7 @@ export function findDeepestSelected(nodes: any): any {
   return deepestSelectedNode;
 }
 
-export function generateReadableRandomString(length: number): string {
+export function generateReadableRandomString(): string {
   const adjectives = [
     'quick',
     'bright',
@@ -69,7 +69,31 @@ export function generateReadableRandomString(length: 
number): string {
     'vivid',
     'zany',
     'zealous',
-    'yummy'
+    'yummy',
+    'agile',
+    'bold',
+    'daring',
+    'fearless',
+    'gleeful',
+    'humble',
+    'jumpy',
+    'keen',
+    'loyal',
+    'majestic',
+    'noble',
+    'playful',
+    'radiant',
+    'spirited',
+    'tenacious',
+    'vibrant',
+    'wise',
+    'youthful',
+    'zippy',
+    'serene',
+    'bubbly',
+    'dreamy',
+    'fierce',
+    'graceful'
   ];
 
   const nouns = [
@@ -92,22 +116,43 @@ export function generateReadableRandomString(length: 
number): string {
     'giraffe',
     'koala',
     'lemur',
-    'lemming'
+    'lemming',
+    'cheetah',
+    'dragon',
+    'owl',
+    'rhino',
+    'stingray',
+    'jaguar',
+    'panther',
+    'elk',
+    'ocelot',
+    'beaver',
+    'walrus',
+    'gazelle',
+    'coyote',
+    'vulture',
+    'iguana',
+    'porcupine',
+    'raccoon',
+    'sloth',
+    'armadillo',
+    'chameleon',
+    'kestrel',
+    'weasel',
+    'hedgehog'
   ];
 
-  const digits = '0123456789';
-  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+  const digits = '23456789';
+  const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz';
 
   // Randomly select an adjective and a noun
   let adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
   let noun = nouns[Math.floor(Math.random() * nouns.length)];
 
   // Randomly generate a sequence of numbers and characters
-  const randomDigits = Array.from({ length: Math.floor(length / 4) }, () => 
digits.charAt(Math.floor(Math.random() * digits.length))).join(
-    ''
-  );
+  const randomDigits = Array.from({ length: 2 }, () => 
digits.charAt(Math.floor(Math.random() * digits.length))).join('');
 
-  const randomChars = Array.from({ length: Math.floor(length / 4) }, () => 
chars.charAt(Math.floor(Math.random() * chars.length))).join('');
+  const randomChars = Array.from({ length: 2 }, () => 
chars.charAt(Math.floor(Math.random() * chars.length))).join('');
   adjective = capitalizeFirstLetter(adjective);
   noun = capitalizeFirstLetter(noun);
   // Combine the parts to form the final string


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to