Skip to content

Commit

Permalink
Merge pull request #55 from latin-language-toolkit/conf_tweaks
Browse files Browse the repository at this point in the history
Conf tweaks
  • Loading branch information
LFDM committed May 10, 2014
2 parents 58d23ac + 599f469 commit 2ea3b80
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 28 deletions.
8 changes: 1 addition & 7 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<script src="./js/arethusa.core/directives/fire_event.directive.js"></script>
<script src="./js/arethusa.core/directives/token.js"></script>
<script src="./js/arethusa.core/directives/state_debug.js"></script>
<script src="./js/arethusa.core/routes/main.constant.js"></script>

<script src="./js/arethusa.morph.js"></script>
<script src="./js/arethusa.morph/morph.service.js"></script>
Expand Down Expand Up @@ -69,12 +70,5 @@ <h1><a href="#">LLT Annotation Environment <em>(Arethusa)</em></a></h1>
<p/>

<div id="arethusa-main-view" ng-view></div>
<!--<div ng-include="template"></div>-->

<!--<div class="row">-->
<!--<div class="columns small-12">-->
<!--<button ng-click="addPlugin()">Add Plugin</button>-->
<!--</div>-->
<!--</div>-->
</body>
</html>
12 changes: 8 additions & 4 deletions app/js/arethusa.core/configurator.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ angular.module('arethusa.core').service('configurator', function($injector) {
};

this.getServices = function(serviceNames) {
var that = this;
return arethusaUtil.map(serviceNames, function(name) {
return that.getService(name);
});
if (serviceNames) {
var that = this;
return arethusaUtil.map(serviceNames, function(name) {
return that.getService(name);
});
} else {
return [];
}
};

// this.configuration is set from outside on page load
Expand Down
33 changes: 33 additions & 0 deletions app/js/arethusa.core/routes/main.constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";

angular.module('arethusa.core').constant('MAIN_ROUTE', {
controller: 'MainCtrl',
template: '<div ng-include="template"></div>',
resolve: {
loadConfiguration: function($q, $http, $route, configurator) {
var files = {
default: './static/configuration_default.json',
staging: './static/configuration1.json'
};
var params = $route.current.params;
var confUrl;

// Fall back to default and wrong paths to conf files
// need to be handled separately eventually
if (params.conf) {
confUrl = files[params.conf] || files.default;
} else if (params.conf_file) {
confUrl = params.conf_file;
} else {
confUrl = files.default;
}

return $http({
method: 'GET',
url: confUrl,
}).then(function(result) {
configurator.configuration = result.data;
});
}
}
});
21 changes: 4 additions & 17 deletions app/js/arethusa.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,7 @@ angular.module(
'arethusa.morph',
'arethusa.hist'
],
function($routeProvider) {
$routeProvider.when('/', {
controller: 'MainCtrl',
templateUrl: 'templates/main2.html',
resolve: {
loadConfiguration: function($q, $http, configurator) {
return $http({
method: 'GET',
url: './static/configuration1.json'
}).then(function(result) {
configurator.configuration = result.data;
});
}
}
}
);
});
function($routeProvider, MAIN_ROUTE) {
$routeProvider.when('/', MAIN_ROUTE);
}
);
7 changes: 7 additions & 0 deletions app/static/configuration_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"state" : {},

"MainCtrl" : {
"template" : "templates/main3.html"
}
}
1 change: 1 addition & 0 deletions app/templates/main3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Running Arethusa with default conf file. Nothing to see here.
5 changes: 5 additions & 0 deletions spec/arethusa.core/configurator.service_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ describe('configurator', function() {
expect(services).toContain(mock1);
expect(services).toContain(mock2);
}));

it('returns an empty array when no service names are given', inject(function(configurator) {
var services = configurator.getServices(undefined);
expect(services).toEqual([]);
}));
});
});

0 comments on commit 2ea3b80

Please sign in to comment.