msaltnet / T.Viewer

Cross Platform Tizen Log Viewer
https://blog.msalt.net/313
MIT License
16 stars 7 forks source link

[Feature] Global settings #33

Closed msaltnet closed 4 years ago

msaltnet commented 4 years ago
msaltnet commented 4 years ago

Settings

      <Settings
        v-bind:settingShow.sync="settingShow"
        @restart="restartForSetting"
      />

<template>
  <div>

    <v-dialog
      v-model="settingShow"
      persistent
      min-width="500"
      max-width="700"
    >
      <v-card>
        <v-card-title class="headline">Settings</v-card-title>

        <v-card-text>
          <v-container>
            <v-row>
              <v-checkbox
                v-model="timestamp"
                label="dlog timestamp option"
                v-on:change="onChangeTimestampOption()"
              ></v-checkbox>
            </v-row>
            <v-row>
              <v-text-field
                readonly
                label="Example"
                :value="sampleLogMessage"
              ></v-text-field>
            </v-row>
            <v-row>
              <v-checkbox
                v-model="sdbClear"
                label="SDB clear first"
                v-on:change="onChangeSdbClearOption()"
              ></v-checkbox>
            </v-row>
            <v-row>
              <v-text-field
                readonly
                label="Command"
                :value="sampleSdbCommand"
              ></v-text-field>
            </v-row>
          </v-container>
        </v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn
            color="primary"
            text
            @click="onCloseClick()"
          >
            Close
          </v-btn>
          <v-btn
            color="primary"
            text
            @click="confirmDialog = true"
          >
            Save
          </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
    <v-dialog v-model="confirmDialog" persistent max-width="600">
      <v-card>
        <v-card-title class="title yellow lighten-2" primary-title>
          ⚠️ Warning
        </v-card-title>
        <v-card-text>
          <v-container>
            <v-row>
            It is necessary to restart the application to apply changes
            </v-row>
          </v-container>
        </v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="green darken-1" text @click="onCloseClick()">Cancel</v-btn>
          <v-btn color="green darken-1" text @click="onSaveClick()">Ok</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </div>
</template>

<script>
const SAMPLE_LOG_WITH_TIMESTAMP = '07-10 14:51:21.337+0900 D/RESOURCED( 2617): heart-battery.c';
const SAMPLE_LOG = 'D/RESOURCED( 2617): heart-battery.c';
const SAMPLE_SDB_CMD_WITH_CLEAR = '$sdb dlog -c && sdb dlog';
const SAMPLE_SDB_CMD = '$sdb dlog';
export default {
  props: ['settingShow'],
  data: function () {
    return {
      confirmDialog: false,
      timestamp: true,
      sdbClear: true,
      sampleLogMessage: SAMPLE_LOG_WITH_TIMESTAMP,
      sampleSdbCommand: SAMPLE_SDB_CMD_WITH_CLEAR
    }
  },
  computed: {
  },
  watch: {
  },
  created: function () {
  },
  mounted: function () {
  },
  methods: {
    onChangeTimestampOption: function () {
      this.sampleLogMessage = this.timestamp ? SAMPLE_LOG_WITH_TIMESTAMP : SAMPLE_LOG;
    },
    onChangeSdbClearOption: function () {
      this.sampleSdbCommand = this.sdbClear ? SAMPLE_SDB_CMD_WITH_CLEAR : SAMPLE_SDB_CMD;
    },
    onCloseClick: function () {
      this.confirmDialog = false
      this.$emit('update:settingShow', false);
    },
    onSaveClick: function () {
      this.confirmDialog = false
      this.$emit('update:settingShow', false);
      this.$emit('restart', true);
    }
  }
}
</script>
msaltnet commented 4 years ago

Rel 1.0 에서는 color 설정 제외.