Skip to content

Commit

Permalink
Add baseUrl parameter to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Dec 1, 2023
1 parent b269c9b commit 7f3d1ab
Show file tree
Hide file tree
Showing 38 changed files with 81 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/main/html/webapp/components/admin/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default Control.extend({
}));
$(element).fadeIn();

$.getJSON("/api/v2/admin/server/statistics", {
$.getJSON("api/v2/admin/server/statistics", {
days: 1
}, function(mydata) {

Expand Down Expand Up @@ -55,7 +55,7 @@ export default Control.extend({

var days = $("#day_combo").val();
var that = this;
$.getJSON("/api/v2/admin/server/statistics", {
$.getJSON("api/v2/admin/server/statistics", {
days: days
}, function(mydata) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default Control.extend({
$(element).hide();
$(element).html(template());
$(element).fadeIn();
$("#log-cloudgene").load("/api/v2/admin/server/logs/cloudgene.log");
$("#log-cloudgene").load("api/v2/admin/server/logs/cloudgene.log");
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default Control.extend({

"init": function(element, options) {

$.get('/logs/' + options.job.attr('id'),function(data) {
$.get('logs/' + options.job.attr('id'),function(data) {
$(element).html(template({
content: data,
job: options.job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="container">


<form id="parameters" class="form-horizontal" action="/api/v2/jobs/submit/{{application.id}}" method="POST" enctype="multipart/form-data" novalidate autocomplete="off">
<form id="parameters" class="form-horizontal" action="api/v2/jobs/submit/{{application.id}}" method="POST" enctype="multipart/form-data" novalidate autocomplete="off">

<div class="form-group row">
<label for="job-name" class="col-sm-2 col-form-label">Name</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<br>
{{#data.success}}
<div class="alert alert-success" id="success-message">
<b>Well done!</b> Your account is now active. <a href="/">Login now</a>.
<b>Well done!</b> Your account is now active. <a href="./">Login now</a>.
<br>
</div>
{{else}}
Expand Down
4 changes: 2 additions & 2 deletions src/main/html/webapp/components/core/user/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default Control.extend({
var password = $(element).find("[name='password']");

$.ajax({
url: "/login",
url: "login",
type: "POST",
data: $(element).find("#signin-form").serialize(),
dataType: 'json',
Expand All @@ -33,7 +33,7 @@ export default Control.extend({
};
localStorage.setItem('cloudgene', JSON.stringify(dataToken));

var redirect = '/';
var redirect = './';
window.location = redirect;

},
Expand Down
2 changes: 1 addition & 1 deletion src/main/html/webapp/components/core/user/logout/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default Control.extend({

localStorage.removeItem("cloudgene");

var redirect = '/';
var redirect = './';
window.location = redirect;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default Control.extend({


$.ajax({
url: "/api/v2/users/update-password",
url: "api/v2/users/update-password",
type: "POST",
data: $(element).find("#update-password-form")
.serialize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default Control.extend({
var username = $(element).find("[name='username']");

$.ajax({
url: "/api/v2/users/reset",
url: "api/v2/users/reset",
type: "POST",
data: $(element).find("#reset-form").serialize(),
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default Control.extend({
}

$.ajax({
url: "/api/v2/users/me/profile",
url: "api/v2/users/me/profile",
type: "POST",
data: $(element).find("#account-form").serialize(),
dataType: 'json',
Expand Down
2 changes: 1 addition & 1 deletion src/main/html/webapp/components/core/user/signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default Control.extend({
$('#save').button('loading');

$.ajax({
url: "/api/v2/users/register",
url: "api/v2/users/register",
type: "POST",
data: $(element).find("#signon-form").serialize(),
dataType: 'json',
Expand Down
4 changes: 2 additions & 2 deletions src/main/html/webapp/models/application-settings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/server/apps/{id}/settings',
update: 'PUT /api/v2/server/apps/{id}/settings'
findOne: 'GET api/v2/server/apps/{id}/settings',
update: 'PUT api/v2/server/apps/{id}/settings'
}, {

});
10 changes: 5 additions & 5 deletions src/main/html/webapp/models/application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findAll: 'GET /api/v2/server/apps',
findOne: 'GET /api/v2/server/apps/{tool}',
create: 'POST /api/v2/server/apps',
update: 'PUT /api/v2/server/apps/{id}',
destroy: 'DELETE /api/v2/server/apps/{id}'
findAll: 'GET api/v2/server/apps',
findOne: 'GET api/v2/server/apps/{tool}',
create: 'POST api/v2/server/apps',
update: 'PUT api/v2/server/apps/{id}',
destroy: 'DELETE api/v2/server/apps/{id}'
}, {

'updateBinding': function() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/cloudgene-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Model from 'can-connect/can/model/model';


export default Model.extend({
findAll: 'GET /api/v2/admin/server/cloudgene-apps',
findAll: 'GET api/v2/admin/server/cloudgene-apps',
}, {

});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/cluster.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/admin/server/cluster'
findOne: 'GET api/v2/admin/server/cluster'
}, {

});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/counter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/server/counters'
findOne: 'GET api/v2/server/counters'
}, {

});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/group.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findAll: 'GET /api/v2/admin/groups',
findAll: 'GET api/v2/admin/groups',
}, {});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/job-admin-details.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Job from 'models/job';

export default Job.extend({
findAll: 'GET /api/v2/admin/jobs'
findAll: 'GET api/v2/admin/jobs'
}, {

});
4 changes: 2 additions & 2 deletions src/main/html/webapp/models/job-details.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Job from 'models/job';

export default Job.extend({
findOne: 'GET /api/v2/jobs/{id}',
destroy: 'DELETE /api/v2/jobs/{id}'
findOne: 'GET api/v2/jobs/{id}',
destroy: 'DELETE api/v2/jobs/{id}'
}, {});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/job-operation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
update: 'GET /api/v2/jobs/{id}/{action}'
update: 'GET api/v2/jobs/{id}/{action}'
}, {});
6 changes: 3 additions & 3 deletions src/main/html/webapp/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import Model from 'can-connect/can/model/model';


export default Model.extend({
findAll: 'GET /api/v2/jobs',
findOne: 'GET /api/v2/jobs/{id}/status',
destroy: 'DELETE /api/v2/jobs/{id}',
findAll: 'GET api/v2/jobs',
findOne: 'GET api/v2/jobs/{id}/status',
destroy: 'DELETE api/v2/jobs/{id}',
}, {

'syncTime': function () {
Expand Down
6 changes: 3 additions & 3 deletions src/main/html/webapp/models/nextflow-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/admin/server/nextflow/config',
create: 'POST /api/v2/admin/server/nextflow/config/update',
update: 'POST /api/v2/admin/server/nextflow/config/update'
findOne: 'GET api/v2/admin/server/nextflow/config',
create: 'POST api/v2/admin/server/nextflow/config/update',
update: 'POST api/v2/admin/server/nextflow/config/update'
}, {});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/server'
findOne: 'GET api/v2/server'
}, {});
6 changes: 3 additions & 3 deletions src/main/html/webapp/models/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/admin/server/settings',
create: 'POST /api/v2/admin/server/settings/update',
update: 'POST /api/v2/admin/server/settings/update'
findOne: 'GET api/v2/admin/server/settings',
create: 'POST api/v2/admin/server/settings/update',
update: 'POST api/v2/admin/server/settings/update'
}, {});
10 changes: 5 additions & 5 deletions src/main/html/webapp/models/template.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findAll: 'GET /api/v2/admin/server/templates',
findOne: 'GET /api/v2/admin/server/templates/{key}',
destroy: 'POST /api/v2/admin/server/templates/delete',
create: 'POST /api/v2/admin/server/templates/{key}',
update: 'POST /api/v2/admin/server/templates/{key}'
findAll: 'GET api/v2/admin/server/templates',
findOne: 'GET api/v2/admin/server/templates/{key}',
destroy: 'POST api/v2/admin/server/templates/delete',
create: 'POST api/v2/admin/server/templates/{key}',
update: 'POST api/v2/admin/server/templates/{key}'
}, {});
2 changes: 1 addition & 1 deletion src/main/html/webapp/models/user-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default Model.extend({
destroy: function(user) {

return $.ajax({
url: "/api/v2/users/" + user.username + "/profile",
url: "api/v2/users/" + user.username + "/profile",
type: "DELETE",
data: {
"username": user.username,
Expand Down
4 changes: 2 additions & 2 deletions src/main/html/webapp/models/user-token.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
create: 'POST /api/v2/users/{user}/api-token?expiration={expiration}',
destroy: 'DELETE /api/v2/users/{user}/api-token',
create: 'POST api/v2/users/{user}/api-token?expiration={expiration}',
destroy: 'DELETE api/v2/users/{user}/api-token',
}, {});
8 changes: 4 additions & 4 deletions src/main/html/webapp/models/user.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Model from 'can-connect/can/model/model';

export default Model.extend({
findOne: 'GET /api/v2/users/{user}/profile',
destroy: 'POST /api/v2/admin/users/{username}/delete',
update: 'POST /api/v2/admin/users/changegroup',
findAll: 'GET /api/v2/admin/users'
findOne: 'GET api/v2/users/{user}/profile',
destroy: 'POST api/v2/admin/users/{username}/delete',
update: 'POST api/v2/admin/users/changegroup',
findAll: 'GET api/v2/admin/users'
}, {

define: {
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/cloudgene/mapred/cli/StartServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ public int run() {

}

// TODO: urlPrefix
String baseUrl = Application.settings.getBaseUrl();
if (!baseUrl.trim().isEmpty()) {
if (!baseUrl.startsWith("/") || baseUrl.endsWith("/")){
System.out.println("Error: baseUrl has wrong format. Example: \"/path\" or \"/path/subpath\".");
System.exit(1);
}
properties.put("micronaut.server.context-path", baseUrl);
} else {

}

if (new File("webapp").exists()) {

Expand Down Expand Up @@ -131,7 +140,7 @@ protected Settings loadSettings(Config config) throws FileNotFoundException, Yam
}

if (settings.getServerUrl() == null || settings.getServerUrl().trim().isEmpty()) {
System.out.println("serverUrl not set. Please set serverUrl in file '" + settingsFilename + "'");
System.out.println("Error: serverUrl not set. Please set serverUrl in file '" + settingsFilename + "'");
System.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cloudgene/mapred/jobs/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Environment {

public Environment(Settings settings) {
add("SERVICE_NAME", settings.getName());
add("SERVICE_URL", settings.getServerUrl());
add("SERVICE_URL", settings.getServerUrl() + settings.getBaseUrl());
add("CONTACT_EMAIL", settings.getAdminMail());
add("CONTACT_NAME", settings.getAdminName());
if (settings.getMail() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public InputStream download(String url) throws IOException {
String key = S3Util.getKey(url);

AmazonS3 s3 = S3Util.getAmazonS3();

S3Object o = s3.getObject(bucket, key);
S3ObjectInputStream s3is = o.getObjectContent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String addContext(CloudgeneContext context) {
contexts.put(context.getPublicJobId(), context);
Settings settings = context.getSettings();
log.info("[Job {}] Register collector for public job id '{}'", context.getJobId(), context.getPublicJobId());
return settings.getServerUrl() + settings.getUrlPrefix() + COLLECTOR_ENDPOINT + context.getPublicJobId();
return settings.getServerUrl() + settings.getBaseUrl() + COLLECTOR_ENDPOINT + context.getPublicJobId();
}

public void addEvent(String job, Map<String, Object> event) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public String downloadScript(String paramId, String hash) {
List<Download> downloads = dao.findAllByParameter(param);

String hostname = application.getSettings().getServerUrl();
hostname += application.getSettings().getUrlPrefix();
hostname += application.getSettings().getBaseUrl();

StringBuffer script = new StringBuffer();
script.append("#!/bin/bash\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ServerResponse build(Settings settings) {
response.setName(settings.getName());
response.setAdminName(settings.getAdminName());
response.setAdminMail(settings.getAdminMail());
response.setServerUrl(settings.getServerUrl());
response.setServerUrl(settings.getServerUrl() + settings.getBaseUrl());
response.setBackgroundColor(settings.getColors().get("background"));
response.setForegroundColor(settings.getColors().get("foreground"));
response.setGoogleAnalytics(settings.getGoogleAnalytics());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public MessageResponse resetPassword(String username) {
}

String hostname = application.getSettings().getServerUrl();
hostname += application.getSettings().getUrlPrefix();
hostname += application.getSettings().getBaseUrl();

String link = hostname + "/#!recovery/" + user.getUsername() + "/" + key;

Expand Down Expand Up @@ -362,7 +362,7 @@ public MessageResponse registerUser(String username, String mail, String new_pas
try {

String hostname = application.getSettings().getServerUrl();
hostname += application.getSettings().getUrlPrefix();
hostname += application.getSettings().getBaseUrl();

// if email server configured, send mails with activation link. Else
// activate user immediately.
Expand Down
Loading

0 comments on commit 7f3d1ab

Please sign in to comment.