Commit d3457649 authored by Bas Lijnse's avatar Bas Lijnse

Updated the services api with an overview page, and made it accessible from...

Updated the services api with an overview page, and made it accessible from within the client through the debug window.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1145 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 216aaba9
......@@ -51,6 +51,7 @@
,{"text":"itasks.RemoteDataPanel.js","path":"src/js/"}
,{"text":"itasks.NewWorkPanel.js","path":"src/js/"}
,{"text":"itasks.DebugPanel.js","path":"src/js/"}
,{"text":"itasks.ServicesPanel.js","path":"src/js/"}
,{"text":"itasks.WorkListPanel.js","path":"src/js/"}
,{"text":"itasks.HomeTabPanel.js","path":"src/js/"}
,{"text":"itasks.WorkTabPanel.js","path":"src/js/"}
......
......@@ -14,6 +14,24 @@ itasks.DebugPanel = Ext.extend(Ext.Panel, {
bodyStyle: "padding: 5px",
deferredRender: false,
items: [{
xtype: "fieldset",
title: "Overviews",
autoHeight: true,
items: [{
xtype: "button",
text: "Browse service API...",
iconCls: "icon-services",
style: "margin-bottom: 2px;",
listeners: {
click: {
fn: function() {
this.worktabs.openServicesTab();
},
scope: this
}
}
}]
},{
xtype: "fieldset",
title: "Session",
html: itasks.app.session,
......@@ -26,4 +44,6 @@ itasks.DebugPanel = Ext.extend(Ext.Panel, {
}
});
Ext.reg("itasks.debug",itasks.DebugPanel);
\ No newline at end of file
Ext.reg("itasks.debug",itasks.DebugPanel);
......@@ -9,7 +9,7 @@ itasks.HomeTabPanel = Ext.extend(Ext.Panel, {
initComponent: function () {
Ext.apply(this, {
title: "Welcome",
closable: false,
closable: true,
iconCls: "icon-home",
autoLoad: "skins/" + itasks.config.skin + "/welcome.html"
});
......
/**
* Panel which opens the services url for debugging.
*/
Ext.ns("itasks");
itasks.ServicesPanel = Ext.extend(Ext.Panel, {
initComponent: function () {
Ext.apply(this, {
title: "Services",
closable: true,
iconCls: "icon-services",
html: '<iframe style="overflow:auto;width:100%;height:100%;" frameborder="0" src="' + itasks.config.serviceUrl + '/html' + '"></iframe>'
});
itasks.ServicesPanel.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg("itasks.services",itasks.ServicesPanel);
\ No newline at end of file
......@@ -72,6 +72,15 @@ itasks.WorkTabsPanel = Ext.extend(Ext.TabPanel, {
}
this.activate(tab);
return tab;
},
openServicesTab: function() {
var tab = this.getComponent("servicestab");
if(tab == undefined) {
tab = new itasks.ServicesPanel({id: "servicestab", worktabs: this, closable: true});
this.add(tab);
}
this.activate(tab);
return tab;
}
});
......
......@@ -114,6 +114,7 @@
<script type="text/javascript" src="../js/itasks.RemoteDataPanel.js"></script>
<script type="text/javascript" src="../js/itasks.NewWorkPanel.js"></script>
<script type="text/javascript" src="../js/itasks.DebugPanel.js"></script>
<script type="text/javascript" src="../js/itasks.ServicesPanel.js"></script>
<script type="text/javascript" src="../js/itasks.WorkListPanel.js"></script>
<script type="text/javascript" src="../js/itasks.HomeTabPanel.js"></script>
<script type="text/javascript" src="../js/itasks.TaskForestTabPanel.js"></script>
......
......@@ -20,15 +20,9 @@ button.icon-logout, .icon-logout {
button.icon-refresh, .icon-refresh {
background-image: url('img/icons/refresh.png');
}
button.icon-thread-table, .icon-thread-table {
background-image: url('img/icons/table_lightning.png');
}
button.icon-process-table, .icon-process-table {
button.icon-services, .icon-services {
background-image: url('img/icons/table_gear.png');
}
button.icon-task-tree, .icon-task-tree {
background-image: url('img/icons/chart_organisation.png');
}
button.icon-states, .icon-states {
background-image: url('img/icons/table_gear.png');
}
......
......@@ -50,11 +50,14 @@ where
# reqpath = (http_urldecode req.req_path)
# reqpath = reqpath % (size config.serverPath, size reqpath)
# (response,tst) = case (split "/" reqpath) of
[""] = (redirectResponse (req.req_path +++ "/html"), tst)
["","html"] = (overviewResponse, tst)
["",format:path]
# html = format == "html"
# json = format == "json"
| html || json
= case path of
["application":path] = applicationService req.req_path html path req tst
["sessions":path] = sessionService req.req_path html path req tst
["workflows":path] = workflowService req.req_path html path req tst
......@@ -111,39 +114,14 @@ handleStaticResourceRequest config req world
("Content-Length", toString (size content))
]
,rsp_data = content}, HTTPServerContinue, world)
= http_notfoundResponse req world
= (notFoundResponse req,HTTPServerContinue,world)
where
//Translate a URL path to a filesystem path
filePath path = ((replaceSubString "/" PATH_SEP) o (replaceSubString ".." "")) path
handleStopRequest :: HTTPRequest *World -> (!HTTPResponse,!HTTPServerControl,!*World)
handleStopRequest req world = ({http_emptyResponse & rsp_data = "Server stopped..."},HTTPServerStop, world)
handleAnonRequest :: Config [Workflow] (HTTPRequest *TSt -> (!HTTPResponse, !*TSt)) !HTTPRequest *World -> (!HTTPResponse, !HTTPServerControl, !*World)
handleAnonRequest config flows handler request world
# tst = initTSt request config flows world
# (response, tst) = handler request tst
# world = finalizeTSt tst
= (response, HTTPServerContinue, world)
handleSessionRequest :: Config [Workflow] (HTTPRequest *TSt -> (!HTTPResponse, !*TSt)) !HTTPRequest *World -> (!HTTPResponse, !HTTPServerControl, !*World)
handleSessionRequest config flows handler request world
# tst = initTSt request config flows world
# sessionId = http_getValue "_session" (request.arg_get ++ request.arg_post) ""
# (mbSession,timeout,tst=:{staticInfo}) = restoreSession sessionId tst
= case mbSession of
Nothing
# world = finalizeTSt tst
= ({http_emptyResponse & rsp_data = mkSessionFailureResponse timeout}, HTTPServerContinue, world)
(Just session)
# tst = {tst & staticInfo = {staticInfo & currentSession = session}}
# (response,tst) = handler request tst
# tst = flushStore tst
# world = finalizeTSt tst
= (response, HTTPServerContinue, world)
where
mkSessionFailureResponse to = "{\"success\" : false, \"session\": false, \"error\" : \"" +++ (if to "Your session timed out" "Failed to load session") +++ "\"}"
initTSt :: !HTTPRequest !Config ![Workflow] !*World -> *TSt
initTSt request config flows world
# (appName,world) = determineAppName world
......
......@@ -24,7 +24,20 @@ servicePage :: !String !String !String ![(String,String,Bool)] JSONNode -> HtmlT
*/
serviceResponse :: !Bool !String !String !String ![(String,String,Bool)] JSONNode -> HTTPResponse
/**
* Creates a static page with information about the service API.
*/
overviewPage :: HtmlTag
/**
* Creates an HTTP response of a the overview page
*/
overviewResponse :: HTTPResponse
/**
* Creates a 302 Redirect response
*/
redirectResponse :: !String -> HTTPResponse
/**
* Creates a 404 Not found error page
*/
......
......@@ -6,18 +6,18 @@ import StdList
embeddedStyle :: HtmlTag
embeddedStyle = StyleTag [TypeAttr "text/css"] [RawText css]
where
css = "body { background: #d1dded; font-family: Verdana, Arial, sans-serif; font-size: 12px;} th { text-align: left; } "
css = "body { background: #fff; font-family: Verdana, Arial, sans-serif; font-size: 12px;} th { text-align: left; } "
+++ ".field-error em {color: #f00; font-weight: bold} .field-error input {border-color: #f00;} "
+++ "#main {width: 700px; position: absolute; left: 50%; margin-left: -350px; top: 50px; background: #fff; border: solid 2px #3a81ad; -moz-border-radius: 5px; background: -moz-linear-gradient(bottom, #3a81ad, #fff);} "
+++ "#main {margin: 20px; background: #d1dded; border: solid 2px #3a81ad; -moz-border-radius: 5px; background: -moz-linear-gradient(bottom, #d1dded, #fff);} "
+++ "#content { padding: 10px; } "
+++ ".buttons { padding: 5px; background-color: #3a81ad; } "
+++ ".section { margin: 10px; border: solid 1px #d1dded; -moz-border-radius: 10px; padding: 5px; overflow: auto;} "
+++ ".description { padding: 15px; } "
+++ ".parameters th, .parameters td { width: 25%; } "
+++ ".section { margin: 10px; padding: 5px; overflow: auto;} "
+++ ".description { margin: 0px 15px 0px 15px; } "
+++ ".parameters th, { width: 150px; } "
+++ ".json { font-family: Courier, monotype; font-size: 12px;} "
+++ ".json ul { padding-left: 15px;} "
+++ "h1 { margin: 10px; font-weight: normal; font-size: 24px;} "
+++ "h2 { margin: 5px; font-weight: bold; font-size: 14px;} "
+++ "h1 { margin: 10px 15px 10px 15px; font-weight: normal; font-size: 24px;} "
+++ "h2 { margin: 5px 5px 5px 0px; font-weight: bold; font-size: 14px; border: solid #999; border-width: 0px 0px 1px 0px;} "
+++ "p { margin: 0px 0px 10px 0px; } "
+++ "button {-moz-border-radius: 3px; }"
......@@ -58,6 +58,31 @@ formatJSON (JSONObject fields) = [UlTag [] [LiTag [] [Text label,Text ": " :form
formatJSON (JSONRaw r) = [PreTag [] [Text (toString r)]]
formatJSON _ = []
overviewPage :: HtmlTag
overviewPage = pageLayout "Services" description [application,sessions,workflows,tasks,users,documents]
where
description = "This application can be accessed through a RESTful JSON API.<br />Below is an overview of the available service urls."
application = pageSection "application"
[ATag [HrefAttr "html/application"] [Text "General information information about this application"]]
sessions = pageSection "sessions"
[ATag [HrefAttr "html/sessions"] [Text "Authentication and session management"]]
workflows = pageSection "workflows"
[ATag [HrefAttr "html/workflows"] [Text "A catalogue of available workflows"]]
tasks = pageSection "tasks"
[ATag [HrefAttr "html/tasks"] [Text "Listing of and working on tasks"]]
users = pageSection "users"
[ATag [HrefAttr "html/users"] [Text "User management"]]
documents = pageSection "documents"
[ATag [HrefAttr "html/documents"] [Text "Upload/download of binary files"]]
overviewResponse :: HTTPResponse
overviewResponse = {http_emptyResponse & rsp_data = toString overviewPage}
redirectResponse :: !String -> HTTPResponse
redirectResponse url
= {HTTPResponse | rsp_headers = [("Status","302 - Found"),("Location",url)], rsp_data = ""}
notFoundPage :: !HTTPRequest -> HtmlTag
notFoundPage req = pageLayout "404 - Not Found" "" message
where
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment