Add org's favicon.

This commit is contained in:
Yang Luo 2021-04-29 20:27:07 +08:00
parent 5779d57960
commit 3065bacad2
4 changed files with 45 additions and 2 deletions

View File

@ -26,6 +26,7 @@ type Organization struct {
DisplayName string `xorm:"varchar(100)" json:"displayName"`
WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"`
Favicon string `xorm:"varchar(100)" json:"favicon"`
}
func GetOrganizations(owner string) []*Organization {

View File

@ -440,7 +440,7 @@ class App extends Component {
<React.Fragment>
<Helmet>
<title>{organization.displayName}</title>
<link rel="icon" href={organization.websiteUrl} />
<link rel="icon" href={organization.favicon} />
</Helmet>
{
this.renderPage()

View File

@ -17,6 +17,7 @@ import {Button, Card, Col, Input, Row} from 'antd';
import * as OrganizationBackend from "./backend/OrganizationBackend";
import * as Setting from "./Setting";
import i18next from "i18next";
import {LinkOutlined} from "@ant-design/icons";
class OrganizationEditPage extends React.Component {
constructor(props) {
@ -86,6 +87,33 @@ class OrganizationEditPage extends React.Component {
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Favicon:
</Col>
<Col span={22} >
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={1}>
URL:
</Col>
<Col span={23} >
<Input prefix={<LinkOutlined/>} value={this.state.organization.favicon} onChange={e => {
this.updateOrganizationField('favicon', e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={1}>
{i18next.t("general:Preview")}:
</Col>
<Col span={23} >
<a target="_blank" rel="noreferrer" href={this.state.organization.favicon}>
<img src={this.state.organization.favicon} alt={this.state.organization.favicon} height={90} style={{marginBottom: '20px'}}/>
</a>
</Col>
</Row>
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{i18next.t("organization:Website URL")}:

View File

@ -48,7 +48,8 @@ class OrganizationListPage extends React.Component {
name: `organization_${this.state.organizations.length}`,
createdTime: moment().format(),
displayName: `New Organization - ${this.state.organizations.length}`,
websiteUrl: "https://cdn.casbin.com/static/favicon.ico",
websiteUrl: "https://door.casbin.com",
favicon: "https://cdn.casbin.com/static/favicon.ico",
}
}
@ -114,6 +115,19 @@ class OrganizationListPage extends React.Component {
// width: '100px',
sorter: (a, b) => a.displayName.localeCompare(b.displayName),
},
{
title: 'Favicon',
dataIndex: 'favicon',
key: 'favicon',
width: '50px',
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={text}>
<img src={text} alt={text} width={40} />
</a>
)
}
},
{
title: i18next.t("organization:Website URL"),
dataIndex: 'websiteUrl',