e1e656153ea11935dad965c83bbe3dfb9fcc4284
[archive/20170607/tools/tic.git] / public / src / js / main.js
1 define([
2     'jquery',
3     'bootstrap',
4     'bootstrap-treeview',
5     'js/util',
6     'js/page/package',
7     'js/page/settings',
8     'js/page/image',
9     'js/logger'
10 ], function (
11     $,
12     bootstrap,
13     bootstrapTreeview,
14     Util,
15     Package,
16     Settings,
17     Image,
18     Logger
19 ) {
20     'use strict';
21
22     var logger = Logger('main.js');
23
24     function init() {
25         logger.info("init");
26
27         Util.showLoadingDialog(true);
28
29         Settings.updatePackage()
30         .then(Package.updatePackageTree)
31         .then(function () {
32             Util.showLoadingDialog(false);
33         })
34         .catch(function (reason) {
35             logger.error(reason);
36             Util.showLoadingDialog(false);
37             Util.showAlertDialog('Failed to load package list.<br>Please check the tic-core.');
38         });
39
40         // Keep the state of the active item on navbar
41         $(".navbar a").on("click", function() {
42             $(".navbar").find(".active").removeClass("active");
43             $(this).parent().addClass("active");
44         });
45
46         // initially, hide the log view
47         // in job and image section
48         $('#log-view-content').hide();
49         $('.log-view-content .log-view-content-close').on('click', function (e) {
50             e.preventDefault();
51             $('#log-view-content-body').empty();
52             $('#log-view-content').hide();
53         });
54
55     }
56
57     $(document).ready(function () {
58         init();
59     });
60
61 });