Skip to content

Commit

Permalink
Reviewed packaging form. Fixed #108. Also added special parameters 'I…
Browse files Browse the repository at this point in the history
…nstanceToken' and 'Backend root URL' as well as 'allowInstanceCreation' option
  • Loading branch information
otsakir committed Nov 5, 2014
1 parent 27a6413 commit 965b3c7
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class RvdConfiguration {
public static final String TICKET_COOKIE_NAME = "rvdticket"; // the name of the cookie that is used to store ticket ids for authentication
private static Set<String> restcommParameterNames = new HashSet<String>(Arrays.asList(new String[] {"CallSid","AccountSid","From","To","Body","CallStatus","ApiVersion","Direction","CallerName"})); // the names of the parameters supplied by restcomm request when starting an application
public static final String PROJECT_LOG_FILENAME = "projectLog";
public static final String DEFAULT_APPSTORE_DOMAIN = "restcommapps.wpengine.com";
public static final String DEFAULT_APPSTORE_DOMAIN = "apps.restcomm.com";

private String workspaceBasePath;
private String prototypeProjectsPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ConfigOption {
}

public String howTo;
public Boolean allowInstanceCreation;

public List<ConfigOption> options = new ArrayList<ConfigOption>();

public RappConfig() {
Expand Down
31 changes: 26 additions & 5 deletions restcomm/restcomm.rvd/src/main/webapp/js/controllers/packaging.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
rvdMod.controller('packagingCtrl', function ($scope, $routeParams, Rapp, ConfigOption, $http, rappWrap, $location, notifications, rvdSettings) {

$scope.addConfigurationOption = function(type) {
console.log("Adding configuration option");
$scope.rapp.config.addOption( ConfigOption.getTypeByLabel(type));
$scope.rapp.config.addOption(type);
}

$scope.removeConfigurationOption = function (option) {
$scope.rapp.config.removeOption(option);
}

$scope.optionExists = function (name) {
return $scope.rapp.config.optionExists(name);
}

$scope.saveRapp = function (projectName,rapp) {
var packed = rapp.pack();
$http({
Expand Down Expand Up @@ -99,11 +102,24 @@ rvdMod.factory('RappService', ['$http', '$q', 'Rapp', '$route', '$location', fun
return serviceFunctions;
}])
.factory('ConfigOption', ['rvdModel', function (rvdModel) {
var types = ['value'];
var typesByLabel = {'Add value': 'value'};

//var types = ['value'];

function ConfigOption() {
function ConfigOption(type) {
// {name:'', label:'', type:'value', description:'', defaultValue:'', required: true }
//this.type = type;
if ( type == 'instanceToken') {
this.name = 'instanceToken';
this.label = 'Instance token';
this.description = 'An instance token your application needs to access the multitenant backend';
this.required = true;
} else
if ( type == 'backendRootURL') {
this.name = 'backendRootURL';
this.label = 'Backend root URL';
this.description = 'Root URL of application backend. Storage, UI are hosted under this URL. Do not change this unless the application Vendor asks you to.';
this.required = true;
}
};
ConfigOption.prototype = new rvdModel();
ConfigOption.prototype.constructor = ConfigOption;
Expand All @@ -124,6 +140,11 @@ rvdMod.factory('RappService', ['$http', '$q', 'Rapp', '$route', '$location', fun
RappConfig.prototype.removeOption = function (option) {
this.options.splice(this.options.indexOf(option,1));
}
RappConfig.prototype.optionExists = function (name) {
for (var i=0; i<this.options.length; i++)
if (this.options[i].name == name) return true;
return false;
}
return RappConfig;
}])
.factory('RappInfo', ['rvdModel', function (rvdModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h4 class="panel-title">
<i ng-click='panel.isCollapsed = !panel.isCollapsed' class="fa rvd-clickable" ng-class="{'fa-caret-right': panel.isCollapsed, 'fa-caret-down': !panel.isCollapsed}"></i>
&nbsp; &nbsp;
<span ng-show='title' tooltip='{{panel.title}}'>{{title}}</span>
<span ng-show='title' tooltip='{{title}}'>{{title}}</span>
<span ng-hide='title' tooltip='Untitled'>Untitled</span>
<i ng-click='closePanel()' class='fa fa-trash-o pull-right rvd-clickable'></i>
</h4>
Expand Down
42 changes: 30 additions & 12 deletions restcomm/restcomm.rvd/src/main/webapp/templates/packaging/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ <h1 class="page-header">{{projectName}}
</h1>

<p class="lead">
Create a package from your application to submit it to the <a target="_blank" href="http://{{effectiveSettings.appStoreDomain}}">Restcomm Application Store</a>
Package your application to submit it to the <a target="_blank" href="http://{{effectiveSettings.appStoreDomain}}">Restcomm Application Store</a>
</p>
<p>
Provide configuration options for plugging this application into the customer's environment.
</p>

<form name="packagingForm">
<!--
<!-- -->
<div class="rvd-appinfo" name="appinfoForm">
<h3>General information</h3>
<div class="row">
Expand Down Expand Up @@ -48,7 +48,7 @@ <h3>General information</h3>
</div>
</div>
</div>
-->
<!-- -->

<div class="rvd-appconfig">
<h3>Configuration</h3>
Expand All @@ -57,20 +57,20 @@ <h3>Configuration</h3>
<textarea ng-model='rapp.config.howTo' class="form-control"></textarea>
<span class="help-block">Type a small text describing general configuration guidelines</span>

<h4>Options</h4>
<span class="help-block">Customize you app by adding options. Add an option for any piece of information you need to be adjusted by the end user. Users of this application will have the opportunity to fill in these options in order to customize their installation.</span>
<h4>Application parameters</h4>
<span class="help-block">Customize your app by adding parameters. Add a parameter for any piece of information you need to be adjusted by the end user. Users of this application will have the opportunity to fill in these options in order to customize their installation.</span>

<div basic-sortable list-model='rapp.config.options'>
<div ng-repeat="configOption in rapp.config.options" class='form-group'>
<rvd-panel on-close='removeConfigurationOption(configOption)'>
<rvd-panel on-close='removeConfigurationOption(configOption)' title="configOption.label">
<div class="row">
<div class="form-group col-md-3">
<label tooltip-popup-delay="1000" tooltip-trigger="mouseenter" tooltip="An identifier for this option. It will be used to map this option to an RVD variable">Name *</label>
<input ng-model='configOption.name' class="form-control" ng-pattern="/^[A-Za-z]+[A-Za-z0-9_]*$/" required placeholder="{{$index==0 ? 'welcomeMsg' : ''}}">
<input ng-model='configOption.name' ng-disabled="configOption.name=='instanceToken' || configOption.name=='backendRootURL'" class="form-control" ng-pattern="/^[A-Za-z]+[A-Za-z0-9_]*$/" required placeholder="{{$index==0 ? 'welcomeMsg' : ''}}">
</div>
<div class="form-group col-md-3">
<label tooltip-popup-delay="1000" tooltip-trigger="mouseenter" tooltip="A label for the generated option field. Try to choose an appropriate label.">Label *</label>
<input ng-model='configOption.label' class="form-control" required placeholder="{{$index==0 ? 'Welcome Message' : ''}}">
<input ng-model='configOption.label' ng-disabled="configOption.name=='instanceToken' || configOption.name=='backendRootURL'" class="form-control" required placeholder="{{$index==0 ? 'Welcome Message' : ''}}">
</div>
<div class="form-group col-md-3">
<label tooltip-popup-delay="1000" tooltip-trigger="mouseenter" tooltip="Type an optional default value for the field. It will be pre-filled with it.">Default value</label>
Expand All @@ -79,7 +79,7 @@ <h4>Options</h4>
<div class="form-group col-md-3">
<label tooltip-popup-delay="1000" tooltip-trigger="mouseenter" tooltip="Is this field required ? Your application should handle absence of this field properly.">Required</label>
<div>
<input type='checkbox' ng-model='configOption.required'>
<input type='checkbox' ng-disabled="configOption.name=='instanceToken' || configOption.name=='backendRootURL'" ng-model='configOption.required'>
</div>
</div>
</div>
Expand All @@ -88,18 +88,36 @@ <h4>Options</h4>
<label tooltip-popup-delay="1000" tooltip-trigger="mouseenter" tooltip="Describe what this field is used for and how it should be completed">Description *</label>
<textarea ng-model='configOption.description' class="form-control" required placeholder="{{$index==0 ? 'This is the first message you callers hear. Welcome them and inform them what comes next.' : ''}}"></textarea>
</div>
</div>
</div>
</rvd-panel>
</div>
</div>

<button class="btn btn-primary" ng-click="addConfigurationOption('value')">Add parameter</button>

<div class="rvd-spacer10">&nbsp;</div>

<h4>Application services parameters</h4>
<p>If your application relies on additional services you will need to specify <em>instanceToken</em> and <em>backendRootURL</em> parameters. For more information on custom application services and multitenancy please see <a href="#">Writing multitenant application for the application store</a>.
<ul>
<li><strong>instanceToken</strong> - Used to identify each individual instance of this application to the backend. It also works as an authentication token.</li>
<li><strong>backendRootURL</strong> - The root url for the REST services. Place all custom scripts under this URL.</li>
</ul>



<button ng-show="!optionExists('instanceToken')" class="btn btn-primary" ng-click="addConfigurationOption('instanceToken')">Add <em>Instance Token</em> parameter</button>
&nbsp;<button ng-show="!optionExists('backendRootURL')" class="btn btn-primary" ng-click="addConfigurationOption('backendRootURL')">Add <em>Backend root URL</em> parameter</button>

<div>
Allow user to create new instance on the backend &nbsp;&nbsp; <input type='checkbox' ng-model='rapp.config.allowInstanceCreation'>
</div>

</div>
{{watchFormStatus(packagingForm.$valid)}}
</form>
</div>

<multibutton ng-click='addConfigurationOption(selectedOption)' options="['Add value']" button-class="btn-primary"></multibutton>

<!-- </div> -->


Expand Down

0 comments on commit 965b3c7

Please sign in to comment.