Sha256: f17ae0eccd8b2eb67a68f47853df2c71852cfb80d57c83d9d20790a69fd770b1

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module = angular.module("mb.controllers")

# TODO clenup this controller, see DatabasesController
class CollectionsController
  constructor: (@$scope, @$routeParams, @Collection, @$http, @confirmationDialog, @alerts) ->

    @$scope.dbName = @$routeParams.dbName
    @$scope.filterValue = ""

    _onLoadComplete = (data) =>
      @$scope.collections = data
      @$scope.loading = false

    @$scope.fetchCollections = =>
      @$scope.loading = true
      @$scope.collections = @Collection.query({ dbName: @$scope.dbName }, _onLoadComplete)

    @$scope.fetchCollections()

    # TODO create resource for this call
    @$http.get("/api/databases/#{@$scope.dbName}/stats.json").success (data) =>
      @$scope.dbStats = data

    @$scope.isLoading = => @$scope.loading

    @$scope.delete = (collection) =>
      @confirmationDialog
        message: "Deleting #{collection.name}. Are you sure?"
        onOk: =>
          resource = new @Collection()
          params = dbName: collection.dbName, id: collection.name

          resource.$delete params, =>
            @alerts.info("Collection #{collection.name} has been deleted.")
            @$scope.fetchCollections()

CollectionsController.$inject = ["$scope", "$routeParams",
  "Collection", "$http", "confirmationDialog", "alerts"]

module.controller "collections", CollectionsController

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.2.0.rc2 app/assets/javascripts/app/controllers/collections.js.coffee