"use strict";

angular.module('app.layout', ['ui.router', 'ui.bootstrap'])

.config(function ($stateProvider, $urlRouterProvider, $locationProvider, SQEventsProvider) {

    SQEventsProvider.add("SKIN_CHANGED", "skin-changed");
    SQEventsProvider.add("APP_PANEL_CHANGED", "app-panel-changed");
    SQEventsProvider.add("OPEN_ABOUT_DIALOG", "open-about-dialog");

    $stateProvider
        .state('app', {
            abstract: false,
            url: '/',
            views: {
                root: {
                    templateUrl: '../QDM/layout/views/layout.html',
                    controller: 'LayoutCtrl'
                }
            },
            resolve: {
                connectWebSocket: function(SQWebSocketService){
                    return SQWebSocketService.connectWebSocket(location.port);
                },
                loadConstants: function(SQConstants){
                    return SQConstants.loadAll();
                },
                loadLanguage: function(L){
                    return L.downloadLanguage();
                },
                loadSkin: function(SkinService){
                    return SkinService.loadSkins();
                }
            }
        });
        
    $urlRouterProvider.otherwise(window.appConfig.defaultURL);

})