Skip to content

Commit

Permalink
Add tag to site
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Oct 5, 2023
1 parent a45cf55 commit a2546a4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
3 changes: 2 additions & 1 deletion object/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Site struct {
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
DisplayName string `xorm:"varchar(100)" json:"displayName"`

Tag string `xorm:"varchar(100)" json:"tag"`
Domain string `xorm:"varchar(100)" json:"domain"`
Host string `xorm:"varchar(100)" json:"host"`
Port int `json:"port"`
Expand Down Expand Up @@ -66,7 +67,7 @@ func GetGlobalSites() []*Site {

func GetSites(owner string) []*Site {
sites := []*Site{}
err := ormer.Engine.Desc("created_time").Find(&sites, &Site{Owner: owner})
err := ormer.Engine.Asc("tag").Asc("name").Desc("created_time").Find(&sites, &Site{Owner: owner})
if err != nil {
panic(err)
}
Expand Down
22 changes: 21 additions & 1 deletion web/src/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {message} from "antd";
import {Tag, message} from "antd";
import {isMobile as isMobileDevice} from "react-device-detect";
import i18next from "i18next";
import moment from "moment";
Expand Down Expand Up @@ -183,6 +183,26 @@ export function getAvatarColor(s) {
return colorList[random % 4];
}

export function getTagColor(s) {
return "processing";
}

export function getTags(tags) {
const res = [];
if (!tags) {
return res;
}

tags.forEach((tag, i) => {
res.push(
<Tag color={getTagColor(tag)}>
{tag}
</Tag>
);
});
return res;
}

export function getLanguage() {
return i18next.language;
}
Expand Down
10 changes: 10 additions & 0 deletions web/src/SiteEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ class SiteEditPage extends React.Component {
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={2}>
{i18next.t("general:Tag")}:
</Col>
<Col span={22} >
<Input value={this.state.site.tag} onChange={e => {
this.updateSiteField("tag", e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={2}>
{i18next.t("site:Domain")}:
Expand Down
21 changes: 19 additions & 2 deletions web/src/SiteListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class SiteListPage extends React.Component {
};

const columns = [
{
title: i18next.t("general:Tag"),
dataIndex: "tag",
key: "tag",
width: "120px",
sorter: (a, b) => a.tag.localeCompare(b.tag),
},
{
title: i18next.t("general:Name"),
dataIndex: "name",
Expand Down Expand Up @@ -161,11 +168,11 @@ class SiteListPage extends React.Component {
title: i18next.t("site:Host"),
dataIndex: "host",
key: "host",
width: "180px",
width: "110px",
sorter: (a, b) => a.host.localeCompare(b.host),
render: (text, record, index) => {
if (text === "") {
text = `http://localhost:${record.port}`;
text = `${record.port}`;
}

if (!record.isSelf) {
Expand All @@ -179,6 +186,16 @@ class SiteListPage extends React.Component {
);
},
},
{
title: i18next.t("site:Nodes"),
dataIndex: "nodes",
key: "nodes",
// width: "200px",
sorter: (a, b) => a.nodes.localeCompare(b.nodes),
render: (text, record, index) => {
return Setting.getTags(record.nodes.map(node => node.name));
},
},
// {
// title: i18next.t("site:Public IP"),
// dataIndex: "publicIp",
Expand Down

0 comments on commit a2546a4

Please sign in to comment.