1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-10 23:53:31 -05:00
shimapan/public/js/panel.min.js
2017-10-20 16:46:14 -04:00

1 line
2.8 KiB
JavaScript

(angular=require("angular")).module("ApiSvc",[]).service("ApiService",["$http","$window",function(e,t){this.getKey=function(t,n){e({method:"GET",url:"/api/keys/get",params:{identifier:t}}).then(function(e){n(e.data)})},this.getAll=function(t){e({method:"GET",url:"/api/keys/get"}).then(function(e){t(e.data)})}}]),(angular=require("angular")).module("AuthSvc",[]).service("AuthService",["$http","$window",function(e,t){this.login=function(n){return e({method:"POST",url:"/api/auth/login",headers:{"Content-Type":"application/x-www-form-urlencoded"},transformRequest:function(e){var t=[];for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")},data:n}).then(function(e){if(401===e.status)return!1;t.location.href="/home"})},this.logout=function(){e({method:"GET",url:"/api/auth/logout"}).then(function(){t.location.href="/"})},this.register=function(n){return e({method:"POST",url:"/api/auth/register",headers:{"Content-Type":"application/x-www-form-urlencoded"},transformRequest:function(e){var t=[];for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")},data:n}).then(function(e){if(401===e.status)return!1;t.location.href="/home"})},this.currentUser=function(t){return e({method:"GET",url:"/api/auth/session",headers:{"Content-Type":"application/json"}}).then(function(e){t(e.data)})}}]),(angular=require("angular")).module("PanelRoutes",["ui.router"]).config(["$stateProvider","$urlRouterProvider","$locationProvider",function(e,t,n){n.html5Mode(!0),t.otherwise("/panel"),e.state("dashboard",{url:"/panel",templateUrl:"/views/panel/dash.html"}).state("search",{url:"/panel/search",templateUrl:"/views/panel/search.html"}).state("api",{url:"/panel/api",templateUrl:"/views/panel/api.html"}).state("invites",{url:"/panel/invites",templateUrl:"/views/panel/invites.html"}).state("stats",{url:"/panel/stats",templateUrl:"/views/panel/stats.html"}).state("users",{url:"/panel/users",templateUrl:"/views/panel/users.html"}).state("home",{onEnter:["$window",function(e){e.location.href="/home"}]})}]);var angular=require("angular"),uirouter=require("angular-ui-router"),app=angular.module("shimapan-panel",["ui.router","AuthSvc","ApiSvc","ApiCtrl","NavCtrl","PanelRoutes"]);app.run(["$rootScope","$state","$stateParams",function(e,t,n){e.$state=t,e.$stateParams=n}]),(angular=require("angular")).module("ApiCtrl",["ApiSvc","AuthSvc"]).controller("ApiController",["$scope","ApiService","AuthService",function(e,t,n){e.getKeys=function(){t.getAll(function(t){e.keys=t}),console.log(e.keys)}}]),(angular=require("angular")).module("NavCtrl",["AuthSvc"]).controller("NavController",["$scope","$window","AuthService",function(e,t,n){e.user={},n.currentUser(function(t){e.user=t}),e.logout=n.logout,e.hasPermission=function(t){return!!e.user.scope&&-1!==e.user.scope.indexOf(t)}}]);