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

Commit

Permalink
Merge pull request #561 from ammendonca/HAWKULAR-613-REMOVE-DS
Browse files Browse the repository at this point in the history
HAWKULAR-613 : Add support for Delete Datasource
  • Loading branch information
mtho11 committed Oct 14, 2015
2 parents b651af5 + 467740f commit f1c3026
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
<div class="panel panel-default hk-summary">
<div class="panel-heading">
<span class="hk-heading">{{ds.properties.name}}</span>
<div class="btn-group pull-right" dropdown auto-close="always">
<button id="ds-actions" class="btn btn-link" type="button" dropdown-toggle aria-haspopup="true"
aria-expanded="true">
Actions
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="ds-actions">
<li class="disabled"><a href="#">Edit</a></li>
<li><a href="" ng-click="vm.deleteDatasource(ds)">Delete</a></li>
<li class="disabled"><a href="#">Enable</a></li>
<li class="disabled"><a href="#">Disable</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-sm-4 hk-summary-item">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="modal-header">
<button type="button" class="close" ng-click="mvm.cancel()">
<span class="pficon pficon-close"></span>
</button>
<h4 class="modal-title">Delete Datasource</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p class="primary-message">Are you sure you want to delete the Datasource <strong>{{ mvm.datasource.properties.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="mvm.cancel()">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="mvm.deleteDatasource()">Delete</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,23 @@ module HawkularMetrics {
});
}

public deleteDatasource(datasource: any): void {
/// create a new isolate scope for dialog inherited from current scope instead of default $rootScope
let datasourceDeleteDialog = this.$modal.open({
templateUrl: 'plugins/metrics/html/app-details/modals/detail-datasources-delete.html',
controller: 'AppServerDatasourcesDeleteDialogController as mvm',
resolve: {
datasource: () => datasource
}
});

datasourceDeleteDialog.result.then((modalValue) => {
// handle any returned modalValue if required
}, (reason) => {
// handle any returned cancel reason if required
});
}

public autoRefresh(intervalInSeconds: number): void {
this.autoRefreshPromise = this.$interval(() => {
this.getDatasources();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
///
/// Copyright 2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///

/// <reference path="../../metricsPlugin.ts"/>

module HawkularMetrics {

export class AppServerDatasourcesDeleteDialogController {

static $inject = ['$scope', '$rootScope', '$modalInstance', '$q', 'HawkularOps', 'NotificationsService',
'datasource'];

constructor(private $scope:any,
private $rootScope:any,
private $modalInstance:any,
private $q:ng.IQService,
private HawkularOps,
private NotificationsService:INotificationsService,
public datasource) {

/// make sure our WS socket is open
HawkularOps.init(this.NotificationsService);

$scope.$on('DatasourceRemoveSuccess', (event, data) => {
this.$modalInstance.close(data);
});

$scope.$on('DatasourceRemoveError', (event, data) => {
this.NotificationsService.error('The Datasource ' + this.datasource.properties.name +
' failed to be deleted.');
});
}

public deleteDatasource(): void {
this.HawkularOps.performRemoveDatasourceOperation(
this.datasource.path,
this.$rootScope.userDetails.token,
this.$rootScope.currentPersona.id);
}

public cancel() {
this.$modalInstance.dismiss('cancel');
}

}

_module.controller('AppServerDatasourcesDeleteDialogController', AppServerDatasourcesDeleteDialogController);

}

0 comments on commit f1c3026

Please sign in to comment.