Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
HAWKULAR-661 - Organizations-related UI adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrohling committed Oct 8, 2015
1 parent c41bc03 commit 8ab620a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="modal-header">
<button type="button" class="close" ng-click="cancel()">
<span class="pficon pficon-close"></span>
</button>
<h4 class="modal-title">Delete Organization</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p class="primary-message">
Are you sure you want to delete the organization <strong>{{organization.name}}</strong>?
</p>
<p>This action can't be undone.</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="delete()">Delete</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ <h1>No organizations inside organization.</h1>
</a>
</td>
<td class="hk-actions-one">
<button type="button" class="btn btn-link" aria-label="Delete" ng-click="remove(organization)" data-toggle="tooltip" data-placement="top" data-original-title="Remove">
<button type="button"
class="btn btn-link"
tooltip-trigger
tooltip-placement="top"
tooltip="Remove"
ng-click="remove(organization)">
<i class="fa fa-trash-o"></i>
</button>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ module HawkularAccounts {
this.$scope.$emit('OrganizationLoaded');
},
(error:IErrorPayload) => {
this.NotificationsService.warning('Organization not found.');
this.$log.warn(`Error while loading the organization: ${error.data.message}`);
this.loading = false;
}
Expand All @@ -122,8 +121,8 @@ module HawkularAccounts {
this.$log.debug(`Finished loading members. Size: ${this.memberships.length}`);
},
(error:IErrorPayload) => {
this.NotificationsService.info('List of organizations could NOT be retrieved.');
this.$log.warn(`List of organizations could NOT be retrieved: ${error.data.message}`);
this.NotificationsService.error('List of memberships could NOT be retrieved.');
this.$log.warn(`List of memberships could NOT be retrieved: ${error.data.message}`);
this.loading = false;
}
);
Expand Down
46 changes: 35 additions & 11 deletions console/src/main/scripts/plugins/accounts/ts/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module HawkularAccounts {
});

createFormModal.result.then((organization) => {
NotificationsService.info(`Organization ${organization.name} created`);
NotificationsService.success(`Organization successfully created`);
$scope.organizations.unshift(organization);
}, (type, error) => {
if (type === 'error') {
Expand All @@ -68,17 +68,28 @@ module HawkularAccounts {
};

$scope.remove = (organization) => {
organization.$remove().then(
() => {
NotificationsService.info(`Organization ${organization.name} removed`);
$scope.$emit('OrganizationRemoved');
$scope.organizations.splice($scope.organizations.indexOf(organization), 1);
}, (error) => {
$log.warn('Error while trying to remove organization');
$log.warn(error);
NotificationsService.info(`Failed to remove the organization ${organization.name}: ${error.data.message}`);
var removeOrgModal = $modal.open({
controller: 'HawkularAccounts.OrganizationRemoveController',
templateUrl: 'plugins/accounts/html/organization-remove-modal.html',
resolve: {
organization: () => organization
}
);
});

removeOrgModal.result.then(() => {
organization.$remove().then(
() => {
NotificationsService.success(`Organization successfully deleted`);
$scope.$emit('OrganizationRemoved');
$scope.organizations.splice($scope.organizations.indexOf(organization), 1);
}, (error) => {
$log.warn('Error while trying to remove organization');
$log.warn(error);
let message = error.data.message;
NotificationsService.error(`Failed to remove the organization ${organization.name}: ${message}`);
}
);
});
};

$scope.load();
Expand Down Expand Up @@ -113,4 +124,17 @@ module HawkularAccounts {
$log.debug('Trying to persist the organization');
};
}]);

export var OrganizationRemoveController = _module.controller('HawkularAccounts.OrganizationRemoveController', [
'$scope', '$modalInstance', 'organization', ($scope, $modalInstance, organization) => {
$scope.organization = organization;

$scope.cancel = () => {
$modalInstance.dismiss('cancel');
};

$scope.delete = () => {
$modalInstance.close();
};
}]);
}

0 comments on commit 8ab620a

Please sign in to comment.