mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
continue add view functionality
This commit is contained in:
parent
e397280b9f
commit
62eceb0d77
@ -351,8 +351,8 @@ class Boot extends Loggable{
|
||||
|
||||
LiftRules.addToPackages("code")
|
||||
|
||||
// Use jQuery 1.4
|
||||
LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQuery14Artifacts
|
||||
// Use jQuery from js directory
|
||||
LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQueryArtifacts
|
||||
|
||||
//Show the spinny image when an Ajax call starts
|
||||
LiftRules.ajaxStart =
|
||||
|
||||
@ -163,26 +163,24 @@ object ObpAPI extends Loggable {
|
||||
}
|
||||
}
|
||||
|
||||
def addView(bankId: String, accountId: String, userId : String, viewName: String) = {
|
||||
def addView(bankId: String, accountId: String, viewName: String) = {
|
||||
val addViewUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) +
|
||||
"/views/"
|
||||
"/views"
|
||||
|
||||
/*
|
||||
{
|
||||
"name": "the view name",
|
||||
"description": "a little description.",
|
||||
"is_public": "Boolean to specify if the view can be accessible to not logged in users",
|
||||
"which_alias_to_use": "public/private/none",
|
||||
"hide_metadata_if_alias_used" : true/false,
|
||||
"allowed_actions": [
|
||||
"can_see_transaction_this_bank_account",
|
||||
"can_see_transaction_label",
|
||||
"can_see_transaction_other_bank_account"
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
//ObpPost(addViewUrl, new JObject())
|
||||
val json =
|
||||
("name" -> viewName) ~
|
||||
("description" -> "default description") ~
|
||||
("is_public" -> false) ~
|
||||
("which_alias_to_use" -> "public") ~
|
||||
("hide_metadata_if_alias_used" -> true) ~
|
||||
("allowed_actions", List(
|
||||
"can_see_transaction_this_bank_account",
|
||||
"can_see_transaction_label",
|
||||
"can_see_transaction_other_bank_account")
|
||||
)
|
||||
|
||||
val result = ObpPost(addViewUrl, json)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,17 +2,16 @@ package code.snippet
|
||||
|
||||
import net.liftweb.http.js.JsCmd
|
||||
import net.liftweb.util.Helpers._
|
||||
import scala.xml.NodeSeq
|
||||
import scala.xml.{Node, NodeSeq}
|
||||
import code.lib.ObpJson.CompleteViewJson
|
||||
import net.liftweb.util.CssSel
|
||||
import net.liftweb.http.{S, SHtml}
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.json._
|
||||
import net.liftweb.http.js.JsCmds.{SetHtml, Alert}
|
||||
import net.liftweb.http.js.JsCmds.{SetHtml, Alert, RedirectTo}
|
||||
import net.liftweb.common.{Loggable, Box}
|
||||
import code.lib.ObpAPI
|
||||
import net.liftweb.http.SHtml.{text,ajaxSubmit}
|
||||
import _root_.scala.xml.Text
|
||||
import ObpAPI.addView
|
||||
|
||||
case class ViewUpdateData(
|
||||
@ -29,8 +28,10 @@ case class ViewsDataJSON(
|
||||
/*
|
||||
For maintaining permissions on the views (entitlements on the account)
|
||||
*/
|
||||
class ViewsOverview(viewsDataJson: ViewsDataJSON) {
|
||||
class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable {
|
||||
val views = viewsDataJson.views
|
||||
val bank = viewsDataJson.bankId
|
||||
val account = viewsDataJson.accountId
|
||||
|
||||
def getTableContent(xhtml: NodeSeq) :NodeSeq = {
|
||||
|
||||
@ -153,26 +154,24 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) {
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object AddView extends Loggable {
|
||||
def render = {
|
||||
//set up ajax handlers to add a new view
|
||||
def setupAddView(xhtml: NodeSeq): NodeSeq = {
|
||||
var newViewName = ""
|
||||
|
||||
def process(): JsCmd = {
|
||||
logger.debug(s"ViewsOverview.setupAddView.process: create view called $newViewName")
|
||||
addView(bank, account, newViewName)
|
||||
|
||||
logger.debug(s"AddView.process says: NOT IMPLEMENTED Will create view called $newViewName")
|
||||
//TODO: Create new View
|
||||
//addView(bankId, accountId, newViewName)
|
||||
//reload page for new view to be shown
|
||||
RedirectTo("")
|
||||
}
|
||||
|
||||
// Bind view_name field to variable
|
||||
//(http://chimera.labs.oreilly.com/books/1234000000030/ch03.html)
|
||||
|
||||
// On the left is the form field
|
||||
"@new_view_name" #> text(newViewName, s => newViewName = s) &
|
||||
// Replace the type=submit with Javascript that makes the ajax call.
|
||||
"type=submit" #> ajaxSubmit("OK", process)
|
||||
(
|
||||
// Bind newViewName field to variable (e.g. http://chimera.labs.oreilly.com/books/1234000000030/ch03.html)
|
||||
"@new_view_name" #> text(newViewName, s => newViewName = s) &
|
||||
// Replace the type=submit with Javascript that makes the ajax call.
|
||||
"type=submit" #> ajaxSubmit("OK", process)
|
||||
).apply(xhtml)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,14 +28,16 @@ Berlin 13359, Germany
|
||||
|
||||
<div id="main" class="lift:surround?with=default;at=content">
|
||||
<div id="homeContent">
|
||||
<h1>404 Not Found</h1>
|
||||
<h1>404 - Resource Not Found</h1>
|
||||
<div id="404_text">
|
||||
<p>
|
||||
Sorry, we couldn't find the page you were looking for.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Maybe this is because you need permission - and you are not logged in?
|
||||
Maybe this is because you don't have the right permissions
|
||||
<lift:TestCond.loggedOut>
|
||||
(you are not logged in).
|
||||
</lift:TestCond.loggedOut>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -41,7 +41,7 @@ See views.js for the javascript which manipulates the DOM for editing
|
||||
<div class="views">
|
||||
<div>
|
||||
<button id="view-add">Add new view</button>
|
||||
<div id="add-view-form" class="lift:AddView">
|
||||
<div id="add-view-form" class="lift:ViewsOverview.setupAddView">
|
||||
<form class="lift:form.ajax">
|
||||
<input type="text" name="new_view_name" placeholder="View name">
|
||||
<input type="submit" value="placeholder">
|
||||
|
||||
@ -5,6 +5,11 @@ body {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.1em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#start-login,
|
||||
.logout,
|
||||
a {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
src/main/webapp/media/js/jquery-1.11.1.min.js
vendored
Normal file
4
src/main/webapp/media/js/jquery-1.11.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -19,6 +19,7 @@ $(document).ready(function(){
|
||||
el.hide()
|
||||
} else {
|
||||
el.css("display", "inline-block")
|
||||
$('#add-view-form form input:first-of-type').focus()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ Berlin 13359, Germany
|
||||
<title class="lift:Menu.title">Open Bank Project: %*%</title>
|
||||
|
||||
<link href="/media/css/website.css" rel="stylesheet" type="text/css" />
|
||||
<script id="jquery" src="/media/js/jquery-1.11.0.min.js" type="text/javascript"></script>
|
||||
<script id="jquery" src="/media/js/jquery-1.11.1.min.js" type="text/javascript"></script>
|
||||
<script src="/media/js/polarize.js" type="text/javascript"></script>
|
||||
<script src="/media/js/website.js" type="text/javascript"></script>
|
||||
<script src="/media/js/views.js" type="text/javascript"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user