Skip to content

Commit

Permalink
add js files
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Jan 21, 2017
1 parent 5041e47 commit 031f1a4
Show file tree
Hide file tree
Showing 21 changed files with 1,465 additions and 0 deletions.
14 changes: 14 additions & 0 deletions public/fusio/app/controller/account/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

var angular = require('angular');

angular.module('fusioApp.account', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/account/change_password', {
templateUrl: 'app/controller/account/change_password.html',
controller: 'ChangePasswordCtrl'
});
}])

.controller('ChangePasswordCtrl', require('./change_password'));
72 changes: 72 additions & 0 deletions public/fusio/app/controller/action/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict';

module.exports = function($scope, $http, $uibModalInstance, formBuilder, fusio) {

$scope.action = {
name: "",
class: "",
config: {}
};
$scope.elements = [];
$scope.config = {};
$scope.actions = [];

$scope.create = function(action) {
var data = angular.copy(action);

if (angular.isObject($scope.config)) {
data.config = formBuilder.postProcessModel($scope.config, $scope.elements);
}

$http.post(fusio.baseUrl + 'backend/action', data)
.then(function(response) {
var data = response.data;
$scope.response = data;
if (data.success === true) {
$uibModalInstance.close(data);
}
})
.catch(function(response) {
$scope.response = response.data;
});
};

$http.get(fusio.baseUrl + 'backend/action/list')
.then(function(response) {
var data = response.data;
$scope.actions = data.actions;

if (data.actions[0]) {
$scope.action.class = data.actions[0].class;
$scope.loadConfig();
}
});

$scope.close = function() {
$uibModalInstance.dismiss('cancel');
};

$scope.closeResponse = function() {
$scope.response = null;
};

$scope.loadConfig = function() {
if ($scope.action.class) {
$http.get(fusio.baseUrl + 'backend/action/form?class=' + encodeURIComponent($scope.action.class))
.then(function(response) {
var data = response.data;
var containerEl = angular.element(document.querySelector('#config-form'));
containerEl.children().remove();

$scope.elements = data.element;
$scope.config = formBuilder.preProcessModel($scope.action.config, $scope.elements);
var linkFn = formBuilder.buildHtml($scope.elements, 'config');
if (angular.isFunction(linkFn)) {
var el = linkFn($scope);
containerEl.append(el);
}
});
}
};

};
29 changes: 29 additions & 0 deletions public/fusio/app/controller/action/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

module.exports = function($scope, $http, $uibModalInstance, action, fusio) {

$scope.action = action;

$scope.delete = function(action) {
$http.delete(fusio.baseUrl + 'backend/action/' + action.id)
.then(function(response) {
var data = response.data;
$scope.response = data;
if (data.success === true) {
$uibModalInstance.close(data);
}
})
.catch(function(response) {
$scope.response = response.data;
});
};

$scope.close = function() {
$uibModalInstance.dismiss('cancel');
};

$scope.closeResponse = function() {
$scope.response = null;
};

};
58 changes: 58 additions & 0 deletions public/fusio/app/controller/action/execute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

module.exports = function($scope, $http, $uibModalInstance, action, fusio) {

$scope.action = action;
$scope.methods = ['GET', 'POST', 'PUT', 'DELETE'];
$scope.request = {
method: 'GET',
uriFragments: '',
parameters: '',
body: '{}'
};
$scope.response = null;

$scope.requestOpen = false;
$scope.responseOpen = true;

$scope.execute = function(action, request) {
var body = JSON.parse(request.body);
if (!angular.isObject(body)) {
body = {};
}
var data = {
method: request.method,
uriFragments: request.uriFragments,
parameters: request.parameters,
body: body
};

$http.post(fusio.baseUrl + 'backend/action/execute/' + action.id, data)
.then(function(response) {
var data = response.data;
// in case we have no body property we have probably a general error
// message in this case we simply show the complete response as body
var resp = {};
if (!data.body) {
resp.statusCode = 500;
resp.headers = {};
resp.body = data;
} else {
resp = data;
}

$scope.response = {
statusCode: resp.statusCode,
headers: resp.headers,
body: JSON.stringify(resp.body, null, 4)
};
});
};

$scope.close = function() {
$uibModalInstance.dismiss('cancel');
};

$scope.execute(action, $scope.request);

};
20 changes: 20 additions & 0 deletions public/fusio/app/controller/action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var angular = require('angular');

angular.module('fusioApp.action', ['ngRoute', 'ui.ace'])

.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/action', {
templateUrl: 'app/controller/action/index.html',
controller: 'ActionCtrl'
});
}])

.controller('ActionCtrl', require('./action'))
.controller('ActionCreateCtrl', require('./create'))
.controller('ActionUpdateCtrl', require('./update'))
.controller('ActionDeleteCtrl', require('./delete'))
.controller('ActionExecuteCtrl', require('./execute'))

;
91 changes: 91 additions & 0 deletions public/fusio/app/controller/action/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
'use strict';

module.exports = function($scope, $http, $uibModalInstance, $uibModal, action, formBuilder, $timeout, fusio) {

$scope.action = action;
$scope.elements = [];
$scope.config = {};
$scope.actions = [];

$scope.update = function(action) {
var data = angular.copy(action);

if (angular.isObject($scope.config)) {
data.config = formBuilder.postProcessModel($scope.config, $scope.elements);
}

$http.put(fusio.baseUrl + 'backend/action/' + action.id, data)
.then(function(response) {
var data = response.data;
$scope.response = data;
if (data.success === true) {
$uibModalInstance.close(data);
}
})
.catch(function(response) {
$scope.response = response.data;
});
};

$scope.close = function() {
$uibModalInstance.dismiss('cancel');
};

$scope.closeResponse = function() {
$scope.response = null;
};

$scope.loadConfig = function() {
if ($scope.action.class) {
$http.get(fusio.baseUrl + 'backend/action/form?class=' + encodeURIComponent($scope.action.class))
.then(function(response) {
var data = response.data;
var containerEl = angular.element(document.querySelector('#config-form'));
containerEl.children().remove();

$scope.elements = data.element;
$scope.config = formBuilder.preProcessModel($scope.action.config, $scope.elements);
var linkFn = formBuilder.buildHtml($scope.elements, 'config');
if (angular.isFunction(linkFn)) {
var el = linkFn($scope);
containerEl.append(el);
}
});
}
};

$scope.execute = function(action) {
$http.put(fusio.baseUrl + 'backend/action/' + action.id, action)
.then(function(response) {
var data = response.data;
$scope.response = data;
if (data.success === true) {
var modalInstance = $uibModal.open({
size: 'lg',
backdrop: 'static',
templateUrl: 'app/controller/action/execute.html',
controller: 'ActionExecuteCtrl',
resolve: {
action: function() {
return action;
}
}
});

modalInstance.result.then(function(response) {
}, function() {
});
}
})
.catch(function(response) {
$scope.response = response.data;
});
};

$http.get(fusio.baseUrl + 'backend/action/' + action.id)
.then(function(response) {
$scope.action = response.data;
$scope.loadConfig();
});

}
Loading

0 comments on commit 031f1a4

Please sign in to comment.