Skip to content

Commit

Permalink
Add initial colors for ONLINE, OFFLINE, IDLE.
Browse files Browse the repository at this point in the history
Fix color change for all items.
  • Loading branch information
MayGo committed Aug 5, 2021
1 parent dfefcf4 commit 5a34211
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
22 changes: 9 additions & 13 deletions client/src/components/Timeline/TimelineItemEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ export const TimelineItemEdit = memo(() => {
clearTimelineItem();
};

const changeColorScopeHandler = newColorScope => {
Logger.debug('Changed color scope:', newColorScope);
const changeColorScopeHandler = e => {
const { value } = e.target;
Logger.debug('Changed color scope:', value);

setState(oldState => ({
...oldState,
colorScope: newColorScope,
colorScope: value,
}));
};

Expand Down Expand Up @@ -211,11 +212,7 @@ export const TimelineItemEdit = memo(() => {
</Box>
<HStack>
<Box>
<ColorPicker
color={trackItem.color}
onChange={changeColorHandler}
readOnly={readOnly}
/>
<ColorPicker color={trackItem.color} onChange={changeColorHandler} />
</Box>
{colorChanged && (
<Tooltip
Expand Down Expand Up @@ -246,11 +243,10 @@ export const TimelineItemEdit = memo(() => {
<Button variant="outline" leftIcon={<AiOutlineClose />} onClick={closeEdit}>
Cancel
</Button>
{!readOnly && (
<Button leftIcon={<AiOutlineSave />} onClick={saveBasedOnColorOptionHandler}>
{isCreating ? 'Create' : 'Update'}
</Button>
)}

<Button leftIcon={<AiOutlineSave />} onClick={saveBasedOnColorOptionHandler}>
{isCreating ? 'Create' : 'Update'}
</Button>
</HStack>
</Box>
);
Expand Down
53 changes: 30 additions & 23 deletions electron/migrations/20200224010206_initial.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
exports.up = function(knex) {
exports.up = function (knex) {
// We renamed table TrackItem to TrackItems at some point with sequalize.
// Try to recover from that
const trackItemsTable = knex.schema.hasTable('TrackItem').then(function(oldExists) {
const trackItemsTable = knex.schema.hasTable('TrackItem').then(function (oldExists) {
if (oldExists) {
return knex.schema.hasTable('TrackItem').then(function(newExists) {
return knex.schema.hasTable('TrackItem').then(function (newExists) {
if (newExists) {
// If we have old table TrackItem and new TrackItems then delete old table
return knex.schema.dropTable('TrackItem');
Expand All @@ -13,9 +13,9 @@ exports.up = function(knex) {
}
});
} else {
return knex.schema.hasTable('TrackItems').then(function(newExists) {
return knex.schema.hasTable('TrackItems').then(function (newExists) {
if (!newExists) {
return knex.schema.createTable('TrackItems', function(table) {
return knex.schema.createTable('TrackItems', function (table) {
table.increments('id');
table.string('app', 255);
table.string('taskName', 255);
Expand All @@ -29,9 +29,9 @@ exports.up = function(knex) {
}
});

const appSettingTable = knex.schema.hasTable('AppSetting').then(function(oldExists) {
const appSettingTable = knex.schema.hasTable('AppSetting').then(function (oldExists) {
if (oldExists) {
return knex.schema.hasTable('AppSettings').then(function(newExists) {
return knex.schema.hasTable('AppSettings').then(function (newExists) {
if (newExists) {
// If we have old table AppSetting and new AppSettings then delete old table
return knex.schema.dropTable('AppSetting');
Expand All @@ -41,36 +41,43 @@ exports.up = function(knex) {
}
});
} else {
return knex.schema.hasTable('AppSettings').then(function(newExists) {
return knex.schema.hasTable('AppSettings').then(function (newExists) {
if (!newExists) {
return knex.schema.createTable('AppSettings', function(table) {
table.increments('id');
table.string('name', 255);
table.string('color', 255);
});
return knex.schema
.createTable('AppSettings', function (table) {
table.increments('id');
table.string('name', 255);
table.string('color', 255);
})
.then(function () {
return knex('AppSettings').insert([
{ name: 'ONLINE', color: '#7ed321' },
{ name: 'OFFLINE', color: '#f31b1b' },
{ name: 'IDLE', color: '#f5a623' },
]);
});
}
});
}
});

return Promise.all([trackItemsTable, appSettingTable].map(p => p.catch(e => console.error(e))))
.then(results =>
knex.schema.hasTable('Settings').then(function(newExists) {
return Promise.all(
[trackItemsTable, appSettingTable].map((p) => p.catch((e) => console.error(e))),
)
.then((results) =>
knex.schema.hasTable('Settings').then(function (newExists) {
if (!newExists) {
return knex.schema.createTable('Settings', function(table) {
return knex.schema.createTable('Settings', function (table) {
table.increments('id');
table.string('name', 255);
table.string('jsonData', 255);
});
}
}),
)
.catch(e => console.log(e));
.catch((e) => console.log(e));
};

exports.down = function(knex) {
return knex.schema
.dropTable('TrackItems')
.dropTable('AppSettings')
.dropTable('Settings');
exports.down = function (knex) {
return knex.schema.dropTable('TrackItems').dropTable('AppSettings').dropTable('Settings');
};

0 comments on commit 5a34211

Please sign in to comment.