import AdhHttp = require("../Http/Http");
import AdhConfig = require("../Config/Config");
import AdhTopLevelState = require("../TopLevelState/TopLevelState");

var notFoundTemplate = "<h1>404 - not Found</h1>";


interface IResourceRouterScope extends ng.IScope {
    template : string;
}


export var resourceRouter = (
    adhHttp : AdhHttp.Service<any>,
    adhConfig : AdhConfig.Type,
    adhTopLevelState : AdhTopLevelState.TopLevelState,
    $routeParams : ng.route.IRouteParamsService,
    $scope : IResourceRouterScope
) => {
    var resourceUrl = adhConfig.rest_url + "/" + $routeParams["path"];

    adhHttp.get(resourceUrl).then((resource) => {
        switch (resource.content_type) {
            case "adhocracy_core.resources.sample_proposal.IProposal":
                $scope.template = "<adh-document-workbench></adh-document-workbench>";
                break;
            default:
                $scope.template = notFoundTemplate;
        }
    }, (reason) => {
        $scope.template = notFoundTemplate;
    });
};

import AdhHttp = require("../Http/Http");
import AdhConfig = require("../Config/Config");
import AdhTopLevelState = require("../TopLevelState/TopLevelState");

import RIBasicPool = require("Resources_/adhocracy_core/resources/pool/IBasicPool");
import RIMercatorProposal = require("Resources_/adhocracy_core/resources/mercator/IMercatorProposal");
import RIUser = require("Resources_/adhocracy_core/resources/principal/IUser");
import RIUsersService = require("Resources_/adhocracy_core/resources/principal/IUsersService");

var notFoundTemplate = "<h1>404 - not Found</h1>";


interface IResourceRouterScope extends ng.IScope {
    template : string;
}


export var resourceRouter = (
    adhHttp : AdhHttp.Service<any>,
    adhConfig : AdhConfig.Type,
    adhTopLevelState : AdhTopLevelState.TopLevelState,
    $routeParams : ng.route.IRouteParamsService,
    $scope : IResourceRouterScope
) => {
    var resourceUrl = adhConfig.rest_url + "/" + $routeParams["path"];

    adhHttp.get(resourceUrl).then((resource) => {
        switch (resource.content_type) {
            case RIBasicPool.content_type:
                $scope.template = "<adh-document-workbench></adh-document-workbench>";
                break;
            case RIMercatorProposal.content_type:
                $scope.template = "<adh-document-workbench></adh-document-workbench>";
                break;
            case RIUser.content_type:
                $scope.template = "<h1>User</h1>";
                break;
            case RIUsersService.content_type:
                $scope.template = "<h1>User List</h1>";
                break;
            default:
                $scope.template = notFoundTemplate;
        }
    }, (reason) => {
        $scope.template = notFoundTemplate;
    });
};

Use some actual content types
Use some actual content types
