a21b7357d4e3126eca7192434ae26bf710181382
[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 = new SummaryPage(manifest.summary);
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]);
35
36         heading.setTitle(manifest.siteTitle);
37         heading.addPageGroup(dashboardPages);
38
39         var router = new PageRouter();
40         router.addPage(summaryPage);
41         router.addPage(chartsPage);
42         router.addPage(createAnalysisTaskPage);
43         router.addPage(analysisTaskPage);
44         router.addPage(analysisCategoryPage);
45         for (var page of dashboardPages)
46             router.addPage(page);
47
48         if (dashboardPages)
49             router.setDefaultPage(dashboardPages[0]);
50         else
51             router.setDefaultPage(chartsPage);
52
53         heading.setRouter(router);
54         router.route();
55     }).catch(function (error) {
56         alert('Failed to load the site manifest: ' + error);
57     });
58 }
59
60 if (document.readyState != 'loading')
61     main();
62 else
63     document.addEventListener('DOMContentLoaded', main);