Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
rjs_json_form
Commits
12d8ca64
Commit
12d8ca64
authored
Jan 04, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo: improve xmla_connection demo
parent
00f99934
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
41 deletions
+118
-41
demo/xmla_connection/index.js
demo/xmla_connection/index.js
+118
-41
No files found.
demo/xmla_connection/index.js
View file @
12d8ca64
...
...
@@ -71,6 +71,7 @@
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
DataSourceInfo
=
{
title
:
"
"
,
oneOf
:
[]
};
var
arr
=
schema
.
properties
.
DataSourceInfo
.
oneOf
;
...
...
@@ -94,6 +95,7 @@
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
Catalog
=
{
title
:
"
"
,
oneOf
:
[]
};
var
arr
=
schema
.
properties
.
Catalog
.
oneOf
;
...
...
@@ -116,6 +118,7 @@
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
Cube
=
{
title
:
"
"
,
oneOf
:
[]
};
var
arr
=
schema
.
properties
.
Cube
.
oneOf
;
...
...
@@ -131,8 +134,8 @@
});
}
function
init_schema
(
)
{
return
{
function
generateSchema
(
settings
)
{
var
schema
=
{
"
type
"
:
"
object
"
,
"
additionalProperties
"
:
false
,
"
required
"
:
[
"
Cube
"
],
...
...
@@ -142,6 +145,74 @@
"
Cube
"
:
{
"
type
"
:
"
string
"
}
}
};
if
(
!
settings
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
schema
;
});
}
if
(
!
settings
.
hasOwnProperty
(
'
properties
'
))
{
settings
.
properties
=
{};
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
discoverDataSources
(
schema
,
{
urls
:
settings
.
urls
,
prop
:
{}
}),
discoverDBCatalogs
(
schema
,
{
urls
:
settings
.
urls
,
prop
:
{
properties
:
{
DataSourceInfo
:
settings
.
properties
.
DataSourceInfo
}
}
}),
discoverMDCubes
(
schema
,
{
urls
:
settings
.
urls
,
prop
:
{
properties
:
{
DataSourceInfo
:
settings
.
properties
.
DataSourceInfo
,
Catalog
:
settings
.
properties
.
Catalog
}
}
})
]);
})
.
push
(
function
()
{
return
schema
;
});
}
function
decodeJsonPointer
(
_str
)
{
// https://tools.ietf.org/html/rfc6901#section-5
return
_str
.
replace
(
/~1/g
,
'
/
'
).
replace
(
/~0/g
,
'
~
'
);
}
function
convertOnMultiLevel
(
d
,
key
,
value
)
{
var
ii
,
kk
,
key_list
=
key
.
split
(
"
/
"
);
for
(
ii
=
1
;
ii
<
key_list
.
length
;
ii
+=
1
)
{
kk
=
decodeJsonPointer
(
key_list
[
ii
]);
if
(
ii
===
key_list
.
length
-
1
)
{
if
(
value
!==
undefined
)
{
d
[
kk
]
=
value
[
0
];
}
else
{
return
d
[
kk
];
}
}
else
{
if
(
!
d
.
hasOwnProperty
(
kk
))
{
if
(
value
!==
undefined
)
{
d
[
kk
]
=
{};
}
else
{
return
;
}
}
d
=
d
[
kk
];
}
}
}
rJS
(
window
)
...
...
@@ -156,10 +227,23 @@
})
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
(
arr
,
scope
)
{
})
.
declareMethod
(
"
render
"
,
function
(
opt
)
{
this
.
props
.
init_value
=
opt
.
value
;
return
this
.
getDeclaredGadget
(
"
xmla_settings
"
)
.
push
(
function
(
g
)
{
return
g
.
render
(
opt
);
});
})
.
declareMethod
(
"
getContent
"
,
function
()
{
return
this
.
getDeclaredGadget
(
"
xmla_settings
"
)
.
push
(
function
(
g
)
{
return
g
.
getContent
();
});
})
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
arr
,
scope
)
{
var
g
=
this
,
p
=
arr
[
0
],
schema
=
init_schema
(),
gadget_settings
,
path
;
...
...
@@ -172,32 +256,19 @@
})
.
push
(
function
(
c
)
{
settings
=
c
;
if
(
!
c
.
hasOwnProperty
(
'
properties
'
))
{
c
.
properties
=
{};
}
var
opt
=
{
urls
:
c
.
urls
,
prop
:
{
properties
:
{
DataSourceInfo
:
c
.
properties
.
DataSourceInfo
,
Catalog
:
c
.
properties
.
Catalog
}
},
cube
:
c
.
properties
.
Cube
};
return
RSVP
.
all
([
discoverDataSources
(
schema
,
opt
),
discoverDBCatalogs
(
schema
,
opt
),
discoverMDCubes
(
schema
,
opt
)
]);
})
.
push
(
function
()
{
g
.
props
.
xmla_connections
[
p
]
=
schema
;
return
gadget_settings
.
getGadgetByPath
(
p
);
return
generateSchema
(
c
);
})
.
push
(
function
(
schema
)
{
return
gadget_settings
.
getGadgetByPath
(
p
+
'
/properties
'
)
.
push
(
function
(
ret
)
{
return
ret
.
gadget
.
rerender
(
settings
);
return
ret
.
gadget
.
rerender
({
schema
:
schema
,
value
:
convertOnMultiLevel
(
settings
,
'
/properties
'
)
});
});
})
.
push
(
function
()
{
// return g.notifyChange();
});
}
...
...
@@ -207,29 +278,35 @@
return
f
(
path
);
}
}
// return g.notifyChange();
})
.
allowPublicAcquisition
(
"
resolveExternalReference
"
,
function
(
arr
)
{
var
g
=
this
,
url
=
arr
[
0
],
schema_path
=
arr
[
1
],
path
=
arr
[
2
],
settings
,
connection_path
;
if
(
"
urn:jio:properties_from_xmla.connection.json
"
===
url
)
{
return
g
.
getDeclaredGadget
(
"
xmla_settings
"
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getContent
();
})
.
push
(
function
(
value
)
{
connection_path
=
path
.
split
(
'
/
'
).
slice
(
0
,
-
1
).
join
(
'
/
'
);
if
(
!
g
.
props
.
xmla_connections
.
hasOwnProperty
(
connection_path
))
{
g
.
props
.
xmla_connections
[
connection_path
]
=
init_schema
();
if
(
!
g
.
props
.
xmla_connections
[
connection_path
])
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
g
.
props
.
init_value
)
{
settings
=
convertOnMultiLevel
(
g
.
props
.
init_value
,
connection_path
);
if
(
settings
)
{
convertOnMultiLevel
(
g
.
props
.
init_value
,
connection_path
,
[]);
}
return
g
.
props
.
xmla_connections
[
connection_path
];
});
}
throw
Error
(
"
urn: '
"
+
url
+
"
' not supported
"
);
return
generateSchema
(
settings
);
})
.
onStateChange
(
function
(
modification_dict
)
{
.
push
(
function
(
s
)
{
g
.
props
.
xmla_connections
[
connection_path
]
=
false
;
return
s
;
});
}
}
throw
new
Error
(
"
urn: '
"
+
url
+
"
' not supported
"
);
});
}(
window
,
rJS
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment