Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BuildFire/sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadfh committed Oct 29, 2017
2 parents 0eb5b98 + 405db75 commit c88b5f4
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 18 deletions.
189 changes: 189 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"body-parser": "1.11.0",
"chai": "^3.3.0",
"express": "4.0.0",
"express": "^4.0.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-uglify": "^3.0.0",
Expand Down
6 changes: 4 additions & 2 deletions pluginTester/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ $app.config(['$routeProvider', '$sceDelegateProvider', function ($routeProvider,
// Allow same origin resource loads.
'self',
// Allow loading from our assets domain. Notice the difference between * and **.
window.siteConfig.endPoints.pluginHost + '/**'
window.siteConfig.endPoints.pluginHost + '/**',
// Allow webpack plugins
'http://127.0.0.1:8080/**'
]);

}]);
Expand All @@ -38,4 +40,4 @@ $app.run(function () {
if (user) {
window.currentUser = JSON.parse(user);
}
});
});
66 changes: 62 additions & 4 deletions pluginTester/pages/controllers/shellCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,57 @@ $app.controller('shellCtrl', ['$rootScope', '$scope', '$routeParams', '$sce', '$
postMaster.widgetPluginAPI.history.pop(breadcrumb);
};

$scope.loadWebpackFrames = function(config) {
var root = 'http://127.0.0.1:' + config.webpack;
$scope.widgetSrc = root + '/widget/index.html?fid=widget';

if (config.widget && config.widget.service) {
serviceFrame = document.createElement('iframe');
serviceFrame.sandbox="allow-scripts allow-forms allow-same-origin";
serviceFrame.id='service';
serviceFrame.style.display='none';
serviceFrame.src = root + '/widget/' + config.widget.service + "?fid=service";
document.body.appendChild(serviceFrame);
}

if (config.control.settings.enabled) {
$scope.currentControl = $scope.settingsSrc = root + '/control/settings/index.html?fid=controlSettings';
}

if (config.control.design.enabled) {
$scope.currentControl = $scope.designSrc = root + '/control/design/index.html?fid=controlDesign';
}

if (config.control.content.enabled) {
$scope.currentControl = $scope.contentSrc = root + '/control/content/index.html?fid=controlContent';
}

$scope.pluginControlIframeVisible = true;

if(config.control.customTabs && config.control.customTabs.length) {
for(var i = 0 ; i < config.control.customTabs.length; i++) {
var tab = config.control.customTabs[i];
if(tab && tab.url) {
if(tab.url.indexOf('//') != 0 && tab.url.indexOf('http://') != 0 && tab.url.indexOf('https://') != 0) {
var root = 'http://127.0.0.1:8080/control/';
// strip leading '/' if any
var customTabUrl = tab.url.indexOf("/") == 0 ? tab.url.substr(1) : tab.url;
tab.controlUrl = $sce.trustAsResourceUrl(root + customTabUrl);
} else {
tab.secureUrl = $sce.trustAsResourceUrl(tab.url);
}
}
}
$scope.customTabs = config.control.customTabs;
}

if (!$scope.$$phase)
$scope.$apply();
}

window.serviceFrame;
$scope.loadFrames = function (pluginFolder, config) {
var root = '../plugins/';
var root = '../plugins/';
$scope.widgetSrc = root + pluginFolder + '/widget/index.html?fid=widget';

if (config.widget && config.widget.service) {
Expand Down Expand Up @@ -100,7 +147,10 @@ $app.controller('shellCtrl', ['$rootScope', '$scope', '$routeParams', '$sce', '$
var pluginFolder = $routeParams.pluginFolder;
if (!pluginFolder) pluginFolder = window.appContext.currentPlugin.pluginPath;

$scope.currentControl = '../plugins/' + pluginFolder + '/control/' + section + '/index.html?fid=control';
$scope.currentControl = $scope.pluginConfig.webpack
? 'http://127.0.0.1:8080/control/' + section + '/index.html?fid=control'
: '../plugins/' + pluginFolder + '/control/' + section + '/index.html?fid=control';

var element = document.querySelector('.active');
if (element)element.className = '';
e.target.className = 'active';
Expand Down Expand Up @@ -166,10 +216,18 @@ $app.controller('shellCtrl', ['$rootScope', '$scope', '$routeParams', '$sce', '$
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
config = JSON.parse(xmlhttp.responseText);
$scope.loadFrames(pluginFolder, config);
$scope.pluginConfig = config;

if (config.webpack) {
console.log('== LOADING WEBPACK PLUGIN ==');
$scope.loadWebpackFrames(config);
} else {
$scope.loadFrames(pluginFolder, config);
}

$scope.navToValue = $scope.pluginFolder = pluginFolder;
keepTrackOfRecentPlugins(pluginFolder);

var hideEmulator = (config.widget && typeof config.widget.enabled != 'undefined') ? !config.widget.enabled : false;

displayEmulator(hideEmulator);
Expand Down
2 changes: 2 additions & 0 deletions pluginTester/scripts/loadScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function _ScriptLoader(){
, this.domain + "app/scripts/framework/pluginAPI/localNotificationsAPI.js"
, this.domain + "app/scripts/framework/pluginAPI/localStorageAPI.js"
, this.domain + "app/scripts/framework/validator.js"
, this.domain + "pages/plugins/common/commonPluginService.js"
, this.domain + "pages/pluginPromo/promoService.js"
];
}

Expand Down
Loading

0 comments on commit c88b5f4

Please sign in to comment.