Extend perf dashboard to support multiple summary pages.
[WebKit-https.git] / Websites / perf.webkit.org / public / v3 / main.js
1
2 class SpinningPage extends Page {
3     static htmlTemplate()
4     {
5         return `<div style="position: absolute; width: 100%; padding-top: 25%; text-align: center;"><spinner-icon></spinner-icon></div>`;
6     }
7 }
8
9 function main() {
10     (new SpinningPage).open();
11
12     Manifest.fetch().then(function (manifest) {
13         var dashboardToolbar = new DashboardToolbar;
14         var dashboardPages = [];
15         if (manifest.dashboards) {
16             for (var name in manifest.dashboards)
17                 dashboardPages.push(new DashboardPage(name, manifest.dashboards[name], dashboardToolbar));
18         }
19
20         var router = new PageRouter();
21         var chartsToolbar = new ChartsToolbar;
22
23         var summaryPages = [];
24         if (manifest.summaryPages) {
25             for (var summaryPage of manifest.summaryPages)
26                 summaryPages.push(new SummaryPage(summaryPage));
27         }
28
29         var chartsPage = new ChartsPage(chartsToolbar);
30         var analysisCategoryPage = new AnalysisCategoryPage();
31
32         var createAnalysisTaskPage = new CreateAnalysisTaskPage();
33         createAnalysisTaskPage.setParentPage(analysisCategoryPage);
34
35         var analysisTaskPage = new AnalysisTaskPage();
36         analysisTaskPage.setParentPage(analysisCategoryPage);
37
38         var buildRequestQueuePage = new BuildRequestQueuePage();
39         buildRequestQueuePage.setParentPage(analysisCategoryPage);
40
41         var heading = new Heading(manifest.siteTitle);
42         heading.addPageGroup(summaryPages.concat([chartsPage, analysisCategoryPage]));
43
44         heading.setTitle(manifest.siteTitle);
45         heading.addPageGroup(dashboardPages);
46
47         var router = new PageRouter();
48         for (var summaryPage of summaryPages)
49             router.addPage(summaryPage);
50         router.addPage(chartsPage);
51         router.addPage(createAnalysisTaskPage);
52         router.addPage(analysisTaskPage);
53         router.addPage(buildRequestQueuePage);
54         router.addPage(analysisCategoryPage);
55         for (var page of dashboardPages)
56             router.addPage(page);
57
58         if (summaryPages.length)
59             router.setDefaultPage(summaryPages[0]);
60         else if (dashboardPages.length)
61             router.setDefaultPage(dashboardPages[0]);
62         else
63             router.setDefaultPage(chartsPage);
64
65         heading.setRouter(router);
66         router.route();
67     }).catch(function (error) {
68         alert('Failed to load the site manifest: ' + error);
69     });
70 }
71
72 if (document.readyState != 'loading')
73     main();
74 else
75     document.addEventListener('DOMContentLoaded', main);