[WIP] Preparing REST API calls

This commit is contained in:
Robert von Burg 2016-03-27 19:55:48 +02:00
parent 53d21eefd2
commit f73c207076
6 changed files with 52 additions and 55 deletions

View File

@ -59,7 +59,7 @@
<depends>SessionHandler</depends> <depends>SessionHandler</depends>
<Properties> <Properties>
<corsEnabled>true</corsEnabled> <corsEnabled>true</corsEnabled>
<corsOrigin>http://localhost:8180</corsOrigin> <corsOrigin>http://localhost:8080</corsOrigin>
</Properties> </Properties>
</Component> </Component>
<Component> <Component>

View File

@ -13,7 +13,7 @@ strolch.const = {
url_base: 'planningwebapp', url_base: 'planningwebapp',
urls: { urls: {
auth: 'rest/strolch/authentication', auth: 'rest/strolch/authentication',
version: 'rest/version', version: 'rest/strolch/version'
}, },
auth_token: 'auth_token', auth_token: 'auth_token',

View File

@ -67,48 +67,48 @@ strolch.fn.setLocale = function (locale) {
localStorage['language_locale'] = locale; localStorage['language_locale'] = locale;
}; };
strolch.fn.const.version = null; strolch.const.version = null;
strolch.fn.version = function () { strolch.fn.version = function () {
if (strolch.fn.const.version == null) { if (strolch.const.version == null) {
strolch.fn.const.version = "unknown"; strolch.const.version = "unknown";
$.ajax({ $.ajax({
async: false, async: false,
url: localStorage['url_version'] url: strolch.fn.url(strolch.const.urls.version)
} }
).done(function (data) { ).done(function (data) {
if (data != null) { if (data != null) {
var ver = data['artifactVersion']; var ver = data['artifactVersion'];
if (data['scmRevision'] == '${buildNumber}') { if (data['scmRevision'] == '${buildNumber}') {
strolch.fn.const.version = ver; strolch.const.version = ver;
} else { } else {
ver = ver ? ver.substr(0, 9) : '?'; ver = ver ? ver.substr(0, 9) : '?';
var rev = data['scmRevision']; var rev = data['scmRevision'];
var rev = rev ? rev.substr(0, 7) : '?'; var rev = rev ? rev.substr(0, 7) : '?';
strolch.fn.const.version = ver + " - " + rev; strolch.const.version = ver + " - " + rev;
}
} }
}); }
});
} }
return strolch.fn.const.version; return strolch.const.version;
}; };
strolch.fn.const.revision = null; strolch.const.revision = null;
strolch.fn.revision = function () { strolch.fn.revision = function () {
if (strolch.fn.const.revision == null) { if (strolch.const.revision == null) {
strolch.fn.const.revision = Math.floor(Math.random() * 10000000); strolch.const.revision = Math.floor(Math.random() * 10000000);
$.ajax({ $.ajax({
async: false, async: false,
url: strolch.fn.url(subPath) url: strolch.fn.url(strolch.const.urls.version)
} }
).done(function (data) { ).done(function (data) {
if (data != null && data['scmRevision'] != '${buildNumber}') { if (data != null && data['scmRevision'] != '${buildNumber}') {
uoms.fn.const.revision = data['scmRevision']; strolch.const.revision = data['scmRevision'];
} }
}); });
} }
return uoms.fn.const.revision; return strolch.const.revision;
}; };
@ -116,7 +116,7 @@ strolch.fn.revision = function () {
* Session management * Session management
*/ */
strolch.fn.showReAuthForm = function () { strolch.fn.showReAuthForm = function () {
$('#reauthFormModal').on('shown.bs.modal', function () { $('#reauthFormModal').on('shown.bs.modal', function () {
$('#auth-password').focus(); $('#auth-password').focus();
}); });
$('#reauthFormModal').modal('show'); $('#reauthFormModal').modal('show');

View File

@ -53,4 +53,9 @@ strolch.index.registerHandlers = function () {
strolch.index.start = function () { strolch.index.start = function () {
var components = ['model'];
$.forEach(components, function (index) {
alert(index);
})
}; };

View File

@ -15,15 +15,15 @@ jQuery(document).ready(function ($) {
}); });
strolch.parts.model.init = function (domParent) { strolch.parts.model.init = function (domParent) {
strolch.parts.model.registerHandlers(); $("#page-content").load("parts/model.html");
strolch.parts.model.registerHandlers();
}; };
strolch.parts.model.registerHandlers = function () { strolch.parts.model.registerHandlers = function () {
}; };
strolch.parts.model.start = function () { strolch.parts.model.start = function () {

View File

@ -1,28 +1,20 @@
<html> <!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#resources" role="tab">Resources</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a></li>
</ul>
<div id="content-model" style="display: none"> <!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="resources" role="tabpanel">
<!-- Nav tabs --> <h1>Resources</h1>
<ul class="nav nav-tabs" role="tablist"> <table id="resourcesTable" class="table table-striped">
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#resources" role="tab">Resources</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a></li>
</ul>
<!-- Tab panes --> <caption>The resources for the current user's realm</caption>
<div class="tab-content">
<div class="tab-pane active" id="resources" role="tabpanel">
<h1>Resources</h1> </table>
<table id="resourcesTable" class="table table-striped">
<caption>The resources for the current user's realm</caption> </div>
<div class="tab-pane" id="orders" role="tabpanel">Orders</div>
</table> </div>
</div>
<div class="tab-pane" id="orders" role="tabpanel">Orders</div>
</div>
</div>
</html>