diff --git a/DnsServerCore/www/js/apps.js b/DnsServerCore/www/js/apps.js
index e62df3c4..3521420c 100644
--- a/DnsServerCore/www/js/apps.js
+++ b/DnsServerCore/www/js/apps.js
@@ -31,59 +31,7 @@ function refreshApps() {
var tableHtmlRows = "";
for (var i = 0; i < apps.length; i++) {
- var id = Math.floor(Math.random() * 10000);
- var name = apps[i].name;
- var version = apps[i].version;
- var updateVersion = apps[i].updateVersion;
- var updateUrl = apps[i].updateUrl;
- var updateAvailable = apps[i].updateAvailable;
-
- var dnsAppsTable = null;
-
- //dnsApps
- if (apps[i].dnsApps.length > 0) {
- dnsAppsTable = "
Class Path
Description
";
-
- for (var j = 0; j < apps[i].dnsApps.length; j++) {
- var labels = "";
- var description = null;
-
- if (apps[i].dnsApps[j].isAppRecordRequestHandler) {
- labels += "APP Record";
- description = "
";
+
+ return tableHtmlRow
+}
+
function showStoreAppsModal() {
var divStoreAppsAlert = $("#divStoreAppsAlert");
var divStoreAppsLoader = $("#divStoreAppsLoader");
@@ -204,9 +214,11 @@ function installStoreApp(objBtn, appName, url) {
var id = btn.attr("data-id");
$("#btnStoreAppUninstall" + id).show();
- refreshApps();
+ var tableHtmlRow = getAppRowHtml(responseJSON.response.installedApp);
+ $("#tableAppsBody").prepend(tableHtmlRow);
+ updateAppsFooterCount();
- showAlert("success", "Store App Installed!", "DNS application was installed successfully from DNS App Store.", divStoreAppsAlert);
+ showAlert("success", "Store App Installed!", "DNS application '" + appName + "' was installed successfully from DNS App Store.", divStoreAppsAlert);
},
error: function () {
btn.button('reset');
@@ -235,21 +247,17 @@ function updateStoreApp(objBtn, appName, url, isModal) {
btn.button('reset');
btn.hide();
- var id = btn.attr("data-id");
-
if (isModal) {
+ var id = btn.attr("data-id");
$("#spanStoreAppUpdateVersion" + id).hide();
$("#spanStoreAppDisplayVersion" + id).text($("#spanStoreAppUpdateVersion" + id).text().replace(/Update/g, "Version"));
-
- refreshApps();
- }
- else {
- $("#btnAppsStoreUpdate" + id).hide();
- $("#trAppUpdateVersion" + id).hide();
- $("#trAppVersion" + id).text($("#trAppUpdateVersion" + id).text().replace(/Update/g, "Version"));
}
- showAlert("success", "Store App Updated!", "DNS application was updated successfully from DNS App Store.", divStoreAppsAlert);
+ var tableHtmlRow = getAppRowHtml(responseJSON.response.updatedApp);
+ var id = getAppRowId(responseJSON.response.updatedApp.name);
+ $("#trApp" + id).replaceWith(tableHtmlRow);
+
+ showAlert("success", "Store App Updated!", "DNS application '" + appName + "' was updated successfully from DNS App Store.", divStoreAppsAlert);
},
error: function () {
btn.button('reset');
@@ -282,9 +290,11 @@ function uninstallStoreApp(objBtn, appName) {
$("#btnStoreAppUpdate" + id).hide();
$("#spanStoreAppVersion" + id).attr("class", "label label-primary");
- refreshApps();
+ var id = getAppRowId(appName);
+ $("#trApp" + id).remove();
+ updateAppsFooterCount();
- showAlert("success", "Store App Uninstalled!", "DNS application was uninstalled successfully.", divStoreAppsAlert);
+ showAlert("success", "Store App Uninstalled!", "DNS application '" + appName + "' was uninstalled successfully.", divStoreAppsAlert);
},
error: function () {
btn.button('reset');
@@ -327,9 +337,11 @@ function installApp() {
success: function (responseJSON) {
$("#modalInstallApp").modal("hide");
- refreshApps();
+ var tableHtmlRow = getAppRowHtml(responseJSON.response.installedApp);
+ $("#tableAppsBody").prepend(tableHtmlRow);
+ updateAppsFooterCount();
- showAlert("success", "App Installed!", "DNS application was installed successfully.");
+ showAlert("success", "App Installed!", "DNS application '" + appName + "' was installed successfully.");
},
error: function () {
btn.button('reset');
@@ -365,9 +377,11 @@ function updateApp() {
success: function (responseJSON) {
$("#modalUpdateApp").modal("hide");
- refreshApps();
+ var tableHtmlRow = getAppRowHtml(responseJSON.response.updatedApp);
+ var id = getAppRowId(responseJSON.response.updatedApp.name);
+ $("#trApp" + id).replaceWith(tableHtmlRow);
- showAlert("success", "App Updated!", "DNS application was updated successfully.");
+ showAlert("success", "App Updated!", "DNS application '" + appName + "' was updated successfully.");
},
error: function () {
btn.button('reset');
@@ -385,7 +399,6 @@ function uninstallApp(objBtn, appName) {
return;
var btn = $(objBtn);
-
btn.button('loading');
HTTPRequest({
@@ -393,15 +406,9 @@ function uninstallApp(objBtn, appName) {
success: function (responseJSON) {
var id = btn.attr("data-id");
$("#trApp" + id).remove();
+ updateAppsFooterCount();
- var totalApps = $('#tableApps >tbody >tr').length;
-
- if (totalApps > 0)
- $("#tableAppsFooter").html("
Total Apps: " + totalApps + "
");
- else
- $("#tableAppsFooter").html("
No App Found
");
-
- showAlert("success", "App Uninstalled!", "DNS application was uninstalled successfully.");
+ showAlert("success", "App Uninstalled!", "DNS application '" + appName + "' was uninstalled successfully.");
},
error: function () {
btn.button('reset');
@@ -412,6 +419,14 @@ function uninstallApp(objBtn, appName) {
});
}
+function updateAppsFooterCount() {
+ var totalApps = $('#tableApps >tbody >tr').length;
+ if (totalApps > 0)
+ $("#tableAppsFooter").html("
Total Apps: " + totalApps + "
");
+ else
+ $("#tableAppsFooter").html("
No App Found
");
+}
+
function showAppConfigModal(objBtn, appName) {
var btn = $(objBtn);
@@ -459,7 +474,7 @@ function saveAppConfig() {
success: function (responseJSON) {
$("#modalAppConfig").modal("hide");
- showAlert("success", "App Config Saved!", "The DNS application config was saved and reloaded successfully.");
+ showAlert("success", "App Config Saved!", "The DNS application '" + appName + "' config was saved and reloaded successfully.");
},
error: function () {
btn.button('reset');