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
Hide 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 @@
...
@@ -71,6 +71,7 @@
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
DataSourceInfo
=
{
schema
.
properties
.
DataSourceInfo
=
{
title
:
"
"
,
oneOf
:
[]
oneOf
:
[]
};
};
var
arr
=
schema
.
properties
.
DataSourceInfo
.
oneOf
;
var
arr
=
schema
.
properties
.
DataSourceInfo
.
oneOf
;
...
@@ -94,6 +95,7 @@
...
@@ -94,6 +95,7 @@
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
Catalog
=
{
schema
.
properties
.
Catalog
=
{
title
:
"
"
,
oneOf
:
[]
oneOf
:
[]
};
};
var
arr
=
schema
.
properties
.
Catalog
.
oneOf
;
var
arr
=
schema
.
properties
.
Catalog
.
oneOf
;
...
@@ -116,6 +118,7 @@
...
@@ -116,6 +118,7 @@
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
if
(
response
&&
response
.
numRows
>
0
)
{
schema
.
properties
.
Cube
=
{
schema
.
properties
.
Cube
=
{
title
:
"
"
,
oneOf
:
[]
oneOf
:
[]
};
};
var
arr
=
schema
.
properties
.
Cube
.
oneOf
;
var
arr
=
schema
.
properties
.
Cube
.
oneOf
;
...
@@ -131,8 +134,8 @@
...
@@ -131,8 +134,8 @@
});
});
}
}
function
init_schema
(
)
{
function
generateSchema
(
settings
)
{
return
{
var
schema
=
{
"
type
"
:
"
object
"
,
"
type
"
:
"
object
"
,
"
additionalProperties
"
:
false
,
"
additionalProperties
"
:
false
,
"
required
"
:
[
"
Cube
"
],
"
required
"
:
[
"
Cube
"
],
...
@@ -142,6 +145,74 @@
...
@@ -142,6 +145,74 @@
"
Cube
"
:
{
"
type
"
:
"
string
"
}
"
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
)
rJS
(
window
)
...
@@ -156,10 +227,23 @@
...
@@ -156,10 +227,23 @@
})
})
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
(
arr
,
scope
)
{
.
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
)
{
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
arr
,
scope
)
{
var
g
=
this
,
var
g
=
this
,
p
=
arr
[
0
],
p
=
arr
[
0
],
schema
=
init_schema
(),
gadget_settings
,
gadget_settings
,
path
;
path
;
...
@@ -172,32 +256,19 @@
...
@@ -172,32 +256,19 @@
})
})
.
push
(
function
(
c
)
{
.
push
(
function
(
c
)
{
settings
=
c
;
settings
=
c
;
if
(
!
c
.
hasOwnProperty
(
'
properties
'
))
{
return
generateSchema
(
c
);
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
()
{
.
push
(
function
(
schema
)
{
g
.
props
.
xmla_connections
[
p
]
=
schema
;
return
gadget_settings
.
getGadgetByPath
(
p
+
'
/properties
'
)
return
gadget_settings
.
getGadgetByPath
(
p
);
.
push
(
function
(
ret
)
{
return
ret
.
gadget
.
rerender
({
schema
:
schema
,
value
:
convertOnMultiLevel
(
settings
,
'
/properties
'
)
});
});
})
})
.
push
(
function
(
ret
)
{
.
push
(
function
()
{
return
ret
.
gadget
.
rerender
(
settings
);
// return g.notifyChange(
);
});
});
}
}
...
@@ -207,29 +278,35 @@
...
@@ -207,29 +278,35 @@
return
f
(
path
);
return
f
(
path
);
}
}
}
}
// return g.notifyChange();
})
})
.
allowPublicAcquisition
(
"
resolveExternalReference
"
,
function
(
arr
)
{
.
allowPublicAcquisition
(
"
resolveExternalReference
"
,
function
(
arr
)
{
var
g
=
this
,
var
g
=
this
,
url
=
arr
[
0
],
url
=
arr
[
0
],
schema_path
=
arr
[
1
],
schema_path
=
arr
[
1
],
path
=
arr
[
2
],
path
=
arr
[
2
],
settings
,
connection_path
;
connection_path
;
if
(
"
urn:jio:properties_from_xmla.connection.json
"
===
url
)
{
if
(
"
urn:jio:properties_from_xmla.connection.json
"
===
url
)
{
return
g
.
getDeclaredGadget
(
"
xmla_settings
"
)
connection_path
=
path
.
split
(
'
/
'
).
slice
(
0
,
-
1
).
join
(
'
/
'
);
.
push
(
function
(
gadget
)
{
if
(
!
g
.
props
.
xmla_connections
[
connection_path
])
{
return
gadget
.
getContent
();
return
new
RSVP
.
Queue
()
})
.
push
(
function
()
{
.
push
(
function
(
value
)
{
if
(
g
.
props
.
init_value
)
{
connection_path
=
path
.
split
(
'
/
'
).
slice
(
0
,
-
1
).
join
(
'
/
'
);
settings
=
convertOnMultiLevel
(
g
.
props
.
init_value
,
connection_path
);
if
(
!
g
.
props
.
xmla_connections
.
hasOwnProperty
(
connection_path
))
{
if
(
settings
)
{
g
.
props
.
xmla_connections
[
connection_path
]
=
init_schema
();
convertOnMultiLevel
(
g
.
props
.
init_value
,
connection_path
,
[]);
}
}
return
g
.
props
.
xmla_connections
[
connection_path
];
}
});
return
generateSchema
(
settings
);
})
.
push
(
function
(
s
)
{
g
.
props
.
xmla_connections
[
connection_path
]
=
false
;
return
s
;
});
}
}
}
throw
Error
(
"
urn: '
"
+
url
+
"
' not supported
"
);
throw
new
Error
(
"
urn: '
"
+
url
+
"
' not supported
"
);
})
.
onStateChange
(
function
(
modification_dict
)
{
});
});
}(
window
,
rJS
));
}(
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