Skip to content

Commit

Permalink
Fixes #65
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiří Helmich committed Oct 21, 2015
1 parent 5a7b915 commit af90549
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 24 deletions.
9 changes: 9 additions & 0 deletions src/app/controllers/api/ComponentTemplateApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import scaldi.{Injectable, Injector}
import play.api.libs.json._
import play.api.libs.functional.syntax._

import scala.util.parsing.json.JSONObject

class ComponentTemplateApiController(implicit inj: Injector) extends ApiController with Injectable {

def delete(componentTemplateId: Long) = DBAction { implicit rws =>
Expand Down Expand Up @@ -67,6 +69,13 @@ class ComponentTemplateApiController(implicit inj: Injector) extends ApiControll
}
}

def makePermanent(id: Long) = DBAction { implicit rws =>
withComponentTemplate(id) { componentTemplate =>
componentTemplateService.save(componentTemplate.copy(isTemporary = false))
Ok(JsObject(Seq()))
}
}

def addDatasource = DBAction { implicit rws =>

case class Endpoint(url: String, graphUris: Option[Seq[String]])
Expand Down
6 changes: 6 additions & 0 deletions src/app/controllers/api/PipelineApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class PipelineApiController(implicit inj: Injector) extends Controller with Inje
pipelineService.evaluate(PipelineId(id))(logger)
}

def makePermanent(id: Long) = DBAction { implicit rws =>
val pipelineId = PipelineId(id)
pipelineService.makePermanent(pipelineId)
Ok(JsObject(Seq()))
}

def pipelineToJson(pipeline: Pipeline)(implicit session: Session) = {
val set = pipeline.bindingSet

Expand Down
2 changes: 2 additions & 0 deletions src/app/model/service/PipelineService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ trait PipelineService extends CrudService[PipelineId, Pipeline, PipelineTable, P

def modifyEvaluationQuery(id: PipelineEvaluationId, token: String, dimensionUri: String, valueUri: String)(implicit session: Session): Option[String]

def makePermanent(pipelineId: PipelineId)(implicit session: Session)

}
6 changes: 6 additions & 0 deletions src/app/model/service/impl/pipeline/PipelineServiceImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,10 @@ class PipelineServiceImpl(implicit inj: Injector) extends PipelineService with I
id
}
}

def makePermanent(pipelineId: PipelineId)(implicit session: Session) = {
findById(pipelineId).map { p =>
repository.save(p.copy(isTemporary = false))
}
}
}
2 changes: 2 additions & 0 deletions src/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ GET /api/v1/component/:id/features
GET /api/v1/component/:id/inputs @controllers.api.ComponentTemplateApiController.inputsById(id: Long)
GET /api/v1/component/:id/output @controllers.api.ComponentTemplateApiController.outputById(id: Long)
GET /api/v1/component/:id/descriptors @controllers.api.ComponentTemplateApiController.descriptorsById(id: Long)
GET /api/v1/component/makePermanent/:id @controllers.api.ComponentTemplateApiController.makePermanent(id: Long)

# LDVM pipelines
GET /api/v1/pipelines/evaluate/:pipelineId @controllers.api.PipelineApiController.evaluate(pipelineId: Long)
GET /api/v1/pipelines @controllers.api.PipelineApiController.list(skip: Int ?= 0, take: Int ?= 50, discoveryId: Option[Long] ?= None, visualizerId: Option[Long] ?= None)
GET /api/v1/pipelines/discover @controllers.api.PipelineApiController.discover(dataSourceTemplateIds: List[Long], combine: Boolean ?= false)
GET /api/v1/pipelines/evaluations/:id @controllers.api.PipelineApiController.evaluations(id: Long, skip: Int ?= 0, pageSize: Int ?= 10)
GET /api/v1/pipelines/visualization/:id @controllers.api.PipelineApiController.visualizationById(id: Long)
GET /api/v1/pipelines/makePermanent/:id @controllers.api.PipelineApiController.makePermanent(id: Long)
GET /api/v1/pipelines/:id @controllers.api.PipelineApiController.findById(id: Long)

# LDVM compatibility
Expand Down
40 changes: 23 additions & 17 deletions src/public/javascripts/angular/component/controllers/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,35 @@ define(['angular', 'underscorejs', '../controllers'], function (ng, _) {
function ($scope, $routeParams, components) {

$scope.mirrorOpts = {
lineWrapping : true,
lineWrapping: true,
lineNumbers: true,
readOnly: 'nocursor',
mode: 'sparql'
};


components.get({id: $routeParams.id}, function(c){
components.get({id: $routeParams.id}, function (c) {
$scope.component = c;
});
components.features({id: $routeParams.id}, function(f){
components.features({id: $routeParams.id}, function (f) {
$scope.features = f;
});
components.inputs({id: $routeParams.id}, function(i){
components.inputs({id: $routeParams.id}, function (i) {
$scope.inputs = i;
});
components.output({id: $routeParams.id}, function(o){
components.output({id: $routeParams.id}, function (o) {
$scope.output = o;
});
components.descriptors({id: $routeParams.id}, function(d){
components.descriptors({id: $routeParams.id}, function (d) {
$scope.descriptors = d;
});

$scope.permanent = function (id) {
components.makePermanent({id: id}, function () {
$scope.component.isTemporary = false;
});
};

$scope.componentType = $routeParams.type;

}])
Expand All @@ -73,37 +79,37 @@ define(['angular', 'underscorejs', '../controllers'], function (ng, _) {

// CALLBACKS

uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/, filter, options) {
uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
console.info('onWhenAddingFileFailed', item, filter, options);
};
uploader.onAfterAddingFile = function(fileItem) {
uploader.onAfterAddingFile = function (fileItem) {
console.info('onAfterAddingFile', fileItem);
};
uploader.onAfterAddingAll = function(addedFileItems) {
uploader.onAfterAddingAll = function (addedFileItems) {
console.info('onAfterAddingAll', addedFileItems);
};
uploader.onBeforeUploadItem = function(item) {
uploader.onBeforeUploadItem = function (item) {
console.info('onBeforeUploadItem', item);
};
uploader.onProgressItem = function(fileItem, progress) {
uploader.onProgressItem = function (fileItem, progress) {
console.info('onProgressItem', fileItem, progress);
};
uploader.onProgressAll = function(progress) {
uploader.onProgressAll = function (progress) {
console.info('onProgressAll', progress);
};
uploader.onSuccessItem = function(fileItem, response, status, headers) {
uploader.onSuccessItem = function (fileItem, response, status, headers) {
console.info('onSuccessItem', fileItem, response, status, headers);
};
uploader.onErrorItem = function(fileItem, response, status, headers) {
uploader.onErrorItem = function (fileItem, response, status, headers) {
console.info('onErrorItem', fileItem, response, status, headers);
};
uploader.onCancelItem = function(fileItem, response, status, headers) {
uploader.onCancelItem = function (fileItem, response, status, headers) {
console.info('onCancelItem', fileItem, response, status, headers);
};
uploader.onCompleteItem = function(fileItem, response, status, headers) {
uploader.onCompleteItem = function (fileItem, response, status, headers) {
console.info('onCompleteItem', fileItem, response, status, headers);
};
uploader.onCompleteAll = function() {
uploader.onCompleteAll = function () {

};

Expand Down
11 changes: 11 additions & 0 deletions src/public/javascripts/angular/component/partials/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ <h2>{{component.title}}
</div>
</div>
</div>

<div class="col-md-6">
<div class="card">
<div class="card-body card-padding text-right">
<div>
<button ng-click="permanent(component.id)" ng-show="component.isTemporary" class="btn btn-default">Make permanent</button>
<span class="badge badge-info" ng-show="!component.isTemporary">Permanent</span>
</div>
</div>
</div>
</div>
</div>

<div class="row">
Expand Down
3 changes: 2 additions & 1 deletion src/public/javascripts/angular/component/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define(['angular'], function (ng) {
features: {url: '/api/v1/component/:id/features', method: 'GET', isArray: true},
inputs: {url: '/api/v1/component/:id/inputs', method: 'GET', isArray: true},
output: {url: '/api/v1/component/:id/output', method: 'GET', isArray: false},
descriptors: {url: '/api/v1/component/:id/descriptors', method: 'GET', isArray: true}
descriptors: {url: '/api/v1/component/:id/descriptors', method: 'GET', isArray: true},
makePermanent: {url: '/api/v1/component/makePermanent/:id', method: 'GET', isArray: false}
});
}]);
});
12 changes: 9 additions & 3 deletions src/public/javascripts/angular/ldvm/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ define(['angular'], function (ng) {
add: {url: '/api/v1/pipelines/ttl', isArray: false},
visualization: {url: '/api/v1/pipelines/visualization/:id', isArray: false},
evaluations: {url: '/api/v1/pipelines/evaluations/:id', isArray: false},
discover: {url: '/api/v1/pipelines/discover', isArray: false}
discover: {url: '/api/v1/pipelines/discover', isArray: false},
makePermanent: {url: '/api/v1/pipelines/makePermanent/:id', isArray: false}
});
}])
.factory('DatasourceApi', ['$resource', function ($resource) {
Expand All @@ -25,7 +26,8 @@ define(['angular'], function (ng) {
}])
.factory('ComponentsApi', ['$resource', function ($resource) {
return $resource(null, null, {
createDatasource: {url: '/api/v1/datasources/add', method: 'POST', isArray: true}
createDatasource: {url: '/api/v1/datasources/add', method: 'POST', isArray: true},
makePermanent: {url: '/api/v1/component/makePermanent/:id', method: 'GET', isArray: false}
});
}])
.factory('EvaluationApi', ['$resource', function ($resource) {
Expand All @@ -45,7 +47,11 @@ define(['angular'], function (ng) {
return $resource(null, null, {
create: {url: '/api/v1/datacube/create/:id', method: 'GET', isArray: false},
dataStructures: {url: '/api/v1/datacube/datastructures/:id', method: 'GET', isArray: true},
dataStructureComponents: {url: '/api/v1/datacube/datastructure-components', method: 'GET', isArray: false}
dataStructureComponents: {
url: '/api/v1/datacube/datastructure-components',
method: 'GET',
isArray: false
}
});
}]);
});
1 change: 1 addition & 0 deletions src/public/javascripts/angular/ldvm/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ define([
'ldvm.controllers',
'ldvm.directives',
'ldvm.filters',
'ldvm.models',
'ngRoute',
'ngResource',
'ngTable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@ define(['angular', './controllers'], function (ng) {
function ($scope, $routeParams, pipelines) {

$scope.pipelineId = $routeParams.id;

$scope.pipeline = null;
$scope.data = [];

pipelines.get($routeParams.id).then(function (pipeline) {
$scope.pipeline = pipeline;
});

pipelines.visualization($routeParams.id).then(function (data) {
$scope.data = data;
console.log(data);
});

pipelines.evaluations($routeParams.id).then(function (data) {
$scope.evaluations = data.data;
});

$scope.permanent = function (id) {
pipelines.makePermanent(id).then(function () {
$scope.pipeline.isTemporary = false;
});
};

}]);
});
3 changes: 3 additions & 0 deletions src/public/javascripts/angular/ldvm/models/componentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ define(['angular', './models'], function (ng) {
return {
createDatasource: function (data) {
return componentsApi.createDatasource(data).$promise;
},
makePermanent: function(id){
return componentsApi.makePermanent({id: id}).$promise;
}
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/public/javascripts/angular/ldvm/models/pipelineModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ define(['angular', './models'], function (ng) {
},
discover: function () {
return pipelineApi.discover().$promise;
},
makePermanent: function (id) {
return pipelineApi.makePermanent({id: id}).$promise;
},
get: function (id) {
return pipelineApi.get({id: id}).$promise;
}
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/public/javascripts/angular/ldvm/partials/detail.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<div class="container">


<div class="panel panel-default">
<div class="panel-body">
<a ng-href="#/evaluate/{{pipelineId}}" class="btn btn-primary"><i class="glyphicon glyphicon-play"></i> Run</a>

<div class="pull-right">
<button ng-click="permanent(pipelineId)" ng-show="pipeline.isTemporary" class="btn btn-default">Make permanent</button>
<span class="badge badge-info" ng-show="!pipeline.isTemporary">Permanent</span>
</div>
</div>
</div>

Expand Down

0 comments on commit af90549

Please sign in to comment.