Skip to content

Commit

Permalink
setting x86_64 as default architecture and modification to the
Browse files Browse the repository at this point in the history
front-end / back-end to relay the defaults from the backend to
the front-end so they do not need to be coded twice (closes #162)
  • Loading branch information
andponlin committed Dec 25, 2018
1 parent 3887fef commit ab20214
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014, Andrew Lindesay
* Copyright 2014-2018, Andrew Lindesay
* Distributed under the terms of the MIT License.
*/

Expand All @@ -17,4 +17,17 @@ public class GetRuntimeInformationResult {

public Boolean isProduction;

/**
* @since 2018-12-24
*/

public Defaults defaults;

public static class Defaults {

public String architectureCode;

public String repositoryCode;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ email.from=integration-test-sender@haiku-os.org
repository.import.populatepayloadlength=false

architecture.default.code=x86_gcc2
repository.default.code=haikuports

hvif2png.path=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.haiku.haikudepotserver.support.RuntimeInformationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;
Expand All @@ -38,20 +39,27 @@ public class MiscellaneousApiImpl extends AbstractApiImpl implements Miscellaneo
private final MessageSource messageSource;
private final NaturalLanguageService naturalLanguageService;
private final Boolean isProduction;
private final String architectureDefaultCode;
private final String repositoryDefaultCode;

@Autowired
public MiscellaneousApiImpl(
ServerRuntime serverRuntime,
RuntimeInformationService runtimeInformationService,
FeedService feedService,
MessageSource messageSource,
NaturalLanguageService naturalLanguageService,
@Value("${deployment.isproduction:false}") Boolean isProduction) {
@Value("${deployment.isproduction:false}") Boolean isProduction,
@Value("${architecture.default.code}") String architectureDefaultCode,
@Value("${repository.default.code}") String repositoryDefaultCode) {
this.serverRuntime = Preconditions.checkNotNull(serverRuntime);
this.runtimeInformationService = Preconditions.checkNotNull(runtimeInformationService);
this.feedService = Preconditions.checkNotNull(feedService);
this.messageSource = Preconditions.checkNotNull(messageSource);
this.naturalLanguageService = Preconditions.checkNotNull(naturalLanguageService);
this.isProduction = Preconditions.checkNotNull(isProduction);
this.architectureDefaultCode = Preconditions.checkNotNull(architectureDefaultCode);
this.repositoryDefaultCode = Preconditions.checkNotNull(repositoryDefaultCode);
}

@Override
Expand Down Expand Up @@ -151,6 +159,11 @@ public GetRuntimeInformationResult getRuntimeInformation(GetRuntimeInformationRe
result.startTimestamp = runtimeInformationService.getStartTimestamp();
}

GetRuntimeInformationResult.Defaults defaults = new GetRuntimeInformationResult.Defaults();
defaults.architectureCode = architectureDefaultCode;
defaults.repositoryCode = repositoryDefaultCode;
result.defaults = defaults;

return result;
}

Expand Down
3 changes: 0 additions & 3 deletions haikudepotserver-webapp/src/main/webapp/js/app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ angular.module('haikudepotserver')

RECENT_DAYS : 90,

ARCHITECTURE_CODE_DEFAULT : 'x86_gcc2', // TODO; from API somehow
REPOSITORY_CODE_DEFAULT : 'haikuports', // TODO; from API somehow

ENDPOINT_API_V1_REPOSITORY : '/__api/v1/repository',
ENDPOINT_API_V1_PKG : '/__api/v1/pkg',
ENDPOINT_API_V1_PKG_JOB: '/__api/v1/pkg/job',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Copyright 2014, Andrew Lindesay
* Copyright 2014-2018, Andrew Lindesay
* Distributed under the terms of the MIT License.
*/

angular.module('haikudepotserver').controller(
'AboutController',
[
'$scope','$log','$location',
'jsonRpc','constants','userState',
'breadcrumbs','breadcrumbFactory','errorHandling',
'$scope', '$log', '$location',
'jsonRpc', 'constants', 'userState', 'runtimeInformation',
'breadcrumbs', 'breadcrumbFactory', 'errorHandling',
function(
$scope,$log,$location,
jsonRpc,constants,userState,
breadcrumbs,breadcrumbFactory,errorHandling) {
$scope, $log, $location,
jsonRpc, constants, userState, runtimeInformation,
breadcrumbs, breadcrumbFactory, errorHandling) {

breadcrumbs.mergeCompleteStack([
breadcrumbFactory.createHome(),
Expand Down Expand Up @@ -60,17 +60,9 @@ angular.module('haikudepotserver').controller(
// RUNTIME INFORMATION

function refreshRuntimeInformation() {
jsonRpc.call(
constants.ENDPOINT_API_V1_MISCELLANEOUS,
"getRuntimeInformation",
[{}]
).then(
runtimeInformation.getRuntimeInformation().then(
function(result) {
$scope.serverProjectVersion = result.projectVersion;
$log.info('have fetched the runtime information');
},
function(err) {
errorHandling.handleJsonRpcError(err);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2015, Andrew Lindesay
* Copyright 2013-2018, Andrew Lindesay
* Distributed under the terms of the MIT License.
*/

Expand All @@ -9,16 +9,16 @@ angular.module('haikudepotserver').controller(
'$log','$scope','$rootScope','$q','$location',
'jsonRpc','constants','userState','messageSource','errorHandling',
'referenceData','breadcrumbs','breadcrumbFactory','searchMixins',
'repositoryService',
'repositoryService', 'runtimeInformation',
function(
$log,$scope,$rootScope,$q,$location,
jsonRpc,constants,userState,messageSource,errorHandling,
referenceData,breadcrumbs,breadcrumbFactory,searchMixins,
repositoryService) {
repositoryService, runtimeInformation) {

angular.extend(this,searchMixins);

const PAGESIZE = 15;
var PAGESIZE = 15;

// keys used in the search of the location
var KEY_OFFSET = 'o';
Expand All @@ -40,6 +40,7 @@ angular.module('haikudepotserver').controller(

var amFetchingPkgs = false;

$scope.runtimeInformationData = undefined; // pulled in with a promise later...
$scope.selectedViewCriteriaTypeOption = undefined;
$scope.searchExpression = $location.search()[KEY_SEARCHEXPRESSION] ? $location.search()[KEY_SEARCHEXPRESSION] : '';
$scope.lastRefetchPkgsSearchExpression = '';
Expand Down Expand Up @@ -179,7 +180,7 @@ angular.module('haikudepotserver').controller(
if(!$scope.selectedArchitecture) {
$scope.selectedArchitecture = _.findWhere(
$scope.architectures,
{ code : constants.ARCHITECTURE_CODE_DEFAULT });
{ code : $scope.runtimeInformationData.defaults.architectureCode });
}

if(!$scope.selectedArchitecture) {
Expand Down Expand Up @@ -295,6 +296,19 @@ angular.module('haikudepotserver').controller(

fnChain([

// fetch the runtime information to get the meta-data.
function(chain) {
runtimeInformation.getRuntimeInformation().then(
function(result) {
$scope.runtimeInformationData = result;
fnChain(chain); // carry on...
},
function(err) {
errorHandling.handleJsonRpcError(err);
}
);
},

// fetch the repositories
function(chain) {
repositoryService.getRepositories().then(
Expand Down Expand Up @@ -363,7 +377,7 @@ angular.module('haikudepotserver').controller(
function(chain) {

$scope.$watch('pkgs.offset', function(newValue, oldValue) {
if(undefined!=oldValue && null!=oldValue && newValue!=oldValue) { // already initialized elsewhere
if(undefined != oldValue && null != oldValue && newValue != oldValue) { // already initialized elsewhere
$log.debug('offset change -> refetching pkgs');
refetchPkgs();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014, Andrew Lindesay
* Copyright 2014-2018, Andrew Lindesay
* Distributed under the terms of the MIT License.
*/

Expand All @@ -9,10 +9,12 @@ angular.module('haikudepotserver').controller(
'$scope','$log','$location',
'jsonRpc','constants','userState',
'breadcrumbs','breadcrumbFactory','errorHandling',
'runtimeInformation',
function(
$scope,$log,$location,
jsonRpc,constants,userState,
breadcrumbs,breadcrumbFactory,errorHandling) {
breadcrumbs,breadcrumbFactory,errorHandling,
runtimeInformation) {

breadcrumbs.mergeCompleteStack([
breadcrumbFactory.createHome(),
Expand All @@ -28,25 +30,17 @@ angular.module('haikudepotserver').controller(
};

function refreshRuntimeInformation() {
jsonRpc.call(
constants.ENDPOINT_API_V1_MISCELLANEOUS,
"getRuntimeInformation",
[{}]
).then(
runtimeInformation.getRuntimeInformation().then(
function(result) {
$scope.versions.serverProject = result.projectVersion;
$scope.versions.serverJava = result.javaVersion;
$scope.serverStartTimestamp = result.startTimestamp;
$log.info('have fetched the runtime information');
},
function(err) {
errorHandling.handleJsonRpcError(err);
}
);
}

refreshRuntimeInformation();

}
]
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016, Andrew Lindesay
* Copyright 2013-2018, Andrew Lindesay
* Distributed under the terms of the MIT License.
*/

Expand All @@ -17,32 +17,26 @@ angular.module('haikudepotserver').directive('banner',function() {
},
controller:
[
'$rootScope','$scope','$log','$location','$route','$window',
'userState','referenceData','messageSource','breadcrumbs',
'errorHandling','breadcrumbFactory','jsonRpc','constants',
'$rootScope', '$scope', '$log', '$location', '$route', '$window',
'userState', 'referenceData', 'messageSource', 'breadcrumbs',
'errorHandling', 'breadcrumbFactory', 'jsonRpc', 'constants',
'runtimeInformation',
function(
$rootScope,$scope,$log,$location,$route,$window,
userState,referenceData,messageSource,breadcrumbs,
errorHandling,breadcrumbFactory,jsonRpc,constants) {
$rootScope, $scope, $log, $location, $route, $window,
userState, referenceData, messageSource, breadcrumbs,
errorHandling, breadcrumbFactory, jsonRpc, constants,
runtimeInformation) {

$scope.showActions = false;
$scope.showWarnNonProduction = undefined;
$scope.userNickname = undefined;
$scope.naturalLanguageCode = userState.naturalLanguageCode();

function refreshShowWarnNonProduction() {
jsonRpc.call(
constants.ENDPOINT_API_V1_MISCELLANEOUS,
"getRuntimeInformation",
[{}]
).then(
function(result) {
runtimeInformation.getRuntimeInformation().then(
function (result) {
$scope.showWarnNonProduction = !result.isProduction;
},
function(err) {
errorHandling.handleJsonRpcError(err);
}
);
});
}

refreshShowWarnNonProduction();
Expand All @@ -51,7 +45,7 @@ angular.module('haikudepotserver').directive('banner',function() {

var p = $location.path();

if(0==p.indexOf('/completepasswordreset/')) {
if(0 === p.indexOf('/completepasswordreset/')) {
return true;
}

Expand Down Expand Up @@ -88,7 +82,7 @@ angular.module('haikudepotserver').directive('banner',function() {

$scope.canGoMore = function() {
var p = $location.path();
return '/about' != p;
return '/about' !== p;
};

// This will take the user to a page about the application.
Expand Down Expand Up @@ -168,7 +162,7 @@ angular.module('haikudepotserver').directive('banner',function() {

$scope.canShowRepository = function() {
var p = $location.path();
return '/repositories' != p;
return '/repositories' !== p;
};

$scope.goListRepositories = function() {
Expand Down Expand Up @@ -227,7 +221,7 @@ angular.module('haikudepotserver').directive('banner',function() {
// not from a permissions perspective, but from a navigational perspective.
$scope.canGoListUsers = function() {
var p = $location.path();
return '/users' != p;
return '/users' !== p;
};

$scope.goListUsers = function() {
Expand Down Expand Up @@ -297,7 +291,7 @@ angular.module('haikudepotserver').directive('banner',function() {
var nlc;
nlc = userState.naturalLanguageCode();

if ($scope.naturalLanguageCode != nlc) {
if ($scope.naturalLanguageCode !== nlc) {
$scope.naturalLanguageCode = nlc;
}
}
Expand Down

0 comments on commit ab20214

Please sign in to comment.