Summary page should show warnings when current or baseline data is missing.
[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 summaryPage = manifest.summary ? new SummaryPage(manifest.summary) : null;
24         var chartsPage = new ChartsPage(chartsToolbar);
25         var analysisCategoryPage = new AnalysisCategoryPage();
26
27         var createAnalysisTaskPage = new CreateAnalysisTaskPage();
28         createAnalysisTaskPage.setParentPage(analysisCategoryPage);
29
30         var analysisTaskPage = new AnalysisTaskPage();
31         analysisTaskPage.setParentPage(analysisCategoryPage);
32
33         var heading = new Heading(manifest.siteTitle);
34         heading.addPageGroup([summaryPage, chartsPage, analysisCategoryPage].filter(function (page) { return page; }));
35
36         heading.setTitle(manifest.siteTitle);
37         heading.addPageGroup(dashboardPages);
38
39         var router = new PageRouter();
40         if(summaryPage)
41             router.addPage(summaryPage);
42         router.addPage(chartsPage);
43         router.addPage(createAnalysisTaskPage);
44         router.addPage(analysisTaskPage);
45         router.addPage(analysisCategoryPage);
46         for (var page of dashboardPages)
47             router.addPage(page);
48
49         if (summaryPage)
50             router.setDefaultPage(summaryPage);
51         else if (dashboardPages)
52             router.setDefaultPage(dashboardPages[0]);
53         else
54             router.setDefaultPage(chartsPage);
55
56         heading.setRouter(router);
57         router.route();
58     }).catch(function (error) {
59         alert('Failed to load the site manifest: ' + error);
60     });
61 }
62
63 if (document.readyState != 'loading')
64     main();
65 else
66     document.addEventListener('DOMContentLoaded', main);