This is an automated email from the ASF dual-hosted git repository.
liuxun 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 4f5114b SUBMARINE-482. Implement database connection in team page
with Angular
4f5114b is described below
commit 4f5114b96270b9d7f97048cac362d586444a52d3
Author: kobe860219 <[email protected]>
AuthorDate: Thu May 14 16:16:16 2020 +0800
SUBMARINE-482. Implement database connection in team page with Angular
### What is this PR for?
Database connection in team page with Angular.
Functions about :
1.List exist teams.
2.Add new team.
3.Delete an exist team.
4.Easy check when add new team.
Above is done.
Something may need to dicuss after version 0.4 released.
Future - Owner value may need to auto-catch user.
### What type of PR is it?
[Improvement]
### Todos
* [ ] - Task
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-482
### How should this be tested?
https://travis-ci.org/github/kobe860219/submarine/builds/685974451
### Screenshots (if appropriate)
TestIT
<img width="558" alt="teamIT test"
src="https://user-images.githubusercontent.com/48027290/81647281-55c50280-945f-11ea-858e-31f2ac62cb03.png">

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: kobe860219 <[email protected]>
Closes #285 from kobe860219/SUBMARINE-482 and squashes the following
commits:
895b299 [kobe860219] Adjustment format of the team.component.scss file
d84317c [kobe860219] Add newline at the end in the team.component.scss file
6a3119b [kobe860219] Add newline at the end of the file
169d7c3 [kobe860219] Remove redundant whitespaces
49f37b5 [kobe860219] Fix the typographical error
cd21d9b [kobe860219] SUBMARINE-482. [WEB]Implement database connection in
team page with Angular
04940ff [kobe860219] SUBMARINE-482. Function of team about add and delete
is done
3d9afd1 [kobe860219] SUBMARINE-482. Function of team about list is done.
---
docs/database/submarine-data.sql | 6 +
.../org/apache/submarine/integration/teamIT.java | 12 +-
.../src/app/interfaces/public-api.ts | 1 +
.../team.component.scss => interfaces/sys-team.ts} | 13 +-
.../workbench/workspace/team/team.component.html | 238 +++++++------------
.../workbench/workspace/team/team.component.scss | 26 ++-
.../workbench/workspace/team/team.component.ts | 251 ++++++++++-----------
.../pages/workbench/workspace/workspace.module.ts | 7 +-
.../src/app/services/public-api.ts | 1 +
.../src/app/services/team.service.ts | 113 ++++++++++
10 files changed, 350 insertions(+), 318 deletions(-)
diff --git a/docs/database/submarine-data.sql b/docs/database/submarine-data.sql
index 644a15e..c0825ba 100644
--- a/docs/database/submarine-data.sql
+++ b/docs/database/submarine-data.sql
@@ -54,3 +54,9 @@ INSERT INTO `sys_department` VALUES
('1bc0cd98c8d311e98edc0242ac110002','AAA','G
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES ('e9ca23d68d884d4ebb19d07889727dae', 'admin',
'administrator', '21232f297a57a5a743894a0e4a801fc3', 'avatar.png', '2018-12-05
00:00:00', NULL, '[email protected]', '18566666661', NULL, NULL, NULL, 1,
'admin', '2019-07-05 14:47:22', 'admin', '2019-07-05 14:47:22');
+
+
+-- ----------------------------
+-- Records of team
+-- ----------------------------
+INSERT INTO `team` VALUES ('e9ca23d68d884d4ebb19d07889721234', 'admin',
'Submarine', 'admin', '2020-05-06 14:00:05', 'Jack', '2020-05-06 14:00:14');
diff --git
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
index 80e8a7b..f0b87ef 100644
---
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
+++
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
@@ -60,12 +60,10 @@ public class teamIT extends AbstractSubmarineIT {
pollingWait(By.xpath("//li[contains(text(), \"Team\")]"),
MAX_BROWSER_TIMEOUT_SEC).click();
Assert.assertEquals(pollingWait(By.xpath("//div[@id='teamDiv']"),
MAX_BROWSER_TIMEOUT_SEC).isDisplayed(), true);
- clickAndWait(By.cssSelector("button[id='createTeamBtn']"));
- pollingWait(By.xpath("//input[@id='inputNewTeamName']"),
MAX_BROWSER_TIMEOUT_SEC).sendKeys("NewTeamTest");
- pollingWait(By.xpath("//textarea[@id='textareaNewTeamDescription']"),
MAX_BROWSER_TIMEOUT_SEC).sendKeys("NewTeamTest");
- clickAndWait(By.cssSelector("button[id='summitCreateTeam']"));
- Assert.assertEquals(pollingWait(By.xpath("//button[@id='createTeamBtn']"),
MAX_BROWSER_TIMEOUT_SEC).isDisplayed(), true);
-
- Thread.sleep(1500);
+ clickAndWait(By.cssSelector("button[id='btnAddTeam']"));
+ pollingWait(By.xpath("//input[@id='inputNewTeamName']"),
MAX_BROWSER_TIMEOUT_SEC).sendKeys("NewTeamNameTest");
+ pollingWait(By.xpath("//input[@id='inputNewTeamOwner']"),
MAX_BROWSER_TIMEOUT_SEC).sendKeys("NewTeamOwnerTest");
+ clickAndWait(By.cssSelector("button[id='submitNewTeamBtn']"));
+ Assert.assertEquals(pollingWait(By.xpath("//td[contains(.,
'NewTeamNameTest')]"), MAX_BROWSER_TIMEOUT_SEC).isDisplayed(), true);
}
}
diff --git
a/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
b/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
index 4123a93..9aed87d 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
@@ -23,3 +23,4 @@ export * from './user-info';
export * from './rest';
export * from './action';
export * from './sys-user';
+export * from './sys-team';
diff --git
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-team.ts
similarity index 85%
copy from
submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
copy to submarine-workbench/workbench-web-ng/src/app/interfaces/sys-team.ts
index 21ecd17..5626713 100644
---
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-team.ts
@@ -17,12 +17,9 @@
* under the License.
*/
- #searchRegion{
- margin:20px;
- background-color: white;
- }
+import { BaseEntity } from './base-entity';
- #teamList {
- margin: 20;
- }
-
\ No newline at end of file
+export interface SysTeam extends BaseEntity {
+ teamName: string;
+ owner: string;
+}
diff --git
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.html
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.html
index 1698227..8f9be94 100644
---
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.html
+++
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.html
@@ -17,176 +17,94 @@
~ under the License.
-->
-<!--TeamHome-->
-<div id="teamDiv" *ngIf="!isEntering">
- <div id="searchRegion" align="right">
- <nz-input-group nzSearch [nzAddOnAfter]="searchIconBtn"
style="width:300px;margin: 10px;">
- <input type="text" nz-input placeholder="Search...">
- </nz-input-group>
- <ng-template #searchIconBtn>
- <button nz-button nzType="primary" nzSearch>
- <i nz-icon nzType="search"></i>
- </button>
- </ng-template>
- <button id="createTeamBtn" nz-button nzType="primary"
(click)="startCreateTeam()" style="margin: 10px;">
- <i nz-icon nzType="usergroup-add" nzTheme="outline"></i>Create Team
+<!--Team Home-->
+<div id="teamDiv">
+ <div align="right">
+ <button nz-button id="btnAddTeam" nzType="primary" style="margin: 10px"
(click)="addTeam()">
+ <i nz-icon nzType="plus"></i>
+ Add Team
</button>
</div>
- <div id="teamList" style="margin: 20px;">
- <div nz-row [nzGutter]="12" nzType="flex" nzJustify="start">
- <div *ngFor="let team of existTeams; let i = index" nz-col [nzSpan]="8">
- <nz-card id="{{ 'team'+i }}" [nzTitle]="team.name"
[nzExtra]="team.department" [nzActions]="[actionEnter]">
- {{ team.description }}
- <br>
- <br>
- <label>
- <i nz-icon nzType="project" nzTheme="outline"></i> {{
team.projectNum }}
- <nz-divider nzType="vertical"></nz-divider>
- <i nz-icon nzType="user" nzTheme="outline"></i> {{ team.memberNum
}}
+ <div>
+ <nz-table #teamListTable [nzData]="teamList" nzNoResult="No result">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Owner</th>
+ <th>Created Time</th>
+ <th>Action</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr *ngFor="let team of teamListTable.data">
+ <td>{{ team.teamName }}</td>
+ <td>{{ team.owner }}</td>
+ <td>{{ team.createTime }}</td>
+ <td>
+ <a (click)="showOverview(team)">Overview</a>
<nz-divider nzType="vertical"></nz-divider>
- <i nz-icon nzType="idcard" nzTheme="outline"></i> {{ team.role }}
- </label>
- </nz-card>
- <ng-template #actionEnter>
- <a (click)="enter(team)"><i nz-icon nzType="arrow-right"
nzTheme="outline"></i> Enter</a>
- </ng-template>
- </div>
- </div>
+ <a>Enter</a>
+ <nz-divider nzType="vertical"></nz-divider>
+ <a (click)="deleteTeam(team)">Delete</a></td>
+ </tr>
+ </tbody>
+ </nz-table>
</div>
</div>
-<!--Creating Team-->
-<nz-modal
- [(nzVisible)]="createTeamModalIsVisible"
- nzTitle="Create New Team"
- (nzOnCancel)="createTeamModalIsVisible=false;"
+<!--Add Team-->
+<nz-drawer
+ nzTitle="Add Team"
+ [nzMaskClosable]="false"
+ [nzWidth]="540"
+ (nzOnClose)="closeDrawer()"
+ [nzVisible]="drawerVisible"
+ [nzBodyStyle]="{ height: 'calc(100% - 55px)', overflow: 'auto',
'padding-bottom': '53px' }">
+ <!--Add Form-->
+ <form
+ nz-form
+ [formGroup]="newTeamForm"
+ nzLayout="horizontal"
>
- <form nz-form>
- <div *nzModalFooter>
- <button id="cancelCreateTeam" nz-button nzType="default"
(click)="createTeamModalIsVisible=false;"> Cancel </button>
- <button id="summitCreateTeam" nz-button nzType="primary"
(click)="createTeamOk()">Create</button>
- </div>
<nz-form-item>
- <nz-form-label nzRequired [nzSpan]="6">Team Name</nz-form-label>
- <nz-form-control [nzSpan]="14">
- <input id="inputNewTeamName" nz-input id="inputNewTeamName"
placeholder="Team Name" style="width: 150px;">
- </nz-form-control>
- </nz-form-item >
+ <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>Team
Name</nz-form-label>
+ <nz-form-control [nzSm]="14" [nzXs]="24"
[nzErrorTip]="formTeamNameErrMesg">
+ <input nz-input id="inputNewTeamName" placeholder="Please input team
name" formControlName="teamName"/>
+ </nz-form-control>
+ </nz-form-item>
<nz-form-item>
- <nz-form-label nzRequired [nzSpan]="6">Description</nz-form-label>
- <nz-form-control [nzSpan]="14">
- <textarea id="textareaNewTeamDescription" rows="4" nz-input
placeholder="Describe this team ..."></textarea>
- </nz-form-control>
- </nz-form-item >
+ <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>Owner</nz-form-label>
+ <nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="This is
required!">
+ <input nz-input id="inputNewTeamOwner" type="text"
placeholder="Please input owner" formControlName="owner"/>
+ </nz-form-control>
+ </nz-form-item>
</form>
-</nz-modal>
-<!--Enter a team-->
-<div *ngIf="isEntering" style="margin: 20px;background-color: white;">
- <nz-card [nzTitle]="currentTeamName" [nzExtra]=cardExtra>
- <ng-template #cardExtra>
- {{ currentTeamDepartment }}
- <button nz-button nzType="primary" nzSize="small"
(click)="isEntering=false" style="margin-left: 10px;">
- <i nz-icon nzType="rollback" nzTheme="outline"></i>Go Back
- </button>
- </ng-template>
- <nz-tabset>
- <!--Profile-->
- <nz-tab [nzTitle]="tab1">
- <div style="text-align: center;">
- <nz-spin [nzSize]="'large'" nzSimple></nz-spin>
- </div>
- </nz-tab>
- <!--Projects-->
- <nz-tab [nzTitle]="tab2">
- <div style="text-align: center;">
- <nz-spin [nzSize]="'large'" nzSimple></nz-spin>
- </div>
- </nz-tab>
- <!--Members-->
- <nz-tab [nzTitle]="tab3">
- <div style="margin: 15px;" align="right">
- <button nz-button nzType="primary" style="margin-right: 10px;"
(click)="startAddUser()"[disabled]="!currentTeamSettingPermission"><i nz-icon
nzType="plus"></i>Add</button>
- <button nz-button nzType="primary" style="margin-right: 10px;"
(click)="startEditMember()" [disabled]="!currentTeamSettingPermission"><i
nz-icon nzType="edit"></i>Edit</button>
- <button nz-button nzType="primary" style="margin-right: 10px;"
(click)="saveEditMember()" [disabled]="!isEditingMember"><i nz-icon
nzType="check"></i>Save</button>
- </div>
- <div>
- <nz-table #basicTable [nzData]="member">
- <thead>
- <tr>
- <th style="width: 100px;">Name</th>
- <th style="width: 100px;">Email</th>
- <th style="width: 100px;">Role</th>
- <th *ngIf="isEditingMember" style="width: 200px;">Edit</th>
- </tr>
- </thead>
- <tbody>
- <tr *ngFor="let data of basicTable.data">
- <td>{{ data.name }}</td>
- <td>{{ data.email }}</td>
- <td>{{ data.permission }}</td>
- <td *ngIf="isEditingMember">
- <nz-select [(ngModel)]="data.permission" style="width:
150px;">
- <nz-option nzValue="admin" nzLabel="admin"></nz-option>
- <nz-option nzValue="contributer"
nzLabel="contributer"></nz-option>
- <nz-option nzValue="viwer" nzLabel="viwer"></nz-option>
- </nz-select>
- <nz-divider nzType="vertical"></nz-divider>
- <a
- nz-popconfirm
- nzTitle="Are you sure to delete this user ?"
- nzOkText="Ok"
- nzCancelText="Cancel"
- (nzOnConfirm)="confirm()"
- (nzOnCancel)="cancel()"
- >Delete</a>
- </td>
- </tr>
- </tbody>
- </nz-table>
- </div>
- </nz-tab>
- <!--Cluster-->
- <nz-tab [nzTitle]="tab4">
- <div style="text-align: center;">
- <nz-spin [nzSize]="'large'" nzSimple></nz-spin>
- </div>
- </nz-tab>
- <!--Setting-->
- <nz-tab [nzTitle]="tab5" [nzDisabled]="!currentTeamSettingPermission">
- <div style="text-align: center;">
- <nz-spin [nzSize]="'large'" nzSimple></nz-spin>
- </div>
- </nz-tab>
- </nz-tabset>
- </nz-card>
- <!--Template for Title of Tabs-->
- <ng-template #tab1>
- <i nz-icon nzType="profile" nzTheme="outline"></i>Profile
- </ng-template>
- <ng-template #tab2>
- <i nz-icon nzType="project" nzTheme="outline"></i>Projects
- </ng-template>
- <ng-template #tab3>
- <i nz-icon nzType="team" nzTheme="outline"></i>Members
- </ng-template>
- <ng-template #tab4>
- <i nz-icon nzType="cluster" nzTheme="outline"></i>Cluster
- </ng-template>
- <ng-template #tab5>
- <i nz-icon nzType="setting" nzTheme="outline"></i>Setting
- </ng-template>
-</div>
+ <div align="right">
+ <button
+ nz-button
+ nzType="default"
+ (click)="drawerVisible=flase;"
+ style="margin-right: 8px;">Cancel</button>
+ <button
+ nz-button
+ id="submitNewTeamBtn"
+ nzType="primary"
+ [nzLoading] = "submitBtnIsLoading"
+ (click)="submitNewTeam()"
+ style="margin-right: 8px;"
+ [disabled] = "!newTeamForm.get('teamName').valid ||
!newTeamForm.get('owner').valid">Create</button>
+ </div>
+</nz-drawer>
-<!--Add User Modal-->
-<nz-modal
- id="addUserModal"
- [(nzVisible)]="addUserModalIsVisible"
- nzTitle="Invite new member"
- (nzOnCancel)="addUserCancel()"
- (nzOnOk)="addUserOk()"
- [nzOkLoading]="addUserIsOkLoading"
->
- <p>Use E-mail to add member!</p>
-
+<!--Detail-->
+<nz-modal [nzVisible]="overviewModalVisible" [nzWidth]="540"
nzTitle="Overview" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
+ <h2>Team Name:</h2>
+ <p>{{ currentTeam_teamName }}</p>
+ <h2>ID:</h2>
+ <p>{{ currentTeam_id }}</p>
+ <h2>Owner:</h2>
+ <p>{{ currentTeam_owner }}</p>
+ <h2>Create Time</h2>
+ <p>{{ currentTeam_createTime }}</p>
</nz-modal>
diff --git
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
index 21ecd17..ea594e9 100644
---
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
+++
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.scss
@@ -17,12 +17,22 @@
* under the License.
*/
- #searchRegion{
- margin:20px;
- background-color: white;
- }
+#teamDiv{
+ margin:20px;
+ background-color: white;
+}
- #teamList {
- margin: 20;
- }
-
\ No newline at end of file
+.redStar{
+ color: red;
+}
+
+.footer{
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ border-top: 1px solid rgb(232, 232, 232);
+ padding: 10px 16px;
+ text-align: right;
+ left: 0px;
+ background: #fff;
+}
diff --git
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.ts
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.ts
index f3fa01c..fa359db 100644
---
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.ts
+++
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/team/team.component.ts
@@ -18,166 +18,153 @@
*/
import { Component, OnInit } from '@angular/core';
-import { NzMessageService } from 'ng-zorro-antd/message';
-import { NzNotificationService } from 'ng-zorro-antd/notification';
+import { FormGroup, FormControl, Validators, ValidationErrors } from
'@angular/forms';
+import { SysTeam } from '@submarine/interfaces';
+import { TeamService } from '@submarine/services';
+import { NzMessageService } from 'ng-zorro-antd';
+
+
@Component({
selector: 'app-team',
templateUrl: './team.component.html',
styleUrls: ['./team.component.scss']
})
-export class TeamComponent implements OnInit {
-
- // Get into a Team or not
- isEntering = false;
-
- //Get Current Team Data (Now Use Simulated Data)
- currentTeamName: string;
- currentTeamDepartment: string;
- currentTeamDescription: string;
- currentTeamProjectNum: Number;
- currentTeamMemberNum: Number;
- currentTeamSettingPermission: boolean;
-
- // Is Editging Members or not
- isEditingMember = false;
-
- // For CreateTeamModal
- createTeamModalIsVisible = false;
-
- // For AddUserModal
- addUserModalIsVisible = false;
- addUserIsOkLoading = false;
-
- // Simulated Data for Members
- member = [
- {
- name: 'Anna',
- email: '[email protected]',
- permission: 'admin'
- },
- {
- name: 'James',
- email: '[email protected]',
- permission: 'admin'
- },
- {
- name: 'Jack',
- email: '[email protected]',
- permission: 'contributer'
- },
- {
- name: 'Ken',
- email: '[email protected]',
- permission: 'viwer'
- }
- ]
-
- // Simulated Data for Teams
- existTeams = [
- {
- name: "Submarine",
- department: "Apache",
- description: "Something about this team...",
- projectNum: 3,
- memberNum: 3,
- role: 'admin',
- settingPermission: true
- },
- {
- name: "Team2",
- department: "Apple",
- description: "Something about this team...",
- projectNum: 3,
- memberNum: 3,
- role: 'viwer',
- settingPermission: false
- },
- ]
- constructor(
- private nzMessageService: NzMessageService,
- private notification: NzNotificationService,
+export class TeamComponent implements OnInit {
+ column: string = 'createdTime';
+ order: string = 'description';
+ teamName: string = "";
+ teamList: SysTeam[] = [];
+
+ //Form
+ newTeamForm: FormGroup; //For Adding Form
+ formTeamNameErrMesg = "";
+
+ //Drawer
+ drawerVisible = false;
+ submitBtnIsLoading = false;
+
+ //Modal
+ overviewModalVisible = false;
+ currentTeam_teamName: string;
+ currentTeam_id: string;
+ currentTeam_owner: string;
+ currentTeam_createTime: string;
+
+ constructor(
+ private teamService: TeamService,
+ private nzMessageService: NzMessageService,
) { }
ngOnInit() {
- }
-
- enter(team) {
- this.isEntering = true;
- this.currentTeamName = team.name;
- this.currentTeamDepartment = team.department;
- this.currentTeamDescription = team.description;
- this.currentTeamProjectNum = team.projectNum;
- this.currentTeamMemberNum = team.memberNum;
- this.currentTeamSettingPermission = team.settingPermission;
- }
-
- startCreateTeam() {
- this.createTeamModalIsVisible = true;
- }
+ this.newTeamForm = new FormGroup({
+ 'teamName': new FormControl(null, [Validators.required,
this.teamNameRequired.bind(this)], this.teamNameCheck.bind(this)),
+ 'owner': new FormControl(null, Validators.required)
+ });
- startEditMember() {
- this.isEditingMember=true;
+ this.getTeamList();
+
}
-
- saveEditMember() {
- this.isEditingMember=false;
+
+ getTeamList() {
+ this.teamService.getTeamList({
+ column: this.column,
+ order: this.order,
+ teamName: this.teamName,
+ }).subscribe(({ records }) => {
+ this.teamList = records;
+ console.log(records);
+ })
}
- cancel(): void {
+ submitNewTeam() {
+ this.submitBtnIsLoading = true;
+ this.teamService.createTeam({
+ teamName: this.newTeamForm.get('teamName').value,
+ owner: this.newTeamForm.get('owner').value,
+ createBy: this.newTeamForm.get('owner').value
+ }).subscribe(
+ () => {
+ this.nzMessageService.success('Create team success!');
+ this.getTeamList();
+ this.drawerVisible = false ;
+ this.submitBtnIsLoading = false ;
+ this.newTeamForm.reset();
+ }, err => {
+ this.nzMessageService.error(err.message);
+ this.submitBtnIsLoading = false ;
+ })
}
- confirm(): void {
- this.nzMessageService.info('Delete Successful!');
+ deleteTeam(teamData: SysTeam) {
+ this.teamService.deleteTeam(teamData.id).subscribe(
+ () => {
+ this.nzMessageService.success('Delete team success!');
+ this.getTeamList();
+ }
+ , err => {
+ this.nzMessageService.error(err.message);
+ }
+ )
}
- // For CreateTeamModal
- createTeamOk() {
- this.createTeamModalIsVisible = false;
- console.log("Create Seuccessful!");
+ closeDrawer() {
+ this.drawerVisible = false ;
+ this.newTeamForm.reset({
+ });
}
-
- // For AddUserModal
- startAddUser(): void {
- this.addUserModalIsVisible = true;
+ addTeam(){
+ this.drawerVisible = true ;
}
- // Add Success
- createNotification(type: string): void {
- this.notification.create(
- type,
- 'Add Successful!',
- 'Make sure that user check invitation!'
- );
- }
-
- // For AddUserModal
- addUserOk(): void {
- this.addUserIsOkLoading = true;
- setTimeout(() => {
- this.addUserModalIsVisible = false;
- this.addUserIsOkLoading = false;
- this.createNotification("success");
- }, 1000);
+ teamNameRequired(check: FormControl): {[key: string]:any}|null{
+ if (check.value === "") {
+ var errorMessage = "Please enter new team name!";
+ this.formTeamNameErrMesg = errorMessage;
+ return {mesg: true}
+ }
+ else {
+ this.formTeamNameErrMesg = "";
+ return null;
+ }
}
- // For AddUserModal
- addUserCancel(): void {
- this.addUserModalIsVisible = false;
+ teamNameCheck(check: FormControl): Promise<ValidationErrors|null>{
+ var params = {
+ tableName: 'team',
+ fieldName: 'team_name',
+ fieldVal: check.value
+ }
+ const promise = new Promise((resolve, reject) => {
+ this.teamService.newTeamNameCheck(params).then((success) => {
+ if (success) {
+ resolve(null);
+ }
+ else {
+ this.formTeamNameErrMesg = "This value already exists is not
available!";
+ resolve({"Duplicate Name": true});
+ }
+ },(err)=>{
+ reject(err);
+ });
+ });
+ return promise;
}
- //TODO(kobe860219) : Get Team From DataBase
- getTeamDataFromDB() {
-
+ showOverview(team) {
+ this.overviewModalVisible = true ;
+ this.currentTeam_teamName = team.teamName;
+ this.currentTeam_id = team.id;
+ this.currentTeam_owner = team.owner;
+ this.currentTeam_createTime = team.createTime;
}
- //TODO(kobe860219) : Get User From DataBase
- getUserDataFromDB() {
+ handleOk() {
+ this.overviewModalVisible = false ;
}
- //TODO(kobe860219) : Update Data to DataBase
- updateTeamData() {
-
+ handleCancel() {
+ this.overviewModalVisible = false ;
}
}
diff --git
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/workspace.module.ts
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/workspace.module.ts
index df74d79..ad73361 100644
---
a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/workspace.module.ts
+++
b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/workspace/workspace.module.ts
@@ -19,7 +19,7 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
-import { FormsModule } from '@angular/forms';
+import { FormsModule , ReactiveFormsModule } from '@angular/forms';
import { ComponentsModule } from '@submarine/components/components.module';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { NewProjectPageComponent } from
'./project/new-project-page/new-project-page.component';
@@ -36,13 +36,14 @@ import { TrainingComponent } from
'./training/training.component';
TrainingComponent,
TeamComponent,
SharedComponent,
- NewProjectPageComponent
+ NewProjectPageComponent,
],
imports: [
CommonModule,
ComponentsModule,
NgZorroAntdModule,
- FormsModule
+ FormsModule,
+ ReactiveFormsModule
],
exports: [
ProjectComponent,
diff --git
a/submarine-workbench/workbench-web-ng/src/app/services/public-api.ts
b/submarine-workbench/workbench-web-ng/src/app/services/public-api.ts
index 4bc5376..3851356 100644
--- a/submarine-workbench/workbench-web-ng/src/app/services/public-api.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/services/public-api.ts
@@ -23,3 +23,4 @@ export * from './department.service';
export * from './local-storage.service';
export * from './system-utils.service';
export * from './user.service';
+export * from './team.service';
diff --git
a/submarine-workbench/workbench-web-ng/src/app/services/team.service.ts
b/submarine-workbench/workbench-web-ng/src/app/services/team.service.ts
new file mode 100644
index 0000000..47d9105
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/services/team.service.ts
@@ -0,0 +1,113 @@
+/*
+ * 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 { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { BaseApiService } from './base-api.service';
+import { ListResult, Rest } from '@submarine/interfaces';
+import { of, Observable } from 'rxjs';
+import { switchMap } from 'rxjs/operators';
+import { SysTeam } from '@submarine/interfaces/sys-team';
+import { ValidationErrors } from '@angular/forms';
+
+interface TeamListQueryParams {
+ teamName: string;
+ owner: string;
+ column: string;
+ order: string;
+}
+
+@Injectable({
+ providedIn: 'root'
+})
+
+export class TeamService {
+
+ constructor(private httpClient: HttpClient, private baseApi: BaseApiService)
{
+ }
+
+ getTeamList(queryParams: Partial<TeamListQueryParams>):
Observable<ListResult<SysTeam>> {
+ const apiUrl = this.baseApi.getRestApi('/team/list');
+ return this.httpClient.get<Rest<ListResult<SysTeam>>>(apiUrl, {
+ params: queryParams
+ }).pipe(
+ switchMap(res => {
+ if (res.success) {
+ console.log(res.result);
+ return of(res.result);
+ }
+ else {
+ throw this.baseApi.createRequestError(res.message, res.code, apiUrl,
'get', queryParams);
+ }
+ })
+ );
+ }
+
+ createTeam(params): Observable<SysTeam> {
+ const apiUrl = this.baseApi.getRestApi('/team/add');
+ return this.httpClient.post<Rest<SysTeam>>(apiUrl, params).pipe(
+ switchMap(res => {
+ console.log(res)
+ if (res.success) {
+ return of(res.result);
+ }
+ else {
+ throw this.baseApi.createRequestError(res.message, res.code, apiUrl,
'post', params);
+ }
+ })
+ );
+ }
+
+ deleteTeam(id: string) {
+ const apiUrl = this.baseApi.getRestApi('/team/delete');
+ return this.httpClient.delete<Rest<any>>(apiUrl, {
+ params: {
+ id
+ }
+ }).pipe(
+ switchMap(res => {
+ if (res.success) {
+ return of(true);
+ }
+ else {
+ throw this.baseApi.createRequestError(res.message, res.code, apiUrl,
'post', id);
+ }
+ })
+ )
+ }
+
+ newTeamNameCheck(nameParams): Promise<ValidationErrors|null> {
+ const promise = new Promise((resolve, reject) => {
+ const apiUrl = this.baseApi.getRestApi('/sys/duplicateCheck');
+ this.httpClient.get<any>(apiUrl,{
+ params: nameParams
+ }).toPromise()
+ .then((res: any) => {
+ console.log(res)
+ resolve(res.success);
+ },
+ err => {
+ console.log(err);
+ reject(err);
+ }
+ );
+ });
+ return promise;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]