admin angular UI ready

parent c1ebf0f7
'use strict';
//--------------------------
// Admin License Controller
//--------------------------
dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl($scope, $window, $http, config, $translate, ngToast) {
// The parameter 'config' is injected from config.js (defined in dashboardConfig module)
// Don't show the message at the begining
$scope.showmessagesupervisor = false;
$scope.formdatalicense = {
duration: ''
};
// This generates a new license and registers it in the database
$scope.create_license = function(supervisor){
$http
.post(config.backend+'/license', $scope.formdatalicense)
.success(function(data, status, headers, config) {
$scope.formdatalicense.duration = '';
$scope.new_number = data.number.substr(0,4) +
"-" + data.number.substr(4,4) +
"-" + data.number.substr(8,4) +
"-" + data.number.substr(12,4);
console.log($scope.new_number);
$scope.duration_registered = data.duration;
})
.error(function(data, status, headers, config) {
ngToast.danger({content: $translate.instant('error_general')});
console.log("Error from API: " + data.error);
});
};
});
<!-- Admin Licenses -->
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4">
<h3 translate>licenses</h3>
<form role="form" ng-submit="create_license()">
<div class="form-group">
<input type="number" class="form-control" id="setup_duration" placeholder="{{ 'duration_in_months' | translate }}" required ng-model="formdatalicense.duration" required/>
</div>
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" translate>generate</button>
</div>
</form>
</div>
<div class="col-md-4">
<div ng-show="new_number.length > 16" class="alert alert-info">
<p>{{ 'license_created' | translate }}: <strong>{{ new_number }}</strong></p>
<p>{{ 'duration_in_months' | translate }}: {{ duration_registered }}</p>
</div>
</div>
<div class="col-md-2">
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment