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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<!DOCTYPE html>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<div id="bodydiv" class="body">
<div id="apps" class="viewcontent"></div>
<script type="text/javascript">
(function() {
/**
* Set page titles.
*/
document.title = config.windowtitle() + ' - Store';
/**
* The store categories
*/
var categories = [
//['Featured', 'featured', 1],
['Top', 'top', 2],
['New', 'new', 3],
['Search', 'all', 4],
['My Apps', 'myapps', 5]
];
/**
* Find a store category.
*/
function findcategory(name) {
if (isNil(name))
return findcategory('top');
var f = filter(function(c) { return cadr(c) == name }, categories);
if (isNil(f))
return findcategory('top');
return car(f);
}
/**
* Get the current store category.
*/
var catname = cadr(findcategory(ui.fragmentParams(location)['category']));
/**
* Build the store menu bar
*/
function catmenu() {
function catmenuitem(name, cat, idx) {
var c = cat == catname? 'smenu' : 'amenu';
return '<span>' + ui.href('storecat_' + cat, '/#view=store&category=' + cat + '&idx=' + idx, '_view', '<span class="' + c + '">' + name + '</span>') + '</span>';
}
var m = '';
map(function(c) { m += catmenuitem(car(c), cadr(c), caddr(c)); }, categories);
m += '<span class="rmenu"><input type="button" class="graybutton bluebutton" id="createApp" title="Create a new app" Value="Create"/></span>';
return m;
}
/**
* Build the store menu bar.
*/
$('viewhead').innerHTML = catmenu();
/**
* Init service references.
*/
var editorComp = sca.component("Editor");
var store = sca.reference(editorComp, "store");
var dashboards = sca.reference(editorComp, "dashboards");
/**
* Edit an app.
*/
function editApp(appname) {
return ui.navigate('/#view=page&app=' + appname, '_view');
}
/**
* View an app.
*/
function viewApp(appname) {
return ui.navigate('/#view=stats&app=' + appname, '_view');
}
/**
* Create an app.
*/
$('createApp').onclick = function() {
return ui.navigate('/#view=create', '_view');
}
/**
* Get and display list of apps.
*/
function getapps(catname) {
//debug('catname', catname);
showStatus('Loading');
function display(doc) {
// Stop now if we didn't get the apps
if (doc == null) {
showError('App not available');
return false;
}
showOnlineStatus();
var apps = '<div>';
var feed = car(elementsToValues(atom.readATOMFeed(mklist(doc))));
var aentries = assoc("'entry", cdr(feed));
var entries = isNil(aentries)? mklist() : isList(car(cadr(aentries)))? cadr(aentries) : mklist(cdr(aentries));
var appimg = ui.b64img(appcache.get('/public/app.b64'));
function displayentries(entries) {
if (isNil(entries))
return apps;
var entry = car(entries);
var title = cadr(assoc("'title", entry))
var name = cadr(assoc("'id", entry));
var author = cadr(assoc("'author", entry));
var updated = cadr(assoc("'updated", entry));
apps += '<div class="box">'
apps += '<span class="appicon">' + ui.href('appicon_' + name, '/#view=stats&app=' + name, '_view', '<img src="' + appimg + '" width="50" height="50"></img>') + '</span>';
apps += '<span>'
apps += '<span class="apptitle">' + ui.href('apptitle_' + name, '/#view=stats&app=' + name, '_view', name) + '</span>';
if (catname != 'myapps')
apps += '<br/><span>' + 'by ' + author.split('@')[0] + '</span>';
apps += '</span>';
apps += '</div>';
return displayentries(cdr(entries));
}
displayentries(entries);
apps += '</div>';
$('apps').innerHTML = apps;
}
if (catname == 'myapps')
return dashboards.get('', display);
return store.get(catname, display);
}
/**
* Get and display the list of apps.
*/
getapps(catname);
})();
</script>
</div>
|