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