From 6a2843d95f15eb6dc6861af153309c16f31d7f69 Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Tue, 24 Oct 2017 12:58:35 -0600 Subject: [PATCH] removing everything not working --- index.html | 2 +- js/app.js | 4 +- js/controllers/website-controller.js | 13 +++++- js/services/shows-service.js | 29 -------------- js/services/websites-service.js | 60 ++++++++++++++++++++++++++++ templates/website.html | 2 +- templates/websites-detail.html | 6 ++- templates/websites.html | 7 ---- 8 files changed, 79 insertions(+), 44 deletions(-) delete mode 100644 js/services/shows-service.js create mode 100644 js/services/websites-service.js diff --git a/index.html b/index.html index b27b603..4b11973 100644 --- a/index.html +++ b/index.html @@ -44,7 +44,7 @@ - + diff --git a/js/app.js b/js/app.js index ad5a5d4..e9f78ef 100644 --- a/js/app.js +++ b/js/app.js @@ -113,7 +113,7 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider } }) .state('app.websites', { - url: 'shows', + url: 'websites', views: { 'content@': { templateUrl: 'templates/websites.html', @@ -124,7 +124,7 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider .state('app.websites.detail', { url: '/detail/:id', templateUrl: 'templates/websites-detail.html', - controller: 'websitesDetailCtrl as vm' + controller: 'websiteCtrl as vm' }) .state('app.dns', { url: 'dns', diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 1070f75..569038a 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -68,8 +68,8 @@ app.directive('notificationBar', [function () { }]); app.controller('websiteCtrl', [ - '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce' -, function ($scope, $q, Auth, Oauth3, $timeout, $sce) { + '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce','$stateParams', 'websitesService', + function ($scope, $q, Auth, Oauth3, $timeout, $sce, $stateParams, websitesService) { var vm = this; var angular = window.angular; @@ -88,6 +88,9 @@ app.controller('websiteCtrl', [ return r.verifiedAt || r.mode; } + // vm.selectedShow = websitesService.find($stateParams.id); + // vm.shows = websitesService.list(); + Auth.api = function (apiname, opts) { var els = []; @@ -703,6 +706,7 @@ app.controller('websiteCtrl', [ // console.log('[listSites] sites:'); // console.log(sites); vm.sites = sites; + vm.shows = sites; vm.sites.forEach(function(site) { site.urlSafeDomain = "https://" + site.domain; site.urlSafeDomain = $sce.trustAsResourceUrl(site.urlSafeDomain); @@ -710,6 +714,11 @@ app.controller('websiteCtrl', [ }); }; + vm.websiteSelected = function (x) { + vm.selectedShow = x; + debugger; + }; + //vm.getDomains(); Auth.api('domains.list', {}).then(function (els) { // console.log('[init] domains.list els:'); diff --git a/js/services/shows-service.js b/js/services/shows-service.js deleted file mode 100644 index 5f6498d..0000000 --- a/js/services/shows-service.js +++ /dev/null @@ -1,29 +0,0 @@ -app.factory('ShowsService',function(){ - var shows = [{ - id: 1, - name: 'Walking Dead', - description: 'The Walking Dead is an American post-apocalyptic horror drama television series developed by Frank Darabont. It is based on the comic book series of the same name by Robert Kirkman, Tony Moore, and Charlie Adlard. It stars Andrew Lincoln as sheriff\'s deputy Rick Grimes, who awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies.' - }, - { - id: 2, - name: 'Breaking Bad', - description: 'Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. The show originally aired on the AMC network for five seasons, from January 20, 2008 to September 29, 2013. The main character is Walter White (Bryan Cranston), a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series.' - }, - { - id: 3, - name: '7D', - description: 'The 7D is an American animated television series produced by Disney Television Animation, and broadcast on Disney XD starting in July 7, 2014. It is a re-imagining of the titular characters from the 1937 film Snow White and the Seven Dwarfs by Walt Disney Productions' - }]; - - - return { - list: function(){ - return shows; - }, - find: function(id){ - return _.find(shows, function(show){ - return show.id == id; - }); - } - }; -}); diff --git a/js/services/websites-service.js b/js/services/websites-service.js new file mode 100644 index 0000000..4eb6f2b --- /dev/null +++ b/js/services/websites-service.js @@ -0,0 +1,60 @@ +app.factory('websitesService',[ + '$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce', '$stateParams', + function($q, Auth, Oauth3, $timeout, $sce, $stateParams){ + // var shows = []; + // var shows = [{ + // id: 1, + // name: 'Walking Dead', + // description: 'The Walking Dead is an American post-apocalyptic horror drama television series developed by Frank Darabont. It is based on the comic book series of the same name by Robert Kirkman, Tony Moore, and Charlie Adlard. It stars Andrew Lincoln as sheriff\'s deputy Rick Grimes, who awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies.' + // }, + // { + // id: 2, + // name: 'Breaking Bad', + // description: 'Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. The show originally aired on the AMC network for five seasons, from January 20, 2008 to September 29, 2013. The main character is Walter White (Bryan Cranston), a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series.' + // }, + // { + // id: 3, + // name: '7D', + // description: 'The 7D is an American animated television series produced by Disney Television Animation, and broadcast on Disney XD starting in July 7, 2014. It is a re-imagining of the titular characters from the 1937 film Snow White and the Seven Dwarfs by Walt Disney Productions' + // }]; + var sites = []; + listSites = function () { + var sites = []; + return $q.all(Auth.sessions.map(function (session) { + return Auth.get(session).then(function (oauth3) { + var pkg = oauth3.pkg('www@daplie.com'); + return pkg.list().then(function (result) { + var _sites = result.data; + if (Array.isArray(_sites)) { + sites = _sites.concat(sites); + return; + } + // console.error('_sites is not an array'); + // console.error(_sites); + }, function (err) { + console.error('_sites had an error'); + console.error(err); + }); + }); + })).then(function () { + var sitez; + sitez = sites; + return sitez; + console.log('[listSites] sites:'); + console.log(sites); + }); + }; + + return { + list: function(){ + console.log('asdf'); + // return sites; + }, + find: function(id){ + return _.find(sites, function(site){ + return site.id == id; + }); + } + }; + +}]); diff --git a/templates/website.html b/templates/website.html index cd2e38a..005c7b7 100644 --- a/templates/website.html +++ b/templates/website.html @@ -115,7 +115,7 @@
  • - +
    diff --git a/templates/websites-detail.html b/templates/websites-detail.html index 1f87e67..ad13e3d 100644 --- a/templates/websites-detail.html +++ b/templates/websites-detail.html @@ -1,4 +1,6 @@ -

    {{ vm.selectedShow.name }}

    +

    hello - {{ vm.blah }}

    +

    {{ vm.selectedShow }}

    +

    {{ vm.selectedShow.id }}

    - {{ vm.selectedShow.description }} + {{ vm.selectedShow.domain }}

    diff --git a/templates/websites.html b/templates/websites.html index 2eb367b..e69de29 100644 --- a/templates/websites.html +++ b/templates/websites.html @@ -1,7 +0,0 @@ - - -