Commits

Chun-Ping Chang  committed fa3be14

show alert before regen api key

  • Participants
  • Parent commits 747e2c9

Comments (0)

Files changed (4)

File assets/css/bs_united.css

 .navbar .brand {
   float: left;
   display: block;
-  padding: 8px 20px 12px;
+  /*padding: 8px 20px 12px;*/
+  padding: 4px 20px 2px;
   margin-left: -20px;
   font-size: 20px;
   font-weight: 200;

File assets/js/custom/manage.js

 $(document).ready( function () {
-  var g_actMode = '';
-  var g_objID = '';
-  var g_hashUserID = '';
-  var g_targetObj = {};
-  var g_apiKey = [];
-  var g_apiDatas = '';
+  var g_actMode = '',
+      g_objID = '',
+      g_hashUserID = '',
+      g_targetObj = {},
+      g_apiKey = [],
+      g_apiDatas = '';
+
+  var idxOldApiKey = '',
+      oldObjID = '',
+      spnApiKey = '',
+      newApiData = '';
 
   // Add Project Dialog
   $("#modalAddMod").bind("show", function() {
     "show"      : false
   });
 
+  // Regen API key Confirm Dialog
+  $("#modalRegenAlert").bind("show", function() {
+    $("#regenYes").click( function () {
+      console.log("YES");
+
+      $.ajax({
+        type:   'GET',
+        url:    '/regen/apikey/' + g_objID,
+        dataType: 'json',
+        success: function (res) {
+          console.log(res[0]);
+          g_apiKey[idxOldApiKey] = res[0];
+          g_apiDatas[res[0]] = newApiData;
+          delete g_apiDatas[oldObjID];
+          g_targetObj.attr('id', g_apiKey[idxOldApiKey]);
+          g_objID = g_targetObj.attr('id');
+          spnApiKey.text(res[0]);
+        },
+        error: function (res) {
+          console.log(res);
+          spnApiKey.text('Can not re-generate API key.');
+        }
+      });
+
+      $("#modalRegenAlert").modal('hide');
+    });
+
+    $("#regenNo").click( function () {
+      console.log("NO");
+      $("#modalRegenAlert").modal('hide');
+    });
+  });
+
+  $("#modalDelAlert").bind("hide", function() {
+    $("#modalDelAlert a.btn").unbind();
+  });
+
+  $("#modalDelAlert").modal({
+    "backdrop"  : true,
+    "keyboard"  : true,
+    "show"      : false
+  });
   function init () {
     // Load Project List
     $.ajax({
   $('div.div_table').on('click', 'a.regen', function (e) {
     e.preventDefault();
     console.log('regen api key');
-    var idxOldApiKey = $.inArray(g_objID, g_apiKey);
+
+    idxOldApiKey = $.inArray(g_objID, g_apiKey);
     g_objID = $(this).parent().parent().parent().attr('id');
-    var oldObjID = g_objID;
+    oldObjID = g_objID;
     g_targetObj = $(this).parent().parent().parent();
-    var spnApiKey = $(this).parent().parent().parent().children('.div_table_col_appkeys').children('span');
-    var newApiData = g_apiDatas[g_objID];
-    $.ajax({
-      type:   'GET',
-      url:    '/regen/apikey/' + g_objID,
-      dataType: 'json',
-      success: function (res) {
-        console.log(res[0]);
-        g_apiKey[idxOldApiKey] = res[0];
-        g_apiDatas[res[0]] = newApiData;
-        delete g_apiDatas[oldObjID];
-        g_targetObj.attr('id', g_apiKey[idxOldApiKey]);
-        g_objID = g_targetObj.attr('id');
-        spnApiKey.text(res[0]);
-      },
-      error: function (res) {
-        console.log(res);
-        spnApiKey.text('Can not re-generate API key.');
-      }
-    });
+    spnApiKey = $(this).parent().parent().parent().children('.div_table_col_appkeys').children('span');
+    newApiData = g_apiDatas[g_objID];
+
+    $('#modalRegenAlert').modal();
   });
 });
             <span class="icon-bar"></span>
             <span class="icon-bar"></span>
           </a>
-          <a class="brand" href="/">GaiaSup</a>
+          <a class="brand" href="/"> <img src="/assets/img/gs_logo.png" height="30" width="123"></a>
           <div class="nav-collapse">
             <ul class="nav">
               <li class="active"><a href="/">Home</a></li>
         <a href="#" class="btn" id="delNo">No</a>
       </div>
     </div>
+
+    <div class="modal hide fade" id="modalRegenAlert">
+      <div class="modal-header">
+        <a class="close" data-dismiss="modal">×</a>
+        <h3>ReGenerate API key</h3>
+      </div>
+      <div class="modal-body">
+        <p>Re-generate API key will clean all layer and node that created by this API key</p>
+        <p>Do you REALLY want to do this modify?</p>
+      </div>
+      <div class="modal-footer">
+        <a href="#" class="btn btn-primary" id="regenYes">Yes</a>
+        <a href="#" class="btn" id="regenNo">No</a>
+      </div>
+    </div>
      <!--twitter bootstrap modals-->
 
   </body>