Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-plan-hs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Drees
food-plan-hs
Commits
ba46c3f2
Commit
ba46c3f2
authored
2 years ago
by
felix
Browse files
Options
Downloads
Patches
Plain Diff
GI GTK comboBox done
parent
d2c07786
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/Main.hs
+6
-10
6 additions, 10 deletions
app/Main.hs
food-plan-hs.cabal
+0
-6
0 additions, 6 deletions
food-plan-hs.cabal
package.yaml
+1
-2
1 addition, 2 deletions
package.yaml
src/LibUniHbMensa.hs
+11
-21
11 additions, 21 deletions
src/LibUniHbMensa.hs
with
18 additions
and
39 deletions
app/Main.hs
+
6
−
10
View file @
ba46c3f2
...
...
@@ -39,10 +39,8 @@ comboBoxHelper comBox strList = do
Gtk
.
comboBoxTextAppendText
comBox
$
head
strList
comboBoxHelper
comBox
$
tail
strList
getMensaIdByText
::
Maybe
Text
->
Int
getMensaIdByText
name
|
(
isJust
name
)
=
getMensaIdByTextRec
(
fromJust
name
)
0
|
otherwise
=
0
-- default id = 0 for Uni Mensa
getMensaIdByText
::
Text
->
Int
getMensaIdByText
name
=
getMensaIdByTextRec
name
0
where
getMensaIdByTextRec
::
Text
->
Int
->
Int
getMensaIdByTextRec
eman
i
...
...
@@ -83,14 +81,12 @@ main = do
Gtk
.
widgetSetHexpand
submit_btn
False
_
<-
Gtk
.
on
submit_btn
#
clicked
$
do
currentCBText
<-
Gtk
.
comboBoxTextGetActiveText
cb
-- TODO ...
-- currentMensaId <- getMensaIdByText $ Gtk.comboBoxTextGetActiveText cb
-- foodPlanPage <- UM.getMensaWebpage currentMensaId -- food plan webpage of selected dining hall
putStrLn
"--- URL ---"
print
$
UM
.
getMensaWebpage
$
if
isJust
currentCBText
then
getMensaIdByText
(
fromJust
currentCBText
)
else
0
-- default id=0 for Uni Mensa
putStrLn
"SUBMIT BUTTON CLICKED: "
-- ++ foodPlanPage
-- TODO display food plan info
-- TODO display selected meal plan ...
-- PLACE OBJECTS IN A GRID ON THE WINDOW ----------------------------------
...
...
This diff is collapsed.
Click to expand it.
food-plan-hs.cabal
+
0
−
6
View file @
ba46c3f2
...
...
@@ -37,8 +37,6 @@ library
, gi-gtk ==3.0.*
, gi-gtk-hs
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
...
...
@@ -55,8 +53,6 @@ executable food-plan-hs-exe
, gi-gtk ==3.0.*
, gi-gtk-hs
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
...
...
@@ -74,7 +70,5 @@ test-suite food-plan-hs-test
, gi-gtk ==3.0.*
, gi-gtk-hs
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
This diff is collapsed.
Click to expand it.
package.yaml
+
1
−
2
View file @
ba46c3f2
...
...
@@ -24,9 +24,8 @@ dependencies:
-
gi-gtk == 3.0.*
-
gi-gtk-hs
-
haskell-gi-base
-
http-client
-
http-client-tls
-
text
# http
ghc-options
:
-
-Wall
...
...
This diff is collapsed.
Click to expand it.
src/LibUniHbMensa.hs
+
11
−
21
View file @
ba46c3f2
...
...
@@ -2,20 +2,17 @@
-- FOOD PLAN GUI - (c) 2022 Felix Drees - GNU GPLv3 --
-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module
LibUniHbMensa
where
import
qualified
Network.HTTP.Client
as
H
import
qualified
Network.HTTP.Client.TLS
as
H
-- import qualified Network.HTTP
--STATIC VARS------------------------------------------------------------------
base
_u
rl
::
[
Char
]
base
_u
rl
=
"https://www.stw-bremen.de"
base
U
rl
::
[
Char
]
base
U
rl
=
"https://www.stw-bremen.de"
mensa
_url_l
ist
::
[[
Char
]]
mensa
_url_l
ist
=
[
mensa
UrlL
ist
::
[[
Char
]]
mensa
UrlL
ist
=
[
"/de/mensa/uni-mensa"
,
-- Uni-Mensa
"/de/mensa/nw-1"
,
-- Mensa NW1
"/de/cafeteria/gw2"
,
-- Cafeteria GW2
...
...
@@ -32,18 +29,11 @@ mensa_url_list = [
getMensaWebpage
::
Int
->
String
getMensaWebpage
mensaId
|
(
mensaId
<
0
)
=
error
"INVALID INPUT FOR getMensaWebpage"
|
(
mensaId
<
10
)
=
getWebpage
$
base_url
++
mensa_url_list
!!
mensaId
|
otherwise
=
getWebpage
$
base_url
++
mensa_url_list
!!
0
|
(
mensaId
>=
0
&&
mensaId
<
length
mensaUrlList
)
=
getWebpage
$
baseUrl
++
mensaUrlList
!!
mensaId
|
otherwise
=
getWebpage
$
baseUrl
++
mensaUrlList
!!
0
where
getWebpage
::
String
->
String
getWebpage
url
=
"test url: "
++
url
-- getWebpage url = H.httpLbs (H.setQueryString [("q", Just "r")] url) H.newManager H.tlsManagerSettings
test
::
IO
()
test
=
do
httpman
<-
H
.
newManager
H
.
tlsManagerSettings
let
req
=
H
.
setQueryString
[(
"q"
,
Just
"r"
)]
"https://wikipedia.org"
response
<-
H
.
httpLbs
req
httpman
print
response
getWebpage
url
=
url
-- getWebpage url = simpleHTTP (getRequest url) >>= fmap (take 100) . getResponseBody
-- fetch document and return it (as a 'String'.)
-- https://hackage.haskell.org/package/HTTP-4000.3.16/docs/Network-HTTP.html
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment