diff options
| -rw-r--r-- | webgui/data/index.html | 4 | ||||
| -rw-r--r-- | webgui/data/style.css | 22 | ||||
| -rw-r--r-- | webgui/data/tabs.js | 27 | ||||
| -rw-r--r-- | webgui/src/Main.hs | 22 |
4 files changed, 57 insertions, 18 deletions
diff --git a/webgui/data/index.html b/webgui/data/index.html index e4a6c63..b677387 100644 --- a/webgui/data/index.html +++ b/webgui/data/index.html | |||
| @@ -15,14 +15,14 @@ | |||
| 15 | Need javascript to function. | 15 | Need javascript to function. |
| 16 | </p> | 16 | </p> |
| 17 | <div class="tabs"> | 17 | <div class="tabs"> |
| 18 | <ul class="tab-links"> | 18 | <ul class="tabLinks" id="tabLinks"> |
| 19 | <li class="active"><a href="#editor">Editor</a></li> | 19 | <li class="active"><a href="#editor">Editor</a></li> |
| 20 | <li><a href="#drafts">Drafts</a></li> | 20 | <li><a href="#drafts">Drafts</a></li> |
| 21 | <li><a href="#printers">Printers & Jobs</a></li> | 21 | <li><a href="#printers">Printers & Jobs</a></li> |
| 22 | <li id="errors-tab" style="display:none;"><a href="#errors">Errors</a></li> | 22 | <li id="errors-tab" style="display:none;"><a href="#errors">Errors</a></li> |
| 23 | </ul> | 23 | </ul> |
| 24 | 24 | ||
| 25 | <div class="tab-content"> | 25 | <div class="tabContent" id="tabContent"> |
| 26 | <div class="tab active" id="editor"> | 26 | <div class="tab active" id="editor"> |
| 27 | <!-- <label id="titleLabel" for="editorTitle">Title</label> --> | 27 | <!-- <label id="titleLabel" for="editorTitle">Title</label> --> |
| 28 | <input id="saveDraft" type="checkbox" checked="checked" /><label for="saveDraft">Save as Draft</label> | 28 | <input id="saveDraft" type="checkbox" checked="checked" /><label for="saveDraft">Save as Draft</label> |
diff --git a/webgui/data/style.css b/webgui/data/style.css index fd40d92..d496e2a 100644 --- a/webgui/data/style.css +++ b/webgui/data/style.css | |||
| @@ -98,6 +98,16 @@ tr.focused td { | |||
| 98 | background-color:#f0f0f0; | 98 | background-color:#f0f0f0; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | .close { | ||
| 102 | float:right; | ||
| 103 | text-decoration:underline; | ||
| 104 | color:#4c4c4c; | ||
| 105 | } | ||
| 106 | |||
| 107 | .close:hover { | ||
| 108 | text-decoration:none; | ||
| 109 | } | ||
| 110 | |||
| 101 | /*----- Tabs -----*/ | 111 | /*----- Tabs -----*/ |
| 102 | .tabs { | 112 | .tabs { |
| 103 | display:block; | 113 | display:block; |
| @@ -109,7 +119,7 @@ tr.focused td { | |||
| 109 | } | 119 | } |
| 110 | 120 | ||
| 111 | /*----- Tab Links -----*/ | 121 | /*----- Tab Links -----*/ |
| 112 | .tab-links { | 122 | .tabLinks { |
| 113 | display:block; | 123 | display:block; |
| 114 | height:2.2em; | 124 | height:2.2em; |
| 115 | margin:0; | 125 | margin:0; |
| @@ -118,19 +128,19 @@ tr.focused td { | |||
| 118 | } | 128 | } |
| 119 | 129 | ||
| 120 | /* Clearfix */ | 130 | /* Clearfix */ |
| 121 | .tab-links:after { | 131 | .tabLinks:after { |
| 122 | display:block; | 132 | display:block; |
| 123 | clear:both; | 133 | clear:both; |
| 124 | content:''; | 134 | content:''; |
| 125 | } | 135 | } |
| 126 | 136 | ||
| 127 | .tab-links li { | 137 | .tabLinks li { |
| 128 | margin:0px 0.5em; | 138 | margin:0px 0.5em; |
| 129 | float:left; | 139 | float:left; |
| 130 | list-style:none; | 140 | list-style:none; |
| 131 | } | 141 | } |
| 132 | 142 | ||
| 133 | .tab-links a { | 143 | .tabLinks a { |
| 134 | padding:0.5em 1em; | 144 | padding:0.5em 1em; |
| 135 | display:inline-block; | 145 | display:inline-block; |
| 136 | border-radius:3px 3px 0px 0px; | 146 | border-radius:3px 3px 0px 0px; |
| @@ -141,7 +151,7 @@ tr.focused td { | |||
| 141 | transition:all linear 0.15s; | 151 | transition:all linear 0.15s; |
| 142 | } | 152 | } |
| 143 | 153 | ||
| 144 | .tab-links a:hover { | 154 | .tabLinks a:hover { |
| 145 | text-decoration:none; | 155 | text-decoration:none; |
| 146 | } | 156 | } |
| 147 | 157 | ||
| @@ -156,7 +166,7 @@ li.active a, li.active a:hover { | |||
| 156 | } | 166 | } |
| 157 | 167 | ||
| 158 | /*----- Content of Tabs -----*/ | 168 | /*----- Content of Tabs -----*/ |
| 159 | .tab-content { | 169 | .tabContent { |
| 160 | padding:0.5em; | 170 | padding:0.5em; |
| 161 | border:1px solid #ddd; | 171 | border:1px solid #ddd; |
| 162 | border-radius:3px; | 172 | border-radius:3px; |
diff --git a/webgui/data/tabs.js b/webgui/data/tabs.js index 1d178d9..0cdb8e5 100644 --- a/webgui/data/tabs.js +++ b/webgui/data/tabs.js | |||
| @@ -1,13 +1,22 @@ | |||
| 1 | jQuery(document).ready(function() { | 1 | jQuery(document).ready(function() { |
| 2 | jQuery('.tabs .tab-links a').on('click', function(e) { | 2 | jQuery('.tabs .tabLinks a').on('click', switchTab); |
| 3 | var currentAttrValue = jQuery(this).attr('href'); | 3 | |
| 4 | var observer = new window.MutationObserver(function(mutations, observer) { | ||
| 5 | jQuery('.tabs .tabLinks a').on('click', switchTab); | ||
| 6 | }); | ||
| 7 | jQuery('.tabLinks').each( function () { | ||
| 8 | observer.observe(this, { childList: true, subtree: true }); | ||
| 9 | }); | ||
| 10 | }); | ||
| 11 | |||
| 12 | function switchTab(e) { | ||
| 13 | var currentAttrValue = jQuery(this).attr('href'); | ||
| 4 | 14 | ||
| 5 | // Show/Hide Tabs | 15 | // Show/Hide Tabs |
| 6 | jQuery('.tabs ' + currentAttrValue).show().siblings().hide(); | 16 | jQuery('.tabs ' + currentAttrValue).show().siblings().hide(); |
| 7 | 17 | ||
| 8 | // Change/remove current tab to active | 18 | // Change/remove current tab to active |
| 9 | jQuery(this).parent('li').addClass('active').siblings().removeClass('active'); | 19 | jQuery(this).parent('li').addClass('active').siblings().removeClass('active'); |
| 10 | 20 | ||
| 11 | e.preventDefault(); | 21 | e.preventDefault(); |
| 12 | }); | 22 | } |
| 13 | }); | ||
diff --git a/webgui/src/Main.hs b/webgui/src/Main.hs index 644c4f6..018e59b 100644 --- a/webgui/src/Main.hs +++ b/webgui/src/Main.hs | |||
| @@ -361,7 +361,27 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do | |||
| 361 | let abortButton' = case status of | 361 | let abortButton' = case status of |
| 362 | Queued _ -> [abortButton] | 362 | Queued _ -> [abortButton] |
| 363 | _ -> [] | 363 | _ -> [] |
| 364 | actions <- UI.td # set children abortButton' | 364 | viewJob = do |
| 365 | tabLinkList <- fatal' "Could not find tab link list" =<< getElementById window "tabLinks" | ||
| 366 | tabContainer <- fatal' "Could not find tab container" =<< getElementById window "tabContent" | ||
| 367 | content <- job rJId | ||
| 368 | let | ||
| 369 | text = cobbcode content | ||
| 370 | case text of | ||
| 371 | Left err -> emitError $ "Could not decode content of job #" ++ show jId ++ ": " ++ show err | ||
| 372 | Right (T.unpack -> text) -> void $ do | ||
| 373 | tabLink <- UI.a # set UI.href ("#viewJob" ++ show jId) # set UI.text ("Job #" ++ show jId) | ||
| 374 | tabLinkItem <- UI.li # set children [tabLink] | ||
| 375 | return tabLinkList #+ [ return tabLinkItem ] | ||
| 376 | closeLink <- UI.a # set UI.text "Close Tab" # set UI.class_ "close" # set UI.href "#printers" | ||
| 377 | tabContent <- UI.pre # set UI.text text | ||
| 378 | tab <- UI.new # set children [closeLink, tabContent] # set UI.id_ ("viewJob" ++ show jId) # set UI.class_ "tab" | ||
| 379 | return tabContainer #+ [ return tab ] | ||
| 380 | on UI.click closeLink . const $ mapM_ delete [tabLink, tabLinkItem, closeLink, tabContent, tab] >> runFunction (switchTab "printers") | ||
| 381 | runFunction . switchTab $ "viewJob" ++ show jId | ||
| 382 | viewButton <- UI.button # set UI.text "View" | ||
| 383 | on UI.click viewButton . const $ viewJob | ||
| 384 | actions <- UI.td # set children (viewButton : abortButton') | ||
| 365 | UI.tr # set UI.id_ ("job" ++ show jId) # set children [jPId, jId', time', jStatus', actions] # sink UI.class_ (bool "" "focused" . Set.member rJId <$> focusedJobs) | 385 | UI.tr # set UI.id_ ("job" ++ show jId) # set children [jPId, jId', time', jStatus', actions] # sink UI.class_ (bool "" "focused" . Set.member rJId <$> focusedJobs) |
| 366 | (:) <$> UI.tr # set children [pId', pFiller, pStatus', pSelect'] <*> mapM toLine jobs | 386 | (:) <$> UI.tr # set children [pId', pFiller, pStatus', pSelect'] <*> mapM toLine jobs |
| 367 | 387 | ||
