Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Fixed db-connection for no autodiscover use case #69

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions dist/apigility-ui/1b07d878.apigility.js

This file was deleted.

13 changes: 13 additions & 0 deletions dist/apigility-ui/53fc2d3b.vendor.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/apigility-ui/62df23e8.apigility.js

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions dist/apigility-ui/6a8334db.vendor.js

This file was deleted.

16 changes: 0 additions & 16 deletions dist/apigility-ui/css/bce07457.apigility.min.css

This file was deleted.

16 changes: 16 additions & 0 deletions dist/apigility-ui/css/ec28ea49.apigility.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<link rel="icon" href="apigility-ui/img/favicon.png">

<link rel="stylesheet" href="apigility-ui/css/bce07457.apigility.min.css"/>
<link rel="stylesheet" href="apigility-ui/css/ec28ea49.apigility.min.css"/>

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
Expand Down Expand Up @@ -42,9 +42,9 @@
</footer>
</div>

<script src="apigility-ui/6a8334db.vendor.js" charset="utf-8"></script>
<script src="apigility-ui/53fc2d3b.vendor.js" charset="utf-8"></script>

<script src="apigility-ui/1b07d878.apigility.js" charset="utf-8"></script>
<script src="apigility-ui/62df23e8.apigility.js" charset="utf-8"></script>

<script>
$(document).ready(function () {
Expand Down
3 changes: 3 additions & 0 deletions src/apigility-ui/modal/new-service.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
vm.loading = false;
return;
}
if (vm.rest.table_name) {
vm.dbServices = [{ table_name : vm.rest.table_name, columns : [] }];
}
if (vm.dbServices.length == 0) {
vm.alert = 'Please choose at least one table';
vm.loading = false;
Expand Down
3 changes: 2 additions & 1 deletion src/apigility-ui/modal/new-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ <h3>No DB Adapters Present</h3>
</div>
<div ng-if="vm.tables && vm.tables.length == 0 && !vm.discovering && !vm.loading">
<h3>No tables found</h3>
<p>Autodiscovery could not find any existing tables, or those tables have already been exposed through DB-connected services.</p>
<p>Autodiscovery could not find any existing tables, you can insert the table name here:</p>
<input type="text" class="form-control" ng-model="vm.rest.table_name" ng-disabled="vm.loading" placeholder="Insert the table name">
</div>
</tab>
<tab heading="Doctrine Connected" ng-if="vm.hasDoctrine" active="vm.tabs.doctrine">
Expand Down
18 changes: 6 additions & 12 deletions src/apigility-ui/rest/rest.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
vm.restName = $stateParams.rest;
vm.httpMethods = [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
vm.disabled = !SidebarService.isLastVersion(vm.version, vm.apiName);
vm.selectorNames = [];

function initGeneral() {
vm.selectorNames = [];
vm.adapterNames = [];

vm.tags = {
accept_whitelist : [],
content_type_whitelist : [],
Expand All @@ -31,11 +33,12 @@
});

api.getDatabase(function(err, response){
vm.db = response;
for(var i in response.db_adapter){
vm.adapterNames.push(response.db_adapter[i].adapter_name);
}
});

api.getDoctrineAdapters(function(err, response) {

vm.doctrine = response.doctrine_adapter;
});

Expand Down Expand Up @@ -65,15 +68,6 @@
vm.doctrineMetadata = response;
});
}
if (vm.rest.hasOwnProperty('table_name') &&
vm.rest.hasOwnProperty('db')) {
for (var i = 0; i < vm.db.db_adapter.length; i++) {
if (vm.db.db_adapter[i].adapter_name == vm.rest.adapter_name) {
vm.adapter = vm.db.db_adapter[i];
break;
}
}
}
vm.rest.source_code = [
{ name : 'Collection Class', classname: vm.rest.collection_class },
{ name : 'Entity Class', classname: vm.rest.entity_class },
Expand Down
10 changes: 9 additions & 1 deletion src/apigility-ui/rest/rest.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ <h3 class="panel-title">
<div class="form-group">
<label for="db_adapter_name" class="col-sm-2 control-label">Adapter name</label>
<div class="col-sm-8">
<select class="form-control" id="db_adapter_name" ng-model="vm.adapter" ng-options="db.adapter_name for db in vm.db.db_adapter" ng-disabled="vm.disabled"></select>
<ui-select
ng-model="vm.rest.adapter_name"
ng-disabled="vm.disabled">
<ui-select-match placeholder="Select db adapter name...">{{$select.selected}}</ui-select-match>
<ui-select-choices
repeat="adapter in vm.adapterNames | filter: $select.search">
<div ng-bind-html="adapter | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group">
Expand Down
11 changes: 9 additions & 2 deletions src/apigility-ui/service/api.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,18 @@
var doctrine_route = isDoctrine ? 'doctrine/' : '';
xhr.get(agApiPath + '/module/' + module + '/' + version + '/autodiscovery/' + doctrine_route + name)
.then(function (response) {
growl.success('Doctrine service(s) created');
return callback(true, response);
})
.catch(function (err) {
growl.error('Error creating Doctrine service(s)', {ttl: -1});
if (err.data.detail) {
growl.error(err.data.detail, {ttl: -1});
} else {
if (isDoctrine) {
growl.error('Error getting Doctrine service(s)', {ttl: -1});
} else {
growl.error('Error getting db service(s)', {ttl: -1});
}
}
return callback(true, null);
});
};
Expand Down
13 changes: 11 additions & 2 deletions src/apigility-ui/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,8 @@ angular.module("apigility-ui/modal/new-service.html", []).run(["$templateCache",
" </div>\n" +
" <div ng-if=\"vm.tables && vm.tables.length == 0 && !vm.discovering && !vm.loading\">\n" +
" <h3>No tables found</h3>\n" +
" <p>Autodiscovery could not find any existing tables, or those tables have already been exposed through DB-connected services.</p>\n" +
" <p>Autodiscovery could not find any existing tables, you can insert the table name here:</p>\n" +
" <input type=\"text\" class=\"form-control\" ng-model=\"vm.rest.table_name\" ng-disabled=\"vm.loading\" placeholder=\"Insert the table name\">\n" +
" </div>\n" +
" </tab>\n" +
" <tab heading=\"Doctrine Connected\" ng-if=\"vm.hasDoctrine\" active=\"vm.tabs.doctrine\">\n" +
Expand Down Expand Up @@ -1994,7 +1995,15 @@ angular.module("apigility-ui/rest/rest.html", []).run(["$templateCache", functio
" <div class=\"form-group\">\n" +
" <label for=\"db_adapter_name\" class=\"col-sm-2 control-label\">Adapter name</label>\n" +
" <div class=\"col-sm-8\">\n" +
" <select class=\"form-control\" id=\"db_adapter_name\" ng-model=\"vm.adapter\" ng-options=\"db.adapter_name for db in vm.db.db_adapter\" ng-disabled=\"vm.disabled\"></select>\n" +
" <ui-select\n" +
" ng-model=\"vm.rest.adapter_name\"\n" +
" ng-disabled=\"vm.disabled\">\n" +
" <ui-select-match placeholder=\"Select db adapter name...\">{{$select.selected}}</ui-select-match>\n" +
" <ui-select-choices\n" +
" repeat=\"adapter in vm.adapterNames | filter: $select.search\">\n" +
" <div ng-bind-html=\"adapter | highlight: $select.search\"></div>\n" +
" </ui-select-choices>\n" +
" </ui-select>\n" +
" </div>\n" +
" </div>\n" +
" <div class=\"form-group\">\n" +
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<link href="vendor/angular-growl-v2/build/angular-growl.css" rel="stylesheet">
<link href="vendor/angular-ui-tree/dist/angular-ui-tree.min.css" rel="stylesheet">
<link href="vendor/ladda/dist/ladda-themeless.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="apigility-ui/css/dashboard.css" rel="stylesheet" type="text/css">
<!-- endbuild -->
Expand Down