iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 26
1

完成了大概80%的功能之後,我們還剩下機房的服務資訊列表沒完成,
我們要去取得這機房內有幾台電腦等相關數據,
首先在message.py之中新增,

class roomResourceslable():
    def returna(self):
        computerdata = []
        for data in RoomInformationdata.find():
            computerdata = data
            
        flex_message = FlexSendMessage(
            alt_text='hello',
            contents={
            "type": "bubble",
            "size": "mega",
            "header": {
                "type": "box",
                "layout": "vertical",
                "contents": [
                {
                    "type": "box",
                    "layout": "vertical",
                    "contents": [
                    {
                        "type": "text",
                        "text": "機房資源列表",
                        "color": "#ffffff",
                        "size": "xl",
                        "flex": 4,
                        "weight": "regular",
                        "margin": "xs"
                    }
                    ]
                }
                ],
                "paddingAll": "20px",
                "backgroundColor": "#0367D3",
                "spacing": "md",
                "height": "80px",
                "paddingTop": "22px"
            },
            "body": {
                "type": "box",
                "layout": "vertical",
                "contents": [
                {
                    "type": "text",
                    "text": "VCPU數量(顆):"+ str(computerdata["vcpu"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "RAM數量(GB):"+ str(computerdata["ram"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "機房儲存空間(TB):"+str(computerdata["disk"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "機房Switch數量(台):"+str(computerdata["switch"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "機房SDN Switch 數量(台):"+str(computerdata["sdnSwitch"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "機房一般主機數量(台):"+str(computerdata["pc"]),
                    "color": "#0367D3"
                },
                {
                    "type": "text",
                    "text": "機房伺服器數量(台):"+str(computerdata["server"]),
                    "color": "#0367D3"
                }
                ]
            }
            }
        )
        return flex_message

再來我們在views.py中新增,

if event.message.text == "機房資訊":

                    line_bot_api.reply_message(  # 回復「機房資訊」按鈕輪播訊息
                        event.reply_token,
                        roomResourceslable().returna()
                    )

展示就大概如下!

撒花!!!我們把機房大概的功能都完成ㄌ~~
下一篇將做個總整理。


今天是 陳鈺羲 的 最愛 網址如下~~~

https://www.youtube.com/watch?v=3NGLAlxEMUk&list=PLZ_d6NX2sE80xcb4RjHSCBt3E1nTclmC4&index=20&ab_channel=%E9%99%B3%E9%88%BA%E7%BE%B2



上一篇
Day25 機房好狗走起(5)
下一篇
Day27 機房好狗結果展示(7)
系列文
狗狗 Line Bot 以python及Django建構30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言