2013-07-27 18:33:20 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trackino application.
|
|
|
|
*/
|
2013-08-08 01:38:30 +02:00
|
|
|
var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.validate', 'ui.sortable', 'restangular', 'ngSanitize', 'colorpicker.module'])
|
2013-07-27 18:33:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuring modules.
|
|
|
|
*/
|
|
|
|
.config(function($stateProvider, $httpProvider, $routeProvider, RestangularProvider) {
|
|
|
|
// Configuring UI Router
|
|
|
|
$stateProvider
|
|
|
|
.state('main', {
|
|
|
|
url: '',
|
|
|
|
views: {
|
|
|
|
'page': {
|
|
|
|
templateUrl: 'partial/main.html',
|
|
|
|
controller: 'Main'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-07-30 01:34:30 +02:00
|
|
|
.state('tag', {
|
|
|
|
url: '/tag',
|
|
|
|
views: {
|
|
|
|
'page': {
|
|
|
|
templateUrl: 'partial/tag.html',
|
|
|
|
controller: 'Tag'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-08-01 22:50:08 +02:00
|
|
|
.state('settings', {
|
|
|
|
url: '/settings',
|
2013-08-03 17:20:44 +02:00
|
|
|
abstract: true,
|
2013-08-01 22:50:08 +02:00
|
|
|
views: {
|
|
|
|
'page': {
|
|
|
|
templateUrl: 'partial/settings.html',
|
|
|
|
controller: 'Settings'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-08-03 17:20:44 +02:00
|
|
|
.state('settings.default', {
|
|
|
|
url: '',
|
|
|
|
views: {
|
|
|
|
'settings': {
|
|
|
|
templateUrl: 'partial/settings.default.html',
|
|
|
|
controller: 'SettingsDefault'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('settings.account', {
|
|
|
|
url: '/account',
|
|
|
|
views: {
|
|
|
|
'settings': {
|
|
|
|
templateUrl: 'partial/settings.account.html',
|
|
|
|
controller: 'SettingsAccount'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('settings.session', {
|
|
|
|
url: '/session',
|
|
|
|
views: {
|
|
|
|
'settings': {
|
|
|
|
templateUrl: 'partial/settings.session.html',
|
|
|
|
controller: 'SettingsSession'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-08-03 21:51:15 +02:00
|
|
|
.state('settings.log', {
|
|
|
|
url: '/log',
|
|
|
|
views: {
|
|
|
|
'settings': {
|
|
|
|
templateUrl: 'partial/settings.log.html',
|
|
|
|
controller: 'SettingsLog'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-07-27 18:33:20 +02:00
|
|
|
.state('document', {
|
|
|
|
url: '/document',
|
2013-07-28 01:07:04 +02:00
|
|
|
abstract: true,
|
2013-07-27 18:33:20 +02:00
|
|
|
views: {
|
|
|
|
'page': {
|
|
|
|
templateUrl: 'partial/document.html',
|
|
|
|
controller: 'Document'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-07-28 01:07:04 +02:00
|
|
|
.state('document.default', {
|
|
|
|
url: '',
|
|
|
|
views: {
|
|
|
|
'document': {
|
2013-08-01 13:53:52 +02:00
|
|
|
templateUrl: 'partial/document.default.html',
|
|
|
|
controller: 'DocumentDefault'
|
2013-07-28 01:07:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-07-27 18:33:20 +02:00
|
|
|
.state('document.add', {
|
|
|
|
url: '/add',
|
|
|
|
views: {
|
|
|
|
'document': {
|
|
|
|
templateUrl: 'partial/document.edit.html',
|
|
|
|
controller: 'DocumentEdit'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('document.edit', {
|
|
|
|
url: '/edit/:id',
|
|
|
|
views: {
|
|
|
|
'document': {
|
|
|
|
templateUrl: 'partial/document.edit.html',
|
|
|
|
controller: 'DocumentEdit'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('document.view', {
|
|
|
|
url: '/view/:id',
|
|
|
|
views: {
|
|
|
|
'document': {
|
|
|
|
templateUrl: 'partial/document.view.html',
|
|
|
|
controller: 'DocumentView'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-07-28 01:07:04 +02:00
|
|
|
.state('document.view.file', {
|
|
|
|
url: '/file/:fileId',
|
2013-07-28 18:29:03 +02:00
|
|
|
views: {
|
|
|
|
'file': {
|
2013-07-28 01:07:04 +02:00
|
|
|
controller: 'FileView'
|
2013-07-28 18:29:03 +02:00
|
|
|
}
|
2013-07-28 01:07:04 +02:00
|
|
|
}
|
|
|
|
})
|
2013-07-27 18:33:20 +02:00
|
|
|
.state('login', {
|
|
|
|
url: '/login',
|
|
|
|
views: {
|
|
|
|
'page': {
|
|
|
|
templateUrl: 'partial/login.html',
|
|
|
|
controller: 'Login'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Configuring Restangular
|
|
|
|
RestangularProvider.setBaseUrl('api');
|
|
|
|
|
|
|
|
// Configuring $http
|
|
|
|
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
|
2013-08-01 23:32:55 +02:00
|
|
|
$httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
|
2013-07-27 18:33:20 +02:00
|
|
|
$httpProvider.defaults.transformRequest = [function(data) {
|
|
|
|
var param = function(obj) {
|
|
|
|
var query = '';
|
|
|
|
var name, value, fullSubName, subName, subValue, innerObj, i;
|
|
|
|
|
|
|
|
for(name in obj) {
|
|
|
|
value = obj[name];
|
|
|
|
|
|
|
|
if(value instanceof Array) {
|
|
|
|
for(i=0; i<value.length; ++i) {
|
|
|
|
subValue = value[i];
|
2013-08-01 23:32:55 +02:00
|
|
|
fullSubName = name;
|
2013-07-27 18:33:20 +02:00
|
|
|
innerObj = {};
|
|
|
|
innerObj[fullSubName] = subValue;
|
|
|
|
query += param(innerObj) + '&';
|
|
|
|
}
|
|
|
|
} else if(value instanceof Object) {
|
|
|
|
for(subName in value) {
|
|
|
|
subValue = value[subName];
|
|
|
|
fullSubName = name + '[' + subName + ']';
|
|
|
|
innerObj = {};
|
|
|
|
innerObj[fullSubName] = subValue;
|
|
|
|
query += param(innerObj) + '&';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(value !== undefined && value !== null) {
|
|
|
|
query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return query.length ? query.substr(0, query.length - 1) : query;
|
|
|
|
};
|
|
|
|
|
|
|
|
return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
|
|
|
|
}];
|
|
|
|
})
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Application initialization.
|
|
|
|
*/
|
|
|
|
.run(function($rootScope, $state, $stateParams) {
|
|
|
|
$rootScope.$state = $state;
|
|
|
|
$rootScope.$stateParams = $stateParams;
|
|
|
|
});
|