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

pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new dd6a2924 SUBMARINE-1296. Add create user function when register a new 
user.
dd6a2924 is described below

commit dd6a292414d3e1547d5603c8daceddabdda6d6ae
Author: HH <[email protected]>
AuthorDate: Sun Nov 6 00:09:24 2022 +0800

    SUBMARINE-1296. Add create user function when register a new user.
    
    ### What is this PR for?
    <!-- A few sentences describing the overall goals of the pull request's 
commits.
    First time? Check out the contributing guide - 
https://submarine.apache.org/contribution/contributions.html
    -->
    Originally we were unable to create a user correctly; We add create user 
function when registering a new user in this PR.
    ### What type of PR is it?
    [Bug Fix | Improvement | Feature | Documentation | Hot Fix | Refactoring]
    Bug Fix
    ### Future work
    
    - When we log in to the account, it always shows adim in the userInfo
    - Remove the mock data in 
[here](https://github.com/apache/submarine/blob/2faebb8efd69833853f62d89b4f1fea1b1718148/submarine-workbench/workbench-web/src/app/pages/user/register/register.component.ts#L32)
    
    ### What is the Jira issue?
    [SUBMARINE-1293](https://issues.apache.org/jira/browse/SUBMARINE-1293)
    ### How should this be tested?
    <!--
    * First time? Setup Travis CI as described on 
https://submarine.apache.org/contribution/contributions.html#continuous-integration
    * Strongly recommended: add automated unit tests for any new or changed 
behavior
    * Outline any manual steps to test the PR here.
    -->
    ### Screenshots (if appropriate)
    
    - When you haven't created such a user
    <img width="888" alt="image" 
src="https://user-images.githubusercontent.com/52046377/200595282-6262060c-aca6-4dd1-9ca5-cdd6a8bb5ed7.png";>
    
    - When you save duplicated username
    <img width="1440" alt="image" 
src="https://user-images.githubusercontent.com/52046377/200595715-2e900dd4-659d-4977-a732-a8436cb93e80.png";>
    
    - Done creation and log in again
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: HH <[email protected]>
    
    Signed-off-by: Kevin <[email protected]>
    
    Closes #1012 from hhcs9527/SUBMARINE-1296 and squashes the following 
commits:
    
    e118d814 [HH] SUBMARINE-1296. Add create user function when register a new 
user.
---
 .../app/pages/user/register/register.component.ts  | 42 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git 
a/submarine-workbench/workbench-web/src/app/pages/user/register/register.component.ts
 
b/submarine-workbench/workbench-web/src/app/pages/user/register/register.component.ts
index 9b5e589f..aaee7666 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/user/register/register.component.ts
+++ 
b/submarine-workbench/workbench-web/src/app/pages/user/register/register.component.ts
@@ -20,6 +20,8 @@
 import { Component, OnInit } from '@angular/core';
 import { FormBuilder, FormControl, FormGroup, Validators } from 
'@angular/forms';
 import { Router } from '@angular/router';
+import { UserService } from '@submarine/services';
+import { NzNotificationService } from 'ng-zorro-antd';
 
 @Component({
   selector: 'submarine-register',
@@ -32,7 +34,13 @@ export class RegisterComponent implements OnInit {
   existedUsernames = ['test', 'haha'];
   existedEmails = ['[email protected]'];
 
-  constructor(private fb: FormBuilder, private router: Router) {}
+  constructor(
+    private fb: FormBuilder,
+    private router: Router,
+    private userService: UserService,
+    private nzNotificationService: NzNotificationService
+  ) {}
+
   ngOnInit(): void {
     this.validateForm = this.fb.group({
       username: [null, [Validators.required, 
this.checkExistedUsernames.bind(this)]],
@@ -48,8 +56,26 @@ export class RegisterComponent implements OnInit {
       this.validateForm.controls[i].markAsDirty();
       this.validateForm.controls[i].updateValueAndValidity();
     }
-    this.router.navigate(['/user/login']);
-    console.log('SubmitForm (Sign up Page)');
+
+    if (this.validateForm.status === 'VALID') {
+      const { value } = this.validateForm;
+      const params = {
+        'userName': value['username'],
+        'realName': value['username'],
+        'password': value['password'],
+        'email': value['email'],
+        'deleted': 0
+      };
+
+      this.userService.createUser(params).subscribe(
+        () => {
+          this.router.navigate(['/user/login']);
+        },
+        (error) => {
+          this.registerFailed(error);
+        }
+      );
+    }
   }
 
   updateConfirmValidator(): void {
@@ -100,4 +126,14 @@ export class RegisterComponent implements OnInit {
     }
     return null;
   }
+
+  registerFailed(error: Error) {
+    this.nzNotificationService.error(
+      'Register Failed',
+      'Save user failed!',
+      {
+        nzDuration: 4000
+      }
+    );
+  }
 }


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

Reply via email to