Admin Pannel with parse.com

Discussion in 'Programming' started by iqee3, Sep 5, 2015.

  1. #1
    Hello guys,
    I am new in angular and parse.com, but I need to make an admin panel (http://i61.tinypic.com/2hoz0ad.jpg).

    I succeeded to display the queries from parse.com but I can't figure out how to edit them from admin panel. I read the parse.com documentation and I have an idea how should it work but I can write the code for that, I tried to make the editUser function but I don't know what is missing from my code. Can somebody help me with a method?

    <!DOCTYPE html>
    <html>
    <head>
        <script type="text/javascript" src="js/parse-1.5.0.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        <script type="text/javascript" src="js/main.js"></script>
    </head>
    <body ng-app="demo">
        <div class="container" ng-controller="adminPannel">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Username</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                    </tr>
                </thead>
                <tbody><tr ng-repeat="user in users">
                        <td><button class="btn" ng-click="editUser()"><input type="text" id="newUserName" ng-model="firstNameCh"/></button></td>
                        <td>{{ user.firstname }}</td>
                        <td>{{ user.lastname }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
    </html>
    Code (markup):

    and my main.js file

    var app=angular.module('demo',[]);
    app.controller('adminPannel',['$scope',function($scope) {
    $scope.users=[];
    
    Parse.initialize("WnaPPAytzCE8AR7NNGENpVGMGQ6pQ9wH2LKRQ6wE", "2qfXZunNrQPnCgNuusPpbGCDmbRBzo7CG4X0edDF");
    $scope.use=Parse.User.current();
    var noname2=Parse.Object.extend("noname2");
    var query=new Parse.Query(noname2);
    //query.equalTo("uname",$scope.use.get('username'));
    query.find({
      success:function(results) {
      alert("success");
      alert(results.length);
      for(var i=0;i<results.length;i++)
       {
         var object= results[i];
    
         $scope.users.push({'firstname':object.get('firstname') , 'lastname':object.get('lastname') ,'age':object.get('age')});
    
       }
        $scope.$apply();
    },
    error:function(error) {
      alert("error:"+ error.code +" "+error.message);
       }
    });
    $scope.editUser = function(){
      noname2SubClass.save(null,{
        success:function(noname2SubClass){
          noname2SubClass.set('firstname', $scope.firstNameCh);
          noname2SubClass.save();
        }
      });
    }
    }]);
    Code (markup):
     
    iqee3, Sep 5, 2015 IP
  2. Harshal shah

    Harshal shah Active Member

    Messages:
    126
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    65
    #2
    Hi,

    I am not a technical person. But I have a team who can review your code and give you suggestion..
     
    Harshal shah, Sep 12, 2015 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    While I'm not that familiar with Angular and never even heard of "parse", but a LOT of the code you presented is throwing up warning flags in my head --- the markup for example I'm not convinced just one row qualifies as a table, the INPUT inside a BUTTON without a FORM is utter and complete gibberish, and the scripting reeks of doing something client side that has no damned business being done client-side (unless this is a standalone web crapplet).

    Even if that were to be done client side having scripting only markup is sloppy/bad practice no matter what the two goofy bloated bits of framework asshattery you've chosen (jq and angular) claim.

    It's unclear what you are actually trying to do here, but I'm pretty sure that's not how one should go about it.
     
    deathshadow, Sep 12, 2015 IP