feat(apps): more progress on app pages

This commit is contained in:
Torkel Ödegaard 2016-02-09 12:10:59 +01:00
parent 18eb9d6076
commit 0def04ad34
9 changed files with 30 additions and 25 deletions

View File

@ -1,4 +1,2 @@
<h1>Nginx logs view</h1>
Logs!

View File

@ -1,4 +1,2 @@
<h1>Nginx stream view</h1>
testing!
streams!

View File

@ -1,5 +1,7 @@
///<reference path="../../headers/common.d.ts" />
import './dashboard_loaders';
import angular from 'angular';
import coreModule from 'app/core/core_module';
import {BundleLoader} from './bundle_loader';

View File

@ -5,19 +5,21 @@ import _ from 'lodash';
export class AppEditCtrl {
appModel: any;
appId: any;
includedPanels: any;
/** @ngInject */
constructor(private backendSrv: any, private $routeParams: any) {
this.appModel = {};
this.appId = $routeParams.appId;
this.backendSrv.get(`/api/org/apps/${this.$routeParams.appId}/settings`).then(result => {
this.backendSrv.get(`/api/org/apps/${this.appId}/settings`).then(result => {
this.appModel = result;
this.includedPanels = _.where(result.includes, {type: 'panel'});
});
}
update(options) {
update() {
var updateCmd = _.extend({
appId: this.appModel.appId,
orgId: this.appModel.orgId,
@ -25,19 +27,19 @@ export class AppEditCtrl {
pinned: this.appModel.pinned,
jsonData: this.appModel.jsonData,
secureJsonData: this.appModel.secureJsonData,
}, options);
}, {});
this.backendSrv.post(`/api/org/apps/${this.$routeParams.appId}/settings`, updateCmd).then(function() {
this.backendSrv.post(`/api/org/apps/${this.appId}/settings`, updateCmd).then(function() {
window.location.href = window.location.href;
});
}
toggleEnabled() {
this.update({enabled: this.appModel.enabled});
this.update();
}
togglePinned() {
this.update({pinned: this.appModel.pinned});
this.update();
}
}

View File

@ -6,9 +6,8 @@ export class AppListCtrl {
apps: any[];
/** @ngInject */
constructor(private backendSrv: any) {}
constructor(private backendSrv: any) {
init() {
this.backendSrv.get('api/org/apps').then(apps => {
this.apps = apps;
});

View File

@ -5,11 +5,14 @@ import _ from 'lodash';
export class AppPageCtrl {
page: any;
appId: any;
appModel: any;
/** @ngInject */
constructor(private backendSrv, private $routeParams: any, private $rootScope) {
this.backendSrv.get(`/api/org/apps/${this.$routeParams.appId}/settings`).then(app => {
this.appId = $routeParams.appId;
this.backendSrv.get(`/api/org/apps/${this.appId}/settings`).then(app => {
this.appModel = app;
this.page = _.findWhere(app.pages, {slug: this.$routeParams.slug});
if (!this.page) {

View File

@ -78,7 +78,7 @@
</div>
<ul>
<li ng-repeat="page in ctrl.appModel.pages">
<a href="{{page.url}}" class="external-link">{{page.name}}</a>
<a href="apps/{{ctrl.appId}}/page/{{page.slug}}" class="external-link">{{page.name}}</a>
</li>
</ul>
</div>

View File

@ -2,7 +2,7 @@
</navbar>
<div class="page-container">
<div class="page-wide" ng-init="ctrl.init()">
<div class="page-wide">
<h1>Apps</h1>
<div ng-if="!ctrl.apps">
@ -18,7 +18,7 @@
<li>
<div class="filter-list-card-controls">
<div class="filter-list-card-config">
<a href="apps/edit/{{app.appId}}">
<a href="apps/{{app.appId}}/edit">
<i class="fa fa-cog"></i>
</a>
</div>

View File

@ -1,14 +1,17 @@
<navbar icon="fa fa-fw fa-cubes" title="{{ctrl.appModel.name}}" subnav="true">
<navbar icon="fa fa-fw fa-cubes" title="{{ctrl.appModel.name}}" title-url="apps/{{ctrl.appId}}/edit" subnav="true">
<ul class="nav">
<li class="active"><a href="apps/nginx">{{ctrl.page.name}}</a></li>
<li class="active"><a href="apps/{{ctrl.appId}}/ctrl.page.slug">{{ctrl.page.name}}</a></li>
</ul>
</navbar>
<h2>
App page
</h2>
<div class="page-container">
<div class="page-wide">
<h1>{{ctrl.page.name}}</h1>
<div ng-if="ctrl.page">
<plugin-component type="app-page" page="ctrl.page">
</plugin-component>
<div ng-if="ctrl.page">
<plugin-component type="app-page">
</plugin-component>
</div>
</div>
</div>