-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (101 loc) · 4.68 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<script src="/scripts/jquery-1.7.2.min.js"></script>
<script src="scripts/datajs-1.0.3.js"></script>
<script type="text/javascript" src="scripts/q.js"></script>
<script src="/scripts/jaydata/jaydata.js"></script>
<script src="scripts/jaydata/jaydataproviders/SqLiteProvider.js"></script>
<script src="scripts/jaydata/jaydataproviders/oDataProvider.js"></script>
<script src="/scripts/JaySvcUtil.js"></script>
<script src="scripts/knockout-2.1.0.debug.js"></script>
<script type="text/javascript" src="scripts/jaydata/jaydatamodules/qDeferred.js"></script>
<script src="scripts/jaygrid-table-template.js"></script>
<script src="scripts/jaygrid.js"></script>
<!--<script src="scripts/jay-property-editor.js"></script>-->
<script src="scripts/jaydata/jaydatamodules/knockout.js"></script>
<script type="text/javascript">
$(function() {
function dataManagerModel() {
var self = this;
self.context = ko.observable();
self.sets = ko.computed( function() {
if (self.context()) {
console.log(self.context());
var result = [];
for(var name in self.context()) {
if (self.context()[name] instanceof $data.EntitySet) {
result.push(this.context()[name]);
}
}
console.log(result);
return result;
}
}, this);
//self.currentSet = ko.observable();
self.selectSet = function(eSet) {
self.collection(eSet);
}
self.esPageSize = ko.observable(50);
self.collection = ko.observable();
self.visible = ko.observable(false);
}
var databaseManagerModel = new dataManagerModel();
ko.applyBindings(databaseManagerModel, document.getElementById("DataManagerUI"));
$data.Entity.extend("$odata.Endpoint", {
id: { type: 'int', key: true, computed: true },
url: { type: String } ,
username: { type: String } ,
password: { type: String }
});
$data.EntityContext.extend("$odata.db", {
repositories: { type: $data.EntitySet, elementType: $odata.Endpoint }
});
function repositoriesModel() {
var c = new $odata.db({ name: 'sqLite', databaseName:'odata'});
self.repositories = ko.observable();
self.selectEndpoint = function(ep) {
$data.MetadataLoader.load(ep.url(), function (factory, type, code) {
var context = factory();
console.dir("setting context");
databaseManagerModel.context(context);
console.dir("context set");
});
}
c.onReady( function() {
self.repositories(c.repositories);
})
};
var repoModel = new repositoriesModel();
ko.applyBindings(repoModel, document.getElementById("RepositoriesUI"));
})
</script>
</head>
<body>
<div id="output">
!!
</div>
<div id="RepositoriesUI">
<h3>Your repositories</h3>
<div id="repos" data-bind="jayGrid: { source: repositories }">
</div>
</div>
<div id="DataManagerUI" data-bind="if: context">
<h3>Your data</h3>
<div data-bind="foreach: sets">
<a href="#" data-bind="click: $root.selectSet, text: $data.collectionName"></a>
</div>
<h4></h4>
<div id="x567" data-bind="jayGrid: { source: collection }">
<script type="text/html" data-type-template="Edm.String">
<div style="background-color: silver" data-bind="text: $parent[name]"></div>
</script>
<script type="text/html" data-type-template="Edm.Boolean">
<input type="checkbox" data-bind="checked: $parent[name]" disabled />
</script>
<script type="text/html" data-field-template="Roles">
<div data-bind="text: $data"></div>
</script>
</div>
</div>
</body>
</html>