diff options
author | WuKong <rebirthmonkey@gmail.com> | 2017-04-22 13:25:07 +0200 |
---|---|---|
committer | WuKong <rebirthmonkey@gmail.com> | 2017-04-22 13:25:07 +0200 |
commit | d182202fc6001983541504ed323d68479086317e (patch) | |
tree | 11d4c10cdd3e995f519c3e0e324968fdaf175114 /moonv4/moon_gui/static/app/model/action | |
parent | 83c1c966baf73329fab8ddcfad19ad7fe0c41c2a (diff) |
add moonv4
Change-Id: I247af788d0b0fb961fbc85416486b241eb1d807c
Signed-off-by: WuKong <rebirthmonkey@gmail.com>
Diffstat (limited to 'moonv4/moon_gui/static/app/model/action')
6 files changed, 342 insertions, 0 deletions
diff --git a/moonv4/moon_gui/static/app/model/action/model-add.tpl.html b/moonv4/moon_gui/static/app/model/action/model-add.tpl.html new file mode 100644 index 00000000..dee53a97 --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model-add.tpl.html @@ -0,0 +1,66 @@ +<div ng-controller="ModelAddController as add" class="modal" tabindex="-1" data-role="modalAddModel"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.model.add.title"></h4> + </div> + + <div class="modal-body"> + + <form class="form-horizontal" role="form" name="add.form"> + + <div class="form-group" ng-class="{'has-error': add.form.name.$invalid && add.form.name.$dirty}"> + + <label for="name" class="col-sm-3 control-label" data-translate="moon.model.add.form.name">Name</label> + + <div class="col-sm-6"> + + <input name="name" id="name" class="form-control" type="text" data-ng-model="add.model.name" required /> + + <div class="help-block" ng-show="add.form.name.$dirty && add.form.name.$invalid"> + <small class="error" ng-show="add.form.name.$error.required" data-translate="moon.model.add.check.name.required">Name is required</small> + </div> + + </div> + </div> + + <div class="form-group"> + + <label for="description" class="col-sm-3 control-label" data-translate="moon.model.add.form.description">Description</label> + <div class="col-sm-6"> + <textarea id="description" name="description" class="form-control" data-ng-model="add.model.description"></textarea> + </div> + + </div> + + </form> + + </div> + + <div class="modal-footer"> + + <div class="btn-toolbar" style="float: right;"> + + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.model.add.action.cancel">Cancel</span> + </a> + + <a href="" ng-disabled="add.loading" ng-click="add.create()" class="btn btn-warning"> + <span class="glyphicon glyphicon-save"></span> + <span data-translate="moon.model.add.action.create">Create Model</span> + </a> + <moon-loader ng-if="add.loading"></moon-loader> + + </div> + + </div> + + </div> + + </div> + +</div> diff --git a/moonv4/moon_gui/static/app/model/action/model-delete.tpl.html b/moonv4/moon_gui/static/app/model/action/model-delete.tpl.html new file mode 100644 index 00000000..cde16d0e --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model-delete.tpl.html @@ -0,0 +1,39 @@ +<div ng-controller="ModelDeleteController as del" class="modal" tabindex="-1" data-role="modalDeleteModel"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.model.remove.title"></h4> + </div> + + <div class="modal-body"> + + <p><span data-translate="moon.model.remove.content.query" data-translate-values="{ modelName: del.model.name }"></span></p> + + </div> + + <div class="modal-footer"> + <div class="btn-toolbar" style="float: right;"> + + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.model.remove.action.cancel">Cancel</span> + </a> + + <a href="" ng-disabled="del.loading" ng-click="del.remove()" class="btn btn-warning"> + <span class="glyphicon glyphicon-trash"></span> + <span data-translate="moon.model.remove.action.delete">Delete</span> + </a> + + <moon-loader ng-if="del.loading" ></moon-loader> + + </div> + </div> + + </div> + + </div> + +</div>
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/model/action/model-view.tpl.html b/moonv4/moon_gui/static/app/model/action/model-view.tpl.html new file mode 100644 index 00000000..46c295c7 --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model-view.tpl.html @@ -0,0 +1,41 @@ +<div ng-controller="ModelViewController as view" class="modal" tabindex="-1" data-role="modalViewProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.model.view.title" data-translate-values="{modelName: view.model.name}"></h4> + </div> + <div class="modal-body"> + <dl class="dl-horizontal"> + <dt data-translate="moon.model.view.id">Id</dt> + <dd ng-bind="view.model.id"></dd> + <dt data-translate="moon.model.view.name">Name</dt> + <dd ng-bind="view.model.name"></dd> + <dt data-translate="moon.model.view.description">Description</dt> + <dd ng-bind="view.model.description"></dd> + </dl> + + <div ng-if="view.meta_rules_values"> + <moon-meta-rules-list mapped-model="view.model" edit-mode="false"></moon-meta-rules-list> + </div> + + <div ng-if="!view.meta_rules_values"> + <moon-loader></moon-loader> + </div> + + </div> + + <div class="modal-footer top10"> + <div class="btn-toolbar" style="float: right;"> + <button ng-click="$hide()" class="btn btn-default" data-translate="moon.model.view.action.close">Close</button> + </div> + </div> + + </div> + + </div> + +</div> diff --git a/moonv4/moon_gui/static/app/model/action/model.controller.add.js b/moonv4/moon_gui/static/app/model/action/model.controller.add.js new file mode 100644 index 00000000..11d3abf4 --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model.controller.add.js @@ -0,0 +1,71 @@ +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ModelAddController', ModelAddController); + + ModelAddController.$inject = ['$scope', 'modelService', 'alertService', '$translate', 'formService', 'utilService']; + + function ModelAddController($scope, modelService, alertService, $translate, formService, utilService) { + + var add = this; + + /* + * + */ + + add.form = {}; + + add.loading = false; + + add.model = { name: null, description: null, meta_rules : [] }; + + add.create = createModel; + + function createModel() { + + if(formService.isInvalid(add.form)) { + + formService.checkFieldsValidity(add.form); + + } else { + + add.loading = true; + + modelService.data.create({}, add.model, createSuccess, createError); + + } + + function createSuccess(data) { + + var createdModel = utilService.transformOne(data, 'models'); + + $translate('moon.model.add.success', { modelName: createdModel.name }).then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + add.loading = false; + + $scope.$emit('event:modelCreatedSuccess', createdModel); + + } + + function createError(reason) { + + $translate('moon.model.add.error', { modelName: add.model.name }).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + add.loading = false; + + $scope.$emit('event:modelCreatedError', add.project); + + } + + } + + } + +})(); diff --git a/moonv4/moon_gui/static/app/model/action/model.controller.delete.js b/moonv4/moon_gui/static/app/model/action/model.controller.delete.js new file mode 100644 index 00000000..5d9dae1a --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model.controller.delete.js @@ -0,0 +1,72 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ModelDeleteController', ModelDeleteController); + + ModelDeleteController.$inject = ['$scope', '$translate', 'alertService', 'modelService']; + + function ModelDeleteController($scope, $translate, alertService, modelService) { + + var del = this; + + /* + * + */ + + del.model = $scope.model; + del.loading = false; + + del.remove = deleteModel; + + activate(); + + /** + * + */ + + function activate(){ + + } + + + function deleteModel(){ + + del.loading = true; + + modelService.delete(del.model, deleteSuccess, deleteError); + + function deleteSuccess(data) { + + $translate('moon.model.remove.success', { modelName: del.model.name }).then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:modelDeletedSuccess', del.model); + + } + + function deleteError(reason) { + + $translate('moon.model.remove.error', { modelName: del.model.name, errorCode: reason.data.error.code, message : reason.data.error.message } ).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:modelDeletedError', del.model); + + } + + } + } + +})(); diff --git a/moonv4/moon_gui/static/app/model/action/model.controller.view.js b/moonv4/moon_gui/static/app/model/action/model.controller.view.js new file mode 100644 index 00000000..7605eecf --- /dev/null +++ b/moonv4/moon_gui/static/app/model/action/model.controller.view.js @@ -0,0 +1,53 @@ +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ModelViewController', ModelViewController); + + ModelViewController.$inject = ['$scope', 'metaRuleService']; + + function ModelViewController($scope, metaRuleService) { + + var view = this; + + /* + * + */ + + view.model = $scope.model; + + view.meta_rules_values = false; + + activate(); + + function activate(){ + + if(view.model.meta_rules.length > 0 ){ + + findMetaRules(); + + }else{ + + view.meta_rules_values = []; + + } + + } + + function findMetaRules(){ + + metaRuleService.findSomeWithMetaData(view.model.meta_rules).then(function(metaRules){ + + view.meta_rules_values = metaRules; + + view.model.meta_rules_values = metaRules; + + }); + + } + + } + +})(); |