Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit cb78d1d

Browse files
committed
Change app list to get current config before pushing the app
1 parent 03fcddb commit cb78d1d

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

dashboard.tar.gz

37 Bytes
Binary file not shown.

digexp-dashboard/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
var dashboardApp = angular.module('dashboardApp',
1212
['ngRoute', 'dashboardApp.navBar','dashboardControllers', 'ngAnimate']);
1313
var firstRoute = true;
14+
var digExperienceDashboard = 'Digital Experience Dashboard';
1415
// Configure routes for the different views
1516
dashboardApp.config(['$routeProvider', function($routeProvider) {
1617
var redirect = '/listApps';
1718
if(firstRoute == true){
1819
firstRoute = false;
19-
var digExperienceDashboard = 'Digital Experience Dashboard';
2020
var configInfo = dashConfig.getConfigInfo();
2121
var haveServers = configInfo.servers[0].host.length!= 0;
2222
// first start up and no routes go to settings

digexp-dashboard/js/controllers/appListController.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
106106
$scope.$apply();
107107
spAppServer = require("ScriptAppServer");
108108
}));
109-
})
109+
});
110110
};
111111

112112
var loadSpConfigs = function(callback) {
@@ -138,10 +138,10 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
138138
cb(e);
139139
}
140140
}
141-
})
141+
});
142142
};
143143

144-
var fns = Object.keys($scope.apps).map(function(id) { return loadSpConfig.bind(null, id) });
144+
var fns = Object.keys($scope.apps).map(function(id) { return loadSpConfig.bind(null, id); });
145145

146146
var cb = function() {
147147
debugLogger.log("Done loading sp-config.json files for apps");
@@ -161,10 +161,10 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
161161
$scope.apps[id].imgUrl = applicationsFolder + "/" + id + "/preview-image.png";
162162
}
163163
cb();
164-
})
164+
});
165165
};
166166

167-
var fns = Object.keys($scope.apps).map(function(id) { return addPreviewImage.bind(null, id) });
167+
var fns = Object.keys($scope.apps).map(function(id) { return addPreviewImage.bind(null, id); });
168168

169169
var cb = function() {
170170
setTimeout($scope.$apply.bind($scope), 300);
@@ -258,7 +258,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
258258
$scope.apps[id].watchIgnore = json.watchIgnore || $scope.apps[id].watchIgnore;
259259
$scope.apps[id].splintIgnore = json.splintIgnore || $scope.apps[id].splintIgnore;
260260
$scope.apps[id].buildCommand = json.buildCommand || $scope.apps[id].buildCommand;
261-
cb && cb(null, json)
261+
cb && cb(null, json);
262262
}
263263
});
264264
};
@@ -287,7 +287,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
287287
$scope.push = function(id) {
288288
$scope.apps[id].loading++;
289289
if ($scope.apps[id].buildCommand) {
290-
prePush(id, function() { spPush(id) });
290+
prePush(id, function() { spPush(id); });
291291
} else {
292292
spPush(id);
293293
}
@@ -323,7 +323,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
323323
// TODO check splint-config.json
324324
options.src = ["./**"];
325325
options.src = options.src.concat($scope.apps[id].splintIgnore.split(";")
326-
.map(function(glob) { return "!" + glob }))
326+
.map(function(glob) { return "!" + glob; }));
327327
}
328328
debugLogger.log(options);
329329

@@ -468,7 +468,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
468468
$scope.$apply();
469469
}
470470
debugLogger.log($scope.spCmdlnLog);
471-
})
471+
});
472472
};
473473

474474
// $scope.modalItem = {};
@@ -486,7 +486,13 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
486486
* Writes the sp-config of the specified to the disk.
487487
*/
488488
$scope.updateSpConfig = function(id, cb) {
489-
$scope.apps[id].config = $scope.apps[id].config || {};
489+
var config;
490+
try{
491+
var curConfig = fs.readFileSync(applicationsFolder + "/" + id + "/sp-config.json");
492+
config = JSON.parse(curConfig);
493+
}
494+
catch(e){};
495+
$scope.apps[id].config = config || {};
490496

491497
$scope.apps[id].name = $scope.apps[id].config.wcmContentName;
492498
var json = JSON.parse(JSON.stringify($scope.apps[id].config)); // clone the config
@@ -502,7 +508,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
502508
fs.writeFile(applicationsFolder + "/" + id + "/sp-config.json", json, function() {
503509
$scope.$apply();
504510
cb && cb();
505-
})
511+
});
506512
};
507513

508514
$scope.$on('$viewContentLoaded', function(){
@@ -594,7 +600,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
594600
if (!killed) {
595601
$scope.apps[id].loading--;
596602
$scope.$apply();
597-
cb && cb()
603+
cb && cb();
598604
};
599605
});
600606

@@ -604,13 +610,13 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
604610
// prompts an option to kill the process if it's still executing after 10s
605611
if (executing) {
606612
var close = function() {
607-
$(".terminateButton" + id).remove()
613+
$(".terminateButton" + id).remove();
608614
};
609615
var buttons = [{
610616
text: "Wait",
611617
onclick: function() {
612618
wait();
613-
close()
619+
close();
614620
}
615621
}, {
616622
text: "Terminate",
@@ -621,7 +627,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
621627
$scope.$apply();
622628
cb && cb();
623629
}
624-
close()
630+
close();
625631
}
626632
}];
627633
displayInfoBox("Command " + $scope.apps[id].buildCommand + " is not finishing",
@@ -685,7 +691,7 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
685691
};
686692

687693
var displayInfoBox = function(msg, type, classes, buttons) {
688-
console.log(arguments)
694+
console.log(arguments);
689695
type = type || "info";
690696
classes = classes || "";
691697
var html = '<div class="alert alert-' + type + ' ' + classes +
@@ -702,13 +708,13 @@ dashboardControllers.controller('AppsListController', ['$scope', '$route', '$loc
702708
btn = buttons[btn];
703709
$("<button>" + btn.text + "</button>")
704710
.addClass("btn btn-sm btn-default")
705-
.on("click", function() { btn.onclick() })
711+
.on("click", function() { btn.onclick(); })
706712
.appendTo($html);
707713
}
708714

709715
$("#alert-wrapper").append($html);
710716
};
711717

712-
$scope.numOfApps = function() { return Object.keys($scope.apps).length}
718+
$scope.numOfApps = function() { return Object.keys($scope.apps).length;};
713719
}
714720
]);

0 commit comments

Comments
 (0)