diff --git a/src/main/java/com/commafeed/backend/model/ApplicationSettings.java b/src/main/java/com/commafeed/backend/model/ApplicationSettings.java index 23aca487..a04b33df 100644 --- a/src/main/java/com/commafeed/backend/model/ApplicationSettings.java +++ b/src/main/java/com/commafeed/backend/model/ApplicationSettings.java @@ -1,5 +1,6 @@ package com.commafeed.backend.model; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import javax.xml.bind.annotation.XmlAccessType; @@ -32,6 +33,9 @@ public class ApplicationSettings extends AbstractModel { private String smtpUserName; private String smtpPassword; + @Column(length = 255) + private String announcement; + public String getPublicUrl() { return publicUrl; } @@ -121,4 +125,12 @@ public class ApplicationSettings extends AbstractModel { this.googleAnalyticsTrackingCode = googleAnalyticsTrackingCode; } + public String getAnnouncement() { + return announcement; + } + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + } diff --git a/src/main/java/com/commafeed/frontend/model/ServerInfo.java b/src/main/java/com/commafeed/frontend/model/ServerInfo.java new file mode 100644 index 00000000..e5d8ea9a --- /dev/null +++ b/src/main/java/com/commafeed/frontend/model/ServerInfo.java @@ -0,0 +1,27 @@ +package com.commafeed.frontend.model; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import com.wordnik.swagger.annotations.ApiClass; + +@SuppressWarnings("serial") +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +@ApiClass("Server infos") +public class ServerInfo implements Serializable { + + private String announcement; + + public String getAnnouncement() { + return announcement; + } + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + +} diff --git a/src/main/java/com/commafeed/frontend/rest/RESTApplication.java b/src/main/java/com/commafeed/frontend/rest/RESTApplication.java index 8972b943..24608770 100644 --- a/src/main/java/com/commafeed/frontend/rest/RESTApplication.java +++ b/src/main/java/com/commafeed/frontend/rest/RESTApplication.java @@ -10,6 +10,7 @@ import com.commafeed.frontend.rest.resources.ApiDocumentationREST; import com.commafeed.frontend.rest.resources.CategoryREST; import com.commafeed.frontend.rest.resources.EntryREST; import com.commafeed.frontend.rest.resources.FeedREST; +import com.commafeed.frontend.rest.resources.ServerREST; import com.commafeed.frontend.rest.resources.UserREST; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import com.google.common.collect.Sets; @@ -31,6 +32,7 @@ public class RESTApplication extends Application { set.add(FeedREST.class); set.add(CategoryREST.class); set.add(UserREST.class); + set.add(ServerREST.class); set.add(AdminREST.class); set.add(ApiDocumentationREST.class); diff --git a/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java new file mode 100644 index 00000000..81cf3b97 --- /dev/null +++ b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java @@ -0,0 +1,23 @@ +package com.commafeed.frontend.rest.resources; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +import com.commafeed.frontend.model.ServerInfo; +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; + +@Path("/server") +@Api(value = "/server", description = "Operations about server infos") +public class ServerREST extends AbstractResourceREST { + + @Path("/get") + @GET + @ApiOperation(value = "Get server infos", notes = "Get server infos") + public ServerInfo get() { + ServerInfo infos = new ServerInfo(); + infos.setAnnouncement(applicationSettingsService.get() + .getAnnouncement()); + return infos; + } +} diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 6cfa3176..f30454ac 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -162,15 +162,16 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat }]); module.controller('ToolbarCtrl', ['$scope', '$http', '$state', '$stateParams', - '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', + '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', 'ServerService', function($scope, $http, $state, $stateParams, $route, $location, - SettingsService, EntryService, ProfileService, AnalyticsService) { + SettingsService, EntryService, ProfileService, AnalyticsService, ServerService) { function totalActiveAjaxRequests() { return ($http.pendingRequests.length + $.active); } $scope.session = ProfileService.get(); + $scope.ServerService = ServerService.get(); $scope.loading = true; $scope.$watch(totalActiveAjaxRequests, function() { diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index aa018b03..7ba211ff 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -198,4 +198,9 @@ module.factory('AdminUsersService', ['$resource', function($resource) { module.factory('AdminSettingsService', ['$resource', function($resource) { var res = $resource('rest/admin/settings/'); return res; +}]); + +module.factory('ServerService', ['$resource', function($resource) { + var res = $resource('rest/server/get'); + return res; }]); \ No newline at end of file diff --git a/src/main/webapp/templates/_toolbar.html b/src/main/webapp/templates/_toolbar.html index f96307e4..adcaa7aa 100644 --- a/src/main/webapp/templates/_toolbar.html +++ b/src/main/webapp/templates/_toolbar.html @@ -33,5 +33,7 @@
+ {{ServerService.announcement}} + \ No newline at end of file diff --git a/src/main/webapp/templates/admin.settings.html b/src/main/webapp/templates/admin.settings.html index df52f0e8..ceb6a689 100644 --- a/src/main/webapp/templates/admin.settings.html +++ b/src/main/webapp/templates/admin.settings.html @@ -57,7 +57,13 @@ ng-model="settings.backgroundThreads" /> Requires restart - + +