-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from exadel-inc/feature/deletereport
[ELI_46] Delete report button.
- Loading branch information
Showing
13 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...in/java/com/exadel/etoolbox/linkinspector/core/services/exceptions/DataFeedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.exadel.etoolbox.linkinspector.core.services.exceptions; | ||
|
||
public class DataFeedException extends Exception { | ||
public DataFeedException(String message) { | ||
super(message); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
core/src/main/java/com/exadel/etoolbox/linkinspector/core/servlets/DeleteReportServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.exadel.etoolbox.linkinspector.core.servlets; | ||
|
||
import com.exadel.etoolbox.linkinspector.core.services.data.DataFeedService; | ||
import com.exadel.etoolbox.linkinspector.core.services.exceptions.DataFeedException; | ||
import org.apache.commons.httpclient.HttpStatus; | ||
import org.apache.sling.api.SlingHttpServletRequest; | ||
import org.apache.sling.api.SlingHttpServletResponse; | ||
import org.apache.sling.api.servlets.HttpConstants; | ||
import org.apache.sling.api.servlets.SlingAllMethodsServlet; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.servlet.Servlet; | ||
|
||
@Component(service = {Servlet.class}, | ||
property = { | ||
"sling.servlet.methods=" + HttpConstants.METHOD_DELETE, | ||
"sling.servlet.paths=" + "/bin/etoolbox/link-inspector/delete-report" | ||
} | ||
) | ||
public class DeleteReportServlet extends SlingAllMethodsServlet { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(DeleteReportServlet.class); | ||
|
||
@Reference | ||
private DataFeedService dataFeedService; | ||
|
||
@Override | ||
protected void doDelete(SlingHttpServletRequest request, SlingHttpServletResponse response) { | ||
try { | ||
dataFeedService.deleteDataFeed(); | ||
response.setStatus(HttpStatus.SC_OK); | ||
} catch (DataFeedException e) { | ||
LOG.error(e.getMessage()); | ||
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...cr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* EToolbox Link Inspector clientlib. | ||
* "Delete Report" action definition. | ||
*/ | ||
(function (window, document, $, ELC, Granite, Coral) { | ||
'use strict'; | ||
const DIALOG_TITLE_LABEL = Granite.I18n.get('Delete Report'); | ||
const CANCEL_LABEL = Granite.I18n.get('Cancel'); | ||
const SUBMIT_FILTER_LABEL = Granite.I18n.get('Delete'); | ||
const ERROR_MSG = Granite.I18n.get('Something went wrong'); | ||
|
||
function onFilterAction(name, el, config, collection, selections) { | ||
const dialog = document.querySelector('#delete-dialog'); | ||
dialog.show(); | ||
} | ||
|
||
function initDeleteDialog(){ | ||
const dialog = new Coral.Dialog().set({ | ||
id : 'delete-dialog', | ||
closable: Coral.Dialog.closable.ON, | ||
backdrop: Coral.Dialog.backdrop.STATIC, | ||
interaction: 'off', | ||
header :{ | ||
innerHTML : DIALOG_TITLE_LABEL | ||
} | ||
}); | ||
|
||
$('<p>').html('Are you sure you want to delete the report?').appendTo(dialog.content); | ||
|
||
const $cancelBtn = $('<button is="coral-button" variant="default" coral-close>').text(CANCEL_LABEL); | ||
const $updateBtn = | ||
$('<button data-dialog-action is="coral-button" variant="primary" coral-close>').text(SUBMIT_FILTER_LABEL); | ||
|
||
$cancelBtn.appendTo(dialog.footer); | ||
$updateBtn.appendTo(dialog.footer); | ||
|
||
function onDeleteDialogSubmit(){ | ||
dialog.trigger('coral-overlay:close'); | ||
$.ajax({ | ||
url: '/bin/etoolbox/link-inspector/delete-report', | ||
type: 'DELETE', | ||
success: function(){ | ||
window.location.reload(); | ||
}, | ||
error: function(){ | ||
var alertPopup = new Coral.Alert().set({ | ||
variant: "error", | ||
header: { | ||
innerHTML: 'ERROR' | ||
}, | ||
content: { | ||
textContent: ERROR_MSG | ||
} | ||
}); | ||
alertPopup.classList.add('elc-coral-alert'); | ||
document.body.append(alertPopup); | ||
} | ||
}); | ||
} | ||
|
||
dialog.on('click', '[data-dialog-action]', onDeleteDialogSubmit); | ||
dialog.on('coral-overlay:close', function (event) { | ||
dialog.remove(); | ||
initDeleteDialog(); | ||
}); | ||
|
||
document.body.appendChild(dialog); | ||
} | ||
|
||
$(window).adaptTo('foundation-registry').register('foundation.collection.action.action', { | ||
name: 'cq-admin.etoolbox.linkinspector.action.delete-report', | ||
handler: onFilterAction | ||
}); | ||
|
||
$(document).ready(function () { | ||
initDeleteDialog(); | ||
}); | ||
|
||
})(window, document, Granite.$, Granite.ELC, Granite, Coral); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters