From 8790e95147c46f1fecc40728ed62478e8b3725ba Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Thu, 11 Feb 2021 23:51:29 +0800 Subject: [PATCH] Add Organization to Application. --- object/application.go | 7 ++++--- web/src/ApplicationEditPage.js | 26 +++++++++++++++++++++++++- web/src/Face.js | 17 ++++++++++++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/object/application.go b/object/application.go index ba4aa305..2a765752 100644 --- a/object/application.go +++ b/object/application.go @@ -24,9 +24,10 @@ type Application struct { Name string `xorm:"varchar(100) notnull pk" json:"name"` CreatedTime string `xorm:"varchar(100)" json:"createdTime"` - DisplayName string `xorm:"varchar(100)" json:"displayName"` - Logo string `xorm:"varchar(100)" json:"logo"` - Providers []string `xorm:"varchar(100)" json:"providers"` + DisplayName string `xorm:"varchar(100)" json:"displayName"` + Logo string `xorm:"varchar(100)" json:"logo"` + Organization string `xorm:"varchar(100)" json:"organization"` + Providers []string `xorm:"varchar(100)" json:"providers"` } func GetApplications(owner string) []*Application { diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index febc95b5..d0f85fe7 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -1,9 +1,10 @@ import React from "react"; -import {AutoComplete, Button, Card, Col, Input, Row, Select} from 'antd'; +import {Button, Card, Col, Input, Row, Select} from 'antd'; import {LinkOutlined} from "@ant-design/icons"; import * as ApplicationBackend from "./backend/ApplicationBackend"; import * as Setting from "./Setting"; import * as ProviderBackend from "./backend/ProviderBackend"; +import * as OrganizationBackend from "./backend/OrganizationBackend"; import Face from "./Face"; const { Option } = Select; @@ -15,12 +16,14 @@ class ApplicationEditPage extends React.Component { classes: props, applicationName: props.match.params.applicationName, application: null, + organizations: [], providers: [], }; } componentWillMount() { this.getApplication(); + this.getOrganizations(); this.getProviders(); } @@ -33,6 +36,15 @@ class ApplicationEditPage extends React.Component { }); } + getOrganizations() { + OrganizationBackend.getOrganizations("admin") + .then((res) => { + this.setState({ + organizations: res, + }); + }); + } + getProviders() { ProviderBackend.getProviders("admin") .then((res) => { @@ -114,6 +126,18 @@ class ApplicationEditPage extends React.Component { + + + Organization: + + + + + Providers: diff --git a/web/src/Face.js b/web/src/Face.js index e036b8c6..29761c2d 100644 --- a/web/src/Face.js +++ b/web/src/Face.js @@ -2,6 +2,8 @@ import React from "react"; import {Button, Checkbox, Col, Form, Input, Row} from "antd"; import {LockOutlined, UserOutlined} from "@ant-design/icons"; import * as ApplicationBackend from "./backend/ApplicationBackend"; +import * as AccountBackend from "./backend/AccountBackend"; +import * as Setting from "./Setting"; class Face extends React.Component { constructor(props) { @@ -34,12 +36,25 @@ class Face extends React.Component { } } + onFinish(values) { + AccountBackend.login(values) + .then((res) => { + if (res.status === 'ok') { + this.props.onLogined(); + Setting.showMessage("success", `Logged in successfully`); + Setting.goToLink("/"); + } else { + Setting.showMessage("error", `Log in failed:${res.msg}`); + } + }); + }; + renderForm() { return (