Skip to content

Commit

Permalink
add card
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH committed Aug 6, 2024
1 parent a2a2ce7 commit f0adc92
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/ysk/ysk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestLongAndShortNoticeInsert(t *testing.T) {
// wait for the service to start
time.Sleep(1 * time.Second)

err := ysk.NewYSKCard(context.Background(), utils.DiskInsertNotice, mockPublish)
err := ysk.NewYSKCard(context.Background(), utils.ZimaOSDataStationNotice, mockPublish)
assert.NilError(t, err)
err = ysk.NewYSKCard(context.Background(), utils.ApplicationUpdateNotice, mockPublish)
assert.NilError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions service/ysk.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func (s *YSKService) Start() {
}

s.UpsertYSKCard(context.Background(), utils.ApplicationInstallProgress.WithProgress("Installing Jellyfin", 20))
s.UpsertYSKCard(context.Background(), utils.DiskInsertNotice)
s.UpsertYSKCard(context.Background(), utils.ZimaOSDataStationNotice)
s.UpsertYSKCard(context.Background(), utils.ZimaOSFileManagementNotice)
s.UpsertYSKCard(context.Background(), utils.ZimaOSRemoteAccessNotice)

s.UpsertYSKCard(context.Background(), utils.DiskInsertNotice)
go func() {
for {
select {
Expand Down
8 changes: 4 additions & 4 deletions service/ysk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestInsertAndGetCardList(t *testing.T) {
assert.Equal(t, len(cardList), 0)

cardInsertQueue := []ysk.YSKCard{
utils.ApplicationInstallProgress, utils.DiskInsertNotice,
utils.ApplicationInstallProgress, utils.ZimaOSDataStationNotice,
}

for _, card := range cardInsertQueue {
Expand All @@ -45,8 +45,8 @@ func TestInsertAndGetCardList(t *testing.T) {
for _, card := range cardList {
if card.Id == utils.ApplicationInstallProgress.Id {
assert.DeepEqual(t, card, utils.ApplicationInstallProgress)
} else if card.Id == utils.DiskInsertNotice.Id {
assert.DeepEqual(t, card, utils.DiskInsertNotice)
} else if card.Id == utils.ZimaOSDataStationNotice.Id {
assert.DeepEqual(t, card, utils.ZimaOSDataStationNotice)
} else {
t.Errorf("unexpected card: %v", card)
}
Expand All @@ -62,7 +62,7 @@ func TestInsertAllTypeCardList(t *testing.T) {
assert.Equal(t, len(cardList), 0)

cardInsertQueue := []ysk.YSKCard{
utils.ApplicationInstallProgress, utils.DiskInsertNotice,
utils.ApplicationInstallProgress, utils.ZimaOSDataStationNotice,
// the notice is short. it didn't be stored
utils.ApplicationUpdateNotice,
utils.ApplicationInstallProgress.WithProgress("Installing LinuxServer/Jellyfin", 50), utils.ApplicationInstallProgress.WithProgress("Installing LinuxServer/Jellyfin", 55),
Expand Down
24 changes: 23 additions & 1 deletion utils/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
},
}

DiskInsertNotice = ysk.YSKCard{
ZimaOSDataStationNotice = ysk.YSKCard{
Id: "long-notice:disk:insert",
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardIconTextNotice,
Expand Down Expand Up @@ -132,4 +132,26 @@ var (
},
},
}

DiskInsertNotice = ysk.YSKCard{
Id: "long-notice:disk:insert",
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardListNotice,
Content: ysk.YSKCardContent{
TitleIcon: "disk logo",
TitleText: "硬盘插入",
BodyList: []ysk.YSKCardListItem{
{
Icon: "disk",
Description: "ZimaOS-HD",
RightText: "2TB",
}, {
Icon: "disk",
Description: "Safe-Storage",
RightText: "2TB",
},
},
FooterActions: nil,
},
}
)

0 comments on commit f0adc92

Please sign in to comment.