forked from Archives/Athou_commafeed
added a way to display an announcement
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
27
src/main/java/com/commafeed/frontend/model/ServerInfo.java
Normal file
27
src/main/java/com/commafeed/frontend/model/ServerInfo.java
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}]);
|
||||
@@ -33,5 +33,7 @@
|
||||
<button class="btn btn-success" type="button" ng-click="toDonate()">Donate</button>
|
||||
</div>
|
||||
<div spinner shown="loading"></div>
|
||||
<span>{{ServerService.announcement}}</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,7 +57,13 @@
|
||||
ng-model="settings.backgroundThreads" />
|
||||
<span class="help-inline">Requires restart</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="announcement">Announcement</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="announcement"
|
||||
ng-model="settings.announcement" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
|
||||
Reference in New Issue
Block a user