mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
started add view functionality
This commit is contained in:
parent
9dd6b80095
commit
361baf1c33
10
pom.xml
10
pom.xml
@ -118,11 +118,11 @@
|
||||
<version>${scala.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>oauth.signpost</groupId>
|
||||
<artifactId>signpost-commonshttp4</artifactId>
|
||||
|
||||
@ -129,6 +129,18 @@ object ObpAPI extends Loggable {
|
||||
ObpGet("/v1.2.1/banks/" + bankId + "/accounts/" + accountId + "/permissions").flatMap(x => x.extractOpt[PermissionsJson])
|
||||
}
|
||||
|
||||
def removePermission(bankId: String, accountId: String, userId : String, viewId: String) = {
|
||||
val removePermissionUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) + "/permissions/" +
|
||||
urlEncode(defaultProvider) + "/" + urlEncode(userId) + "/views/" + urlEncode(viewId)
|
||||
ObpDelete(removePermissionUrl)
|
||||
}
|
||||
|
||||
def removeAllPermissions(bankId: String, accountId: String, userId: String) = {
|
||||
val removeAllPermissionsUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) + "/permissions/" +
|
||||
urlEncode(defaultProvider) + "/" + urlEncode(userId) + "/views"
|
||||
ObpDelete(removeAllPermissionsUrl)
|
||||
}
|
||||
|
||||
def getViews(bankId: String, accountId: String) : Box[List[ViewJson]] = {
|
||||
for {
|
||||
json <- ObpGet("/v1.2.1/banks/" + bankId + "/accounts/" + accountId + "/views")
|
||||
@ -141,7 +153,7 @@ object ObpAPI extends Loggable {
|
||||
json <- ObpGet("/v1.2.1/banks/" + bankId + "/accounts/" + accountId + "/views")
|
||||
} yield {
|
||||
json \ "views" match {
|
||||
case JArray(l) => l.map(viewJson =>
|
||||
case JArray(l) => l.map(viewJson =>
|
||||
viewJson.values match{
|
||||
case vals: Map[String, Any] => CompleteViewJson(vals)
|
||||
case _ => CompleteViewJson(Map.empty)
|
||||
@ -150,19 +162,29 @@ object ObpAPI extends Loggable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def removePermission(bankId: String, accountId: String, userId : String, viewId: String) = {
|
||||
val removePermissionUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) + "/permissions/" +
|
||||
urlEncode(defaultProvider) + "/" + urlEncode(userId) + "/views/" + urlEncode(viewId)
|
||||
ObpDelete(removePermissionUrl)
|
||||
|
||||
def addView(bankId: String, accountId: String, userId : String, viewName: String) = {
|
||||
val addViewUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) +
|
||||
"/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())
|
||||
}
|
||||
|
||||
def removeAllPermissions(bankId: String, accountId: String, userId: String) = {
|
||||
val removeAllPermissionsUrl = "/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) + "/permissions/" +
|
||||
urlEncode(defaultProvider) + "/" + urlEncode(userId) + "/views"
|
||||
ObpDelete(removeAllPermissionsUrl)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The jsons for the tags that were were successfully added
|
||||
*/
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
package code.snippet
|
||||
|
||||
import net.liftweb.http.js.JsCmd
|
||||
import net.liftweb.util.Helpers._
|
||||
import scala.xml.NodeSeq
|
||||
import code.lib.ObpJson.CompleteViewJson
|
||||
import net.liftweb.util.CssSel
|
||||
import net.liftweb.http.SHtml
|
||||
import net.liftweb.http.{S, SHtml}
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.json._
|
||||
import net.liftweb.http.js.JsCmds.Alert
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.http.js.JsCmds.{SetHtml, Alert}
|
||||
import net.liftweb.common.{Loggable, Box}
|
||||
import code.lib.ObpAPI
|
||||
import net.liftweb.http.S
|
||||
import net.liftweb.http.SHtml.{text,ajaxSubmit}
|
||||
import _root_.scala.xml.Text
|
||||
import ObpAPI.addView
|
||||
|
||||
case class ViewUpdateData(
|
||||
viewId: String,
|
||||
@ -69,15 +72,15 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) {
|
||||
}
|
||||
|
||||
val ids = getIds()
|
||||
val viewNameSel = ".view_name *" #> views.map( view => view.shortName.getOrElse(""))
|
||||
val shortNamesSel = ".short_name" #> views.map( view => "* *" #> view.shortName.getOrElse("") & "* [data-viewid]" #> view.id )
|
||||
val aliasSel = ".alias" #> views.map( view => "* *" #> aliasType(view.alias) & "* [data-viewid]" #> view.id )
|
||||
val descriptionSel = ".description" #> views.map( view => ".desc *" #> view.description.getOrElse("") & "* [data-viewid]" #> view.id )
|
||||
val isPublicSel = ".is_public *" #> getIfIsPublic()
|
||||
val addDeleteSel = ".delete" #> ids.map(x => "* [data-id]" #> x)
|
||||
val addEditSel = ".edit" #> ids.map(x => "* [data-id]" #> x)
|
||||
val addSaveSel = ".save" #> ids.map(x => ("* [data-id]" #> x) & saveOnClick(x))
|
||||
val addCancelSel = ".cancel" #> ids.map(x => "* [data-id]" #> x)
|
||||
val viewNameSel = ".view_name *" #> views.map( view => view.shortName.getOrElse(""))
|
||||
val shortNamesSel = ".short_name" #> views.map( view => "* *" #> view.shortName.getOrElse("") & "* [data-viewid]" #> view.id )
|
||||
val aliasSel = ".alias" #> views.map( view => "* *" #> aliasType(view.alias) & "* [data-viewid]" #> view.id )
|
||||
val descriptionSel = ".description" #> views.map( view => ".desc *" #> view.description.getOrElse("") & "* [data-viewid]" #> view.id )
|
||||
val isPublicSel = ".is_public *" #> getIfIsPublic()
|
||||
val addDeleteSel = ".delete" #> ids.map(x => "* [data-id]" #> x)
|
||||
val addEditSel = ".edit" #> ids.map(x => "* [data-id]" #> x)
|
||||
val addSaveSel = ".save" #> ids.map(x => ("* [data-id]" #> x) & saveOnClick(x))
|
||||
val addCancelSel = ".cancel" #> ids.map(x => "* [data-id]" #> x)
|
||||
|
||||
|
||||
val permissionNames = permissions.keys
|
||||
@ -98,56 +101,74 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) {
|
||||
addEditSel &
|
||||
addSaveSel &
|
||||
addCancelSel
|
||||
).apply(xhtml)
|
||||
}
|
||||
).apply(xhtml)
|
||||
}
|
||||
|
||||
def getIds(): List[String] = {
|
||||
views.map( view => view.id.getOrElse(""))
|
||||
}
|
||||
def getIds(): List[String] = {
|
||||
views.map( view => view.id.getOrElse(""))
|
||||
}
|
||||
|
||||
|
||||
def getIfIsPublic() :List[CssSel] = {
|
||||
views.map(
|
||||
view => {
|
||||
val isPublic = view.isPublic.getOrElse(false)
|
||||
val viewId: String = view.id.getOrElse("")
|
||||
val checked =
|
||||
if(isPublic)
|
||||
".is_public_cb [checked]" #> "checked" &
|
||||
".is_public_cb [disabled]" #> "disabled"
|
||||
def getIfIsPublic() :List[CssSel] = {
|
||||
views.map(
|
||||
view => {
|
||||
val isPublic = view.isPublic.getOrElse(false)
|
||||
val viewId: String = view.id.getOrElse("")
|
||||
val checked =
|
||||
if(isPublic)
|
||||
".is_public_cb [checked]" #> "checked" &
|
||||
".is_public_cb [disabled]" #> "disabled"
|
||||
else
|
||||
".is_public_cb [disabled]" #> "disabled"
|
||||
|
||||
val checkBox =
|
||||
checked &
|
||||
".is_public_cb [data-viewid]" #> viewId
|
||||
|
||||
checkBox
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def getPermissionValues(permName: String) :List[CssSel] = {
|
||||
views.map(
|
||||
view => {
|
||||
val permValue: Boolean = view.permissions(permName)
|
||||
val viewId: String = view.id.getOrElse("")
|
||||
val checked =
|
||||
if(permValue){
|
||||
".permission_value_cb [checked]" #> "checked" &
|
||||
".permission_value_cb [disabled]" #> "disabled"
|
||||
}
|
||||
else
|
||||
".is_public_cb [disabled]" #> "disabled"
|
||||
".permission_value_cb [disabled]" #> "disabled"
|
||||
|
||||
val checkBox =
|
||||
checked &
|
||||
".is_public_cb [data-viewid]" #> viewId
|
||||
val checkBox =
|
||||
checked &
|
||||
".permission_value_cb [value]" #> permName &
|
||||
".permission_value_cb [name]" #> permName &
|
||||
".permission_value_cb [data-viewid]" #> viewId
|
||||
|
||||
checkBox
|
||||
}
|
||||
)
|
||||
checkBox
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object AddView extends Loggable {
|
||||
def render = {
|
||||
var view_name = ""
|
||||
|
||||
def process(): JsCmd = {
|
||||
//TODO: Create new View
|
||||
//addView(bankId, accountId, view_name)
|
||||
}
|
||||
|
||||
def getPermissionValues(permName: String) :List[CssSel] = {
|
||||
views.map(
|
||||
view => {
|
||||
val permValue: Boolean = view.permissions(permName)
|
||||
val viewId: String = view.id.getOrElse("")
|
||||
val checked =
|
||||
if(permValue){
|
||||
".permission_value_cb [checked]" #> "checked" &
|
||||
".permission_value_cb [disabled]" #> "disabled"
|
||||
}
|
||||
else
|
||||
".permission_value_cb [disabled]" #> "disabled"
|
||||
|
||||
val checkBox =
|
||||
checked &
|
||||
".permission_value_cb [value]" #> permName &
|
||||
".permission_value_cb [name]" #> permName &
|
||||
".permission_value_cb [data-viewid]" #> viewId
|
||||
|
||||
checkBox
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
// Bind view_name field to variable
|
||||
//(http://chimera.labs.oreilly.com/books/1234000000030/ch03.html)
|
||||
"@view_name" #> text(view_name, s => view_name = s) &
|
||||
// Replace the type=submit with Javascript that makes the ajax call.
|
||||
"type=submit" #> ajaxSubmit("OK", process)
|
||||
}
|
||||
}
|
||||
@ -37,13 +37,19 @@ See views.js for the javascript which manipulates the DOM for editing
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="lift:surround?with=default;at=content">
|
||||
<div class="views">
|
||||
<div class="lift:ViewsOverview.getTableContent" >
|
||||
<div>
|
||||
<button id="view-add">Add new view</button>
|
||||
<div id="add-view-form" class="lift:AddView">
|
||||
<form class="lift:form.ajax">
|
||||
<input type="text" name="view_name" placeholder="View name">
|
||||
<input type="submit" value="placeholder">
|
||||
</form>
|
||||
</div>
|
||||
<button id="view-edit-advanced-options">Show advanced options</button>
|
||||
</div>
|
||||
<div class="lift:ViewsOverview.getTableContent">
|
||||
<table id="view_table">
|
||||
<thead>
|
||||
<tr class="view_head">
|
||||
|
||||
@ -552,7 +552,7 @@ background: #FAFAFA;
|
||||
|
||||
.account {
|
||||
margin-bottom: 5px;
|
||||
//white-space: nowrap;
|
||||
/* white-space: nowrap; */
|
||||
white-space: normal;
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
@ -928,6 +928,10 @@ td.main-attributes{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#add-view-form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
td.imageURL {
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
@ -1,20 +1,25 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#view-edit-advanced-options').click(function(){
|
||||
var thisButton = $(this)
|
||||
var showButtonText = "Show advanced options"
|
||||
var thisButton = $(this)
|
||||
var showButtonText = "Show advanced options"
|
||||
|
||||
if(thisButton.text() === showButtonText) {
|
||||
|
||||
$('.advanced-option').show();
|
||||
|
||||
thisButton.text("Hide advanced options");
|
||||
if(thisButton.text() === showButtonText) {
|
||||
$('.advanced-option').show();
|
||||
thisButton.text("Hide advanced options");
|
||||
} else {
|
||||
|
||||
$('.advanced-option').hide();
|
||||
|
||||
thisButton.text(showButtonText);
|
||||
}
|
||||
$('.advanced-option').hide();
|
||||
thisButton.text(showButtonText);
|
||||
}
|
||||
})
|
||||
|
||||
$('#view-add').click(function(){
|
||||
var el = $('#add-view-form')
|
||||
if (el.is(":visible")) {
|
||||
el.hide()
|
||||
} else {
|
||||
el.css("display", "inline-block")
|
||||
}
|
||||
})
|
||||
|
||||
/* clicking on edit: change view to edit mode for selected view */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user