Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReadOnly option #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<PackageId>Toucan4Life.$(AssemblyName)</PackageId>
<Authors>Toucan4Life</Authors>
<Version>1.0.2</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="dist-dev-server\**" />
<Compile Remove="dist\**" />
<Compile Remove="node_modules\**" />
<EmbeddedResource Remove="dist-dev-server\**" />
<EmbeddedResource Remove="dist\**" />
<EmbeddedResource Remove="node_modules\**" />
<None Remove="dist-dev-server\**" />
<None Remove="dist\**" />
<None Remove="node_modules\**" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/CrystalQuartz.Application.Client/app/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface SchedulerDetails { //1
ThreadPoolSize: number;
ThreadPoolType: TypeInfo;
Version: string;
IsReadOnly: boolean
}

export interface EnvironmentData {
Expand All @@ -114,6 +115,7 @@ export interface EnvironmentData {
DotNetVersion: string;
CustomCssUrl: string;
TimelineSpan: number;
IsReadOnly: boolean;
}

export interface JobGroup extends ManagableActivity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ export default class ApplicationViewModel {
this.timeline,
this.commandService,
this.application,
this.dialogManager);
this.dialogManager,
this.environment);

commandService.onCommandFailed.listen(error => notificationService.showError(error.errorMessage));
commandService.onDisconnected.listen(() => application.goOffline());

this.groupsSynchronizer = new ActivitiesSynschronizer<JobGroup, JobGroupViewModel>(
(group: JobGroup, groupViewModel: JobGroupViewModel) => group.Name === groupViewModel.name,
(group: JobGroup) => new JobGroupViewModel(group, this.commandService, this.application, this.timeline, this.dialogManager, this._schedulerStateService),
(group: JobGroup) => new JobGroupViewModel(group, this.commandService, this.application, this.timeline, this.dialogManager, this._schedulerStateService,this.environment),
this.jobGroups);

application.onDataChanged.listen(data => this.setData(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export class GetEnvironmentDataCommand extends AbstractCommand<EnvironmentData>
QuartzVersion: data.qv,
DotNetVersion: data.dnv,
CustomCssUrl: data.ccss,
TimelineSpan: parseInt(data.ts, 10)
TimelineSpan: parseInt(data.ts, 10),
IsReadOnly: data.iro
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ function mapSchedulerDetails(data): SchedulerDetails {
Started: !!data.ist,
ThreadPoolSize: parseInt(data.tps, 10),
ThreadPoolType: TYPE_MAPPER(data.tpt),
Version: data.v
Version: data.v,
IsReadOnly: data.iro
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JobGroup, Job } from '../../api';
import { JobGroup, Job, EnvironmentData } from '../../api';
import { CommandService } from '../../services';
import { PauseGroupCommand, ResumeGroupCommand, DeleteGroupCommand } from '../../commands/job-group-commands';
import { ApplicationModel } from '../../application-model';
Expand Down Expand Up @@ -29,7 +29,7 @@ export class JobGroupViewModel extends ManagableActivityViewModel<JobGroup> {

private jobsSynchronizer: ActivitiesSynschronizer<Job, JobViewModel> = new ActivitiesSynschronizer<Job, JobViewModel>(
(job: Job, jobViewModel: JobViewModel) => job.Name === jobViewModel.name,
(job: Job) => new JobViewModel(job, this.name, this.commandService, this.applicationModel, this.timeline, this.dialogManager, this.schedulerStateService),
(job: Job) => new JobViewModel(job, this.name, this.commandService, this.applicationModel, this.timeline, this.dialogManager, this.schedulerStateService, this.environment),
this.jobs);

constructor(
Expand All @@ -38,7 +38,8 @@ export class JobGroupViewModel extends ManagableActivityViewModel<JobGroup> {
applicationModel: ApplicationModel,
private timeline: Timeline,
private dialogManager: IDialogManager,
private schedulerStateService: ISchedulerStateService) {
private schedulerStateService: ISchedulerStateService,
public environment: EnvironmentData) {

super(group, commandService, applicationModel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export class JobGroupView extends ActivityView<JobGroupViewModel> {
template = TEMPLATE;

init(dom: js.IDom, viewModel: JobGroupViewModel) {

super.init(dom, viewModel);
dom('.js_jobs').observes(viewModel.jobs, JobView);
if (viewModel.environment.IsReadOnly) {dom('.js_shown').$.hide();}
}

composeActions(viewModel: JobGroupViewModel): (Action | Separator)[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="primary-data">
<div class="status"></div>

<section class="actions dropdown">
<section class="js_shown actions dropdown">
<a href="#" class="actions-toggle dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
<ul class="js_actions dropdown-menu"></ul>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Job, Trigger } from '../../api';
import { Job, Trigger, EnvironmentData } from '../../api';
import { PauseJobCommand, ResumeJobCommand, DeleteJobCommand, ExecuteNowCommand } from '../../commands/job-commands';
import { CommandService } from '../../services';
import { ApplicationModel } from '../../application-model';
Expand All @@ -24,7 +24,7 @@ export class JobViewModel extends ManagableActivityViewModel<Job> {

private triggersSynchronizer: ActivitiesSynschronizer<Trigger, TriggerViewModel> = new ActivitiesSynschronizer<Trigger, TriggerViewModel>(
(trigger: Trigger, triggerViewModel: TriggerViewModel) => trigger.Name === triggerViewModel.name,
(trigger: Trigger) => new TriggerViewModel(trigger, this.commandService, this.applicationModel, this.timeline, this.dialogManager, this.schedulerStateService),
(trigger: Trigger) => new TriggerViewModel(trigger, this.commandService, this.applicationModel, this.timeline, this.dialogManager, this.schedulerStateService, this.environment),
this.triggers);

constructor(
Expand All @@ -34,7 +34,8 @@ export class JobViewModel extends ManagableActivityViewModel<Job> {
applicationModel: ApplicationModel,
private timeline: Timeline,
private dialogManager: IDialogManager,
private schedulerStateService: ISchedulerStateService) {
private schedulerStateService: ISchedulerStateService,
public environment: EnvironmentData) {

super(job, commandService, applicationModel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class JobView extends ActivityView<JobViewModel> {
super.init(dom, viewModel);

dom('.triggers').observes(viewModel.triggers, TriggerView);
dom('.js_viewDetails').on('click').react(viewModel.loadJobDetails);
dom('.js_viewDetails').on('click').react(viewModel.loadJobDetails);
if (viewModel.environment.IsReadOnly) {dom('.js_shown').$.hide();};
}

composeActions(viewModel: JobViewModel): (Action | Separator)[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="data-row data-row-job">
<section class="primary-data">
<div class="status"></div>
<div class="actions dropdown">
<div class="js_shown actions dropdown">
<a href="#" class="actions-toggle dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
<ul class="js_actions dropdown-menu"></ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Trigger, NullableDate, SchedulerData, SimpleTriggerType, CronTriggerType } from '../../api';
import { Trigger, NullableDate, SchedulerData, SimpleTriggerType, CronTriggerType, EnvironmentData } from '../../api';
import { ICommand } from '../../commands/contracts';
import { PauseTriggerCommand, ResumeTriggerCommand, DeleteTriggerCommand } from '../../commands/trigger-commands';
import { TriggerDetailsViewModel } from '../../dialogs/trigger-details/trigger-details-view-model';
Expand Down Expand Up @@ -38,7 +38,8 @@ export class TriggerViewModel extends ManagableActivityViewModel<Trigger> {
applicationModel: ApplicationModel,
private timeline: Timeline,
private dialogManager: IDialogManager,
private schedulerStateService: ISchedulerStateService) {
private schedulerStateService: ISchedulerStateService,
public environment: EnvironmentData) {

super(trigger, commandService, applicationModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export class TriggerView extends ActivityView<TriggerViewModel> {

init(dom: js.IDom, viewModel: TriggerViewModel) {
super.init(dom, viewModel);


if (viewModel.environment.IsReadOnly) {dom('.js_shown').$.hide();};
dom('.js-timeline-data').render(TimelineSlotView, viewModel.timelineSlot);

dom('.status').on('click').react(viewModel.requestCurrentActivityDetails);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="data-row data-row-trigger js_triggerRow">
<section class="primary-data">
<div class="status"></div>
<div class="actions dropdown">
<div class="js_shown actions dropdown">
<a href="#" class="actions-toggle dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
<ul class="js_actions dropdown-menu"></ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SchedulerData } from '../api';
import { SchedulerData , EnvironmentData } from '../api';

import { CommandService } from '../services';
import { ICommand } from '../commands/contracts';
import { StartSchedulerCommand, StopSchedulerCommand, PauseSchedulerCommand, ResumeSchedulerCommand, StandbySchedulerCommand } from '../commands/scheduler-commands';
Expand Down Expand Up @@ -30,15 +31,19 @@ export default class MainHeaderViewModel {

scheduleJobAction = new Action(
'+',
() => { this.scheduleJob(); });
() => {
this.scheduleJob();
}
);

commandProgress = new CommandProgressViewModel(this.commandService);

constructor(
public timeline: Timeline,
private commandService: CommandService,
private application: ApplicationModel,
private dialogManager: IDialogManager) { }
private dialogManager: IDialogManager,
public environment: EnvironmentData) { }

updateFrom(data: SchedulerData) {
this.name.setValue(data.Name);
Expand Down
40 changes: 22 additions & 18 deletions src/CrystalQuartz.Application.Client/app/main-header/header-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class MainHeaderView implements js.IView<ViewModel> {
template = TEMPLATE;

init(dom: js.IDom, viewModel: ViewModel) {

if (viewModel.environment.IsReadOnly) {dom('.js_shown').$.hide();}


dom('.js_schedulerName').observes(viewModel.name);
dom('.ticks-container').render(TimelineCaptionsView, viewModel.timeline);
dom('.js_commandProgress').render(CommandProgressView, viewModel.commandProgress);
Expand All @@ -33,28 +37,28 @@ export default class MainHeaderView implements js.IView<ViewModel> {

dom('.js_scheduleJob').render(ActionView, viewModel.scheduleJobAction);

// const js_standby = dom('.js_standby');
//
// js_standby.className('disabled').observes(viewModel.canStandby);
// const js_standby = dom('.js_standby');
//
// js_standby.className('disabled').observes(viewModel.canStandby);

const $status = dom('.js_schedulerStatus').$ /*,
startSchedulerDom = dom('.js_startScheduler'),
shutdownSchedulerDom = dom('.js_shutdownScheduler')*/;

// dom.manager.manage(
// viewModel.canStart.listen(canStart => {
// if (canStart) {
// startSchedulerDom.$
// .addClass('highlight')
// .removeClass('disabled')
// .prop('disabled', false);
// } else {
// startSchedulerDom.$
// .addClass('disabled')
// .removeClass('highlight')
// .prop('disabled', true);
// }
// }));
// dom.manager.manage(
// viewModel.canStart.listen(canStart => {
// if (canStart) {
// startSchedulerDom.$
// .addClass('highlight')
// .removeClass('disabled')
// .prop('disabled', false);
// } else {
// startSchedulerDom.$
// .addClass('disabled')
// .removeClass('highlight')
// .prop('disabled', true);
// }
// }));

/*
dom.manager.manage(
Expand All @@ -65,7 +69,7 @@ export default class MainHeaderView implements js.IView<ViewModel> {
shutdownSchedulerDom.$.addClass('disabled');
}
}));*/

dom.manager.manage(
viewModel.status.listen((newValue: string, oldValue?: string) => {
if (oldValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</a>
</div>

<div class="scheduler-toolbar">
<div class="js_shown scheduler-toolbar">
<ul class="list-unstyled secondary-actions">
<li class="actions dropdown">
<a href="#" class="actions-toggle dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
Expand Down
4 changes: 3 additions & 1 deletion src/CrystalQuartz.Application.Client/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const
dotNetVersion: 'none',
timelineSpan: 3600 * 1000,
schedulerName: 'DemoScheduler',
isReadOnly: true
},

now = new Date().getTime(),
Expand Down Expand Up @@ -77,7 +78,8 @@ const
schedule: schedule,
schedulerName: options.schedulerName,
timelineSpan: options.timelineSpan,
version: options.version
version: options.version,
isReadOnly: options.isReadOnly
});

const
Expand Down
4 changes: 3 additions & 1 deletion src/CrystalQuartz.Application.Client/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const
dotNetVersion: 'none',
timelineSpan: 3600 * 1000,
schedulerName: 'DemoScheduler',
isReadonly: true
},

now = new Date().getTime(),
Expand Down Expand Up @@ -94,7 +95,8 @@ const
schedule: schedule,
schedulerName: options.schedulerName,
timelineSpan: options.timelineSpan,
version: options.version
version: options.version,
isReadOnly: options.isReadonly
});

const requestHandler = (request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IFakeSchedulerOptions {
timelineSpan: number;
schedulerName: string;
schedule: Schedule;
isReadOnly: boolean;
}

export class FakeSchedulerServer {
Expand All @@ -25,7 +26,8 @@ export class FakeSchedulerServer {
sv: options.version,
qv: options.quartzVersion,
dnv: options.dotNetVersion,
ts: options.timelineSpan
ts: options.timelineSpan,
iro: options.isReadOnly
}),
'get_input_types': (args) => ({
_ok: 1,
Expand Down
Loading