blob: 1a04b406ace31de0a8f9b2a9a5b2b52f2d28179b [file] [log] [blame]
<!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="bodydiv">
<table style="width: 100%;">
<tr><td><h2><span id="h1"></span></h2></td></tr>
</table>
<div id="catmenu"></div>
<div id="apps"></div>
<script type="text/javascript">
// Set page titles
document.title = ui.windowtitle(location.hostname) + ' - Store';
$('h1').innerHTML = ui.hometitle(location.hostname);
// Get the store category
var category = ui.fragmentParams(location)['category'];
if (isNil(category))
category = 'myapps';
/**
* Build store menu bar
*/
function catmenu() {
function catmenuitem(name, cat, idx) {
var c = cat == category? 'smenu' : 'amenu';
return '<th class="thl thr" style="width: 10px; padding-top: 4px; padding-bottom: 4px; padding-right: 6px;">'
+ ui.ahref('/#view=store&category=' + cat + '&idx=' + idx, '_view', '<span class="' + c + '">' + name + '</span>') + '</th>';
}
var m = '<table style="width: 100%; margin-bottom: 2px;"><tr>';
m += catmenuitem('My Apps', 'myapps', '1');
m += catmenuitem('New', 'new', '2');
m += catmenuitem('Top', 'top', '3');
m += catmenuitem('Featured', 'featured', '4');
m += catmenuitem('All', 'all', '5');
if (category == 'myapps') {
m += '<th class="thl thr" style="width: 100%; padding-top: 0px; padding-bottom: 0px; padding-right: 0px; text-align: right;">';
m += '<input type="button" class="graybutton" id="createApp" title="Create a new app" style="font-weight: bold; margin-top: 0px; margin-bottom: 0px; height: 24px;" Value="New App"/>';
m += '</th></tr></table>';
return m;
}
m += '<th class="thl thr" style="width: 100%;"></th></tr></table>';
return m;
}
// Build store menu bar
$('catmenu').innerHTML = catmenu();
/**
* Service references.
*/
var editWidget = sca.component("EditWidget");
var store = sca.reference(editWidget, "store");
var dashboards = sca.reference(editWidget, "dashboards");
/**
* Return the link to an app.
*/
function applink(appname) {
var protocol = location.protocol;
var host = location.hostname;
var port = ':' + location.port;
if (port == ':80' || port == ':443' || port == ':')
port = '';
var link = protocol + '//' + appname + '.' + host + port + '/';
return link;
}
/**
* 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.
*/
if (category == 'myapps') {
$('createApp').onclick = function() {
return ui.navigate('/#view=create', '_view');
}
}
/**
* Get and display list of apps.
*/
function getapps(category) {
//log('category', category);
function display(doc) {
// Stop now if we didn't get the apps
if (doc == null)
return false;
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 = 'joe';
var clone = isNil(config.clone)? 'Clone' : config.clone;
apps += '<div class="box" style="width: 150px; display: inline-block; border: 1px; border-style: solid; border-color: #dcdcdc; border-collapse: collapse; margin: 2px; padding: 2px; vertical-align: top;">'
apps += '<table><tr>';
apps += '<td>';
apps += '<div>' + ui.ahref('/#view=stats&app=' + name, '_view', '<img src="' + appimg + '" width="50" height="50" style="height: 50px; width: 50px; vertical-align: top; margin: 0px; padding: 0px;"></img>') + '</div>';
apps += '</td>';
apps += '<td class="tdw">';
apps += '<div style="font-weight: bold">' + ui.ahref(applink(name), '_blank', name) + '</div>';
if (category == 'myapps')
apps += '<div style="color: #808080;">Shared</div>';
else
apps += '<div>' + 'by&nbsp;' + '<span style="font-weight: bold;">' + author + '</span></div>';
apps += '</td>';
apps += '</tr></table>';
apps += '</div>';
return displayentries(cdr(entries));
}
displayentries(entries);
apps += '</div>';
$('apps').innerHTML = apps;
}
if (category == 'myapps')
return dashboards.get('', display);
return store.get(category, display);
}
// Get and display the list of apps
getapps(category);
</script>
</div>