|
| 1 | + |
1 | 2 | (function () {
|
2 | 3 | "use strict";
|
3 | 4 |
|
|
13 | 14 | vm.customDashboard = null;
|
14 | 15 | vm.tours = [];
|
15 | 16 | vm.systemInfoDisplay = false;
|
| 17 | + vm.labels = {}; |
| 18 | + vm.labels.copiedSuccessInfo = ""; |
| 19 | + vm.labels.copySuccessStatus = ""; |
| 20 | + vm.labels.copiedErrorInfo = ""; |
| 21 | + vm.labels.copyErrorStatus = ""; |
| 22 | + |
16 | 23 |
|
17 | 24 | vm.closeDrawer = closeDrawer;
|
18 | 25 | vm.startTour = startTour;
|
|
36 | 43 | localizationService.localize("general_help").then(function(data){
|
37 | 44 | vm.title = data;
|
38 | 45 | });
|
| 46 | + //Set help dashboard messages |
| 47 | + var labelKeys = [ |
| 48 | + "general_help", |
| 49 | + "speechBubbles_copySuccessMessage", |
| 50 | + "general_success", |
| 51 | + "speechBubbles_cannotCopyInformation", |
| 52 | + "general_error" |
| 53 | + ]; |
| 54 | + localizationService.localizeMany(labelKeys).then(function(resp){ |
| 55 | + [ |
| 56 | + vm.title, |
| 57 | + vm.labels.copiedSuccessInfo, |
| 58 | + vm.labels.copySuccessStatus, |
| 59 | + vm.labels.copiedErrorInfo, |
| 60 | + vm.labels.copyErrorStatus |
| 61 | + ] = resp; |
| 62 | + }); |
| 63 | + |
39 | 64 | currentUserResource.getUserData().then(function(systemInfo){
|
40 | 65 | vm.systemInfo = systemInfo;
|
41 | 66 | let browserInfo = platformService.getBrowserInfo();
|
42 | 67 | if(browserInfo != null){
|
43 | 68 | vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version});
|
44 | 69 | }
|
45 | 70 | vm.systemInfo.push({name :"Browser OS", data: getPlatform()});
|
46 |
| - }); |
| 71 | + } ); |
47 | 72 | tourService.getGroupedTours().then(function(groupedTours) {
|
48 | 73 | vm.tours = groupedTours;
|
49 | 74 | getTourGroupCompletedPercentage();
|
|
208 | 233 | }
|
209 | 234 | }
|
210 | 235 | function copyInformation(){
|
211 |
| - let copyText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n"; |
| 236 | + //Write start and end text for table formatting in github issues |
| 237 | + let copyStartText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n"; |
| 238 | + let copyEndText = "\n<!--EndFragment-->\n</body>\n</html>"; |
| 239 | + |
| 240 | + let copyText = copyStartText; |
212 | 241 | vm.systemInfo.forEach(function (info){
|
213 | 242 | copyText += info.name + " | " + info.data + "\n";
|
214 | 243 | });
|
215 |
| - copyText += "\n<!--EndFragment-->\n</body>\n</html>" |
216 |
| - navigator.clipboard.writeText(copyText); |
217 |
| - if(copyText != null){ |
218 |
| - notificationsService.success("Copied!", "Your system information is now in your clipboard"); |
| 244 | + |
| 245 | + copyText += copyEndText; |
| 246 | + |
| 247 | + // Check if copyText is only start + end text |
| 248 | + // if it is something went wrong and we will not copy to clipboard |
| 249 | + let emptyCopyText = copyStartText + copyEndText; |
| 250 | + if(copyText !== emptyCopyText) { |
| 251 | + notificationsService.success(vm.labels.copySuccessStatus, vm.labels.copiedSuccessInfo); |
| 252 | + navigator.clipboard.writeText(copyText); |
219 | 253 | }
|
220 |
| - else{ |
221 |
| - notificationsService.error("Error", "Could not copy system information"); |
| 254 | + else { |
| 255 | + notificationsService.error(vm.labels.copyErrorStatus, vm.labels.copiedErrorInfo); |
222 | 256 | }
|
223 | 257 | }
|
| 258 | + |
224 | 259 | function getPlatform() {
|
225 | 260 | return window.navigator.platform;
|
226 | 261 | }
|
| 262 | + |
227 | 263 | evts.push(eventsService.on("appState.tour.complete", function (event, tour) {
|
228 | 264 | tourService.getGroupedTours().then(function(groupedTours) {
|
229 | 265 | vm.tours = groupedTours;
|
|
239 | 275 | });
|
240 | 276 |
|
241 | 277 | oninit();
|
242 |
| - |
243 | 278 | }
|
244 | 279 |
|
245 | 280 | angular.module("umbraco").controller("Umbraco.Drawers.Help", HelpDrawerController);
|
| 281 | + |
246 | 282 | })();
|
0 commit comments