fix(ui): print error message in modal
Due to a previous change of the return value (promise) the wrong data was accessed.
Fixed the default messages if the variables are `null|undefined`.
Added CSS to break even on long class paths.
Closes:
MODIFY
manager/ui/war/plugins/api-manager/html/modals/errorModal.html
manager/ui/war/plugins/api-manager/html/modals/errorModal.html
<div class="col-sm-2">
<i class="fa fa-warning" style="font-size:48px;color:red"></i>
</div>
- <div class="col-sm-10">
+ <div class="col-sm-10" style="line-break: anywhere">
{{ message }}
</div>
</div>

MODIFY
manager/ui/war/plugins/api-manager/ts/api/api-def.ts
manager/ui/war/plugins/api-manager/ts/api/api-def.ts
@@ -51,7 +51,7 @@ _module.controller('Apiman.ApiDefController',
switch (definitionType) {
case 'SwaggerJSON':
try {
- $.parseJSON(data);
+ JSON.parse(data);
return true;
} catch (error) {
return false;
@@ -87,7 +87,7 @@ _module.controller('Apiman.ApiDefController',
$scope.finishModification();
},
function (error) {
- Modals.rpcerror(error, null, null);
+ Modals.rpcerror(error.data, null, null);
Logger.error("Error updating definition: {0}", error);
$scope.saveButton.state = 'error';
}
@@ -117,7 +117,7 @@ _module.controller('Apiman.ApiDefController',
var pageData = ApiEntityLoader.getCommonData($scope, $location);
- var loadDefinition = function () {
+ let loadDefinition = function () {
ApiDefinitionSvcs.getApiDefinition(params.org, params.api, params.version).then(
function (definition) {
$scope.apiDefinition = definition;
@@ -125,7 +125,7 @@ _module.controller('Apiman.ApiDefController',
},
function (error) {
Modals.rpcerror(error, null, null);
- Logger.error("Error loading definition: {0}", error);
+ Logger.error("Error loading definition: {0}", error.data.message);
});
};
@@ -204,8 +204,8 @@ _module.controller('Apiman.ApiDefController',
$scope.finishModification();
},
function (error) {
- Modals.rpcerror(error, null, null);
- Logger.error("Error updating definition: {0}", error);
+ Modals.rpcerror(error.data, null, null);
+ Logger.error("Error updating definition: {0}", error.data.message);
$scope.saveButton.state = 'error';
}
)

MODIFY
manager/ui/war/plugins/api-manager/ts/modals.ts
manager/ui/war/plugins/api-manager/ts/modals.ts
@@ -82,11 +82,13 @@ _module.factory('Modals',
try {
switch (typeof(rpcdata)) {
case "string":
- message = JSON.parse(rpcdata).message;
+ message = JSON.parse(rpcdata).message ?? message;
break;
case "object":
- message = rpcdata.message;
+ if (rpcdata.message){
+ message = rpcdata.message ?? message;
+ }
break;
default:

MODIFY
manager/ui/war/plugins/api-manager/ts/rpc.ts
manager/ui/war/plugins/api-manager/ts/rpc.ts
@@ -267,16 +267,13 @@ _module.factory('ApiDefinitionSvcs', ['$resource', '$http', 'Configuration', '$q
Configuration.api.endpoint + '/organizations/:organizationId/apis/:apiId/versions/:version/definition',
{organizationId: orgId, apiId: apiId, version: version});
},
- getApiDefinition: function(orgId, apiId, version, handler): Promise<string> {
+ getApiDefinition: function(orgId, apiId, version): Promise<string> {
var endpoint = formatEndpoint(
Configuration.api.endpoint + '/organizations/:organizationId/apis/:apiId/versions/:version/definition',
{ organizationId: orgId, apiId: apiId, version: version });
return $http({
method: 'GET',
url: endpoint,
- transformResponse: function(data) {
- return data;
- }
}).then(
ok => $q.resolve(ok.data),
failure => $q.reject(failure)

fix(ui): print error message in modal

Due to a previous change of the return value (promise) the wrong data was accessed.
Fixed the default messages if the variables are `null|undefined`.
Added CSS to break even on long class paths.

Closes: #2095