github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/static/app/plugins/addPlugin.controller.js (about) 1 (function(){ 2 'use strict'; 3 4 angular 5 .module('shipyard.plugins') 6 .controller('PluginAddController', PluginAddController); 7 8 PluginAddController.$inject = ['$http', '$state', '$rootScope']; 9 function PluginAddController($http, $state, $rootScope) { 10 var vm = this; 11 vm.error = ""; 12 vm.request = {}; 13 vm.addPlugin = addPlugin; 14 vm.name = ""; 15 vm.kind=""; 16 vm.status="disable" 17 vm.description="" 18 vm.spec="" 19 vm.maual="" 20 vm.request = null; 21 22 function isValid() { 23 return $('.ui.form').form('validate form'); 24 } 25 26 function addPlugin() { 27 if (!isValid()) { 28 return; 29 } 30 vm.request = { 31 name: vm.name, 32 kind: vm.kind, 33 status: vm.status, 34 description: vm.description, 35 spec: vm.spec, 36 manual: vm.maual, 37 } 38 $http 39 .post($rootScope.url + '/plugins', vm.request) 40 .success(function(data, status, headers, config) { 41 $state.transitionTo('dashboard.plugins'); 42 }) 43 .error(function(data, status, headers, config) { 44 vm.error = data; 45 }); 46 } 47 } 48 })();