template-application-angular.ui.resources.js.ui-core-ng-modules.js.template Maven / Gradle / Ivy
/*
* Copyright (c) 2017 SAP and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributors:
* SAP - initial API and implementation
*/
function getPathSegments() {
var path = window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/'))
var pathSegments = path.substr(path.indexOf('services/')).split('/').length;
return pathSegments;
}
function getRelativePath(pathSegments) {
var relativePath = '';
for (var i = 0; i < pathSegments; i ++) {
relativePath += '../';
}
return relativePath;
}
var pathSegments = getPathSegments()
var relativePath = getRelativePath(pathSegments);
/**
* Provides key microservices for constructing and managing the IDE UI
*
*/
angular.module('ideUiCore', ['ngResource'])
.provider('messageHub', function MessageHubProvider() {
this.evtNamePrefix = '';
this.evtNameDelimiter = '.';
this.$get = [function messageHubFactory() {
var messageHub = new FramesMessageHub();
//normalize prefix if any
this.evtNamePrefix = this.evtNamePrefix || '';
this.evtNamePrefix = this.evtNamePrefix ? (this.evtNamePrefix+this.evtNameDelimiter): this.evtNamePrefix;
var send = function(evtName, data, absolute){
if(!evtName)
throw Error('evtname argument must be a valid string, identifying an existing event');
messageHub.post({data: data}, (absolute ? '' : this.evtNamePrefix) + evtName);
}.bind(this);
var on = function(evtName, callbackFunc){
if(typeof callbackFunc !== 'function')
throw Error('Callback argument must be a function');
messageHub.subscribe(callbackFunc, evtName);
};
return {
send: send,
on: on
};
}];
})
.factory('Theme', ['$resource', function($resource){
var themeswitcher = $resource(relativePath + 'services/v3/core/theme?name=:themeName', {themeName: 'default'});
var themes = {
"default": relativePath + "services/v3/web/resources/themes/default/bootstrap.min.css",
"wendy" : relativePath + "services/v3/web/resources/themes/wendy/bootstrap.min.css",
"baroness" : relativePath + "services/v3/web/resources/themes/baroness/bootstrap.min.css",
"simone" : relativePath + "services/v3/web/resources/themes/simone/bootstrap.min.css"
};
return {
changeTheme: function(themeName){
return themeswitcher.get({'themeName':themeName});
},
themeUrl: function(themeName){
return themes[themeName];
},
reload: function(){
location.reload();
}
}
}])
.service('Perspectives', ['$resource', function($resource){
return $resource(relativePath + 'services/v3/js/{{projectName}}/api/launchpad/perspectives.js');
}])
.service('Tiles', ['$resource', function($resource){
return $resource(relativePath + 'services/v3/js/{{projectName}}/api/launchpad/tiles.js');
}])
.service('Menu', ['$resource', function($resource){
return $resource(relativePath + 'services/v3/js/{{projectName}}/api/launchpad/menu.js');
}])
.service('User', ['$http', function($http){
return {
get: function(){
var user = {};
$http({
url: relativePath + 'services/v3/js/ide-core/services/user-name.js',
method: 'GET'
}).success(function(data){
user.name = data;
});
return user;
}
};
}])
/**
* Creates a map object associating a view factory function with a name (id)
*/
.provider('ViewFactories', function(){
var self = this;
this.factories = {
"frame": function(container, componentState){
container.setTitle(componentState.label || 'View');
$('
© 2015 - 2025 Weber Informatics LLC | Privacy Policy