-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package front | ||
|
||
import ( | ||
"strconv" | ||
"github.com/darklab8/fl-darkstat/darkstat/front/urls" | ||
"github.com/darklab8/fl-darkstat/darkstat/common/types" | ||
"github.com/darklab8/fl-configs/configs/configs_export" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func CommoditiesBaseInfoUrl(commodity configs_export.Commodity) string { | ||
return "commodities/comm_base_" + strings.ToLower(commodity.Nickname) | ||
} | ||
|
||
// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers | ||
// https://www.cssscript.com/fast-html-table-sorting/ | ||
templ CommoditiesT(commodities []configs_export.Commodity) { | ||
@TabMenu(urls.Commodities) | ||
@TabContent() { | ||
<div class="splitter"> | ||
<div id="table-wrapper"> | ||
<div id="table-top"> | ||
<table class="sortable"> | ||
<thead> | ||
<tr> | ||
<th style="width:200px;">Commodity</th> | ||
<th style="width:50px;">Price</th> | ||
<th style="width:50px;">Price Per Volume</th> | ||
<th style="width:50px;">Volume</th> | ||
<th style="width:50px;">Best Buy Price / V</th> | ||
<th style="width:50px;">Best Sell Price / V</th> | ||
<th style="width:50px;">Profit Margin / V</th> | ||
<th style="width:100px;">Nickname</th> | ||
<th style="width:100px;">Name ID</th> | ||
<th style="width:100px;">Infocard ID</th> | ||
<th style="max-width:100%;"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
for _, commodity := range commodities { | ||
<tr | ||
id={ "baseinfo_click" + commodity.Nickname } | ||
hx-get={ types.GetCtx(ctx).SiteRoot + CommoditiesBaseInfoUrl(commodity) } | ||
hx-trigger="click" | ||
hx-target="#table-bottom" | ||
hx-swap="innerHTML" | ||
> | ||
<td>{ commodity.Name }</td> | ||
<td>{ strconv.Itoa(commodity.Price) }</td> | ||
<td>{ strconv.Itoa(commodity.PricePerVolume) }</td> | ||
<td>{ fmt.Sprintf("%.6f", commodity.Volume) }</td> | ||
<td>{ strconv.Itoa(commodity.BestBuyPricePerVol) }</td> | ||
<td>{ strconv.Itoa(commodity.BestSellPricePerVol) }</td> | ||
<td>{ strconv.Itoa(commodity.ProffitMarginPerVol) }</td> | ||
<td>{ commodity.Nickname }</td> | ||
<td>{ strconv.Itoa(commodity.NameID) }</td> | ||
<td>{ strconv.Itoa(commodity.InfocardID) }</td> | ||
<td | ||
id={ "infocard_click" + commodity.Nickname } | ||
hx-get={ types.GetCtx(ctx).SiteRoot + InfocardURL(commodity.Infocard) } | ||
hx-trigger="click" | ||
hx-target="#infocard_view" | ||
hx-swap="innerHTML" | ||
></td> | ||
@templ.Raw(JoinClickTriggers("baseinfo_click"+commodity.Nickname, "infocard_click"+commodity.Nickname)) | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
<div id="table-bottom"> | ||
@CommoditiesBasesInfoShared() | ||
</div> | ||
</div> | ||
<div id="infocard_view"> | ||
@InfocardShared() | ||
</div> | ||
</div> | ||
} | ||
} | ||
|
||
templ CommoditiesBasesInfoShared() { | ||
<table class="sortable"> | ||
<thead> | ||
<tr class="flexed-tr"> | ||
<th style="width:200px;">Base</th> | ||
<th style="width:100px;">Faction</th> | ||
<th style="width:50px;">System</th> | ||
<th style="width:50px;">Price Per foume</th> | ||
<th style="width:50px;">Base Sells</th> | ||
<th style="width:50px;">Level Req'd</th> | ||
<th style="width:50px;">Reputation Req'd</th> | ||
<th style="width:50px;">Base Nickname</th> | ||
<th style="max-width:100%;"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{ children... } | ||
</tbody> | ||
</table> | ||
} | ||
|
||
templ CommoditiesBaseInfo(base_infos []configs_export.CommodityAtBase) { | ||
@CommoditiesBasesInfoShared() { | ||
for _, base_info := range base_infos { | ||
<tr | ||
hx-get={ types.GetCtx(ctx).SiteRoot + InfocardURL(configs_export.InfocardKey(base_info.BaseNickname)) } | ||
hx-trigger="click" | ||
hx-target="#infocard_view" | ||
hx-swap="innerHTML" | ||
> | ||
<td>{ base_info.BaseName }</td> | ||
<td>{ base_info.Faction }</td> | ||
<td>{ base_info.SystemName }</td> | ||
<td>{ strconv.Itoa(base_info.PricePerVolume) }</td> | ||
<td>{ strconv.FormatBool(base_info.BaseSells) }</td> | ||
<td>{ strconv.Itoa(base_info.LevelRequired) }</td> | ||
<td>{ fmt.Sprintf("%.2f", base_info.RepRequired) }</td> | ||
<td>{ base_info.BaseNickname }</td> | ||
<td></td> | ||
</tr> | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters